@Test public void testUpdate() throws IOException, Exception { Employee expectedEmployee = getExpectedEmployeeForCreate(); ResponseInfo expectedResponseInfo = new ResponseInfo("emp", "1.0", "2017-01-18T07:18:23.130Z", "uief87324", "20170310130900", "200"); when(employeeService.updateAsync(any(EmployeeRequest.class))) .thenReturn(expectedEmployee); when(responseInfoFactory.createResponseInfoFromRequestInfo(any(RequestInfo.class), any(Boolean.class))) .thenReturn(expectedResponseInfo); mockMvc.perform(post("/employees/_update") .content(getFileContents("RequestInfo.json")).contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(content().json( getFileContents("employeeGetResponse1.json"))); }
@PostMapping(value = "/_update") @ResponseBody public ResponseEntity<?> update(@RequestBody @Valid EmployeeRequest employeeRequest, BindingResult bindingResult) { log.debug("employeeRequest::" + employeeRequest); employeeService.setServiceHistoryDetails(employeeRequest, true); Employee employee = null; try { ResponseEntity<?> errorResponseEntity = validateEmployeeRequest(employeeRequest, bindingResult, true); if (errorResponseEntity != null) return errorResponseEntity; employee = employeeService.updateAsync(employeeRequest); } catch (UserException ue) { log.error("Error while processing request ", ue); return errorHandler.getResponseEntityForUserErrors(ue); } catch (Exception exception) { log.error("Error while processing request ", exception); return errorHandler.getResponseEntityForUnexpectedErrors(employeeRequest.getRequestInfo()); } return getSuccessResponseForUpdate(employee, employeeRequest.getRequestInfo()); }
EmployeeController { @PostMapping(value = "/_update") @ResponseBody public ResponseEntity<?> update(@RequestBody @Valid EmployeeRequest employeeRequest, BindingResult bindingResult) { log.debug("employeeRequest::" + employeeRequest); employeeService.setServiceHistoryDetails(employeeRequest, true); Employee employee = null; try { ResponseEntity<?> errorResponseEntity = validateEmployeeRequest(employeeRequest, bindingResult, true); if (errorResponseEntity != null) return errorResponseEntity; employee = employeeService.updateAsync(employeeRequest); } catch (UserException ue) { log.error("Error while processing request ", ue); return errorHandler.getResponseEntityForUserErrors(ue); } catch (Exception exception) { log.error("Error while processing request ", exception); return errorHandler.getResponseEntityForUnexpectedErrors(employeeRequest.getRequestInfo()); } return getSuccessResponseForUpdate(employee, employeeRequest.getRequestInfo()); } }
EmployeeController { @PostMapping(value = "/_update") @ResponseBody public ResponseEntity<?> update(@RequestBody @Valid EmployeeRequest employeeRequest, BindingResult bindingResult) { log.debug("employeeRequest::" + employeeRequest); employeeService.setServiceHistoryDetails(employeeRequest, true); Employee employee = null; try { ResponseEntity<?> errorResponseEntity = validateEmployeeRequest(employeeRequest, bindingResult, true); if (errorResponseEntity != null) return errorResponseEntity; employee = employeeService.updateAsync(employeeRequest); } catch (UserException ue) { log.error("Error while processing request ", ue); return errorHandler.getResponseEntityForUserErrors(ue); } catch (Exception exception) { log.error("Error while processing request ", exception); return errorHandler.getResponseEntityForUnexpectedErrors(employeeRequest.getRequestInfo()); } return getSuccessResponseForUpdate(employee, employeeRequest.getRequestInfo()); }  }
EmployeeController { @PostMapping(value = "/_update") @ResponseBody public ResponseEntity<?> update(@RequestBody @Valid EmployeeRequest employeeRequest, BindingResult bindingResult) { log.debug("employeeRequest::" + employeeRequest); employeeService.setServiceHistoryDetails(employeeRequest, true); Employee employee = null; try { ResponseEntity<?> errorResponseEntity = validateEmployeeRequest(employeeRequest, bindingResult, true); if (errorResponseEntity != null) return errorResponseEntity; employee = employeeService.updateAsync(employeeRequest); } catch (UserException ue) { log.error("Error while processing request ", ue); return errorHandler.getResponseEntityForUserErrors(ue); } catch (Exception exception) { log.error("Error while processing request ", exception); return errorHandler.getResponseEntityForUnexpectedErrors(employeeRequest.getRequestInfo()); } return getSuccessResponseForUpdate(employee, employeeRequest.getRequestInfo()); }  @PostMapping("_search") @ResponseBody ResponseEntity<?> search(@ModelAttribute @Valid EmployeeCriteria employeeCriteria,
			BindingResult modelAttributeBindingResult, @RequestBody @Valid RequestInfoWrapper requestInfoWrapper,
			BindingResult requestBodyBindingResult); @PostMapping("_baseregisterreport") @ResponseBody ResponseEntity<?> baseregisterreport(
			@ModelAttribute @Valid BaseRegisterReportRequest baseRegisterReportRequest,
			BindingResult modelAttributeBindingResult, @RequestBody @Valid RequestInfoWrapper requestInfoWrapper,
			BindingResult requestBodyBindingResult); @PostMapping("_employeewithoutassignmentreport") @ResponseBody ResponseEntity<?> employeeWithoutAssignment(@ModelAttribute @Valid EmployeeCriteria employeeCriteria,
			BindingResult modelAttributeBindingResult, @RequestBody @Valid RequestInfoWrapper requestInfoWrapper,
			BindingResult requestBodyBindingResult); @PostMapping("_loggedinemployee") @ResponseBody ResponseEntity<?> loggedInEmployee(@RequestBody @Valid RequestInfoWrapper requestInfoWrapper,
			BindingResult requestBodyBindingResult); @PostMapping("{id}/_search") @ResponseBody ResponseEntity<?> get(@ModelAttribute @Valid EmployeeGetRequest employeeGetRequest,
			BindingResult modelAttributeBindingResult, @RequestBody @Valid RequestInfoWrapper requestInfoWrapper,
			BindingResult requestBodyBindingResult); @PostMapping(value = "/_create") @ResponseBody ResponseEntity<?> create(@RequestBody @Valid EmployeeRequest employeeRequest, BindingResult bindingResult); @PostMapping(value = "/_bulkcreate") @ResponseBody ResponseEntity<?> bulkCreate(@RequestBody @Valid EmployeeBulkRequest employeeBulkRequest,
			BindingResult bindingResult); @PostMapping(value = "/_update") @ResponseBody ResponseEntity<?> update(@RequestBody @Valid EmployeeRequest employeeRequest, BindingResult bindingResult); @PostMapping(value = "/_updateemployee") @ResponseBody ResponseEntity<?> updateEmployee(@RequestBody @Valid EmployeeRequest employeeRequest,
			BindingResult bindingResult); ResponseEntity<?> getSuccessResponseForCreate(Employee employee, RequestInfo requestInfo); ResponseEntity<?> getSuccessResponseForGet(Employee employee, RequestInfo requestInfo); ResponseEntity<?> getSuccessResponseForUpdate(Employee employee, RequestInfo requestInfo); }
EmployeeController { @PostMapping(value = "/_update") @ResponseBody public ResponseEntity<?> update(@RequestBody @Valid EmployeeRequest employeeRequest, BindingResult bindingResult) { log.debug("employeeRequest::" + employeeRequest); employeeService.setServiceHistoryDetails(employeeRequest, true); Employee employee = null; try { ResponseEntity<?> errorResponseEntity = validateEmployeeRequest(employeeRequest, bindingResult, true); if (errorResponseEntity != null) return errorResponseEntity; employee = employeeService.updateAsync(employeeRequest); } catch (UserException ue) { log.error("Error while processing request ", ue); return errorHandler.getResponseEntityForUserErrors(ue); } catch (Exception exception) { log.error("Error while processing request ", exception); return errorHandler.getResponseEntityForUnexpectedErrors(employeeRequest.getRequestInfo()); } return getSuccessResponseForUpdate(employee, employeeRequest.getRequestInfo()); }  @PostMapping("_search") @ResponseBody ResponseEntity<?> search(@ModelAttribute @Valid EmployeeCriteria employeeCriteria,
			BindingResult modelAttributeBindingResult, @RequestBody @Valid RequestInfoWrapper requestInfoWrapper,
			BindingResult requestBodyBindingResult); @PostMapping("_baseregisterreport") @ResponseBody ResponseEntity<?> baseregisterreport(
			@ModelAttribute @Valid BaseRegisterReportRequest baseRegisterReportRequest,
			BindingResult modelAttributeBindingResult, @RequestBody @Valid RequestInfoWrapper requestInfoWrapper,
			BindingResult requestBodyBindingResult); @PostMapping("_employeewithoutassignmentreport") @ResponseBody ResponseEntity<?> employeeWithoutAssignment(@ModelAttribute @Valid EmployeeCriteria employeeCriteria,
			BindingResult modelAttributeBindingResult, @RequestBody @Valid RequestInfoWrapper requestInfoWrapper,
			BindingResult requestBodyBindingResult); @PostMapping("_loggedinemployee") @ResponseBody ResponseEntity<?> loggedInEmployee(@RequestBody @Valid RequestInfoWrapper requestInfoWrapper,
			BindingResult requestBodyBindingResult); @PostMapping("{id}/_search") @ResponseBody ResponseEntity<?> get(@ModelAttribute @Valid EmployeeGetRequest employeeGetRequest,
			BindingResult modelAttributeBindingResult, @RequestBody @Valid RequestInfoWrapper requestInfoWrapper,
			BindingResult requestBodyBindingResult); @PostMapping(value = "/_create") @ResponseBody ResponseEntity<?> create(@RequestBody @Valid EmployeeRequest employeeRequest, BindingResult bindingResult); @PostMapping(value = "/_bulkcreate") @ResponseBody ResponseEntity<?> bulkCreate(@RequestBody @Valid EmployeeBulkRequest employeeBulkRequest,
			BindingResult bindingResult); @PostMapping(value = "/_update") @ResponseBody ResponseEntity<?> update(@RequestBody @Valid EmployeeRequest employeeRequest, BindingResult bindingResult); @PostMapping(value = "/_updateemployee") @ResponseBody ResponseEntity<?> updateEmployee(@RequestBody @Valid EmployeeRequest employeeRequest,
			BindingResult bindingResult); ResponseEntity<?> getSuccessResponseForCreate(Employee employee, RequestInfo requestInfo); ResponseEntity<?> getSuccessResponseForGet(Employee employee, RequestInfo requestInfo); ResponseEntity<?> getSuccessResponseForUpdate(Employee employee, RequestInfo requestInfo);  }