@Test(expected = IdeaLabApiException.class) public void deleteModelPrintJobNotFound() { PrintJob printJob = new PrintJob(); printJob.setId(999); when(printJobRepo.findPrintJobById(printJob.getId())).thenReturn(null); operations.deleteModel(printJob.getId()); }
public GenericResponse deleteModel(Integer printId) { GenericResponse response = new GenericResponse(); response.setSuccess(false); response.setMessage("File could not be deleted"); response.setHttpStatus(HttpStatus.BAD_REQUEST); PrintJob printJob = printJobRepo.findPrintJobById(printId); if(printJob == null) { throw new IdeaLabApiException(PRINT_JOBS_NOT_EXIST); } fileService.deleteFile(printJob.getFilePath()); printJob.setFilePath("Deleted"); printJob.setFileSharableLink("Deleted"); printJob = printJobRepo.save(printJob); response.setSuccess(true); response.setMessage("Successfully deleted file from DropBox"); response.setHttpStatus(HttpStatus.ACCEPTED); return response; }
PrintJobOperations { public GenericResponse deleteModel(Integer printId) { GenericResponse response = new GenericResponse(); response.setSuccess(false); response.setMessage("File could not be deleted"); response.setHttpStatus(HttpStatus.BAD_REQUEST); PrintJob printJob = printJobRepo.findPrintJobById(printId); if(printJob == null) { throw new IdeaLabApiException(PRINT_JOBS_NOT_EXIST); } fileService.deleteFile(printJob.getFilePath()); printJob.setFilePath("Deleted"); printJob.setFileSharableLink("Deleted"); printJob = printJobRepo.save(printJob); response.setSuccess(true); response.setMessage("Successfully deleted file from DropBox"); response.setHttpStatus(HttpStatus.ACCEPTED); return response; } }
PrintJobOperations { public GenericResponse deleteModel(Integer printId) { GenericResponse response = new GenericResponse(); response.setSuccess(false); response.setMessage("File could not be deleted"); response.setHttpStatus(HttpStatus.BAD_REQUEST); PrintJob printJob = printJobRepo.findPrintJobById(printId); if(printJob == null) { throw new IdeaLabApiException(PRINT_JOBS_NOT_EXIST); } fileService.deleteFile(printJob.getFilePath()); printJob.setFilePath("Deleted"); printJob.setFileSharableLink("Deleted"); printJob = printJobRepo.save(printJob); response.setSuccess(true); response.setMessage("Successfully deleted file from DropBox"); response.setHttpStatus(HttpStatus.ACCEPTED); return response; } PrintJobOperations(FileService fileService, PrintJobRepo printJobRepo,
                              ColorTypeRepo colorTypeRepo, CustomerInfoRepo customerInfoRepo,
                              EmployeeRepo employeeRepo, EmailHashUtil emailHashUtil, QueueRepo queueRepo); }
PrintJobOperations { public GenericResponse deleteModel(Integer printId) { GenericResponse response = new GenericResponse(); response.setSuccess(false); response.setMessage("File could not be deleted"); response.setHttpStatus(HttpStatus.BAD_REQUEST); PrintJob printJob = printJobRepo.findPrintJobById(printId); if(printJob == null) { throw new IdeaLabApiException(PRINT_JOBS_NOT_EXIST); } fileService.deleteFile(printJob.getFilePath()); printJob.setFilePath("Deleted"); printJob.setFileSharableLink("Deleted"); printJob = printJobRepo.save(printJob); response.setSuccess(true); response.setMessage("Successfully deleted file from DropBox"); response.setHttpStatus(HttpStatus.ACCEPTED); return response; } PrintJobOperations(FileService fileService, PrintJobRepo printJobRepo,
                              ColorTypeRepo colorTypeRepo, CustomerInfoRepo customerInfoRepo,
                              EmployeeRepo employeeRepo, EmailHashUtil emailHashUtil, QueueRepo queueRepo); DataResponse<BasicPrintJob> newPrintJob(PrintJobNewRequest printJobNewRequest, Principal principal); DataResponse<BasicPrintJob> updateModel(Integer printId, PrintModelUpdateRequest model); GenericResponse deleteModel(Integer printId); GenericResponse updatePrintJobStatus(Integer printId, PrintJobUpdateRequest dto); GenericResponse deletePrintJob(PrintJobDeleteRequest dto); DataResponse<BasicPrintJob> getAllPrintJobs(String status); DataResponse<BasicPrintJob> getDeletablePrintJobs(); DataResponse<BasicPrintJob> updatePrintJobProps(Integer printJobId, UpdatePrintJobPropertiesRequest request); DataResponse<BasicPrintJob> getPrintJobById(Integer printJobId); }
PrintJobOperations { public GenericResponse deleteModel(Integer printId) { GenericResponse response = new GenericResponse(); response.setSuccess(false); response.setMessage("File could not be deleted"); response.setHttpStatus(HttpStatus.BAD_REQUEST); PrintJob printJob = printJobRepo.findPrintJobById(printId); if(printJob == null) { throw new IdeaLabApiException(PRINT_JOBS_NOT_EXIST); } fileService.deleteFile(printJob.getFilePath()); printJob.setFilePath("Deleted"); printJob.setFileSharableLink("Deleted"); printJob = printJobRepo.save(printJob); response.setSuccess(true); response.setMessage("Successfully deleted file from DropBox"); response.setHttpStatus(HttpStatus.ACCEPTED); return response; } PrintJobOperations(FileService fileService, PrintJobRepo printJobRepo,
                              ColorTypeRepo colorTypeRepo, CustomerInfoRepo customerInfoRepo,
                              EmployeeRepo employeeRepo, EmailHashUtil emailHashUtil, QueueRepo queueRepo); DataResponse<BasicPrintJob> newPrintJob(PrintJobNewRequest printJobNewRequest, Principal principal); DataResponse<BasicPrintJob> updateModel(Integer printId, PrintModelUpdateRequest model); GenericResponse deleteModel(Integer printId); GenericResponse updatePrintJobStatus(Integer printId, PrintJobUpdateRequest dto); GenericResponse deletePrintJob(PrintJobDeleteRequest dto); DataResponse<BasicPrintJob> getAllPrintJobs(String status); DataResponse<BasicPrintJob> getDeletablePrintJobs(); DataResponse<BasicPrintJob> updatePrintJobProps(Integer printJobId, UpdatePrintJobPropertiesRequest request); DataResponse<BasicPrintJob> getPrintJobById(Integer printJobId);  }