### Question:
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);  }### Answer:
@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")); }
@Test(expected = IdeaLabApiException.class) public void deletePrintJob_shouldThrow_IdeaLabApiException_when_employee_is_not_exist() { 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(null); when(printJobRepo.findPrintJobById(anyInt())).thenReturn(printJob); operations.deletePrintJob(request); GenericResponse response = operations.deletePrintJob(request); assertTrue("response is not false", response.isSuccess() == false); assertTrue("print job was deleted", response.getMessage().equalsIgnoreCase("Print Job Delete Failed")); }
@Test(expected = IdeaLabApiException.class) public void deletePrintJob_shouldThrow_IdeaLabApiException_when_printJob_is_not_exist() { PrintJobDeleteRequest request = new PrintJobDeleteRequest(); request.setEmployeeId(1); request.setPrintJobId(2); Employee employee = new Employee(); employee.setId(1); when(employeeRepo.findEmployeeById(anyInt())).thenReturn(employee); when(printJobRepo.findPrintJobById(anyInt())).thenReturn(null); operations.deletePrintJob(request); }