@Test public void getDeletablePrintJobs() throws Exception { CustomerInfo customerInfo = new CustomerInfo(); customerInfo.setId(1); PrintJob printJob = new PrintJob(); printJob.setColorType(new ColorType(1, "Red")); printJob.setComments("comments"); printJob.setCreatedAt(LocalDateTime.now()); printJob.setQueueId(new Queue()); printJob.setStatus(Status.PENDING_REVIEW); printJob.setEmployee(new Employee()); printJob.setId(1); List<PrintJob> printJobList = Arrays.asList(printJob); List<BasicPrintJob> basicPrintJobs = new BasicPrintJob().ConvertPrintJobs(printJobList); DataResponse<BasicPrintJob> expectedResponse = new DataResponse<BasicPrintJob>(); expectedResponse.setSuccess(true); expectedResponse.setMessage("Successfully returned deletable printjobs."); expectedResponse.setData(basicPrintJobs); expectedResponse.setHttpStatus(HttpStatus.ACCEPTED); Mockito.when(printJobOperations.getDeletablePrintJobs()).thenReturn(expectedResponse); String jsonString = mockMvc.perform( MockMvcRequestBuilders.get("/api/print-jobs/deletable") .accept(MediaType.APPLICATION_JSON) ) .andExpect(status().isAccepted()) .andReturn().getResponse().getContentAsString(); ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JavaTimeModule()); DataResponse<PrintJob> actualResponse = mapper.readValue(jsonString, new TypeReference<DataResponse<PrintJob>>() {}); int actualId = actualResponse.getData() .get(0) .getId(); int expectedId = expectedResponse .getData() .get(0) .getId(); assertEquals(expectedId, actualId); }
@GetMapping("/deletable") public ResponseEntity<?> getDeletablePrintJobs() { LOGGER.info("getDeletablePrintJobs "); DataResponse<BasicPrintJob> response = printJobOperations.getDeletablePrintJobs(); return new ResponseEntity<>(response, response.getHttpStatus()); }
PrintJobController { @GetMapping("/deletable") public ResponseEntity<?> getDeletablePrintJobs() { LOGGER.info("getDeletablePrintJobs "); DataResponse<BasicPrintJob> response = printJobOperations.getDeletablePrintJobs(); return new ResponseEntity<>(response, response.getHttpStatus()); } }
PrintJobController { @GetMapping("/deletable") public ResponseEntity<?> getDeletablePrintJobs() { LOGGER.info("getDeletablePrintJobs "); DataResponse<BasicPrintJob> response = printJobOperations.getDeletablePrintJobs(); return new ResponseEntity<>(response, response.getHttpStatus()); } PrintJobController(PrintJobOperations printJobOperations); }
PrintJobController { @GetMapping("/deletable") public ResponseEntity<?> getDeletablePrintJobs() { LOGGER.info("getDeletablePrintJobs "); DataResponse<BasicPrintJob> response = printJobOperations.getDeletablePrintJobs(); return new ResponseEntity<>(response, response.getHttpStatus()); } PrintJobController(PrintJobOperations printJobOperations); @GetMapping ResponseEntity<?> printJobGetAll(@RequestParam(required = false) String status); @PostMapping ResponseEntity<?> printJobNew(@ModelAttribute PrintJobNewRequest model, Principal principal); @GetMapping("/{print-id}") ResponseEntity<?> printJobGetById(@PathVariable("print-id") Integer printId); @PutMapping("/{print-id}/model") ResponseEntity<?> printJobUpdateModel(@PathVariable("print-id") Integer printId,
                                                  @ModelAttribute PrintModelUpdateRequest model); @DeleteMapping("/{print-id}/model") ResponseEntity<?> printJobDeleteModel(@PathVariable("print-id") Integer printId); @PutMapping("/{print-id}/status") ResponseEntity<?> printJobUpdateStatus(@PathVariable ("print-id") Integer printId,
                                                  @RequestBody PrintJobUpdateRequest dto); @DeleteMapping ResponseEntity<?> printJobDelete(@RequestBody PrintJobDeleteRequest dto); @GetMapping("/deletable") ResponseEntity<?> getDeletablePrintJobs(); @PutMapping("/{print-id}") ResponseEntity<?> updatePrintJobProperties(@PathVariable("print-id") Integer printId, @RequestBody UpdatePrintJobPropertiesRequest request, Principal principal); }
PrintJobController { @GetMapping("/deletable") public ResponseEntity<?> getDeletablePrintJobs() { LOGGER.info("getDeletablePrintJobs "); DataResponse<BasicPrintJob> response = printJobOperations.getDeletablePrintJobs(); return new ResponseEntity<>(response, response.getHttpStatus()); } PrintJobController(PrintJobOperations printJobOperations); @GetMapping ResponseEntity<?> printJobGetAll(@RequestParam(required = false) String status); @PostMapping ResponseEntity<?> printJobNew(@ModelAttribute PrintJobNewRequest model, Principal principal); @GetMapping("/{print-id}") ResponseEntity<?> printJobGetById(@PathVariable("print-id") Integer printId); @PutMapping("/{print-id}/model") ResponseEntity<?> printJobUpdateModel(@PathVariable("print-id") Integer printId,
                                                  @ModelAttribute PrintModelUpdateRequest model); @DeleteMapping("/{print-id}/model") ResponseEntity<?> printJobDeleteModel(@PathVariable("print-id") Integer printId); @PutMapping("/{print-id}/status") ResponseEntity<?> printJobUpdateStatus(@PathVariable ("print-id") Integer printId,
                                                  @RequestBody PrintJobUpdateRequest dto); @DeleteMapping ResponseEntity<?> printJobDelete(@RequestBody PrintJobDeleteRequest dto); @GetMapping("/deletable") ResponseEntity<?> getDeletablePrintJobs(); @PutMapping("/{print-id}") ResponseEntity<?> updatePrintJobProperties(@PathVariable("print-id") Integer printId, @RequestBody UpdatePrintJobPropertiesRequest request, Principal principal);  }