@Test public void shouldReturnStatusOKAndObjectContainingLoginInformation() { LoginInformation loggedInUser = new LoginInformation(); when(restLoginService.login("username", "pass")).thenReturn(loggedInUser); RestLoginRequest request = new RestLoginRequest(); request.setUsername("username"); request.setPassword("pass"); ResponseEntity<RestResponse> response = restLoginController.login(request); assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(loggedInUser, response.getBody().getData().get("userInformation")); }
@RequestMapping(value = "/rest-api/login", method = RequestMethod.POST, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> login(@RequestBody RestLoginRequest restLogin) { try { LoginInformation loginInformation = restLoginService.login(restLogin.getUsername(), restLogin.getPassword()); return RestResponse.response("userInformation", loginInformation); } catch (BadCredentialsException e) { return new ResponseEntity(HttpStatus.UNAUTHORIZED); } }
RestLoginController extends BaseController { @RequestMapping(value = "/rest-api/login", method = RequestMethod.POST, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> login(@RequestBody RestLoginRequest restLogin) { try { LoginInformation loginInformation = restLoginService.login(restLogin.getUsername(), restLogin.getPassword()); return RestResponse.response("userInformation", loginInformation); } catch (BadCredentialsException e) { return new ResponseEntity(HttpStatus.UNAUTHORIZED); } } }
RestLoginController extends BaseController { @RequestMapping(value = "/rest-api/login", method = RequestMethod.POST, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> login(@RequestBody RestLoginRequest restLogin) { try { LoginInformation loginInformation = restLoginService.login(restLogin.getUsername(), restLogin.getPassword()); return RestResponse.response("userInformation", loginInformation); } catch (BadCredentialsException e) { return new ResponseEntity(HttpStatus.UNAUTHORIZED); } }  }
RestLoginController extends BaseController { @RequestMapping(value = "/rest-api/login", method = RequestMethod.POST, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> login(@RequestBody RestLoginRequest restLogin) { try { LoginInformation loginInformation = restLoginService.login(restLogin.getUsername(), restLogin.getPassword()); return RestResponse.response("userInformation", loginInformation); } catch (BadCredentialsException e) { return new ResponseEntity(HttpStatus.UNAUTHORIZED); } }  @RequestMapping(value = "/rest-api/login", method = RequestMethod.POST, headers = ACCEPT_JSON) ResponseEntity<RestResponse> login(@RequestBody RestLoginRequest restLogin); }
RestLoginController extends BaseController { @RequestMapping(value = "/rest-api/login", method = RequestMethod.POST, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> login(@RequestBody RestLoginRequest restLogin) { try { LoginInformation loginInformation = restLoginService.login(restLogin.getUsername(), restLogin.getPassword()); return RestResponse.response("userInformation", loginInformation); } catch (BadCredentialsException e) { return new ResponseEntity(HttpStatus.UNAUTHORIZED); } }  @RequestMapping(value = "/rest-api/login", method = RequestMethod.POST, headers = ACCEPT_JSON) ResponseEntity<RestResponse> login(@RequestBody RestLoginRequest restLogin);  }