Search in sources :

Example 1 with ExtensionPointInterface

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));
}
Also used : Repository(org.pentaho.di.repository.Repository) TransMeta(org.pentaho.di.trans.TransMeta) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) ExtensionPointInterface(org.pentaho.di.core.extension.ExtensionPointInterface) Test(org.junit.Test)

Example 2 with ExtensionPointInterface

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));
}
Also used : IRepositoryFileData(org.pentaho.platform.api.repository2.unified.IRepositoryFileData) Serializable(java.io.Serializable) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) Calendar(java.util.Calendar) TransMeta(org.pentaho.di.trans.TransMeta) Matchers.anyString(org.mockito.Matchers.anyString) StringObjectId(org.pentaho.di.repository.StringObjectId) RepositoryElementInterface(org.pentaho.di.repository.RepositoryElementInterface) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) ExtensionPointInterface(org.pentaho.di.core.extension.ExtensionPointInterface) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Test(org.junit.Test)

Example 3 with ExtensionPointInterface

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));
}
Also used : Spoon(org.pentaho.di.ui.spoon.Spoon) TransMeta(org.pentaho.di.trans.TransMeta) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) ExtensionPointInterface(org.pentaho.di.core.extension.ExtensionPointInterface) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 ExtensionPointInterface (org.pentaho.di.core.extension.ExtensionPointInterface)3 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)3 TransMeta (org.pentaho.di.trans.TransMeta)3 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)2 Serializable (java.io.Serializable)1 Calendar (java.util.Calendar)1 Matchers.anyString (org.mockito.Matchers.anyString)1 ObjectId (org.pentaho.di.repository.ObjectId)1 Repository (org.pentaho.di.repository.Repository)1 RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)1 RepositoryElementInterface (org.pentaho.di.repository.RepositoryElementInterface)1 StringObjectId (org.pentaho.di.repository.StringObjectId)1 StepMeta (org.pentaho.di.trans.step.StepMeta)1 Spoon (org.pentaho.di.ui.spoon.Spoon)1 IRepositoryFileData (org.pentaho.platform.api.repository2.unified.IRepositoryFileData)1 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)1