DataServiceResolverDelegate implements DataServiceResolver { @Override public DataServiceExecutor.Builder createBuilder( SQL sql ) throws KettleException { boolean foundDataService = false; for ( DataServiceResolver resolver : resolvers ) { DataServiceExecutor.Builder builder = resolver.createBuilder( sql ); if ( builder != null ) { return builder; } else { foundDataService = foundDataService || ( resolver.getDataService( sql.getServiceName() ) != null ); } } throw new KettleException( foundDataService ? "Error when creating builder for sql query" : MessageFormat.format( "Data Service {0} was not found", sql.getServiceName() ) ); } DataServiceResolverDelegate();  DataServiceResolverDelegate( List<DataServiceResolver> resolvers ); void addResolver( DataServiceResolver resolver ); void removeResolver( DataServiceResolver resolver ); @Override List<DataServiceMeta> getDataServices( Function<Exception, Void> logger ); @Override List<DataServiceMeta> getDataServices( String dataServiceName, Function<Exception, Void> logger ); @Override DataServiceMeta getDataService( String dataServiceName ); @Override List<String> getDataServiceNames( String dataServiceName ); @Override DataServiceExecutor.Builder createBuilder( SQL sql ); @Override List<String> getDataServiceNames();  }
@Test public void testCreateBuilder() throws KettleException { DataServiceExecutor.Builder returnBuilder = dataServiceResolverDelegate.createBuilder( sql ); assertEquals( returnBuilder, builder ); verify( resolver ).createBuilder( sql ); verify( sql, never() ).getServiceName(); }
@Test public void testCreateBuilderExceptionDataServiceFailedSqlBuild() throws KettleException { when( resolver.createBuilder( sql ) ).thenReturn( null ); thrown.expect( KettleException.class ); thrown.expectMessage( ERROR_BUILDING_SQL ); DataServiceExecutor.Builder returnBuilder = dataServiceResolverDelegate.createBuilder( sql ); verify( resolver ).createBuilder( sql ); verify( sql ).getServiceName(); }