@Test public void test_update_error() throws IOException, Exception { when(instrumentTypeService.update(any(List.class), any(BindingResult.class), any(RequestInfo.class))) .thenReturn(getInstrumentTypes()); mockMvc.perform(post("/instrumenttypes/_update") .content(resources.readRequest("instrumenttype/instrumenttype_create_invalid_field_value.json")) .contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().is5xxServerError()); }
@PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public InstrumentTypeResponse update(@RequestBody InstrumentTypeRequest instrumentTypeRequest, BindingResult errors) { InstrumentTypeMapper mapper = new InstrumentTypeMapper(); instrumentTypeRequest.getRequestInfo().setAction(ACTION_UPDATE); InstrumentTypeResponse instrumentTypeResponse = new InstrumentTypeResponse(); List<InstrumentType> instrumenttypes = new ArrayList<>(); instrumentTypeResponse.setResponseInfo(getResponseInfo(instrumentTypeRequest.getRequestInfo())); InstrumentType instrumentType; InstrumentTypeContract contract; List<InstrumentTypeContract> instrumentTypeContracts = new ArrayList<>(); for (InstrumentTypeContract instrumentTypeContract : instrumentTypeRequest.getInstrumentTypes()) { instrumentType = mapper.toDomain(instrumentTypeContract); instrumentType.setLastModifiedBy(instrumentTypeRequest.getRequestInfo().getUserInfo()); instrumentType.setLastModifiedDate(new Date()); instrumenttypes.add(instrumentType); } instrumenttypes = instrumentTypeService.update(instrumenttypes, errors, instrumentTypeRequest.getRequestInfo()); for (InstrumentType it : instrumenttypes) { contract = mapper.toContract(it); instrumentTypeContracts.add(contract); } instrumentTypeResponse.setInstrumentTypes(instrumentTypeContracts); return instrumentTypeResponse; }
InstrumentTypeController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public InstrumentTypeResponse update(@RequestBody InstrumentTypeRequest instrumentTypeRequest, BindingResult errors) { InstrumentTypeMapper mapper = new InstrumentTypeMapper(); instrumentTypeRequest.getRequestInfo().setAction(ACTION_UPDATE); InstrumentTypeResponse instrumentTypeResponse = new InstrumentTypeResponse(); List<InstrumentType> instrumenttypes = new ArrayList<>(); instrumentTypeResponse.setResponseInfo(getResponseInfo(instrumentTypeRequest.getRequestInfo())); InstrumentType instrumentType; InstrumentTypeContract contract; List<InstrumentTypeContract> instrumentTypeContracts = new ArrayList<>(); for (InstrumentTypeContract instrumentTypeContract : instrumentTypeRequest.getInstrumentTypes()) { instrumentType = mapper.toDomain(instrumentTypeContract); instrumentType.setLastModifiedBy(instrumentTypeRequest.getRequestInfo().getUserInfo()); instrumentType.setLastModifiedDate(new Date()); instrumenttypes.add(instrumentType); } instrumenttypes = instrumentTypeService.update(instrumenttypes, errors, instrumentTypeRequest.getRequestInfo()); for (InstrumentType it : instrumenttypes) { contract = mapper.toContract(it); instrumentTypeContracts.add(contract); } instrumentTypeResponse.setInstrumentTypes(instrumentTypeContracts); return instrumentTypeResponse; } }
InstrumentTypeController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public InstrumentTypeResponse update(@RequestBody InstrumentTypeRequest instrumentTypeRequest, BindingResult errors) { InstrumentTypeMapper mapper = new InstrumentTypeMapper(); instrumentTypeRequest.getRequestInfo().setAction(ACTION_UPDATE); InstrumentTypeResponse instrumentTypeResponse = new InstrumentTypeResponse(); List<InstrumentType> instrumenttypes = new ArrayList<>(); instrumentTypeResponse.setResponseInfo(getResponseInfo(instrumentTypeRequest.getRequestInfo())); InstrumentType instrumentType; InstrumentTypeContract contract; List<InstrumentTypeContract> instrumentTypeContracts = new ArrayList<>(); for (InstrumentTypeContract instrumentTypeContract : instrumentTypeRequest.getInstrumentTypes()) { instrumentType = mapper.toDomain(instrumentTypeContract); instrumentType.setLastModifiedBy(instrumentTypeRequest.getRequestInfo().getUserInfo()); instrumentType.setLastModifiedDate(new Date()); instrumenttypes.add(instrumentType); } instrumenttypes = instrumentTypeService.update(instrumenttypes, errors, instrumentTypeRequest.getRequestInfo()); for (InstrumentType it : instrumenttypes) { contract = mapper.toContract(it); instrumentTypeContracts.add(contract); } instrumentTypeResponse.setInstrumentTypes(instrumentTypeContracts); return instrumentTypeResponse; }  }
InstrumentTypeController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public InstrumentTypeResponse update(@RequestBody InstrumentTypeRequest instrumentTypeRequest, BindingResult errors) { InstrumentTypeMapper mapper = new InstrumentTypeMapper(); instrumentTypeRequest.getRequestInfo().setAction(ACTION_UPDATE); InstrumentTypeResponse instrumentTypeResponse = new InstrumentTypeResponse(); List<InstrumentType> instrumenttypes = new ArrayList<>(); instrumentTypeResponse.setResponseInfo(getResponseInfo(instrumentTypeRequest.getRequestInfo())); InstrumentType instrumentType; InstrumentTypeContract contract; List<InstrumentTypeContract> instrumentTypeContracts = new ArrayList<>(); for (InstrumentTypeContract instrumentTypeContract : instrumentTypeRequest.getInstrumentTypes()) { instrumentType = mapper.toDomain(instrumentTypeContract); instrumentType.setLastModifiedBy(instrumentTypeRequest.getRequestInfo().getUserInfo()); instrumentType.setLastModifiedDate(new Date()); instrumenttypes.add(instrumentType); } instrumenttypes = instrumentTypeService.update(instrumenttypes, errors, instrumentTypeRequest.getRequestInfo()); for (InstrumentType it : instrumenttypes) { contract = mapper.toContract(it); instrumentTypeContracts.add(contract); } instrumentTypeResponse.setInstrumentTypes(instrumentTypeContracts); return instrumentTypeResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) InstrumentTypeResponse create(@RequestBody InstrumentTypeRequest instrumentTypeRequest,
            BindingResult errors); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) InstrumentTypeResponse update(@RequestBody InstrumentTypeRequest instrumentTypeRequest,
            BindingResult errors); @PostMapping("/_delete") @ResponseStatus(HttpStatus.CREATED) InstrumentTypeResponse delete(@RequestBody InstrumentTypeRequest instrumentTypeRequest,
            BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) InstrumentTypeResponse search(@ModelAttribute InstrumentTypeSearchContract instrumentTypeSearchContract,
            RequestInfo requestInfo, BindingResult errors); }
InstrumentTypeController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public InstrumentTypeResponse update(@RequestBody InstrumentTypeRequest instrumentTypeRequest, BindingResult errors) { InstrumentTypeMapper mapper = new InstrumentTypeMapper(); instrumentTypeRequest.getRequestInfo().setAction(ACTION_UPDATE); InstrumentTypeResponse instrumentTypeResponse = new InstrumentTypeResponse(); List<InstrumentType> instrumenttypes = new ArrayList<>(); instrumentTypeResponse.setResponseInfo(getResponseInfo(instrumentTypeRequest.getRequestInfo())); InstrumentType instrumentType; InstrumentTypeContract contract; List<InstrumentTypeContract> instrumentTypeContracts = new ArrayList<>(); for (InstrumentTypeContract instrumentTypeContract : instrumentTypeRequest.getInstrumentTypes()) { instrumentType = mapper.toDomain(instrumentTypeContract); instrumentType.setLastModifiedBy(instrumentTypeRequest.getRequestInfo().getUserInfo()); instrumentType.setLastModifiedDate(new Date()); instrumenttypes.add(instrumentType); } instrumenttypes = instrumentTypeService.update(instrumenttypes, errors, instrumentTypeRequest.getRequestInfo()); for (InstrumentType it : instrumenttypes) { contract = mapper.toContract(it); instrumentTypeContracts.add(contract); } instrumentTypeResponse.setInstrumentTypes(instrumentTypeContracts); return instrumentTypeResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) InstrumentTypeResponse create(@RequestBody InstrumentTypeRequest instrumentTypeRequest,
            BindingResult errors); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) InstrumentTypeResponse update(@RequestBody InstrumentTypeRequest instrumentTypeRequest,
            BindingResult errors); @PostMapping("/_delete") @ResponseStatus(HttpStatus.CREATED) InstrumentTypeResponse delete(@RequestBody InstrumentTypeRequest instrumentTypeRequest,
            BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) InstrumentTypeResponse search(@ModelAttribute InstrumentTypeSearchContract instrumentTypeSearchContract,
            RequestInfo requestInfo, BindingResult errors); static final String ACTION_CREATE; static final String ACTION_UPDATE; static final String ACTION_DELETE; static final String PLACEHOLDER; }