@Test public void test_Should_Create_Notices() throws Exception{ NoticeResponse noticeResponse = new NoticeResponse(); noticeResponse.setResponseInfo(new ResponseInfo()); when(noticeService.generateNotice(any(NoticeRequest.class))).thenReturn(noticeResponse); mockMvc.perform(post("/agreement/notice/_create") .contentType(MediaType.APPLICATION_JSON) .content(getFileContents("noticerequest.json"))) .andExpect(status().isCreated()) .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) .andExpect(content().json(getFileContents("noticeresponse.json"))); }
@PostMapping("_create") @ResponseBody public ResponseEntity<?> generateNotice(@RequestBody NoticeRequest noticeRequest, BindingResult errors) { LOGGER.info("NoticeController noticeRequest:" + noticeRequest); if (errors.hasErrors()) { ErrorResponse errRes = populateErrors(errors); return new ResponseEntity<>(errRes, HttpStatus.BAD_REQUEST); } NoticeResponse noticeResponse = noticeService.generateNotice(noticeRequest); return new ResponseEntity<>(noticeResponse, HttpStatus.CREATED); }
NoticeController { @PostMapping("_create") @ResponseBody public ResponseEntity<?> generateNotice(@RequestBody NoticeRequest noticeRequest, BindingResult errors) { LOGGER.info("NoticeController noticeRequest:" + noticeRequest); if (errors.hasErrors()) { ErrorResponse errRes = populateErrors(errors); return new ResponseEntity<>(errRes, HttpStatus.BAD_REQUEST); } NoticeResponse noticeResponse = noticeService.generateNotice(noticeRequest); return new ResponseEntity<>(noticeResponse, HttpStatus.CREATED); } }
NoticeController { @PostMapping("_create") @ResponseBody public ResponseEntity<?> generateNotice(@RequestBody NoticeRequest noticeRequest, BindingResult errors) { LOGGER.info("NoticeController noticeRequest:" + noticeRequest); if (errors.hasErrors()) { ErrorResponse errRes = populateErrors(errors); return new ResponseEntity<>(errRes, HttpStatus.BAD_REQUEST); } NoticeResponse noticeResponse = noticeService.generateNotice(noticeRequest); return new ResponseEntity<>(noticeResponse, HttpStatus.CREATED); }  }
NoticeController { @PostMapping("_create") @ResponseBody public ResponseEntity<?> generateNotice(@RequestBody NoticeRequest noticeRequest, BindingResult errors) { LOGGER.info("NoticeController noticeRequest:" + noticeRequest); if (errors.hasErrors()) { ErrorResponse errRes = populateErrors(errors); return new ResponseEntity<>(errRes, HttpStatus.BAD_REQUEST); } NoticeResponse noticeResponse = noticeService.generateNotice(noticeRequest); return new ResponseEntity<>(noticeResponse, HttpStatus.CREATED); }  @PostMapping("_create") @ResponseBody ResponseEntity<?> generateNotice(@RequestBody NoticeRequest noticeRequest, BindingResult errors); @PostMapping("_search") @ResponseBody ResponseEntity<?> search(@ModelAttribute @Valid NoticeCriteria noticeCriteria,
			@RequestBody @Valid RequestInfo requestInfo, BindingResult errors); @PostMapping("_duenotice") @ResponseBody ResponseEntity<?> generateDueNotice(@ModelAttribute @Valid DueSearchCriteria dueCriteria,
			@RequestBody @Valid RequestInfo requestInfo, BindingResult errors); @PostMapping("duenotice/_create") @ResponseBody ResponseEntity<?> createDueNotice(@RequestBody @Valid DueNoticeRequest dueNoticeRequest,
			BindingResult errors); @PostMapping("duenotice/_search") @ResponseBody ResponseEntity<?> searchDueNotice(@ModelAttribute @Valid DueNoticeCriteria noticeCriteria,
			@RequestBody @Valid RequestInfo requestInfo, BindingResult errors); }
NoticeController { @PostMapping("_create") @ResponseBody public ResponseEntity<?> generateNotice(@RequestBody NoticeRequest noticeRequest, BindingResult errors) { LOGGER.info("NoticeController noticeRequest:" + noticeRequest); if (errors.hasErrors()) { ErrorResponse errRes = populateErrors(errors); return new ResponseEntity<>(errRes, HttpStatus.BAD_REQUEST); } NoticeResponse noticeResponse = noticeService.generateNotice(noticeRequest); return new ResponseEntity<>(noticeResponse, HttpStatus.CREATED); }  @PostMapping("_create") @ResponseBody ResponseEntity<?> generateNotice(@RequestBody NoticeRequest noticeRequest, BindingResult errors); @PostMapping("_search") @ResponseBody ResponseEntity<?> search(@ModelAttribute @Valid NoticeCriteria noticeCriteria,
			@RequestBody @Valid RequestInfo requestInfo, BindingResult errors); @PostMapping("_duenotice") @ResponseBody ResponseEntity<?> generateDueNotice(@ModelAttribute @Valid DueSearchCriteria dueCriteria,
			@RequestBody @Valid RequestInfo requestInfo, BindingResult errors); @PostMapping("duenotice/_create") @ResponseBody ResponseEntity<?> createDueNotice(@RequestBody @Valid DueNoticeRequest dueNoticeRequest,
			BindingResult errors); @PostMapping("duenotice/_search") @ResponseBody ResponseEntity<?> searchDueNotice(@ModelAttribute @Valid DueNoticeCriteria noticeCriteria,
			@RequestBody @Valid RequestInfo requestInfo, BindingResult errors); static final Logger LOGGER; }