use of org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider in project pentaho-metaverse by pentaho.
the class AbstractStepMetaJsonSerializer method writeInputFields.
protected void writeInputFields(T meta, JsonGenerator json) throws IOException {
IFieldLineageMetadataProvider fieldLineageProvider = getFieldLineageMetadataProvider(meta);
Map<String, RowMetaInterface> fieldMap = fieldLineageProvider.getInputFields(meta);
List<RowMetaInterface> fieldMetaList = new ArrayList<RowMetaInterface>();
if (!MapUtils.isEmpty(fieldMap)) {
for (RowMetaInterface rowMetaInterface : fieldMap.values()) {
fieldMetaList.add(rowMetaInterface);
}
}
writeFields(json, fieldMetaList, JSON_PROPERTY_INPUT_FIELDS);
}
use of org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider in project pentaho-metaverse by pentaho.
the class AbstractStepMetaJsonSerializerTest method testWriteFieldMappings.
@Test
public void testWriteFieldMappings() throws Exception {
Set<IFieldMapping> mappings = new HashSet<IFieldMapping>();
FieldMapping fieldMapping1 = new FieldMapping("full name", "first name");
FieldMapping fieldMapping2 = new FieldMapping("full name", "last name");
mappings.add(fieldMapping1);
mappings.add(fieldMapping2);
IFieldLineageMetadataProvider mapper = mock(IFieldLineageMetadataProvider.class);
AbstractStepMetaJsonSerializer spy = spy(serializer);
when(spy.getFieldLineageMetadataProvider(spyMeta)).thenReturn(mapper);
when(mapper.getFieldMappings(spyMeta)).thenReturn(mappings);
spy.writeFieldMappings(spyMeta, json, provider);
verify(json).writeObject(fieldMapping1);
verify(json).writeObject(fieldMapping2);
}
use of org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider in project pentaho-metaverse by pentaho.
the class AbstractStepMetaJsonSerializerTest method testGetStepFieldMapper_noProviderAvailable.
@Test
public void testGetStepFieldMapper_noProviderAvailable() throws Exception {
IStepAnalyzerProvider provider = mock(IStepAnalyzerProvider.class);
when(provider.getAnalyzers(any(Set.class))).thenReturn(null);
serializer.setStepAnalyzerProvider(provider);
IFieldLineageMetadataProvider handler = serializer.getFieldLineageMetadataProvider(spyMeta);
assertTrue(handler instanceof GenericStepMetaAnalyzer);
}
use of org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider in project pentaho-metaverse by pentaho.
the class AbstractStepMetaJsonSerializerTest method testWriteInputFields.
@Test
public void testWriteInputFields() throws Exception {
serializer = new BaseStepMetaJsonSerializer(BaseStepMeta.class);
serializer.setLineageRepository(repo);
when(spyParent.getParentTransMeta()).thenReturn(spyParentTrans);
IFieldLineageMetadataProvider mapper = mock(IFieldLineageMetadataProvider.class);
AbstractStepMetaJsonSerializer spy = spy(serializer);
when(spy.getFieldLineageMetadataProvider(spyMeta)).thenReturn(mapper);
RowMetaInterface rmi = mock(RowMetaInterface.class);
List<ValueMetaInterface> vml = new ArrayList<ValueMetaInterface>();
ValueMetaInterface col1 = mock(ValueMetaInterface.class);
ValueMetaInterface col2 = mock(ValueMetaInterface.class);
ValueMetaInterface col3 = mock(ValueMetaInterface.class);
vml.add(col1);
vml.add(col2);
vml.add(col3);
when(rmi.getValueMetaList()).thenReturn(vml);
HashMap<String, RowMetaInterface> fieldMetaMap = new HashMap<String, RowMetaInterface>(1);
fieldMetaMap.put("prev step name", rmi);
when(mapper.getInputFields(spyMeta)).thenReturn(fieldMetaMap);
spy.writeInputFields(spyMeta, json);
verify(json, times(3)).writeObject(any(IFieldInfo.class));
}
use of org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider in project pentaho-metaverse by pentaho.
the class AbstractStepMetaJsonSerializerTest method testWriteFieldTransforms.
@Test
public void testWriteFieldTransforms() throws Exception {
Set<ComponentDerivationRecord> changeRecords = new HashSet<ComponentDerivationRecord>();
ComponentDerivationRecord change1 = mock(ComponentDerivationRecord.class);
ComponentDerivationRecord change2 = mock(ComponentDerivationRecord.class);
when(change1.hasDelta()).thenReturn(true);
when(change2.hasDelta()).thenReturn(false);
changeRecords.add(change1);
changeRecords.add(change2);
IFieldLineageMetadataProvider mapper = mock(IFieldLineageMetadataProvider.class);
AbstractStepMetaJsonSerializer spy = spy(serializer);
when(spy.getFieldLineageMetadataProvider(spyMeta)).thenReturn(mapper);
when(mapper.getChangeRecords(spyMeta)).thenReturn(changeRecords);
spy.writeFieldTransforms(spyMeta, json, provider);
verify(json).writeObject(change1);
verify(json, never()).writeObject(change2);
}
Aggregations