Skip to content

Commit

Permalink
Small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan-Shaml committed Jan 13, 2024
1 parent 5f54e39 commit bca6325
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/test/java/com/faforever/api/user/SteamServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ class SteamServiceTest {
private static final String DUMMY_RESPONSE = "dummy response";
@Mock
private AccountLinkRepository accountLinkRepositoryMock;
@Mock
private HttpServletRequest requestMock;
@InjectMocks
private SteamService beanUnderTest;

@Test
void testHandleInvalidOpenIdRedirect() {
HttpServletRequest requestMock = Mockito.mock(HttpServletRequest.class);
when(requestMock.getParameterMap())
.thenReturn(Map.of(IDENTITY_NAME_PARAM, new String[]{DUMMY_URL}));
when(requestMock.getParameter(IDENTITY_NAME_PARAM)).thenReturn(DUMMY_URL);
Expand All @@ -47,7 +48,6 @@ void testHandleInvalidOpenIdRedirect() {

@Test
void testHandleInvalidOpenIdRedirectBlankIdentityParam() {
HttpServletRequest requestMock = Mockito.mock(HttpServletRequest.class);
final String blankDummyUrl = "";
when(requestMock.getParameterMap())
.thenReturn(Map.of(IDENTITY_NAME_PARAM, new String[]{blankDummyUrl}));
Expand All @@ -61,7 +61,6 @@ void testHandleInvalidOpenIdRedirectBlankIdentityParam() {

@Test
void testHandleInvalidOpenIdRedirectNoIdentityInRequest() {
HttpServletRequest requestMock = Mockito.mock(HttpServletRequest.class);
when(requestMock.getParameterMap()).thenReturn(Collections.emptyMap());

ApiException thrownException = assertThrows(ApiException.class,
Expand All @@ -72,7 +71,6 @@ void testHandleInvalidOpenIdRedirectNoIdentityInRequest() {

@Test
void testHandleInvalidOpenIdRedirectLinkedAccountExists() {
HttpServletRequest requestMock = Mockito.mock(HttpServletRequest.class);
User userMock = Mockito.mock(User.class);
when(userMock.getId()).thenReturn(1);
when(userMock.getLogin()).thenReturn("dummyLogin");
Expand Down

0 comments on commit bca6325

Please sign in to comment.