ScanServiceImpl implements ScanService { @Override public void updatePriority(String jobId, ScanPriority priority) throws ScanManagerException { Integer updatedRows = scanDAO.updatePriority(priority.getValue(), jobId); if (updatedRows != 1) { throw new ScanManagerException("Error occurred while updating scan priority of the scan: " + jobId); } } @Autowired  ScanServiceImpl(ScanDAO scanDAO); @Override Scan update(Scan scan); @Override Scan insert(Scan scan); @Override Page<Scan> getAll(Integer pageNumber, Integer pageSize); @Override Scan getByJobId(String jobId); @Override void updateStatus(String jobId, ScanStatus status); @Override void updatePriority(String jobId, ScanPriority priority); @Override void updateScannerAppId(String jobId, String scannerAppId); @Override List<Scan> getByStatus(ScanStatus status); @Override List<Scan> getPendingScans(ScanStatus status); @Override List<Scan> getByStatusesAndScannerAndProduct(List<ScanStatus> statuses, Scanner scanner, String product);  }
@Test(dataProvider = "getScanData", dataProviderClass = ServiceTestDataProvider.class, expectedExceptions = ScanManagerException.class) public void testUpdatePriorityException(Scan scan) throws ScanManagerException { Mockito.when(mockScanDAO.updatePriority(ScanPriority.MEDIUM.getValue(), scan.getJobId())).thenReturn(-1); scanService.updatePriority(scan.getJobId(), ScanPriority.MEDIUM); }