Search in sources :

Example 1 with Operation

use of org.pentaho.di.engine.api.model.Operation in project pentaho-kettle by pentaho.

the class TransMetaConverterTest method errorHops.

@Test
public void errorHops() throws Exception {
    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));
    StepMeta error = new StepMeta("errorHandler", stepMetaInterface);
    meta.addStep(error);
    TransHopMeta errorHop = new TransHopMeta(from, error);
    errorHop.setErrorHop(true);
    meta.addTransHop(errorHop);
    Transformation trans = TransMetaConverter.convert(meta);
    Map<String, List<Hop>> hops = trans.getHops().stream().collect(Collectors.groupingBy(Hop::getType));
    List<Hop> normalHops = hops.get(Hop.TYPE_NORMAL);
    assertThat(normalHops.size(), is(1));
    assertThat(normalHops.get(0).getTo().getId(), is("step2"));
    List<Hop> errorHops = hops.get(Hop.TYPE_ERROR);
    assertThat(errorHops.size(), is(1));
    assertThat(errorHops.get(0).getTo().getId(), is("errorHandler"));
    assertThat(hops.values().stream().flatMap(List::stream).map(Hop::getFrom).map(Operation::getId).collect(Collectors.toList()), everyItem(equalTo("step1")));
}
Also used : Transformation(org.pentaho.di.engine.api.model.Transformation) TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) Hop(org.pentaho.di.engine.api.model.Hop) List(java.util.List) TransHopMeta(org.pentaho.di.trans.TransHopMeta) Operation(org.pentaho.di.engine.api.model.Operation) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Test(org.junit.Test)

Example 2 with Operation

use of org.pentaho.di.engine.api.model.Operation in project pentaho-kettle by pentaho.

the class MessageEncoderDecoderTest method assertMetricsEvent.

private void assertMetricsEvent(MetricsEvent expected, MetricsEvent actual) {
    // Assert Operation
    Operation expectedOperation = (Operation) expected.getSource();
    Operation actualOperation = (Operation) actual.getSource();
    assertThat(expectedOperation.getId(), equalTo(actualOperation.getId()));
    assertThat(expectedOperation.getFrom().size(), equalTo(actualOperation.getFrom().size()));
    assertThat(expectedOperation.getTo().size(), equalTo(actualOperation.getTo().size()));
    // Assert Metrics
    Metrics expectedMetrics = (Metrics) expected.getData();
    Metrics actualMetrics = (Metrics) actual.getData();
    assertThat(expectedMetrics.getIn(), equalTo(actualMetrics.getIn()));
    assertThat(expectedMetrics.getOut(), equalTo(actualMetrics.getOut()));
    assertThat(expectedMetrics.getDropped(), equalTo(actualMetrics.getDropped()));
    assertThat(expectedMetrics.getInFlight(), equalTo(actualMetrics.getInFlight()));
}
Also used : Metrics(org.pentaho.di.engine.api.reporting.Metrics) Operation(org.pentaho.di.engine.api.model.Operation)

Example 3 with Operation

use of org.pentaho.di.engine.api.model.Operation in project pentaho-kettle by pentaho.

the class MessageEncoderDecoderTest method metricsEvent.

private MetricsEvent metricsEvent() {
    Operation step1 = new TestOperation("step2");
    Operation step2 = new TestOperation("step2");
    Operation step3 = new TestOperation("step2");
    step1.getTo().add(step2);
    step2.getFrom().add(step1);
    step2.getTo().add(step3);
    step3.getFrom().add(step2);
    Metrics metrics = new Metrics(1, 2, 3, 4);
    return new MetricsEvent<>(step2, metrics);
}
Also used : Metrics(org.pentaho.di.engine.api.reporting.Metrics) MetricsEvent(org.pentaho.di.engine.api.events.MetricsEvent) Operation(org.pentaho.di.engine.api.model.Operation)

Aggregations

Operation (org.pentaho.di.engine.api.model.Operation)3 Metrics (org.pentaho.di.engine.api.reporting.Metrics)2 List (java.util.List)1 Test (org.junit.Test)1 MetricsEvent (org.pentaho.di.engine.api.events.MetricsEvent)1 Hop (org.pentaho.di.engine.api.model.Hop)1 Transformation (org.pentaho.di.engine.api.model.Transformation)1 TransHopMeta (org.pentaho.di.trans.TransHopMeta)1 TransMeta (org.pentaho.di.trans.TransMeta)1 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)1 StepMeta (org.pentaho.di.trans.step.StepMeta)1 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)1