ScannerServiceImpl implements ScannerService { @Override public void removeByScannerId(String scannerId) throws ScanManagerException { Integer updatedRows = scannerDAO.removeById(scannerId); if (updatedRows != 1) { throw new ScanManagerException("Error occurred while removing scanner: " + scannerId); } } @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(expectedExceptions = ScanManagerException.class) public void testRemoveByScannerIdException() throws ScanManagerException { Mockito.when(mockScannerDAO.removeById(TEST_SCANNER_ID)).thenReturn(-1); scannerService.removeByScannerId(TEST_SCANNER_ID); }