@@ -37,7 +37,11 @@ public UserRest createUser(@RequestBody UserDetailsRequestModel userDetails) thr
3737
3838 UserRest returnValue = new UserRest ();
3939
40- if (userDetails .getFirstName ().isEmpty ()) throw new
40+ if (userDetails .getFirstName ().isEmpty () ||
41+ userDetails .getLastName ().isEmpty () ||
42+ userDetails .getEmail ().isEmpty () ||
43+ userDetails .getPassword ().isEmpty ()
44+ ) throw new
4145 UserServiceException (ErrorMessages .MISSING_REQUIRED_FIELD .getErrorMessage ());
4246
4347 UserDTO userDTO = new UserDTO ();
@@ -50,9 +54,22 @@ public UserRest createUser(@RequestBody UserDetailsRequestModel userDetails) thr
5054 }
5155
5256
53- @ PutMapping
54- public String updateUser (){
55- return "update user was called" ;
57+ @ PutMapping (path = "/{id}" ,consumes = {MediaType .APPLICATION_XML_VALUE ,
58+ MediaType .APPLICATION_JSON_VALUE },
59+ produces = {MediaType .APPLICATION_XML_VALUE ,
60+ MediaType .APPLICATION_JSON_VALUE })
61+ public UserRest updateUser (@ PathVariable String id , @ RequestBody UserDetailsRequestModel userDetails ){
62+
63+ UserRest returnValue = new UserRest ();
64+
65+ UserDTO userDTO = new UserDTO ();
66+ BeanUtils .copyProperties (userDetails ,userDTO );
67+
68+ UserDTO updateUser = userService .updateUser (userDTO );
69+ BeanUtils .copyProperties (updateUser ,returnValue );
70+
71+
72+ return returnValue ;
5673 }
5774
5875 @ DeleteMapping
0 commit comments