DataServiceMetaFactory implements IDataServiceMetaFactory { private String createDataServiceName( StepMeta step, Integer rowLimit, boolean streaming ) throws KettleException { TransMeta transMeta = step.getParentTransMeta(); String fullFileName; if ( !Utils.isEmpty( transMeta.getFilename() ) && transMeta.getObjectId() == null ) { fullFileName = transMeta.getFilename(); } else { if ( transMeta.getRepositoryDirectory() != null ) { String path = transMeta.getRepositoryDirectory().getPath(); if ( path.endsWith( RepositoryDirectory.DIRECTORY_SEPARATOR ) ) { fullFileName = path + transMeta.getName(); } else { fullFileName = path + RepositoryDirectory.DIRECTORY_SEPARATOR + transMeta.getName(); } } else { fullFileName = transMeta.getName(); } } String local = isLocal( transMeta ) ? TransientResolver.LOCAL : ""; String stream = streaming ? TransientResolver.STREAMING : ""; return TransientResolver .buildTransient( fullFileName, local + stream + step.getName(), rowLimit ); } DataServiceMetaFactory();  DataServiceMetaFactory( Supplier<Spoon> spoonSupplier ); @Override PushDownFactory getCacheFactory(); @Override void setCacheFactory( PushDownFactory cacheFactory ); @Override DataServiceMeta createDataService( StepMeta step ); @Override DataServiceMeta createDataService( StepMeta step, Integer rowLimit );  }
@Test public void testCreateDataServiceName() throws Exception { when( transMeta.getObjectId() ).thenReturn( null ); when( transMeta.getFilename() ).thenReturn( "C:\\windows\\path\\file.ktr" ); DataServiceMeta ds1 = factory.createDataService( stepMeta ); assertTrue( TransientResolver.isTransient( ds1.getName() ) ); when( transMeta.getFilename() ).thenReturn( "/unix/path/file.ktr" ); DataServiceMeta ds2 = factory.createDataService( stepMeta ); assertTrue( TransientResolver.isTransient( ds2.getName() ) ); RepositoryDirectoryInterface repositoryDirectoryInterface = mock( RepositoryDirectoryInterface.class ); when( repositoryDirectoryInterface.getPath() ).thenReturn( "/repository/path" ); when( transMeta.getObjectId() ).thenReturn( mock( ObjectId.class ) ); when( transMeta.getFilename() ).thenReturn( "/unix/path/file.ktr" ); when( transMeta.getRepositoryDirectory() ).thenReturn( repositoryDirectoryInterface ); DataServiceMeta ds3 = factory.createDataService( stepMeta ); assertTrue( TransientResolver.isTransient( ds3.getName() ) ); repositoryDirectoryInterface = mock( RepositoryDirectoryInterface.class ); when( repositoryDirectoryInterface.getPath() ).thenReturn( "/repository/path" ); when( transMeta.getFilename() ).thenReturn( "" ); when( transMeta.getRepositoryDirectory() ).thenReturn( repositoryDirectoryInterface ); DataServiceMeta ds6 = factory.createDataService( stepMeta ); assertTrue( TransientResolver.isTransient( ds6.getName() ) ); when( repositoryDirectoryInterface.getPath() ).thenReturn( "/repository/path/" ); when( transMeta.getFilename() ).thenReturn( "" ); when( transMeta.getRepositoryDirectory() ).thenReturn( repositoryDirectoryInterface ); DataServiceMeta ds4 = factory.createDataService( stepMeta ); assertTrue( TransientResolver.isTransient( ds4.getName() ) ); when( transMeta.getRepositoryDirectory() ).thenReturn( null ); DataServiceMeta ds5 = factory.createDataService( stepMeta ); assertTrue( TransientResolver.isTransient( ds5.getName() ) ); }