@Test void testLoginKo() { // Setting expectations (stubbing methods) when(loginService.login(userForm)).thenReturn(false); // Exercise SUT String reseponseLogin = loginController.login(userForm); // Verification assertEquals("KO", reseponseLogin); verify(loginService).login(userForm); verifyZeroInteractions(loginService); }
@Test void testLoginOk() { // Setting expectations (stubbing methods) when(loginService.login(userForm)).thenReturn(true); // Exercise SUT String reseponseLogin = loginController.login(userForm); // Verification assertEquals("OK", reseponseLogin); verify(loginService).login(userForm); verifyNoMoreInteractions(loginService); }
@Test void testLoginKo() { // Setting expectations (stubbing methods) when(loginService.login(userForm)).thenReturn(false); // Exercise SUT String reseponseLogin = loginController.login(userForm); // Verification assertEquals("KO", reseponseLogin); verify(loginService).login(userForm); verifyZeroInteractions(loginService); }
@Test void testLoginOk() { // Setting expectations (stubbing methods) when(loginService.login(userForm)).thenReturn(true); // Exercise SUT String reseponseLogin = loginController.login(userForm); // Verification assertEquals("OK", reseponseLogin); verify(loginService).login(userForm); verifyNoMoreInteractions(loginService); }
@Test void testLoginException() { // Expectation when(loginService.login(any(UserForm.class))) .thenThrow(IllegalArgumentException.class); // Exercise String response = loginController.login(userForm); // Verify assertEquals("ERROR", response); }
@Test void testLoginException() { // Expectation when(loginService.login(any(UserForm.class))) .thenThrow(IllegalArgumentException.class); // Exercise String response = loginController.login(userForm); // Verify assertEquals("ERROR", response); }
@Test void testArgumentCaptor() { loginService.login(userForm); verify(loginRepository).login(argCaptor.capture()); assertEquals(userForm, argCaptor.getValue()); }
@Test void testArgumentCaptor() { loginService.login(userForm); verify(loginRepository).login(argCaptor.capture()); assertEquals(userForm, argCaptor.getValue()); }
@Test void testLoginKo() { when(loginRepository.login(any(UserForm.class))).thenReturn(false); assertFalse(loginService.login(userForm)); verify(loginRepository, times(1)).login(userForm); }
@Test void testLoginKo() { when(loginRepository.login(any(UserForm.class))).thenReturn(false); assertFalse(loginService.login(userForm)); verify(loginRepository, times(1)).login(userForm); }
@Test void testLoginOk() { when(loginRepository.login(any(UserForm.class))).thenReturn(true); assertTrue(loginService.login(userForm)); verify(loginRepository, atLeast(1)).login(userForm); }
@Test void testLoginOk() { when(loginRepository.login(any(UserForm.class))).thenReturn(true); assertTrue(loginService.login(userForm)); verify(loginRepository, atLeast(1)).login(userForm); }
@Test void testLoginException() { given(loginService.login(any(UserForm.class))) .willThrow(IllegalArgumentException.class); assertEquals("ERROR", loginController.login(userForm)); }
@Test void testLoginException() { given(loginService.login(any(UserForm.class))) .willThrow(IllegalArgumentException.class); assertEquals("ERROR", loginController.login(userForm)); }
@Test void testLoginOk() { given(loginService.login(userForm)).willReturn(true); assertEquals("OK", loginController.login(userForm)); }
@Test void testLoginKo() { given(loginService.login(userForm)).willReturn(false); assertEquals("KO", loginController.login(userForm)); }
@Test void testLoginOk() { given(loginService.login(userForm)).willReturn(true); assertEquals("OK", loginController.login(userForm)); }
@Test void testLoginKo() { given(loginService.login(userForm)).willReturn(false); assertEquals("KO", loginController.login(userForm)); }