StreamingGeneratedTransExecution implements Runnable { @VisibleForTesting protected void waitForGeneratedTransToFinnish() { try { genTrans.waitUntilFinished(); } catch ( RuntimeException e ) { if ( e.getCause() instanceof InterruptedException ) { logger.debug( "The generated transformation was stopped, which resulted in an interruption of the generated transformation wait until finished call" ); } else { throw new RuntimeException( e ); } } } StreamingGeneratedTransExecution( final StreamingServiceTransExecutor serviceExecutor, final Trans genTrans,
                                           final Observer<List<RowMetaAndData>> rowConsumer, boolean pollingMode,
                                           final String injectorStepName, final String resultStepName, final String query,
                                           final IDataServiceClientService.StreamingMode windowMode,
                                           long windowSize, long windowEvery, long windowLimit,
                                           String streamingGeneratedTransCacheKey ); @Override void run(); void addNewRowConsumer( final Observer<List<RowMetaAndData>> consumer, boolean pollingMode ); void clearRowConsumers( );  }
@Test public void testWaitForGeneratedTransToFinnish(){ doThrow( new RuntimeException( new InterruptedException( ) ) ).when( genTrans ).waitUntilFinished(); genTransExecutor.waitForGeneratedTransToFinnish(); }
@Test ( expected = RuntimeException.class ) public void testWaitForGeneratedTransToFinnishCauseNotInterruptedException(){ doThrow( new RuntimeException( new NullPointerException( ) ) ).when( genTrans ).waitUntilFinished(); genTransExecutor.waitForGeneratedTransToFinnish(); fail( "When the thrown exception is not a RuntimeException with a InterruptedException cause, it should rethrow a RuntimeException" ); }
@Test ( expected = RuntimeException.class ) public void testWaitForGeneratedTransToFinnishNullPointerExceptionCatch(){ doThrow( new NullPointerException( ) ).when( genTrans ).waitUntilFinished(); genTransExecutor.waitForGeneratedTransToFinnish(); fail( "When the thrown exception is not a RuntimeException it should rethrow a RuntimeException" ); }