@Test public void test_update() throws IOException, Exception { List<SurrenderReason> surrenderReasons = getSurrenderReasons(); surrenderReasons.get(0).setId("1"); when(surrenderReasonService.update(any(List.class), any(BindingResult.class), any(RequestInfo.class))) .thenReturn(surrenderReasons); mockMvc.perform(post("/surrenderreasons/_update") .content(resources.readRequest("surrenderreason/surrenderreason_update_valid_request.json")) .contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().is(201)) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(content() .json(resources.readResponse("surrenderreason/surrenderreason_update_valid_response.json"))); }
@PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public SurrenderReasonResponse update(@RequestBody SurrenderReasonRequest surrenderReasonRequest, BindingResult errors) { SurrenderReasonMapper mapper = new SurrenderReasonMapper(); surrenderReasonRequest.getRequestInfo().setAction(ACTION_UPDATE); SurrenderReasonResponse surrenderReasonResponse = new SurrenderReasonResponse(); List<SurrenderReason> surrenderreasons = new ArrayList<>(); surrenderReasonResponse.setResponseInfo(getResponseInfo(surrenderReasonRequest.getRequestInfo())); SurrenderReason surrenderReason; SurrenderReasonContract contract; List<SurrenderReasonContract> surrenderReasonContracts = new ArrayList<>(); for (SurrenderReasonContract surrenderReasonContract : surrenderReasonRequest.getSurrenderReasons()) { surrenderReason = mapper.toDomain(surrenderReasonContract); surrenderReason.setLastModifiedBy(surrenderReasonRequest.getRequestInfo().getUserInfo()); surrenderReason.setLastModifiedDate(new Date()); surrenderreasons.add(surrenderReason); } surrenderreasons = surrenderReasonService.update(surrenderreasons, errors, surrenderReasonRequest.getRequestInfo()); for (SurrenderReason sr : surrenderreasons) { contract = mapper.toContract(sr); surrenderReasonContracts.add(contract); } surrenderReasonResponse.setSurrenderReasons(surrenderReasonContracts); return surrenderReasonResponse; }
SurrenderReasonController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public SurrenderReasonResponse update(@RequestBody SurrenderReasonRequest surrenderReasonRequest, BindingResult errors) { SurrenderReasonMapper mapper = new SurrenderReasonMapper(); surrenderReasonRequest.getRequestInfo().setAction(ACTION_UPDATE); SurrenderReasonResponse surrenderReasonResponse = new SurrenderReasonResponse(); List<SurrenderReason> surrenderreasons = new ArrayList<>(); surrenderReasonResponse.setResponseInfo(getResponseInfo(surrenderReasonRequest.getRequestInfo())); SurrenderReason surrenderReason; SurrenderReasonContract contract; List<SurrenderReasonContract> surrenderReasonContracts = new ArrayList<>(); for (SurrenderReasonContract surrenderReasonContract : surrenderReasonRequest.getSurrenderReasons()) { surrenderReason = mapper.toDomain(surrenderReasonContract); surrenderReason.setLastModifiedBy(surrenderReasonRequest.getRequestInfo().getUserInfo()); surrenderReason.setLastModifiedDate(new Date()); surrenderreasons.add(surrenderReason); } surrenderreasons = surrenderReasonService.update(surrenderreasons, errors, surrenderReasonRequest.getRequestInfo()); for (SurrenderReason sr : surrenderreasons) { contract = mapper.toContract(sr); surrenderReasonContracts.add(contract); } surrenderReasonResponse.setSurrenderReasons(surrenderReasonContracts); return surrenderReasonResponse; } }
SurrenderReasonController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public SurrenderReasonResponse update(@RequestBody SurrenderReasonRequest surrenderReasonRequest, BindingResult errors) { SurrenderReasonMapper mapper = new SurrenderReasonMapper(); surrenderReasonRequest.getRequestInfo().setAction(ACTION_UPDATE); SurrenderReasonResponse surrenderReasonResponse = new SurrenderReasonResponse(); List<SurrenderReason> surrenderreasons = new ArrayList<>(); surrenderReasonResponse.setResponseInfo(getResponseInfo(surrenderReasonRequest.getRequestInfo())); SurrenderReason surrenderReason; SurrenderReasonContract contract; List<SurrenderReasonContract> surrenderReasonContracts = new ArrayList<>(); for (SurrenderReasonContract surrenderReasonContract : surrenderReasonRequest.getSurrenderReasons()) { surrenderReason = mapper.toDomain(surrenderReasonContract); surrenderReason.setLastModifiedBy(surrenderReasonRequest.getRequestInfo().getUserInfo()); surrenderReason.setLastModifiedDate(new Date()); surrenderreasons.add(surrenderReason); } surrenderreasons = surrenderReasonService.update(surrenderreasons, errors, surrenderReasonRequest.getRequestInfo()); for (SurrenderReason sr : surrenderreasons) { contract = mapper.toContract(sr); surrenderReasonContracts.add(contract); } surrenderReasonResponse.setSurrenderReasons(surrenderReasonContracts); return surrenderReasonResponse; }  }
SurrenderReasonController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public SurrenderReasonResponse update(@RequestBody SurrenderReasonRequest surrenderReasonRequest, BindingResult errors) { SurrenderReasonMapper mapper = new SurrenderReasonMapper(); surrenderReasonRequest.getRequestInfo().setAction(ACTION_UPDATE); SurrenderReasonResponse surrenderReasonResponse = new SurrenderReasonResponse(); List<SurrenderReason> surrenderreasons = new ArrayList<>(); surrenderReasonResponse.setResponseInfo(getResponseInfo(surrenderReasonRequest.getRequestInfo())); SurrenderReason surrenderReason; SurrenderReasonContract contract; List<SurrenderReasonContract> surrenderReasonContracts = new ArrayList<>(); for (SurrenderReasonContract surrenderReasonContract : surrenderReasonRequest.getSurrenderReasons()) { surrenderReason = mapper.toDomain(surrenderReasonContract); surrenderReason.setLastModifiedBy(surrenderReasonRequest.getRequestInfo().getUserInfo()); surrenderReason.setLastModifiedDate(new Date()); surrenderreasons.add(surrenderReason); } surrenderreasons = surrenderReasonService.update(surrenderreasons, errors, surrenderReasonRequest.getRequestInfo()); for (SurrenderReason sr : surrenderreasons) { contract = mapper.toContract(sr); surrenderReasonContracts.add(contract); } surrenderReasonResponse.setSurrenderReasons(surrenderReasonContracts); return surrenderReasonResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) SurrenderReasonResponse create(@RequestBody SurrenderReasonRequest surrenderReasonRequest,
            BindingResult errors); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) SurrenderReasonResponse update(@RequestBody SurrenderReasonRequest surrenderReasonRequest,
            BindingResult errors); @PostMapping("/_delete") @ResponseStatus(HttpStatus.CREATED) SurrenderReasonResponse delete(@RequestBody SurrenderReasonRequest surrenderReasonRequest,
            BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) SurrenderReasonResponse search(@ModelAttribute SurrenderReasonSearchContract surrenderReasonSearchContract,
            RequestInfo requestInfo, BindingResult errors); }
SurrenderReasonController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public SurrenderReasonResponse update(@RequestBody SurrenderReasonRequest surrenderReasonRequest, BindingResult errors) { SurrenderReasonMapper mapper = new SurrenderReasonMapper(); surrenderReasonRequest.getRequestInfo().setAction(ACTION_UPDATE); SurrenderReasonResponse surrenderReasonResponse = new SurrenderReasonResponse(); List<SurrenderReason> surrenderreasons = new ArrayList<>(); surrenderReasonResponse.setResponseInfo(getResponseInfo(surrenderReasonRequest.getRequestInfo())); SurrenderReason surrenderReason; SurrenderReasonContract contract; List<SurrenderReasonContract> surrenderReasonContracts = new ArrayList<>(); for (SurrenderReasonContract surrenderReasonContract : surrenderReasonRequest.getSurrenderReasons()) { surrenderReason = mapper.toDomain(surrenderReasonContract); surrenderReason.setLastModifiedBy(surrenderReasonRequest.getRequestInfo().getUserInfo()); surrenderReason.setLastModifiedDate(new Date()); surrenderreasons.add(surrenderReason); } surrenderreasons = surrenderReasonService.update(surrenderreasons, errors, surrenderReasonRequest.getRequestInfo()); for (SurrenderReason sr : surrenderreasons) { contract = mapper.toContract(sr); surrenderReasonContracts.add(contract); } surrenderReasonResponse.setSurrenderReasons(surrenderReasonContracts); return surrenderReasonResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) SurrenderReasonResponse create(@RequestBody SurrenderReasonRequest surrenderReasonRequest,
            BindingResult errors); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) SurrenderReasonResponse update(@RequestBody SurrenderReasonRequest surrenderReasonRequest,
            BindingResult errors); @PostMapping("/_delete") @ResponseStatus(HttpStatus.CREATED) SurrenderReasonResponse delete(@RequestBody SurrenderReasonRequest surrenderReasonRequest,
            BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) SurrenderReasonResponse search(@ModelAttribute SurrenderReasonSearchContract surrenderReasonSearchContract,
            RequestInfo requestInfo, BindingResult errors); static final String ACTION_CREATE; static final String ACTION_UPDATE; static final String ACTION_DELETE; static final String PLACEHOLDER; }