@Test public void testServiceLoginOk() { when(loginRepository.login(any(UserForm.class))).thenReturn(true); assertTrue(loginService.login(userForm)); verify(loginRepository, atLeast(1)).login(userForm); verifyNoMoreInteractions(loginRepository); }
public boolean login(UserForm userForm) { System.out.println("LoginService.login " + userForm); checkForm(userForm); String username = userForm.getUsername(); if (usersLogged.contains(username)) { throw new LoginException(username + " already logged"); } boolean login = loginRepository.login(userForm); if (login) { usersLogged.add(username); } return login; }
LoginService { public boolean login(UserForm userForm) { System.out.println("LoginService.login " + userForm); checkForm(userForm); String username = userForm.getUsername(); if (usersLogged.contains(username)) { throw new LoginException(username + " already logged"); } boolean login = loginRepository.login(userForm); if (login) { usersLogged.add(username); } return login; } }
LoginService { public boolean login(UserForm userForm) { System.out.println("LoginService.login " + userForm); checkForm(userForm); String username = userForm.getUsername(); if (usersLogged.contains(username)) { throw new LoginException(username + " already logged"); } boolean login = loginRepository.login(userForm); if (login) { usersLogged.add(username); } return login; }  }
LoginService { public boolean login(UserForm userForm) { System.out.println("LoginService.login " + userForm); checkForm(userForm); String username = userForm.getUsername(); if (usersLogged.contains(username)) { throw new LoginException(username + " already logged"); } boolean login = loginRepository.login(userForm); if (login) { usersLogged.add(username); } return login; }  boolean login(UserForm userForm); void logout(UserForm userForm); int getUserLoggedCount(); }
LoginService { public boolean login(UserForm userForm) { System.out.println("LoginService.login " + userForm); checkForm(userForm); String username = userForm.getUsername(); if (usersLogged.contains(username)) { throw new LoginException(username + " already logged"); } boolean login = loginRepository.login(userForm); if (login) { usersLogged.add(username); } return login; }  boolean login(UserForm userForm); void logout(UserForm userForm); int getUserLoggedCount();  }