Search in sources :

Example 21 with StepMetaInterface

use of org.pentaho.di.trans.step.StepMetaInterface in project pentaho-kettle by pentaho.

the class RepositoryImporterTest method testImportTrans_patchTransEntries_when_directory_path_starts_with_variable.

@Test
public void testImportTrans_patchTransEntries_when_directory_path_starts_with_variable() throws KettleException {
    JobEntryInterface jobEntryInterface = createJobEntry("");
    StepMetaInterface stepMeta = createStepMeta("${USER_VARIABLE}/myDir");
    RepositoryImporter importer = createRepositoryImporter(jobEntryInterface, stepMeta, true);
    importer.setBaseDirectory(baseDirectory);
    importer.importTransformation(entityNode, feedback);
    verify((HasRepositoryDirectories) stepMeta).setDirectories(new String[] { "${USER_VARIABLE}/myDir" });
    StepMetaInterface stepMeta2 = createStepMeta("${USER_VARIABLE}/myDir");
    RepositoryImporter importerWithCompatibilityImportPath = createRepositoryImporter(jobEntryInterface, stepMeta2, false);
    importerWithCompatibilityImportPath.setBaseDirectory(baseDirectory);
    importerWithCompatibilityImportPath.importTransformation(entityNode, feedback);
    verify((HasRepositoryDirectories) stepMeta2).setDirectories(new String[] { ROOT_PATH + "/${USER_VARIABLE}/myDir" });
}
Also used : JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) Test(org.junit.Test)

Example 22 with StepMetaInterface

use of org.pentaho.di.trans.step.StepMetaInterface in project pentaho-kettle by pentaho.

the class RepositoryImporterTest method testImportJob_patchJobEntries_with_variable.

@Test
public void testImportJob_patchJobEntries_with_variable() throws KettleException {
    JobEntryInterface jobEntryInterface = createJobEntry("${USER_VARIABLE}");
    StepMetaInterface stepMeta = createStepMeta("");
    RepositoryImporter importer = createRepositoryImporter(jobEntryInterface, stepMeta, true);
    importer.setBaseDirectory(baseDirectory);
    importer.importJob(entityNode, feedback);
    verify((HasRepositoryDirectories) jobEntryInterface).setDirectories(new String[] { "${USER_VARIABLE}" });
}
Also used : JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) Test(org.junit.Test)

Example 23 with StepMetaInterface

use of org.pentaho.di.trans.step.StepMetaInterface in project pentaho-kettle by pentaho.

the class RepositoryImporterTest method testImportJob_patchJobEntries_without_variables.

@Test
public void testImportJob_patchJobEntries_without_variables() throws KettleException {
    JobEntryInterface jobEntry = createJobEntry("/userName");
    StepMetaInterface stepMeta = createStepMeta("");
    RepositoryImporter importer = createRepositoryImporter(jobEntry, stepMeta, true);
    importer.setBaseDirectory(baseDirectory);
    importer.importJob(entityNode, feedback);
    verify((HasRepositoryDirectories) jobEntry).setDirectories(new String[] { ROOT_PATH + USER_NAME_PATH });
}
Also used : JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) Test(org.junit.Test)

Example 24 with StepMetaInterface

use of org.pentaho.di.trans.step.StepMetaInterface in project pentaho-kettle by pentaho.

the class RepositoryImporterTest method testImportTrans_patchTransEntries_when_directory_path_ends_with_variable.

@Test
public void testImportTrans_patchTransEntries_when_directory_path_ends_with_variable() throws KettleException {
    JobEntryInterface jobEntryInterface = createJobEntry("");
    StepMetaInterface stepMeta = createStepMeta("/myDir/${USER_VARIABLE}");
    RepositoryImporter importer = createRepositoryImporter(jobEntryInterface, stepMeta, true);
    importer.setBaseDirectory(baseDirectory);
    importer.importTransformation(entityNode, feedback);
    verify((HasRepositoryDirectories) stepMeta).setDirectories(new String[] { "/myDir/${USER_VARIABLE}" });
    StepMetaInterface stepMeta2 = createStepMeta("/myDir/${USER_VARIABLE}");
    RepositoryImporter importerWithCompatibilityImportPath = createRepositoryImporter(jobEntryInterface, stepMeta2, false);
    importerWithCompatibilityImportPath.setBaseDirectory(baseDirectory);
    importerWithCompatibilityImportPath.importTransformation(entityNode, feedback);
    verify((HasRepositoryDirectories) stepMeta2).setDirectories(new String[] { ROOT_PATH + "/myDir/${USER_VARIABLE}" });
}
Also used : JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) Test(org.junit.Test)

Example 25 with StepMetaInterface

use of org.pentaho.di.trans.step.StepMetaInterface in project pentaho-kettle by pentaho.

the class TransMetaConverterTest method testDisabledHops.

@Test
public void testDisabledHops() {
    TransMeta trans = new TransMeta();
    StepMeta start = new StepMeta("Start", stepMetaInterface);
    trans.addStep(start);
    StepMeta withEnabledHop = new StepMeta("WithEnabledHop", stepMetaInterface);
    trans.addStep(withEnabledHop);
    StepMeta withDisabledHop = new StepMeta("WithDisabledHop", stepMetaInterface);
    trans.addStep(withDisabledHop);
    StepMeta shouldStay = new StepMeta("ShouldStay", stepMetaInterface);
    trans.addStep(shouldStay);
    StepMeta shouldNotStay = new StepMeta("ShouldNotStay", stepMetaInterface);
    trans.addStep(shouldNotStay);
    StepMeta withEnabledAndDisabledHops = new StepMeta("WithEnabledAndDisabledHops", stepMetaInterface);
    trans.addStep(withEnabledAndDisabledHops);
    StepMeta afterEnabledDisabled = new StepMeta("AfterEnabledDisabled", stepMetaInterface);
    trans.addStep(afterEnabledDisabled);
    trans.addTransHop(new TransHopMeta(start, withEnabledHop));
    trans.addTransHop(new TransHopMeta(start, withDisabledHop, false));
    trans.addTransHop(new TransHopMeta(withEnabledHop, shouldStay));
    trans.addTransHop(new TransHopMeta(withDisabledHop, shouldStay));
    trans.addTransHop(new TransHopMeta(withDisabledHop, shouldNotStay));
    trans.addTransHop(new TransHopMeta(start, withEnabledAndDisabledHops));
    trans.addTransHop(new TransHopMeta(withEnabledHop, withEnabledAndDisabledHops, false));
    trans.addTransHop(new TransHopMeta(withEnabledAndDisabledHops, afterEnabledDisabled));
    Transformation transformation = TransMetaConverter.convert(trans);
    List<String> steps = transformation.getOperations().stream().map(op -> op.getId()).collect(Collectors.toList());
    assertThat("Only 5 ops should exist", steps.size(), is(5));
    assertThat(steps, hasItems("Start", "WithEnabledHop", "ShouldStay", "WithEnabledAndDisabledHops", "AfterEnabledDisabled"));
    List<String> hops = transformation.getHops().stream().map(hop -> hop.getId()).collect(Collectors.toList());
    assertThat("Only 4 hops should exist", hops.size(), is(4));
    assertThat(hops, hasItems("Start -> WithEnabledHop", "WithEnabledHop -> ShouldStay", "Start -> WithEnabledAndDisabledHops", "WithEnabledAndDisabledHops -> AfterEnabledDisabled"));
}
Also used : Transformation(org.pentaho.di.engine.api.model.Transformation) CoreMatchers.is(org.hamcrest.CoreMatchers.is) Trans(org.pentaho.di.trans.Trans) StepDataInterface(org.pentaho.di.trans.step.StepDataInterface) StepPluginType(org.pentaho.di.core.plugins.StepPluginType) Hop(org.pentaho.di.engine.api.model.Hop) CoreMatchers.startsWith(org.hamcrest.CoreMatchers.startsWith) KettleClientEnvironment(org.pentaho.di.core.KettleClientEnvironment) Operation(org.pentaho.di.engine.api.model.Operation) TransMeta(org.pentaho.di.trans.TransMeta) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) Document(org.w3c.dom.Document) Matchers.eq(org.mockito.Matchers.eq) Spy(org.mockito.Spy) KettleMissingPluginsException(org.pentaho.di.core.exception.KettleMissingPluginsException) Map(java.util.Map) Mockito.doAnswer(org.mockito.Mockito.doAnswer) CsvInputMeta(org.pentaho.di.trans.steps.csvinput.CsvInputMeta) ClassRule(org.junit.ClassRule) Mockito.doReturn(org.mockito.Mockito.doReturn) StepInterface(org.pentaho.di.trans.step.StepInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) AfterClass(org.junit.AfterClass) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) Variables(org.pentaho.di.core.variables.Variables) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) Collectors(java.util.stream.Collectors) ResolvableResource(org.pentaho.di.workarounds.ResolvableResource) List(java.util.List) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Mockito.mock(org.mockito.Mockito.mock) RestorePDIEngineEnvironment(org.pentaho.di.junit.rules.RestorePDIEngineEnvironment) BeforeClass(org.junit.BeforeClass) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) KettleException(org.pentaho.di.core.exception.KettleException) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) Mockito.spy(org.mockito.Mockito.spy) Answer(org.mockito.stubbing.Answer) CoreMatchers.everyItem(org.hamcrest.CoreMatchers.everyItem) InvocationOnMock(org.mockito.invocation.InvocationOnMock) XMLHandler(org.pentaho.di.core.xml.XMLHandler) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) Node(org.w3c.dom.Node) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Before(org.junit.Before) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) Props(org.pentaho.di.core.Props) Repository(org.pentaho.di.repository.Repository) CoreMatchers.hasItems(org.hamcrest.CoreMatchers.hasItems) Assert.assertNotNull(org.junit.Assert.assertNotNull) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) KettleEnvironment(org.pentaho.di.core.KettleEnvironment) File(java.io.File) Mockito.verify(org.mockito.Mockito.verify) Mockito.never(org.mockito.Mockito.never) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) TransHopMeta(org.pentaho.di.trans.TransHopMeta) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) TableInputMeta(org.pentaho.di.trans.steps.tableinput.TableInputMeta) Assert.assertEquals(org.junit.Assert.assertEquals) Transformation(org.pentaho.di.engine.api.model.Transformation) TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) TransHopMeta(org.pentaho.di.trans.TransHopMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Test(org.junit.Test)

Aggregations

StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)77 StepMeta (org.pentaho.di.trans.step.StepMeta)40 KettleException (org.pentaho.di.core.exception.KettleException)31 Test (org.junit.Test)22 ArrayList (java.util.ArrayList)21 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)20 TransMeta (org.pentaho.di.trans.TransMeta)16 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)16 TableItem (org.eclipse.swt.widgets.TableItem)15 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)15 SourceToTargetMapping (org.pentaho.di.core.SourceToTargetMapping)14 Trans (org.pentaho.di.trans.Trans)14 EnterMappingDialog (org.pentaho.di.ui.core.dialog.EnterMappingDialog)14 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)12 Point (org.pentaho.di.core.gui.Point)12 TransHopMeta (org.pentaho.di.trans.TransHopMeta)11 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)11 NotePadMeta (org.pentaho.di.core.NotePadMeta)8 KettleStepException (org.pentaho.di.core.exception.KettleStepException)8 JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)8