@Test public void test_create() throws IOException, Exception { when(voucherSubTypeService.create(any(List.class), any(BindingResult.class), any(RequestInfo.class))) .thenReturn(getVoucherSubTypes()); mockMvc.perform(post("/vouchersubtype/_create") .content(resources.readRequest("vouchersubtype/vouchersubtype_create_valid_request.json")) .contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().is(201)) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(content() .json(resources.readResponse("vouchersubtype/vouchersubtype_create_valid_response.json"))); }
@PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public VoucherSubTypeResponse create( @RequestBody VoucherSubTypeRequest voucherSubTypeRequest, BindingResult errors) { ModelMapper model = new ModelMapper(); VoucherSubTypeResponse voucherSubTypeResponse = new VoucherSubTypeResponse(); voucherSubTypeResponse .setResponseInfo(getResponseInfo(voucherSubTypeRequest .getRequestInfo())); List<VoucherSubType> voucherSubTypes = new ArrayList<>(); VoucherSubType voucherSubType; List<VoucherSubTypeContract> voucherSubTypeContracts = new ArrayList<>(); VoucherSubTypeContract contract; voucherSubTypeRequest.getRequestInfo().setAction( Constants.ACTION_CREATE); for (VoucherSubTypeContract voucherSubTypeContract : voucherSubTypeRequest .getVoucherSubTypes()) { voucherSubType = new VoucherSubType(); model.map(voucherSubTypeContract, voucherSubType); voucherSubType.setCreatedDate(new Date()); voucherSubType.setCreatedBy(voucherSubTypeRequest.getRequestInfo() .getUserInfo()); voucherSubType.setLastModifiedBy(voucherSubTypeRequest .getRequestInfo().getUserInfo()); voucherSubTypes.add(voucherSubType); } voucherSubTypes = voucherSubTypeService.create(voucherSubTypes, errors, voucherSubTypeRequest.getRequestInfo()); for (VoucherSubType f : voucherSubTypes) { contract = new VoucherSubTypeContract(); model.map(f, contract); voucherSubTypeContracts.add(contract); } voucherSubTypeResponse.setVoucherSubTypes(voucherSubTypeContracts); return voucherSubTypeResponse; }
VoucherSubTypeController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public VoucherSubTypeResponse create( @RequestBody VoucherSubTypeRequest voucherSubTypeRequest, BindingResult errors) { ModelMapper model = new ModelMapper(); VoucherSubTypeResponse voucherSubTypeResponse = new VoucherSubTypeResponse(); voucherSubTypeResponse .setResponseInfo(getResponseInfo(voucherSubTypeRequest .getRequestInfo())); List<VoucherSubType> voucherSubTypes = new ArrayList<>(); VoucherSubType voucherSubType; List<VoucherSubTypeContract> voucherSubTypeContracts = new ArrayList<>(); VoucherSubTypeContract contract; voucherSubTypeRequest.getRequestInfo().setAction( Constants.ACTION_CREATE); for (VoucherSubTypeContract voucherSubTypeContract : voucherSubTypeRequest .getVoucherSubTypes()) { voucherSubType = new VoucherSubType(); model.map(voucherSubTypeContract, voucherSubType); voucherSubType.setCreatedDate(new Date()); voucherSubType.setCreatedBy(voucherSubTypeRequest.getRequestInfo() .getUserInfo()); voucherSubType.setLastModifiedBy(voucherSubTypeRequest .getRequestInfo().getUserInfo()); voucherSubTypes.add(voucherSubType); } voucherSubTypes = voucherSubTypeService.create(voucherSubTypes, errors, voucherSubTypeRequest.getRequestInfo()); for (VoucherSubType f : voucherSubTypes) { contract = new VoucherSubTypeContract(); model.map(f, contract); voucherSubTypeContracts.add(contract); } voucherSubTypeResponse.setVoucherSubTypes(voucherSubTypeContracts); return voucherSubTypeResponse; } }
VoucherSubTypeController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public VoucherSubTypeResponse create( @RequestBody VoucherSubTypeRequest voucherSubTypeRequest, BindingResult errors) { ModelMapper model = new ModelMapper(); VoucherSubTypeResponse voucherSubTypeResponse = new VoucherSubTypeResponse(); voucherSubTypeResponse .setResponseInfo(getResponseInfo(voucherSubTypeRequest .getRequestInfo())); List<VoucherSubType> voucherSubTypes = new ArrayList<>(); VoucherSubType voucherSubType; List<VoucherSubTypeContract> voucherSubTypeContracts = new ArrayList<>(); VoucherSubTypeContract contract; voucherSubTypeRequest.getRequestInfo().setAction( Constants.ACTION_CREATE); for (VoucherSubTypeContract voucherSubTypeContract : voucherSubTypeRequest .getVoucherSubTypes()) { voucherSubType = new VoucherSubType(); model.map(voucherSubTypeContract, voucherSubType); voucherSubType.setCreatedDate(new Date()); voucherSubType.setCreatedBy(voucherSubTypeRequest.getRequestInfo() .getUserInfo()); voucherSubType.setLastModifiedBy(voucherSubTypeRequest .getRequestInfo().getUserInfo()); voucherSubTypes.add(voucherSubType); } voucherSubTypes = voucherSubTypeService.create(voucherSubTypes, errors, voucherSubTypeRequest.getRequestInfo()); for (VoucherSubType f : voucherSubTypes) { contract = new VoucherSubTypeContract(); model.map(f, contract); voucherSubTypeContracts.add(contract); } voucherSubTypeResponse.setVoucherSubTypes(voucherSubTypeContracts); return voucherSubTypeResponse; }  }
VoucherSubTypeController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public VoucherSubTypeResponse create( @RequestBody VoucherSubTypeRequest voucherSubTypeRequest, BindingResult errors) { ModelMapper model = new ModelMapper(); VoucherSubTypeResponse voucherSubTypeResponse = new VoucherSubTypeResponse(); voucherSubTypeResponse .setResponseInfo(getResponseInfo(voucherSubTypeRequest .getRequestInfo())); List<VoucherSubType> voucherSubTypes = new ArrayList<>(); VoucherSubType voucherSubType; List<VoucherSubTypeContract> voucherSubTypeContracts = new ArrayList<>(); VoucherSubTypeContract contract; voucherSubTypeRequest.getRequestInfo().setAction( Constants.ACTION_CREATE); for (VoucherSubTypeContract voucherSubTypeContract : voucherSubTypeRequest .getVoucherSubTypes()) { voucherSubType = new VoucherSubType(); model.map(voucherSubTypeContract, voucherSubType); voucherSubType.setCreatedDate(new Date()); voucherSubType.setCreatedBy(voucherSubTypeRequest.getRequestInfo() .getUserInfo()); voucherSubType.setLastModifiedBy(voucherSubTypeRequest .getRequestInfo().getUserInfo()); voucherSubTypes.add(voucherSubType); } voucherSubTypes = voucherSubTypeService.create(voucherSubTypes, errors, voucherSubTypeRequest.getRequestInfo()); for (VoucherSubType f : voucherSubTypes) { contract = new VoucherSubTypeContract(); model.map(f, contract); voucherSubTypeContracts.add(contract); } voucherSubTypeResponse.setVoucherSubTypes(voucherSubTypeContracts); return voucherSubTypeResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) VoucherSubTypeResponse create(
            @RequestBody VoucherSubTypeRequest voucherSubTypeRequest,
            BindingResult errors); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) VoucherSubTypeResponse update(@RequestBody VoucherSubTypeRequest voucherSubTypeRequest, BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) VoucherSubTypeResponse search(@ModelAttribute VoucherSubTypeSearchContract voucherSubTypeSearchContract,
            RequestInfo requestInfo,
            BindingResult errors); }
VoucherSubTypeController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public VoucherSubTypeResponse create( @RequestBody VoucherSubTypeRequest voucherSubTypeRequest, BindingResult errors) { ModelMapper model = new ModelMapper(); VoucherSubTypeResponse voucherSubTypeResponse = new VoucherSubTypeResponse(); voucherSubTypeResponse .setResponseInfo(getResponseInfo(voucherSubTypeRequest .getRequestInfo())); List<VoucherSubType> voucherSubTypes = new ArrayList<>(); VoucherSubType voucherSubType; List<VoucherSubTypeContract> voucherSubTypeContracts = new ArrayList<>(); VoucherSubTypeContract contract; voucherSubTypeRequest.getRequestInfo().setAction( Constants.ACTION_CREATE); for (VoucherSubTypeContract voucherSubTypeContract : voucherSubTypeRequest .getVoucherSubTypes()) { voucherSubType = new VoucherSubType(); model.map(voucherSubTypeContract, voucherSubType); voucherSubType.setCreatedDate(new Date()); voucherSubType.setCreatedBy(voucherSubTypeRequest.getRequestInfo() .getUserInfo()); voucherSubType.setLastModifiedBy(voucherSubTypeRequest .getRequestInfo().getUserInfo()); voucherSubTypes.add(voucherSubType); } voucherSubTypes = voucherSubTypeService.create(voucherSubTypes, errors, voucherSubTypeRequest.getRequestInfo()); for (VoucherSubType f : voucherSubTypes) { contract = new VoucherSubTypeContract(); model.map(f, contract); voucherSubTypeContracts.add(contract); } voucherSubTypeResponse.setVoucherSubTypes(voucherSubTypeContracts); return voucherSubTypeResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) VoucherSubTypeResponse create(
            @RequestBody VoucherSubTypeRequest voucherSubTypeRequest,
            BindingResult errors); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) VoucherSubTypeResponse update(@RequestBody VoucherSubTypeRequest voucherSubTypeRequest, BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) VoucherSubTypeResponse search(@ModelAttribute VoucherSubTypeSearchContract voucherSubTypeSearchContract,
            RequestInfo requestInfo,
            BindingResult errors);  }