ScanServiceImpl implements ScanService { @Override public Page<Scan> getAll(Integer pageNumber, Integer pageSize) { Pageable pageable = PageRequest.of(pageNumber, pageSize); return scanDAO.getAllByOrderBySubmittedTimestampDesc(pageable); } @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) public void testGetAll(Scan scan) { Mockito.when(mockScanDAO.getAllByOrderBySubmittedTimestampDesc(PageRequest.of(1, 10))) .thenReturn(new PageImpl<>(Collections.singletonList(scan))); Page retrievedScansPage = scanService.getAll(1, 10); Assert.assertNotNull(retrievedScansPage); List<Scan> retrievedScans = retrievedScansPage.getContent(); Assert.assertNotNull(retrievedScans); Assert.assertFalse(retrievedScans.isEmpty()); Assert.assertEquals(scan, retrievedScans.get(0)); }