@Test public void test_update_error() throws IOException, Exception { when(budgetDetailService.update(any(List.class), any(BindingResult.class), any(RequestInfo.class))) .thenReturn(getBudgetDetails()); mockMvc.perform(post("/budgetdetails/_update") .content(resources.readRequest("budgetdetail/budgetdetail_create_invalid_field_value.json")) .contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().is5xxServerError()); }
@PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public BudgetDetailResponse update(@RequestBody @Valid final BudgetDetailRequest budgetDetailRequest, final BindingResult errors) { final BudgetDetailMapper mapper = new BudgetDetailMapper(); budgetDetailRequest.getRequestInfo().setAction(ACTION_UPDATE); final BudgetDetailResponse budgetDetailResponse = new BudgetDetailResponse(); budgetDetailResponse.setResponseInfo(getResponseInfo(budgetDetailRequest.getRequestInfo())); List<BudgetDetail> budgetdetails = new ArrayList<>(); BudgetDetail budgetDetail = null; BudgetDetailContract contract = null; final List<BudgetDetailContract> budgetDetailContracts = new ArrayList<BudgetDetailContract>(); for (final BudgetDetailContract budgetDetailContract : budgetDetailRequest.getBudgetDetails()) { budgetDetail = mapper.toDomain(budgetDetailContract); budgetDetail.setCreatedBy(budgetDetailRequest.getRequestInfo().getUserInfo()); budgetDetail.setLastModifiedBy(budgetDetailRequest.getRequestInfo().getUserInfo()); budgetdetails.add(budgetDetail); } budgetdetails = budgetDetailService.update(budgetdetails, errors, budgetDetailRequest.getRequestInfo()); for (final BudgetDetail bd : budgetdetails) { contract = mapper.toContract(bd); budgetDetailContracts.add(contract); } budgetDetailResponse.setBudgetDetails(budgetDetailContracts); return budgetDetailResponse; }
BudgetDetailController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public BudgetDetailResponse update(@RequestBody @Valid final BudgetDetailRequest budgetDetailRequest, final BindingResult errors) { final BudgetDetailMapper mapper = new BudgetDetailMapper(); budgetDetailRequest.getRequestInfo().setAction(ACTION_UPDATE); final BudgetDetailResponse budgetDetailResponse = new BudgetDetailResponse(); budgetDetailResponse.setResponseInfo(getResponseInfo(budgetDetailRequest.getRequestInfo())); List<BudgetDetail> budgetdetails = new ArrayList<>(); BudgetDetail budgetDetail = null; BudgetDetailContract contract = null; final List<BudgetDetailContract> budgetDetailContracts = new ArrayList<BudgetDetailContract>(); for (final BudgetDetailContract budgetDetailContract : budgetDetailRequest.getBudgetDetails()) { budgetDetail = mapper.toDomain(budgetDetailContract); budgetDetail.setCreatedBy(budgetDetailRequest.getRequestInfo().getUserInfo()); budgetDetail.setLastModifiedBy(budgetDetailRequest.getRequestInfo().getUserInfo()); budgetdetails.add(budgetDetail); } budgetdetails = budgetDetailService.update(budgetdetails, errors, budgetDetailRequest.getRequestInfo()); for (final BudgetDetail bd : budgetdetails) { contract = mapper.toContract(bd); budgetDetailContracts.add(contract); } budgetDetailResponse.setBudgetDetails(budgetDetailContracts); return budgetDetailResponse; } }
BudgetDetailController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public BudgetDetailResponse update(@RequestBody @Valid final BudgetDetailRequest budgetDetailRequest, final BindingResult errors) { final BudgetDetailMapper mapper = new BudgetDetailMapper(); budgetDetailRequest.getRequestInfo().setAction(ACTION_UPDATE); final BudgetDetailResponse budgetDetailResponse = new BudgetDetailResponse(); budgetDetailResponse.setResponseInfo(getResponseInfo(budgetDetailRequest.getRequestInfo())); List<BudgetDetail> budgetdetails = new ArrayList<>(); BudgetDetail budgetDetail = null; BudgetDetailContract contract = null; final List<BudgetDetailContract> budgetDetailContracts = new ArrayList<BudgetDetailContract>(); for (final BudgetDetailContract budgetDetailContract : budgetDetailRequest.getBudgetDetails()) { budgetDetail = mapper.toDomain(budgetDetailContract); budgetDetail.setCreatedBy(budgetDetailRequest.getRequestInfo().getUserInfo()); budgetDetail.setLastModifiedBy(budgetDetailRequest.getRequestInfo().getUserInfo()); budgetdetails.add(budgetDetail); } budgetdetails = budgetDetailService.update(budgetdetails, errors, budgetDetailRequest.getRequestInfo()); for (final BudgetDetail bd : budgetdetails) { contract = mapper.toContract(bd); budgetDetailContracts.add(contract); } budgetDetailResponse.setBudgetDetails(budgetDetailContracts); return budgetDetailResponse; }  }
BudgetDetailController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public BudgetDetailResponse update(@RequestBody @Valid final BudgetDetailRequest budgetDetailRequest, final BindingResult errors) { final BudgetDetailMapper mapper = new BudgetDetailMapper(); budgetDetailRequest.getRequestInfo().setAction(ACTION_UPDATE); final BudgetDetailResponse budgetDetailResponse = new BudgetDetailResponse(); budgetDetailResponse.setResponseInfo(getResponseInfo(budgetDetailRequest.getRequestInfo())); List<BudgetDetail> budgetdetails = new ArrayList<>(); BudgetDetail budgetDetail = null; BudgetDetailContract contract = null; final List<BudgetDetailContract> budgetDetailContracts = new ArrayList<BudgetDetailContract>(); for (final BudgetDetailContract budgetDetailContract : budgetDetailRequest.getBudgetDetails()) { budgetDetail = mapper.toDomain(budgetDetailContract); budgetDetail.setCreatedBy(budgetDetailRequest.getRequestInfo().getUserInfo()); budgetDetail.setLastModifiedBy(budgetDetailRequest.getRequestInfo().getUserInfo()); budgetdetails.add(budgetDetail); } budgetdetails = budgetDetailService.update(budgetdetails, errors, budgetDetailRequest.getRequestInfo()); for (final BudgetDetail bd : budgetdetails) { contract = mapper.toContract(bd); budgetDetailContracts.add(contract); } budgetDetailResponse.setBudgetDetails(budgetDetailContracts); return budgetDetailResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) BudgetDetailResponse create(@RequestBody final BudgetDetailRequest budgetDetailRequest, final BindingResult errors); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) BudgetDetailResponse update(@RequestBody @Valid final BudgetDetailRequest budgetDetailRequest,
            final BindingResult errors); @PostMapping("/_delete") @ResponseStatus(HttpStatus.CREATED) BudgetDetailResponse delete(@RequestBody @Valid final BudgetDetailRequest budgetDetailRequest,
            final BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) BudgetDetailResponse search(@ModelAttribute final BudgetDetailSearchContract budgetDetailSearchContract,
            @RequestBody final RequestInfo requestInfo, final BindingResult errors); }
BudgetDetailController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public BudgetDetailResponse update(@RequestBody @Valid final BudgetDetailRequest budgetDetailRequest, final BindingResult errors) { final BudgetDetailMapper mapper = new BudgetDetailMapper(); budgetDetailRequest.getRequestInfo().setAction(ACTION_UPDATE); final BudgetDetailResponse budgetDetailResponse = new BudgetDetailResponse(); budgetDetailResponse.setResponseInfo(getResponseInfo(budgetDetailRequest.getRequestInfo())); List<BudgetDetail> budgetdetails = new ArrayList<>(); BudgetDetail budgetDetail = null; BudgetDetailContract contract = null; final List<BudgetDetailContract> budgetDetailContracts = new ArrayList<BudgetDetailContract>(); for (final BudgetDetailContract budgetDetailContract : budgetDetailRequest.getBudgetDetails()) { budgetDetail = mapper.toDomain(budgetDetailContract); budgetDetail.setCreatedBy(budgetDetailRequest.getRequestInfo().getUserInfo()); budgetDetail.setLastModifiedBy(budgetDetailRequest.getRequestInfo().getUserInfo()); budgetdetails.add(budgetDetail); } budgetdetails = budgetDetailService.update(budgetdetails, errors, budgetDetailRequest.getRequestInfo()); for (final BudgetDetail bd : budgetdetails) { contract = mapper.toContract(bd); budgetDetailContracts.add(contract); } budgetDetailResponse.setBudgetDetails(budgetDetailContracts); return budgetDetailResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) BudgetDetailResponse create(@RequestBody final BudgetDetailRequest budgetDetailRequest, final BindingResult errors); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) BudgetDetailResponse update(@RequestBody @Valid final BudgetDetailRequest budgetDetailRequest,
            final BindingResult errors); @PostMapping("/_delete") @ResponseStatus(HttpStatus.CREATED) BudgetDetailResponse delete(@RequestBody @Valid final BudgetDetailRequest budgetDetailRequest,
            final BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) BudgetDetailResponse search(@ModelAttribute final BudgetDetailSearchContract budgetDetailSearchContract,
            @RequestBody final RequestInfo requestInfo, final BindingResult errors); static final String ACTION_CREATE; static final String ACTION_UPDATE; static final String ACTION_DELETE; static final String PLACEHOLDER; }