DeleteRepositoryObjectExtensionPointPlugin implements ExtensionPointInterface { @Override public void callExtensionPoint( LogChannelInterface log, Object object ) throws KettleException { RepositoryExtension repositoryExtension = (RepositoryExtension) object; UIRepositoryObject repositoryObject = repositoryExtension.getRepositoryObject(); if ( repositoryObject instanceof UIRepositoryDirectory ) { List<UIRepositoryObject> transformationList = new ArrayList<UIRepositoryObject>(); getAllTransformations( (UIRepositoryDirectory) repositoryObject, transformationList ); for ( UIRepositoryObject uiRepositoryObject : transformationList ) { Repository repository = uiRepositoryObject.getRepository(); metaStoreUtil.clearReferences( repository.loadTransformation( uiRepositoryObject.getObjectId(), null ) ); } } else if ( repositoryObject.getRepositoryElementType().equals( RepositoryObjectType.TRANSFORMATION ) ) { Repository repository = repositoryObject.getRepository(); metaStoreUtil.clearReferences( repository.loadTransformation( repositoryObject.getObjectId(), null ) ); } } DeleteRepositoryObjectExtensionPointPlugin( DataServiceContext context ); @Override void callExtensionPoint( LogChannelInterface log, Object object );  }
@Test public void testCallExtensionPoint() throws Exception { when( repositoryExtension.getRepositoryObject() ).thenReturn( repositoryObject ); when( repositoryObject.getRepositoryElementType() ).thenReturn( RepositoryObjectType.TRANSFORMATION ); when( repositoryObject.getRepository() ).thenReturn( repository ); when( repositoryObject.getObjectId() ).thenReturn( objectId ); when( repository.loadTransformation( objectId, null ) ).thenReturn( transMeta ); plugin.callExtensionPoint( log, repositoryExtension ); verify( repositoryExtension ).getRepositoryObject(); verify( repositoryObject ).getRepositoryElementType(); verify( repositoryObject ).getRepository(); verify( metaStoreUtil ).clearReferences( any( TransMeta.class ) ); }
@Test public void testCallExtensionPointWEmptyDirectory() throws Exception { when( repositoryExtension.getRepositoryObject() ).thenReturn( repositoryEmptyDirectory ); when( repositoryEmptyDirectory.getChildren() ).thenReturn( null ); when( repositoryEmptyDirectory.getRepositoryObjects() ).thenReturn( new UIRepositoryObjects() ); plugin.callExtensionPoint( log, repositoryExtension ); verify( repositoryExtension ).getRepositoryObject(); verify( repositoryEmptyDirectory ).getChildren(); verify( repositoryEmptyDirectory ).getChildren(); verify( repositoryEmptyDirectory ).getRepositoryObjects(); verify( metaStoreUtil, never() ).clearReferences( any( TransMeta.class ) ); }
@Test public void testCallExtensionPointWParentDirectory() throws Exception { when( repositoryExtension.getRepositoryObject() ).thenReturn( repositoryParentDirectory ); when( repositoryParentDirectory.getChildren() ).thenReturn( null ); when( repositoryParentDirectory.getRepositoryObjects() ).thenReturn( repoObjects ); when( repositoryObject.getRepositoryElementType() ).thenReturn( RepositoryObjectType.TRANSFORMATION ); when( repositoryObject.getRepository() ).thenReturn( repository ); when( repositoryObject.getObjectId() ).thenReturn( objectId ); when( repository.loadTransformation( objectId, null ) ).thenReturn( transMeta ); plugin.callExtensionPoint( log, repositoryExtension ); verify( repositoryExtension ).getRepositoryObject(); verify( repositoryParentDirectory ).getChildren(); verify( repositoryParentDirectory ).getRepositoryObjects(); verify( repositoryObject ).getRepositoryElementType(); verify( repositoryObject ).getRepository(); verify( metaStoreUtil ).clearReferences( any( TransMeta.class ) ); }
@Test public void testCallExtensionPointSubDirectory() throws Exception { when( repositoryExtension.getRepositoryObject() ).thenReturn( repositoryParentDirectory ); when( repositoryParentDirectory.getChildren() ).thenReturn( repoDirectories ); when( repositoryParentDirectory.getRepositoryObjects() ).thenReturn( repoObjects ); when( repositorySubDirectory.getChildren() ).thenReturn( null ); when( repositorySubDirectory.getRepositoryObjects() ).thenReturn( repoObjects ); when( repositoryObject.getRepositoryElementType() ).thenReturn( RepositoryObjectType.TRANSFORMATION ); when( repositoryObject.getRepository() ).thenReturn( repository ); when( repositoryObject.getObjectId() ).thenReturn( objectId ); when( repository.loadTransformation( objectId, null ) ).thenReturn( transMeta ); plugin.callExtensionPoint( log, repositoryExtension ); verify( repositoryExtension ).getRepositoryObject(); verify( repositoryParentDirectory, times( 3 ) ).getChildren(); verify( repositoryParentDirectory ).getRepositoryObjects(); verify( repositorySubDirectory, times( 1 ) ).getChildren(); verify( repositorySubDirectory ).getRepositoryObjects(); verify( repositoryObject, times( 2 ) ).getRepositoryElementType(); verify( repositoryObject, times( 2 ) ).getRepository(); verify( metaStoreUtil, times( 2 ) ).clearReferences( any( TransMeta.class ) ); }