DataServiceFactory extends DataServiceMetaStoreUtil { public DataServiceExecutor.Builder createBuilder( SQL sql ) throws MetaStoreException { DataServiceMeta dataService = getDataService( sql.getServiceName() ); if ( dataService.isStreaming() ) { return new DataServiceExecutor.Builder( sql, dataService, context ) .rowLimit( dataService.getRowLimit() ).timeLimit( dataService.getTimeLimit() ); } return new DataServiceExecutor.Builder( sql, dataService, context ); } protected  DataServiceFactory( DataServiceContext context ); abstract Repository getRepository(); IMetaStore getMetaStore(); DataServiceMeta getDataService( String serviceName ); Iterable<DataServiceMeta> getDataServices( Function<Exception, Void> exceptionHandler ); List<String> getDataServiceNames(); DataServiceExecutor.Builder createBuilder( SQL sql );  }
@Test public void testCreateBuilderNonStreaming() throws Exception { when( dsMeta.isStreaming() ).thenReturn( false ); factory = new DataServiceFactory( context ) { @Override public Repository getRepository() { return supplier.get(); } @Override public DataServiceMeta getDataService( String serviceName, Repository repository, IMetaStore metaStore ) { return dsMeta; } }; factory.createBuilder( sql ); verify( dsMeta, never() ).getRowLimit(); verify( dsMeta, never() ).getTimeLimit(); }
@Test public void testCreateBuilderStreaming() throws Exception { when( dsMeta.isStreaming() ).thenReturn( true ); factory = new DataServiceFactory( context ) { @Override public Repository getRepository() { return supplier.get(); } @Override public DataServiceMeta getDataService( String serviceName, Repository repository, IMetaStore metaStore ) { return dsMeta; } }; factory.createBuilder( sql ); verify( dsMeta ).getRowLimit(); verify( dsMeta ).getTimeLimit(); }