TrackerImpl implements Tracker { @Override public void printOperationLog( String source, UUID operationTrackId, long maxOperationDurationMs ) { int logSize = 0; long startedTs = System.currentTimeMillis(); while ( !Thread.interrupted() ) { TrackerOperationView po = getTrackerOperation( source.toUpperCase(), operationTrackId ); if ( po != null ) { if ( logSize != po.getLog().length() ) { System.out.println( po.getLog().substring( logSize, po.getLog().length() ) ); logSize = po.getLog().length(); } long ts = System.currentTimeMillis() - startedTs; if ( po.getState() != OperationState.RUNNING || ts > maxOperationDurationMs ) { return; } TaskUtil.sleep( 100 ); } else { LOG.warn( "Tracker operation not found" ); return; } } }  @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 testPrintOperationLog() throws Exception { doReturn( productOperationView ).when( tracker ).getTrackerOperation( SOURCE.toUpperCase(), OPERATION_ID ); when( productOperationView.getLog() ).thenReturn( "log" ); when( productOperationView.getState() ).thenReturn( OperationState.RUNNING ) .thenReturn( OperationState.SUCCEEDED ); tracker.printOperationLog( SOURCE, OPERATION_ID, 200 ); assertEquals( "log", getSysOut() ); }