use of org.pentaho.di.trans.step.StepMetaInterface in project pentaho-kettle by pentaho.
the class RepositoryImporterTest method testImportTrans_patchTransEntries_with_variable.
@Test
public void testImportTrans_patchTransEntries_with_variable() throws KettleException {
JobEntryInterface jobEntryInterface = createJobEntry("");
StepMetaInterface stepMeta = createStepMeta("${USER_VARIABLE}");
RepositoryImporter importer = createRepositoryImporter(jobEntryInterface, stepMeta, true);
importer.setBaseDirectory(baseDirectory);
importer.importTransformation(entityNode, feedback);
verify((HasRepositoryDirectories) stepMeta).setDirectories(new String[] { "${USER_VARIABLE}" });
}
use of org.pentaho.di.trans.step.StepMetaInterface in project pentaho-kettle by pentaho.
the class RepositoryImporterTest method createStepMeta.
private static StepMetaInterface createStepMeta(String directory) {
StepMetaInterface stepMetaInterface = mock(StepMetaInterface.class, withSettings().extraInterfaces(HasRepositoryDirectories.class));
when(stepMetaInterface.isReferencedObjectEnabled()).thenReturn(new boolean[] { true });
doAnswer(invocationOnMock -> new ObjectLocationSpecificationMethod[] { ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME }).when(((HasRepositoryDirectories) stepMetaInterface)).getSpecificationMethods();
doAnswer(invocationOnMock -> new String[] { directory }).when((HasRepositoryDirectories) stepMetaInterface).getDirectories();
return stepMetaInterface;
}
use of org.pentaho.di.trans.step.StepMetaInterface in project pentaho-kettle by pentaho.
the class RepositoryImporterTest method testImportJob_patchJobEntries_when_directory_path_ends_with_variable.
@Test
public void testImportJob_patchJobEntries_when_directory_path_ends_with_variable() throws KettleException {
JobEntryInterface jobEntryInterface = createJobEntry("/myDir/${USER_VARIABLE}");
StepMetaInterface stepMeta = createStepMeta("");
RepositoryImporter importer = createRepositoryImporter(jobEntryInterface, stepMeta, true);
importer.setBaseDirectory(baseDirectory);
importer.importJob(entityNode, feedback);
verify((HasRepositoryDirectories) jobEntryInterface).setDirectories(new String[] { "/myDir/${USER_VARIABLE}" });
JobEntryInterface jobEntryInterface2 = createJobEntry("/myDir/${USER_VARIABLE}");
RepositoryImporter importerWithCompatibilityImportPath = createRepositoryImporter(jobEntryInterface2, stepMeta, false);
importerWithCompatibilityImportPath.setBaseDirectory(baseDirectory);
importerWithCompatibilityImportPath.importJob(entityNode, feedback);
verify((HasRepositoryDirectories) jobEntryInterface2).setDirectories(new String[] { ROOT_PATH + "/myDir/${USER_VARIABLE}" });
}
use of org.pentaho.di.trans.step.StepMetaInterface in project pentaho-kettle by pentaho.
the class TransMetaTest method getThisStepFieldsPassesCloneRowMeta.
@Test
public void getThisStepFieldsPassesCloneRowMeta() throws Exception {
final String overriddenValue = "overridden";
StepMeta nextStep = mockStepMeta("nextStep");
StepMetaInterface smi = mock(StepMetaInterface.class);
StepIOMeta ioMeta = mock(StepIOMeta.class);
when(smi.getStepIOMeta()).thenReturn(ioMeta);
doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
RowMetaInterface rmi = (RowMetaInterface) invocation.getArguments()[0];
rmi.clear();
rmi.addValueMeta(new ValueMetaString(overriddenValue));
return null;
}
}).when(smi).getFields(any(RowMetaInterface.class), anyString(), any(RowMetaInterface[].class), eq(nextStep), any(VariableSpace.class), any(Repository.class), any(IMetaStore.class));
StepMeta thisStep = mockStepMeta("thisStep");
when(thisStep.getStepMetaInterface()).thenReturn(smi);
RowMeta rowMeta = new RowMeta();
rowMeta.addValueMeta(new ValueMetaString("value"));
RowMetaInterface thisStepsFields = transMeta.getThisStepFields(thisStep, nextStep, rowMeta);
assertEquals(1, thisStepsFields.size());
assertEquals(overriddenValue, thisStepsFields.getValueMeta(0).getName());
}
use of org.pentaho.di.trans.step.StepMetaInterface in project pentaho-kettle by pentaho.
the class TransMetaConverterTest method testRemovingDisabledInputSteps.
@Test
public void testRemovingDisabledInputSteps() {
TransMeta trans = new TransMeta();
StepMeta inputToBeRemoved = new StepMeta("InputToBeRemoved", stepMetaInterface);
trans.addStep(inputToBeRemoved);
StepMeta inputToStay = new StepMeta("InputToStay", stepMetaInterface);
trans.addStep(inputToStay);
StepMeta inputReceiver1 = new StepMeta("InputReceiver1", stepMetaInterface);
trans.addStep(inputReceiver1);
StepMeta inputReceiver2 = new StepMeta("InputReceiver2", stepMetaInterface);
trans.addStep(inputReceiver2);
TransHopMeta hop1 = new TransHopMeta(inputToBeRemoved, inputReceiver1, false);
TransHopMeta hop2 = new TransHopMeta(inputToStay, inputReceiver1);
TransHopMeta hop3 = new TransHopMeta(inputToBeRemoved, inputReceiver2, false);
trans.addTransHop(hop1);
trans.addTransHop(hop2);
trans.addTransHop(hop3);
Transformation transformation = TransMetaConverter.convert(trans);
List<String> steps = transformation.getOperations().stream().map(op -> op.getId()).collect(Collectors.toList());
assertThat("Only 2 ops should exist", steps.size(), is(2));
assertThat(steps, hasItems("InputToStay", "InputReceiver1"));
List<String> hops = transformation.getHops().stream().map(hop -> hop.getId()).collect(Collectors.toList());
assertThat("Only 1 hop should exist", hops.size(), is(1));
assertThat(hops, hasItems("InputToStay -> InputReceiver1"));
}
Aggregations