AuthenticationService { public LoginToken authenticate(String username, String password) { RestTemplate restTemplate = new RestTemplate(); MultiValueMap<String, String> multiValueMap = new LinkedMultiValueMap<>(); multiValueMap.add("username", username); multiValueMap.add("password", password); LoginToken loginToken = restTemplate.postForObject(authUrl, multiValueMap, LoginToken.class); return loginToken; }  LoginToken authenticate(String username, String password);  }
@Test public void authenticate_kmh_abcd1234() { LoginToken loginToken = authenticationService.authenticate("kmh", "abcd1234"); assertEquals("kmh", loginToken.getUsername()); assertEquals("Monirul Hasan", loginToken.getFullname()); assertEquals("faculty", loginToken.getRole()); }
@Test public void authenticate_2012000000089_xyz123() { LoginToken loginToken = authenticationService.authenticate("2012000000089", "xyz123"); assertEquals("2012000000089", loginToken.getUsername()); assertEquals("Md. Masum", loginToken.getFullname()); assertEquals("student", loginToken.getRole()); }
@Test public void authenticate_incorrect() { LoginToken loginToken = authenticationService.authenticate("kmh", "abcd1234xx"); assertNull(loginToken.getUsername()); assertNull(loginToken.getFullname()); assertEquals("norole", loginToken.getRole()); }