ScannerServiceImpl implements ScannerService { @Override public List<ScannerApp> getAppsByScannerAndAssignedProduct(Scanner scanner, String productName) { return scannerAppDAO.getByScannerAndAssignedProduct(scanner, productName); } @Autowired  ScannerServiceImpl(ScannerDAO scannerDAO, ScannerAppDAO scannerAppDAO); @Override Scanner insert(Scanner scanner); @Override Scanner update(Scanner scanner); @Override Scanner getById(String scannerId); @Override List<Scanner> getAll(); @Override List<ScannerApp> getAppsByScannerAndAssignedProduct(Scanner scanner, String productName); @Override void removeByScannerId(String scannerId);  }
@Test(dataProvider = "getScannerData", dataProviderClass = ServiceTestDataProvider.class) public void testGetAppsByScannerAndAssignedProduct(Scanner testScanner) { Mockito.when(mockScannerAppDAO.getByScannerAndAssignedProduct(testScanner, TEST_PRODUCT_ID)) .thenReturn(new ArrayList<>(testScanner.getApps())); List<ScannerApp> returnedScannerApps = scannerService.getAppsByScannerAndAssignedProduct(testScanner, TEST_PRODUCT_ID); Assert.assertNotNull(returnedScannerApps); Assert.assertFalse(returnedScannerApps.isEmpty()); Assert.assertEquals(TEST_PRODUCT_ID, returnedScannerApps.get(0).getAssignedProduct()); }