@Test public void test_delete() throws IOException, Exception { List<Instrument> instruments = getInstruments(); instruments.get(0).setId("1"); when(instrumentService.delete(any(List.class), any(BindingResult.class), any(RequestInfo.class))) .thenReturn(instruments); mockMvc.perform(post("/instruments/_delete") .content(resources.readRequest("instrument/instrument_delete_valid_request.json")) .contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().is(201)) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(content().json(resources.readResponse("instrument/instrument_delete_valid_response.json"))); }
@PostMapping("/_delete") @ResponseStatus(HttpStatus.CREATED) public InstrumentResponse delete(@RequestBody InstrumentRequest instrumentRequest, BindingResult errors) { InstrumentMapper mapper = new InstrumentMapper(); instrumentRequest.getRequestInfo().setAction(ACTION_DELETE); InstrumentResponse instrumentResponse = new InstrumentResponse(); List<Instrument> instruments = new ArrayList<>(); instrumentResponse.setResponseInfo(getResponseInfo(instrumentRequest.getRequestInfo())); Instrument instrument; InstrumentContract contract; List<InstrumentContract> instrumentContracts = new ArrayList<>(); for (InstrumentContract instrumentContract : instrumentRequest.getInstruments()) { instrument = mapper.toDomain(instrumentContract); instruments.add(instrument); } instruments = instrumentService.delete(instruments, errors, instrumentRequest.getRequestInfo()); for (Instrument i : instruments) { contract = mapper.toContract(i); instrumentContracts.add(contract); } instrumentResponse.setInstruments(instrumentContracts); return instrumentResponse; }
InstrumentController { @PostMapping("/_delete") @ResponseStatus(HttpStatus.CREATED) public InstrumentResponse delete(@RequestBody InstrumentRequest instrumentRequest, BindingResult errors) { InstrumentMapper mapper = new InstrumentMapper(); instrumentRequest.getRequestInfo().setAction(ACTION_DELETE); InstrumentResponse instrumentResponse = new InstrumentResponse(); List<Instrument> instruments = new ArrayList<>(); instrumentResponse.setResponseInfo(getResponseInfo(instrumentRequest.getRequestInfo())); Instrument instrument; InstrumentContract contract; List<InstrumentContract> instrumentContracts = new ArrayList<>(); for (InstrumentContract instrumentContract : instrumentRequest.getInstruments()) { instrument = mapper.toDomain(instrumentContract); instruments.add(instrument); } instruments = instrumentService.delete(instruments, errors, instrumentRequest.getRequestInfo()); for (Instrument i : instruments) { contract = mapper.toContract(i); instrumentContracts.add(contract); } instrumentResponse.setInstruments(instrumentContracts); return instrumentResponse; } }
InstrumentController { @PostMapping("/_delete") @ResponseStatus(HttpStatus.CREATED) public InstrumentResponse delete(@RequestBody InstrumentRequest instrumentRequest, BindingResult errors) { InstrumentMapper mapper = new InstrumentMapper(); instrumentRequest.getRequestInfo().setAction(ACTION_DELETE); InstrumentResponse instrumentResponse = new InstrumentResponse(); List<Instrument> instruments = new ArrayList<>(); instrumentResponse.setResponseInfo(getResponseInfo(instrumentRequest.getRequestInfo())); Instrument instrument; InstrumentContract contract; List<InstrumentContract> instrumentContracts = new ArrayList<>(); for (InstrumentContract instrumentContract : instrumentRequest.getInstruments()) { instrument = mapper.toDomain(instrumentContract); instruments.add(instrument); } instruments = instrumentService.delete(instruments, errors, instrumentRequest.getRequestInfo()); for (Instrument i : instruments) { contract = mapper.toContract(i); instrumentContracts.add(contract); } instrumentResponse.setInstruments(instrumentContracts); return instrumentResponse; }  }
InstrumentController { @PostMapping("/_delete") @ResponseStatus(HttpStatus.CREATED) public InstrumentResponse delete(@RequestBody InstrumentRequest instrumentRequest, BindingResult errors) { InstrumentMapper mapper = new InstrumentMapper(); instrumentRequest.getRequestInfo().setAction(ACTION_DELETE); InstrumentResponse instrumentResponse = new InstrumentResponse(); List<Instrument> instruments = new ArrayList<>(); instrumentResponse.setResponseInfo(getResponseInfo(instrumentRequest.getRequestInfo())); Instrument instrument; InstrumentContract contract; List<InstrumentContract> instrumentContracts = new ArrayList<>(); for (InstrumentContract instrumentContract : instrumentRequest.getInstruments()) { instrument = mapper.toDomain(instrumentContract); instruments.add(instrument); } instruments = instrumentService.delete(instruments, errors, instrumentRequest.getRequestInfo()); for (Instrument i : instruments) { contract = mapper.toContract(i); instrumentContracts.add(contract); } instrumentResponse.setInstruments(instrumentContracts); return instrumentResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) InstrumentResponse create(@RequestBody InstrumentRequest instrumentRequest, BindingResult errors); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) InstrumentResponse update(@RequestBody InstrumentRequest instrumentRequest, BindingResult errors); @PostMapping("/_delete") @ResponseStatus(HttpStatus.CREATED) InstrumentResponse delete(@RequestBody InstrumentRequest instrumentRequest, BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) InstrumentResponse search(@ModelAttribute InstrumentSearchContract instrumentSearchContract,
            RequestInfo requestInfo, BindingResult errors); @PostMapping("/_deposit") @ResponseStatus(HttpStatus.CREATED) InstrumentResponse depositInstrument(@RequestBody InstrumentRequest instrumentDepositRequest, BindingResult errors); @PostMapping("/_dishonor") @ResponseStatus(HttpStatus.CREATED) InstrumentResponse dishonorInstrument(@RequestBody InstrumentRequest instrumentDepositRequest, BindingResult errors); }
InstrumentController { @PostMapping("/_delete") @ResponseStatus(HttpStatus.CREATED) public InstrumentResponse delete(@RequestBody InstrumentRequest instrumentRequest, BindingResult errors) { InstrumentMapper mapper = new InstrumentMapper(); instrumentRequest.getRequestInfo().setAction(ACTION_DELETE); InstrumentResponse instrumentResponse = new InstrumentResponse(); List<Instrument> instruments = new ArrayList<>(); instrumentResponse.setResponseInfo(getResponseInfo(instrumentRequest.getRequestInfo())); Instrument instrument; InstrumentContract contract; List<InstrumentContract> instrumentContracts = new ArrayList<>(); for (InstrumentContract instrumentContract : instrumentRequest.getInstruments()) { instrument = mapper.toDomain(instrumentContract); instruments.add(instrument); } instruments = instrumentService.delete(instruments, errors, instrumentRequest.getRequestInfo()); for (Instrument i : instruments) { contract = mapper.toContract(i); instrumentContracts.add(contract); } instrumentResponse.setInstruments(instrumentContracts); return instrumentResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) InstrumentResponse create(@RequestBody InstrumentRequest instrumentRequest, BindingResult errors); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) InstrumentResponse update(@RequestBody InstrumentRequest instrumentRequest, BindingResult errors); @PostMapping("/_delete") @ResponseStatus(HttpStatus.CREATED) InstrumentResponse delete(@RequestBody InstrumentRequest instrumentRequest, BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) InstrumentResponse search(@ModelAttribute InstrumentSearchContract instrumentSearchContract,
            RequestInfo requestInfo, BindingResult errors); @PostMapping("/_deposit") @ResponseStatus(HttpStatus.CREATED) InstrumentResponse depositInstrument(@RequestBody InstrumentRequest instrumentDepositRequest, BindingResult errors); @PostMapping("/_dishonor") @ResponseStatus(HttpStatus.CREATED) InstrumentResponse dishonorInstrument(@RequestBody InstrumentRequest instrumentDepositRequest, BindingResult errors); static final String ACTION_CREATE; static final String ACTION_UPDATE; static final String ACTION_DELETE; static final String PLACEHOLDER; }