use of org.pentaho.di.core.extension.ExtensionPointInterface in project pentaho-kettle by pentaho.
the class StreamToTransNodeConverterTest method convertPostRepoSave.
@Test
public void convertPostRepoSave() throws Exception {
StreamToTransNodeConverter converter = mock(StreamToTransNodeConverter.class);
doCallRealMethod().when(converter).convertPostRepoSave(any(RepositoryFile.class));
Repository repository = mock(Repository.class);
when(converter.connectToRepository()).thenReturn(repository);
TransMeta transMeta = mock(TransMeta.class);
when(repository.loadTransformation(any(), anyString())).thenReturn(transMeta);
RepositoryFile file = mock(RepositoryFile.class);
when(file.getId()).thenReturn("fileId");
PluginMockInterface pluginInterface = mock(PluginMockInterface.class);
when(pluginInterface.getName()).thenReturn(KettleExtensionPoint.TransImportAfterSaveToRepo.id);
when(pluginInterface.getMainType()).thenReturn((Class) ExtensionPointInterface.class);
when(pluginInterface.getIds()).thenReturn(new String[] { "extensionpointId" });
ExtensionPointInterface extensionPoint = mock(ExtensionPointInterface.class);
when(pluginInterface.loadClass(ExtensionPointInterface.class)).thenReturn(extensionPoint);
PluginRegistry.addPluginType(ExtensionPointPluginType.getInstance());
PluginRegistry.getInstance().registerPlugin(ExtensionPointPluginType.class, pluginInterface);
converter.convertPostRepoSave(file);
verify(extensionPoint, times(1)).callExtensionPoint(any(LogChannelInterface.class), same(transMeta));
}
use of org.pentaho.di.core.extension.ExtensionPointInterface in project pentaho-kettle by pentaho.
the class PurRepositoryUnitTest method testTransRepoAfterSaveExtensionPoint.
@Test
public void testTransRepoAfterSaveExtensionPoint() throws KettleException {
PluginMockInterface pluginInterface = mock(PluginMockInterface.class);
when(pluginInterface.getName()).thenReturn(KettleExtensionPoint.TransImportAfterSaveToRepo.id);
when(pluginInterface.getMainType()).thenReturn((Class) ExtensionPointInterface.class);
when(pluginInterface.getIds()).thenReturn(new String[] { "extensionpointId" });
ExtensionPointInterface extensionPoint = mock(ExtensionPointInterface.class);
when(pluginInterface.loadClass(ExtensionPointInterface.class)).thenReturn(extensionPoint);
PluginRegistry.addPluginType(ExtensionPointPluginType.getInstance());
PluginRegistry.getInstance().registerPlugin(ExtensionPointPluginType.class, pluginInterface);
PurRepository rep = mock(PurRepository.class);
doCallRealMethod().when(rep).saveTransOrJob(any(ISharedObjectsTransformer.class), any(RepositoryElementInterface.class), anyString(), any(Calendar.class), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean());
IUnifiedRepository pur = mock(IUnifiedRepository.class);
doCallRealMethod().when(rep).setTest(same(pur));
PurRepositoryMeta mockMeta = mock(PurRepositoryMeta.class);
doCallRealMethod().when(rep).init(same(mockMeta));
rep.init(mockMeta);
rep.setTest(pur);
RepositoryFile file = mock(RepositoryFile.class);
when(file.getId()).thenReturn("id");
when(pur.createFile(any(Serializable.class), any(RepositoryFile.class), any(IRepositoryFileData.class), anyString())).thenReturn(file);
TransMeta trans = mock(TransMeta.class);
when(trans.getRepositoryElementType()).thenReturn(RepositoryObjectType.TRANSFORMATION);
when(trans.getName()).thenReturn("trans");
RepositoryDirectory dir = mock(RepositoryDirectory.class);
when(dir.getObjectId()).thenReturn(new StringObjectId("id"));
when(trans.getRepositoryDirectory()).thenReturn(dir);
TransMeta transFromRepo = mock(TransMeta.class);
when(rep.loadTransformation(any(ObjectId.class), isNull(String.class))).thenReturn(transFromRepo);
ISharedObjectsTransformer transformer = mock(ISharedObjectsTransformer.class);
rep.saveTransOrJob(transformer, trans, "", Calendar.getInstance(), false, false, false, false, false);
verify(extensionPoint, times(1)).callExtensionPoint(any(LogChannelInterface.class), same(transFromRepo));
}
use of org.pentaho.di.core.extension.ExtensionPointInterface in project pentaho-kettle by pentaho.
the class SpoonStepsDelegateTest method testDelStepsExtensionPointCancelDelete.
@Test
public void testDelStepsExtensionPointCancelDelete() throws Exception {
PluginMockInterface pluginInterface = mock(PluginMockInterface.class);
when(pluginInterface.getName()).thenReturn(KettleExtensionPoint.TransBeforeDeleteSteps.id);
when(pluginInterface.getMainType()).thenReturn((Class) ExtensionPointInterface.class);
when(pluginInterface.getIds()).thenReturn(new String[] { KettleExtensionPoint.TransBeforeDeleteSteps.id });
ExtensionPointInterface extensionPoint = mock(ExtensionPointInterface.class);
when(pluginInterface.loadClass(ExtensionPointInterface.class)).thenReturn(extensionPoint);
doThrow(KettleException.class).when(extensionPoint).callExtensionPoint(any(LogChannelInterface.class), any(StepMeta[].class));
PluginRegistry.addPluginType(ExtensionPointPluginType.getInstance());
PluginRegistry.getInstance().registerPlugin(ExtensionPointPluginType.class, pluginInterface);
SpoonStepsDelegate delegate = mock(SpoonStepsDelegate.class);
delegate.spoon = mock(Spoon.class);
doCallRealMethod().when(delegate).delSteps(any(TransMeta.class), any(StepMeta[].class));
TransMeta trans = mock(TransMeta.class);
StepMeta[] steps = new StepMeta[] { mock(StepMeta.class) };
delegate.delSteps(trans, steps);
verify(extensionPoint, times(1)).callExtensionPoint(any(), eq(steps));
}
Aggregations