ScannerServiceImpl implements ScannerService { @Override public Scanner insert(Scanner scanner) { return scannerDAO.saveAndFlush(scanner); } @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 testInsert(Scanner testScanner) { Mockito.when(mockScannerDAO.saveAndFlush(testScanner)).thenReturn(testScanner); Scanner insertedScanner = scannerService.insert(testScanner); Assert.assertNotNull(insertedScanner); Assert.assertEquals(TEST_SCANNER_ID, insertedScanner.getId()); }