use of org.pentaho.di.engine.api.model.Transformation in project pentaho-kettle by pentaho.
the class TransMetaConverterTest method lazyConversionTurnedOff.
@Test
public void lazyConversionTurnedOff() throws KettleException {
KettleEnvironment.init();
TransMeta transMeta = new TransMeta();
CsvInputMeta csvInputMeta = new CsvInputMeta();
csvInputMeta.setLazyConversionActive(true);
StepMeta csvInput = new StepMeta("Csv", csvInputMeta);
transMeta.addStep(csvInput);
TableInputMeta tableInputMeta = new TableInputMeta();
tableInputMeta.setLazyConversionActive(true);
StepMeta tableInput = new StepMeta("Table", tableInputMeta);
transMeta.addStep(tableInput);
Transformation trans = TransMetaConverter.convert(transMeta);
TransMeta cloneMeta;
String transMetaXml = (String) trans.getConfig().get(TransMetaConverter.TRANS_META_CONF_KEY);
Document doc;
try {
doc = XMLHandler.loadXMLString(transMetaXml);
Node stepNode = XMLHandler.getSubNode(doc, "transformation");
cloneMeta = new TransMeta(stepNode, null);
} catch (KettleXMLException | KettleMissingPluginsException e) {
throw new RuntimeException(e);
}
assertThat(((CsvInputMeta) cloneMeta.findStep("Csv").getStepMetaInterface()).isLazyConversionActive(), is(false));
assertThat(((TableInputMeta) cloneMeta.findStep("Table").getStepMetaInterface()).isLazyConversionActive(), is(false));
}
use of org.pentaho.di.engine.api.model.Transformation in project pentaho-kettle by pentaho.
the class TransMetaConverterTest method transIdFromRepo.
@Test
public void transIdFromRepo() throws Exception {
TransMeta meta = new TransMeta();
meta.setName("transName");
Transformation trans = TransMetaConverter.convert(meta);
assertThat(trans.getId(), is("/transName"));
}
use of org.pentaho.di.engine.api.model.Transformation 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"));
}
use of org.pentaho.di.engine.api.model.Transformation in project pentaho-kettle by pentaho.
the class TransMetaConverterTest method transWithHops.
@Test
public void transWithHops() {
TransMeta meta = new TransMeta();
meta.setFilename("fileName");
StepMeta from = new StepMeta("step1", stepMetaInterface);
meta.addStep(from);
StepMeta to = new StepMeta("step2", stepMetaInterface);
meta.addStep(to);
meta.addTransHop(new TransHopMeta(from, to));
Transformation trans = TransMetaConverter.convert(meta);
assertThat(trans.getId(), is(meta.getFilename()));
assertThat(trans.getOperations().size(), is(2));
assertThat(trans.getHops().size(), is(1));
assertThat(trans.getHops().get(0).getFrom().getId(), is(from.getName()));
assertThat(trans.getHops().get(0).getTo().getId(), is(to.getName()));
assertThat(trans.getHops().stream().map(Hop::getType).collect(Collectors.toList()), everyItem(is(Hop.TYPE_NORMAL)));
}
use of org.pentaho.di.engine.api.model.Transformation in project pentaho-kettle by pentaho.
the class TransMetaConverterTest method testMultipleDisabledHops.
@Test
public void testMultipleDisabledHops() {
TransMeta trans = new TransMeta();
StepMeta input = new StepMeta("Input", stepMetaInterface);
trans.addStep(input);
StepMeta step1 = new StepMeta("Step1", stepMetaInterface);
trans.addStep(step1);
StepMeta step2 = new StepMeta("Step2", stepMetaInterface);
trans.addStep(step2);
StepMeta step3 = new StepMeta("Step3", stepMetaInterface);
trans.addStep(step3);
TransHopMeta hop1 = new TransHopMeta(input, step1, false);
TransHopMeta hop2 = new TransHopMeta(step1, step2, false);
TransHopMeta hop3 = new TransHopMeta(step2, step3, false);
trans.addTransHop(hop1);
trans.addTransHop(hop2);
trans.addTransHop(hop3);
Transformation transformation = TransMetaConverter.convert(trans);
assertThat("Trans has steps though all of them should be removed", transformation.getOperations().size(), is(0));
assertThat("Trans has hops though all of them should be removed", transformation.getHops().size(), is(0));
}
Aggregations