use of org.pentaho.metaverse.api.model.kettle.IFieldMapping in project pentaho-metaverse by pentaho.
the class AbstractStepMetaJsonSerializer method writeFieldMappings.
protected void writeFieldMappings(T meta, JsonGenerator json, SerializerProvider serializerProvider) throws IOException {
json.writeArrayFieldStart(JSON_PROPERTY_MAPPINGS);
IFieldLineageMetadataProvider mapper = getFieldLineageMetadataProvider(meta);
try {
Set<IFieldMapping> fieldMappings = mapper.getFieldMappings(meta);
if (fieldMappings != null) {
for (IFieldMapping fieldMapping : fieldMappings) {
json.writeObject(fieldMapping);
}
}
} catch (MetaverseAnalyzerException e) {
LOGGER.warn(Messages.getString("WARNING.Serialization.Step.WriteFieldMappings", meta.getParentStepMeta().getName()), e);
}
json.writeEndArray();
}
use of org.pentaho.metaverse.api.model.kettle.IFieldMapping 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);
}
Aggregations