ServiceTrans implements MetaStoreElement { @Override public String getName() { return name; }  static ServiceTrans create( DataServiceMeta dataServiceMeta ); static ServiceTrans create( String name, TransMeta transMeta ); static List<Reference> references( TransMeta transMeta ); static Predicate<ServiceTrans> isReferenceTo( final TransMeta transMeta ); static Predicate<ServiceTrans> isValid( final Repository repository ); @Override String getName(); @Override void setName( String name ); List<Reference> getReferences(); @Override String toString();  }
@Test public void testRepoPathStorageMethod() throws KettleException { ObjectId transId = new StringObjectId( "transId" ); when( repository.loadTransformation( eq( transId ), isNull( String.class ) ) ).thenReturn( transMeta ); RepositoryDirectoryInterface root = mock( RepositoryDirectoryInterface.class ); ObjectId rootId = new StringObjectId( "dirId" ); when( root.getObjectId() ).thenReturn( rootId ); when( repository.loadRepositoryDirectoryTree() ).thenReturn( root ); RepositoryDirectoryInterface dir = mock( RepositoryDirectoryInterface.class ); when( root.findDirectory( eq( "/existing" ) ) ).thenReturn( dir, null ); when( repository.getTransformationID( eq( "Trans" ), eq( dir ) ) ).thenReturn( null ); RepositoryElementMetaInterface transInfo = mock( RepositoryElementMetaInterface.class ); when( transInfo.getName() ).thenReturn( "Trans" ); when( transInfo.getObjectId() ).thenReturn( transId ); when( repository.getTransformationObjects( eq( rootId ), eq( true ) ) ).thenReturn( Arrays.asList( transInfo ) ); ServiceTrans.StorageMethod method = ServiceTrans.StorageMethod.REPO_PATH; assertThat( method.exists( repository, "/existing/Trans" ), is( true ) ); RepositoryObject transObjectInfo = mock( RepositoryObject.class ); when( transObjectInfo.isDeleted() ).thenReturn( false, true ); when( repository.getObjectInformation( eq( transId ), eq( RepositoryObjectType.TRANSFORMATION ) ) ) .thenReturn( transObjectInfo ); assertThat( method.load( repository, "/existing/Trans" ), is( transMeta ) ); assertThat( method.load( repository, "/existing/Trans" ), is( nullValue() ) ); }