DeveloperService { public Developer login(DeveloperLogin developerLogin) { return developerRepository.findByEmailAndPassword(developerLogin.getEmail(), developerLogin.getPassword()); }  Developer find(Long id); Developer login(DeveloperLogin developerLogin); DeveloperPage list(DeveloperDTO developerDTO, PageableDTO pageableDTO); List<Developer> list(DeveloperDTO developerDTO); @Transactional Developer save(DeveloperDTO developerDTO); @Transactional Developer update(Long id, DeveloperDTO developerDTO); @Transactional void delete(Long id);  }
@Test public void loginWithSuccess() { DeveloperLogin developerLogin = new DeveloperLogin(); developerLogin.setEmail(developer.getEmail()); developerLogin.setPassword(developer.getPassword()); Mockito.when(developerRepository.findByEmailAndPassword(developer.getEmail(), developer.getPassword())).thenReturn(developer); Developer logged = developerService.login(developerLogin); assertEquals(developer, logged); }
@Test public void loginWithError() { DeveloperLogin developerLogin = new DeveloperLogin(); developerLogin.setEmail("other@gmail.com"); developerLogin.setPassword("otherPassword"); Mockito.when(developerRepository.findByEmailAndPassword(Mockito.anyString(), Mockito.anyString())).thenReturn(null); Developer logged = developerService.login(developerLogin); assertNull(logged); }