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;
}
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());
}
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);
}
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);
}
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);
}
Aggregations