### Question:
GetAuthenticationTokenAPIController { @RequestMapping(method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE) @ResponseBody public String authenticationtoken(Authentication authentication) { log.debug("Storing authentication token for user: '" + authentication.getName() + "'"); String token = getAuthenticationTokenService().getTokenForAuthentication(authentication); return token; }  @RequestMapping(method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE) @ResponseBody String authenticationtoken(Authentication authentication); AuthenticationTokenService getAuthenticationTokenService(); void setAuthenticationTokenService(AuthenticationTokenService authenticationTokenService);  }### Answer:
@Test public void authenticationtoken() throws Exception { String token = "token"; expect(mockAuthentication.getName()).andReturn("user").atLeastOnce(); expect(mockAuthenticationTokenService.getTokenForAuthentication(mockAuthentication)).andReturn(token); replayAll(); MvcResult result = mockMvc.perform( get("/api/v1/authenticationtoken") .principal(mockAuthentication) .accept(MediaType.TEXT_PLAIN)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.TEXT_PLAIN)) .andReturn(); verifyAll(); String found = result.getResponse().getContentAsString(); assertEquals(token, found); }