use of org.pentaho.di.base.Params in project pentaho-kettle by pentaho.
the class PanCommandExecutorTest method testExecuteWithInvalidRepository.
@Test
public void testExecuteWithInvalidRepository() {
// Create Mock Objects
Params params = mock(Params.class);
PanCommandExecutor panCommandExecutor = new PanCommandExecutor(Kitchen.class);
PowerMockito.mockStatic(BaseMessages.class);
// Mock returns
when(params.getRepoName()).thenReturn("NoExistingRepository");
when(BaseMessages.getString(any(Class.class), anyString(), anyVararg())).thenReturn("");
try {
Result result = panCommandExecutor.execute(params, null);
Assert.assertEquals(CommandExecutorCodes.Pan.COULD_NOT_LOAD_TRANS.getCode(), result.getExitStatus());
} catch (Throwable throwable) {
Assert.fail();
}
}
use of org.pentaho.di.base.Params in project pentaho-kettle by pentaho.
the class PanCommandExecutorTest method testTransformationFinishExtensionPointCalled.
/**
* This method test a ktr that fails in preparation step and and checks to make sure the callExtensionPoint is
* called once.
* @throws Throwable
*/
@Test
public void testTransformationFinishExtensionPointCalled() throws Throwable {
PluginMockInterface pluginInterface = mock(PluginMockInterface.class);
when(pluginInterface.getName()).thenReturn(KettleExtensionPoint.TransformationFinish.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);
// Execute a sample KTR
String fullPath = getClass().getResource("fail_on_prep_hello_world.ktr").getPath();
Params params = mock(Params.class);
when(params.getRepoName()).thenReturn("");
when(params.getLocalInitialDir()).thenReturn("");
when(params.getLocalFile()).thenReturn(fullPath);
when(params.getLocalJarFile()).thenReturn("");
when(params.getBase64Zip()).thenReturn("");
Trans trans = mockedPanCommandExecutor.loadTransFromFilesystem("", fullPath, "", "");
PanCommandExecutor panCommandExecutor = new PanCommandExecutor(PanCommandExecutor.class);
Result result = panCommandExecutor.execute(params);
verify(extensionPoint, times(1)).callExtensionPoint(any(LogChannelInterface.class), any(Trans.class));
}
use of org.pentaho.di.base.Params in project pentaho-kettle by pentaho.
the class PanCommandExecutorTest method testNoTransformationFinishExtensionPointCalled.
/**
* This method test a valid ktr and make sure the callExtensionPoint is never called, as this method is called
* if the ktr fails in preparation step
* @throws Throwable
*/
@Test
public void testNoTransformationFinishExtensionPointCalled() throws Throwable {
PluginMockInterface pluginInterface = mock(PluginMockInterface.class);
when(pluginInterface.getName()).thenReturn(KettleExtensionPoint.TransformationFinish.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);
// Execute a sample KTR
String fullPath = getClass().getResource(SAMPLE_KTR).getPath();
Params params = mock(Params.class);
when(params.getRepoName()).thenReturn("");
when(params.getLocalInitialDir()).thenReturn("");
when(params.getLocalFile()).thenReturn(fullPath);
when(params.getLocalJarFile()).thenReturn("");
when(params.getBase64Zip()).thenReturn("");
Trans trans = mockedPanCommandExecutor.loadTransFromFilesystem("", fullPath, "", "");
PanCommandExecutor panCommandExecutor = new PanCommandExecutor(PanCommandExecutor.class);
Result result = panCommandExecutor.execute(params);
verify(extensionPoint, times(0)).callExtensionPoint(any(LogChannelInterface.class), same(trans));
}
Aggregations