Search in sources :

Example 6 with BaseStepMeta

use of org.pentaho.di.trans.step.BaseStepMeta in project pentaho-metaverse by pentaho.

the class TransformationAnalyzer method getStepAnalyzers.

protected Set<IStepAnalyzer> getStepAnalyzers(final StepMeta stepMeta) {
    Set<IStepAnalyzer> stepAnalyzers = new HashSet<IStepAnalyzer>();
    // Attempt to discover a BaseStepMeta from the given StepMeta
    BaseStepMeta baseStepMeta = getBaseStepMetaFromStepMeta(stepMeta);
    stepAnalyzerProvider = getStepAnalyzerProvider();
    if (stepAnalyzerProvider != null) {
        if (baseStepMeta == null) {
            stepAnalyzers.addAll(stepAnalyzerProvider.getAnalyzers());
        } else {
            Set<Class<?>> analyzerClassSet = new HashSet<Class<?>>(1);
            analyzerClassSet.add(baseStepMeta.getClass());
            stepAnalyzers.addAll(stepAnalyzerProvider.getAnalyzers(analyzerClassSet));
        }
    } else {
        stepAnalyzers.add(new GenericStepMetaAnalyzer());
    }
    return stepAnalyzers;
}
Also used : IStepAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) HashSet(java.util.HashSet) GenericStepMetaAnalyzer(org.pentaho.metaverse.analyzer.kettle.step.GenericStepMetaAnalyzer)

Example 7 with BaseStepMeta

use of org.pentaho.di.trans.step.BaseStepMeta in project pentaho-metaverse by pentaho.

the class TransformationAnalyzerTest method testGetBaseStepMetaFromStepMetaWithNull.

@Test
public void testGetBaseStepMetaFromStepMetaWithNull() {
    // BaseStepMeta should not be null, but its parent should be
    BaseStepMeta baseStepMeta = analyzer.getBaseStepMetaFromStepMeta(null);
    assertNotNull(baseStepMeta);
    assertNull(baseStepMeta.getParentStepMeta());
}
Also used : BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Test(org.junit.Test)

Example 8 with BaseStepMeta

use of org.pentaho.di.trans.step.BaseStepMeta in project pentaho-metaverse by pentaho.

the class StepExternalConsumerRowListenerTest method testStepExternalConsumerRowListener.

@Test
public void testStepExternalConsumerRowListener() throws Exception {
    IStepExternalResourceConsumer consumer = mock(IStepExternalResourceConsumer.class);
    BaseStep mockStep = mock(BaseStep.class, withSettings().extraInterfaces(StepInterface.class));
    StepMeta mockStepMeta = mock(StepMeta.class);
    BaseStepMeta bsm = mock(BaseStepMeta.class, withSettings().extraInterfaces(StepMetaInterface.class));
    StepMetaInterface stepMetaInterface = (StepMetaInterface) bsm;
    when(mockStep.getStepMeta()).thenReturn(mockStepMeta);
    when(mockStepMeta.getStepMetaInterface()).thenReturn(stepMetaInterface);
    Trans mockTrans = mock(Trans.class);
    when(mockStep.getTrans()).thenReturn(mockTrans);
    IExecutionProfile executionProfile = mock(IExecutionProfile.class);
    IExecutionData executionData = mock(IExecutionData.class);
    when(executionProfile.getExecutionData()).thenReturn(executionData);
    LineageHolder holder = new LineageHolder();
    holder.setExecutionProfile(executionProfile);
    TransLineageHolderMap.getInstance().putLineageHolder(mockTrans, holder);
    StepExternalConsumerRowListener listener = new StepExternalConsumerRowListener(consumer, mockStep);
    RowMetaInterface rmi = mock(RowMetaInterface.class);
    Object[] row = new Object[0];
    listener.rowReadEvent(rmi, row);
}
Also used : BaseStep(org.pentaho.di.trans.step.BaseStep) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) IStepExternalResourceConsumer(org.pentaho.metaverse.api.analyzer.kettle.step.IStepExternalResourceConsumer) StepInterface(org.pentaho.di.trans.step.StepInterface) IExecutionData(org.pentaho.metaverse.api.model.IExecutionData) IExecutionProfile(org.pentaho.metaverse.api.model.IExecutionProfile) Trans(org.pentaho.di.trans.Trans) LineageHolder(org.pentaho.metaverse.api.model.LineageHolder) Test(org.junit.Test)

Example 9 with BaseStepMeta

use of org.pentaho.di.trans.step.BaseStepMeta in project pentaho-metaverse by pentaho.

the class StepExternalResourceConsumerListenerTest method testCallStepExtensionPoint.

@Test
public void testCallStepExtensionPoint() throws Exception {
    StepExternalResourceConsumerListener stepExtensionPoint = new StepExternalResourceConsumerListener();
    stepExtensionPoint.setStepExternalResourceConsumerProvider(MetaverseTestUtils.getStepExternalResourceConsumerProvider());
    StepMetaDataCombi stepCombi = mock(StepMetaDataCombi.class);
    BaseStepMeta bsm = mock(BaseStepMeta.class, withSettings().extraInterfaces(StepMetaInterface.class));
    stepCombi.meta = (StepMetaInterface) bsm;
    stepCombi.step = mock(StepInterface.class);
    stepCombi.stepMeta = mock(StepMeta.class);
    stepExtensionPoint.callExtensionPoint(null, stepCombi);
    Map<Class<? extends BaseStepMeta>, Set<IStepExternalResourceConsumer>> stepConsumerMap = new StepExternalResourceConsumerProvider().getStepConsumerMap();
    Set<IStepExternalResourceConsumer> consumers = new HashSet<IStepExternalResourceConsumer>();
    stepConsumerMap.put(bsm.getClass(), consumers);
    stepExtensionPoint.callExtensionPoint(null, stepCombi);
    IStepExternalResourceConsumer consumer = mock(IStepExternalResourceConsumer.class);
    when(consumer.getResourcesFromMeta(Mockito.any())).thenReturn(Collections.emptyList());
    consumers.add(consumer);
    Trans mockTrans = mock(Trans.class);
    when(stepCombi.step.getTrans()).thenReturn(mockTrans);
    stepExtensionPoint.callExtensionPoint(null, stepCombi);
    when(consumer.isDataDriven(Mockito.any())).thenReturn(Boolean.TRUE);
    stepExtensionPoint.callExtensionPoint(null, stepCombi);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) IStepExternalResourceConsumer(org.pentaho.metaverse.api.analyzer.kettle.step.IStepExternalResourceConsumer) StepInterface(org.pentaho.di.trans.step.StepInterface) StepExternalResourceConsumerProvider(org.pentaho.metaverse.analyzer.kettle.step.StepExternalResourceConsumerProvider) StepMetaDataCombi(org.pentaho.di.trans.step.StepMetaDataCombi) Trans(org.pentaho.di.trans.Trans) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 10 with BaseStepMeta

use of org.pentaho.di.trans.step.BaseStepMeta in project pentaho-metaverse by pentaho.

the class AbstractStepMetaJsonSerializerTest method testSerializeBasic.

@Test
public void testSerializeBasic() throws Exception {
    AbstractStepMetaJsonSerializer<BaseStepMeta> spySerializer = spy(serializer);
    IFieldLineageMetadataProvider mapper = mock(IFieldLineageMetadataProvider.class);
    when(spySerializer.getFieldLineageMetadataProvider(spyMeta)).thenReturn(mapper);
    when(mapper.getInputFields(spyMeta)).thenReturn(new HashMap<String, RowMetaInterface>());
    spySerializer.serialize(spyMeta, json, provider);
    verify(json).writeStartObject();
    verify(json).writeStringField(IInfo.JSON_PROPERTY_CLASS, spyMeta.getClass().getName());
    verify(json).writeStringField(IInfo.JSON_PROPERTY_NAME, spyParent.getName());
    verify(json).writeStringField(eq(AbstractStepMetaJsonSerializer.JSON_PROPERTY_TYPE), anyString());
    // make sure the templated methods are called
    verify(spySerializer).writeRepoAttributes(spyMeta, json);
    verify(spySerializer).writeCustomProperties(spyMeta, json, provider);
    verify(spySerializer).writeInputFields(spyMeta, json);
    verify(spySerializer).writeOutputFields(spyParent, json);
    verify(json).writeArrayFieldStart(AbstractStepMetaJsonSerializer.JSON_PROPERTY_TRANSFORMS);
    verify(spySerializer).writeFieldTransforms(spyMeta, json, provider);
    verify(json).writeEndObject();
    verify(spySerializer).writeExternalResources(spyMeta, json, provider);
}
Also used : IFieldLineageMetadataProvider(org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) Matchers.anyString(org.mockito.Matchers.anyString) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Test(org.junit.Test)

Aggregations

BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)22 Test (org.junit.Test)8 HashSet (java.util.HashSet)7 StepMeta (org.pentaho.di.trans.step.StepMeta)7 StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)6 Before (org.junit.Before)4 ArrayList (java.util.ArrayList)3 KettleException (org.pentaho.di.core.exception.KettleException)3 TransMeta (org.pentaho.di.trans.TransMeta)3 StepInterface (org.pentaho.di.trans.step.StepInterface)3 MetaverseObjectFactory (org.pentaho.metaverse.api.MetaverseObjectFactory)3 StepField (org.pentaho.metaverse.api.StepField)3 IStepAnalyzer (org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer)3 IStepExternalResourceConsumer (org.pentaho.metaverse.api.analyzer.kettle.step.IStepExternalResourceConsumer)3 IExternalResourceInfo (org.pentaho.metaverse.api.model.IExternalResourceInfo)3 Set (java.util.Set)2 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)2 ObjectId (org.pentaho.di.repository.ObjectId)2 StringObjectId (org.pentaho.di.repository.StringObjectId)2 Trans (org.pentaho.di.trans.Trans)2