use of org.pentaho.di.trans.steps.metainject.MetaInjectMeta in project pentaho-kettle by pentaho.
the class RepositoryImporterTest method testPatchTransSteps_with_meta_inject_step.
@Test
public void testPatchTransSteps_with_meta_inject_step() throws Exception {
Repository repository = mock(Repository.class);
LogChannelInterface log = mock(LogChannelInterface.class);
RepositoryImporter importer = spy(new RepositoryImporter(repository, log));
importer.setBaseDirectory(mock(RepositoryDirectoryInterface.class));
doReturn("TEST_PATH").when(importer).resolvePath(anyString(), anyString());
MetaInjectMeta metaInjectMeta = mock(MetaInjectMeta.class);
doReturn(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME).when(metaInjectMeta).getSpecificationMethod();
StepMeta stepMeta = mock(StepMeta.class);
doReturn(metaInjectMeta).when(stepMeta).getStepMetaInterface();
doReturn(true).when(stepMeta).isEtlMetaInject();
TransMeta transMeta = mock(TransMeta.class);
doReturn(Collections.singletonList(stepMeta)).when(transMeta).getSteps();
Object[] object = new Object[4];
object[0] = "TEST_PATH";
object[1] = mock(RepositoryDirectoryInterface.class);
object[2] = stepMeta;
object[3] = true;
RepositoryImporterExtension repositoryImporterExtension = new RepositoryImporterExtension();
repositoryImporterExtension.callExtensionPoint(log, object);
verify(metaInjectMeta).setDirectoryPath("TEST_PATH");
}
use of org.pentaho.di.trans.steps.metainject.MetaInjectMeta in project pentaho-kettle by pentaho.
the class TransMetaTest method testStepChangeListener.
@Test
public void testStepChangeListener() throws Exception {
MetaInjectMeta mim = new MetaInjectMeta();
StepMeta sm = new StepMeta("testStep", mim);
try {
transMeta.addOrReplaceStep(sm);
} catch (Exception ex) {
fail();
}
}
use of org.pentaho.di.trans.steps.metainject.MetaInjectMeta in project pentaho-kettle by pentaho.
the class TransMetaTest method testTransListeners.
@Test
public void testTransListeners() {
TransMeta TransMeta = new TransMeta();
StepMeta oldFormStep = new StepMeta();
oldFormStep.setName("Generate_1");
StepMeta newFormStep = new StepMeta();
newFormStep.setName("Generate_2");
StepMeta toStep = new StepMeta();
toStep.setStepMetaInterface(new MetaInjectMeta());
toStep.setName("ETL Inject Metadata");
StepMeta deletedStep = new StepMeta();
deletedStep.setStepMetaInterface(new MetaInjectMeta());
deletedStep.setName("ETL Inject Metadata for delete");
// Verify add & remove listeners
TransMeta.addStep(oldFormStep);
TransMeta.addStep(toStep);
TransMeta.addStep(deletedStep);
assertEquals(TransMeta.nrStepChangeListeners(), 2);
TransMeta.removeStepChangeListener((StepMetaChangeListenerInterface) deletedStep.getStepMetaInterface());
assertEquals(TransMeta.nrStepChangeListeners(), 1);
TransMeta.removeStep(2);
TransHopMeta hi = new TransHopMeta(oldFormStep, toStep);
TransMeta.addTransHop(hi);
// Verify MetaInjectMeta.onStepChange()
// add new TargetStepAttribute
MetaInjectMeta toMeta = (MetaInjectMeta) toStep.getStepMetaInterface();
Map<TargetStepAttribute, SourceStepField> sourceMapping = new HashMap<TargetStepAttribute, SourceStepField>();
TargetStepAttribute keyTest = new TargetStepAttribute("File", "key", true);
SourceStepField valueTest = new SourceStepField(oldFormStep.getName(), oldFormStep.getName());
sourceMapping.put(keyTest, valueTest);
toMeta.setTargetSourceMapping(sourceMapping);
// Run all listeners
TransMeta.notifyAllListeners(oldFormStep, newFormStep);
// Verify changes, which listeners makes
sourceMapping = toMeta.getTargetSourceMapping();
for (Entry<TargetStepAttribute, SourceStepField> entry : sourceMapping.entrySet()) {
SourceStepField value = entry.getValue();
if (!value.getStepname().equals(newFormStep.getName())) {
fail();
}
}
// verify another functions
TransMeta.addStep(deletedStep);
assertEquals(TransMeta.nrSteps(), 3);
assertEquals(TransMeta.nrStepChangeListeners(), 2);
TransMeta.removeStep(0);
assertEquals(TransMeta.nrSteps(), 2);
}
use of org.pentaho.di.trans.steps.metainject.MetaInjectMeta in project pentaho-kettle by pentaho.
the class TransMetaTest method testAddOrReplaceStep.
@Test
public void testAddOrReplaceStep() throws Exception {
StepMeta stepMeta = mockStepMeta("ETL Metadata Injection");
MetaInjectMeta stepMetaInterfaceMock = mock(MetaInjectMeta.class);
when(stepMeta.getStepMetaInterface()).thenReturn(stepMetaInterfaceMock);
transMeta.addOrReplaceStep(stepMeta);
verify(stepMeta).setParentTransMeta(any(TransMeta.class));
// to make sure that method comes through positive scenario
assert transMeta.steps.size() == 1;
assert transMeta.changed_steps;
}
Aggregations