### Question:
UserController { @PutMapping("/update") public ResponseEntity<?> updateUser(@RequestBody EmployeeUpdateRequest request) { GenericResponse response = userOperations.updateUser(request); return new ResponseEntity<>(response, response.getHttpStatus()); } UserController(UserOperations userOperations); @PostMapping("/sign-up") ResponseEntity<?> signUp(@RequestBody EmployeeSignUpRequest user); @PutMapping("/update") ResponseEntity<?> updateUser(@RequestBody EmployeeUpdateRequest request); @DeleteMapping("/{id}") ResponseEntity<?> deleteUser(@PathVariable("id") Integer id); @PostMapping("/password") ResponseEntity<?> changePassword(@RequestBody UserChangePasswordRequest request); @GetMapping() ResponseEntity<?> getUsers();  }### Answer:
@Test public void employeeUpdate() throws Exception { GenericResponse genericResponse = new GenericResponse(); genericResponse.setSuccess(true); genericResponse.setMessage("Employee Updated Successful"); genericResponse.setHttpStatus(HttpStatus.ACCEPTED); EmployeeUpdateRequest e = new EmployeeUpdateRequest(); e.setUsername("test"); e.setRole("ADMIN"); String inputJson = employeeAsJsonString(e); when(operations.updateUser(e)).thenReturn(genericResponse); String returnJson = mockMvc.perform(put("/users/update") .contentType(MediaType.APPLICATION_JSON) .content(inputJson) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().is2xxSuccessful()) .andReturn().getResponse().getContentAsString(); GenericResponse returnedResponse = stringToGenericResponse(returnJson); verify(operations, times(1)).updateUser(e); assert (returnedResponse.equals(genericResponse)); }
@Test public void employeeUpdate_UpdateFailed() throws Exception { GenericResponse genericResponse = new GenericResponse(); genericResponse.setSuccess(false); genericResponse.setMessage("Employee Successful"); genericResponse.setHttpStatus(HttpStatus.BAD_REQUEST); EmployeeUpdateRequest e = new EmployeeUpdateRequest(); e.setUsername("test"); e.setRole("ADMIN"); String inputJson = employeeAsJsonString(e); when(operations.updateUser(e)).thenReturn(genericResponse); String returnJson = mockMvc.perform(put("/users/update") .contentType(MediaType.APPLICATION_JSON) .content(inputJson) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().is4xxClientError()) .andReturn().getResponse().getContentAsString(); GenericResponse returnedResponse = stringToGenericResponse(returnJson); verify(operations, times(1)).updateUser(e); assert (returnedResponse.equals(genericResponse)); }