@Test public void deletePrintJobSuccess() { PrintJobDeleteRequest request = new PrintJobDeleteRequest(); request.setEmployeeId(1); request.setPrintJobId(2); Employee employee = new Employee(); employee.setId(1); PrintJob printJob = new PrintJob(); printJob.setEmployee(employee); printJob.setId(2); when(employeeRepo.findEmployeeById(anyInt())).thenReturn(employee); when(printJobRepo.findPrintJobById(anyInt())).thenReturn(printJob); doNothing().when(printJobRepo).delete(printJob); GenericResponse response = operations.deletePrintJob(request); assertTrue("response is not true", response.isSuccess() == true); assertTrue("print job was not deleted", response.getMessage().equalsIgnoreCase("Print Job Deleted Successfully")); }
public GenericResponse deletePrintJob(PrintJobDeleteRequest dto) { dto.validate(); Employee employee = employeeRepo.findEmployeeById(dto.getEmployeeId()); PrintJob printJob = printJobRepo.findPrintJobById(dto.getPrintJobId()); if(employee == null || printJob == null){ ErrorType.PRINT_JOB_CANT_DELETED.throwException(); } GenericResponse response = new GenericResponse(); printJobRepo.delete(printJob); response.setSuccess(true); response.setMessage("Print Job Deleted Successfully"); response.setHttpStatus(HttpStatus.ACCEPTED); return response; }
PrintJobOperations { public GenericResponse deletePrintJob(PrintJobDeleteRequest dto) { dto.validate(); Employee employee = employeeRepo.findEmployeeById(dto.getEmployeeId()); PrintJob printJob = printJobRepo.findPrintJobById(dto.getPrintJobId()); if(employee == null || printJob == null){ ErrorType.PRINT_JOB_CANT_DELETED.throwException(); } GenericResponse response = new GenericResponse(); printJobRepo.delete(printJob); response.setSuccess(true); response.setMessage("Print Job Deleted Successfully"); response.setHttpStatus(HttpStatus.ACCEPTED); return response; } }
PrintJobOperations { public GenericResponse deletePrintJob(PrintJobDeleteRequest dto) { dto.validate(); Employee employee = employeeRepo.findEmployeeById(dto.getEmployeeId()); PrintJob printJob = printJobRepo.findPrintJobById(dto.getPrintJobId()); if(employee == null || printJob == null){ ErrorType.PRINT_JOB_CANT_DELETED.throwException(); } GenericResponse response = new GenericResponse(); printJobRepo.delete(printJob); response.setSuccess(true); response.setMessage("Print Job Deleted Successfully"); response.setHttpStatus(HttpStatus.ACCEPTED); return response; } PrintJobOperations(FileService fileService, PrintJobRepo printJobRepo,
                              ColorTypeRepo colorTypeRepo, CustomerInfoRepo customerInfoRepo,
                              EmployeeRepo employeeRepo, EmailHashUtil emailHashUtil, QueueRepo queueRepo); }
PrintJobOperations { public GenericResponse deletePrintJob(PrintJobDeleteRequest dto) { dto.validate(); Employee employee = employeeRepo.findEmployeeById(dto.getEmployeeId()); PrintJob printJob = printJobRepo.findPrintJobById(dto.getPrintJobId()); if(employee == null || printJob == null){ ErrorType.PRINT_JOB_CANT_DELETED.throwException(); } GenericResponse response = new GenericResponse(); printJobRepo.delete(printJob); response.setSuccess(true); response.setMessage("Print Job Deleted Successfully"); 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 deletePrintJob(PrintJobDeleteRequest dto) { dto.validate(); Employee employee = employeeRepo.findEmployeeById(dto.getEmployeeId()); PrintJob printJob = printJobRepo.findPrintJobById(dto.getPrintJobId()); if(employee == null || printJob == null){ ErrorType.PRINT_JOB_CANT_DELETED.throwException(); } GenericResponse response = new GenericResponse(); printJobRepo.delete(printJob); response.setSuccess(true); response.setMessage("Print Job Deleted Successfully"); 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);  }