TrackerImpl implements Tracker { public void init() { dataService = new TrackerOperationDataService( daoManager.getEntityManagerFactory() ); purger.scheduleAtFixedRate( new Runnable() { @Override public void run() { try { dataService.deleteOldTrackerOperations( 30L ); } catch ( Exception e ) { LOG.error( "Error purging old operations", e ); } } }, 0, 1, TimeUnit.DAYS ); }  @Override TrackerOperationView getTrackerOperation( String source, UUID operationTrackId ); @Override TrackerOperation createTrackerOperation( String source, String description ); @Override List<TrackerOperationView> getTrackerOperations( String source, Date fromDate, Date toDate, int limit ); @Override List<String> getTrackerOperationSources(); @Override void printOperationLog( String source, UUID operationTrackId, long maxOperationDurationMs ); @Override void setOperationViewState( String source, UUID operationId, boolean display ); @Override void setOperationsViewStates( boolean display ); @Override List<TrackerOperationView> getNotifications(); void init(); void dispose(); void setDaoManager( final DaoManager daoManager ); void setIdentityManager( final IdentityManager identityManager );  }
@Test public void testInit() throws Exception { tracker.setDaoManager( daoManager ); when( daoManager.getEntityManagerFactory() ).thenReturn( entityManagerFactory ); when( entityManagerFactory.createEntityManager() ).thenReturn( entityManager ); tracker.init(); verify( entityManager, atLeastOnce() ).close(); }