Search in sources :

Example 6 with IFieldLineageMetadataProvider

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);
}
Also used : IFieldLineageMetadataProvider(org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider) ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface)

Example 7 with IFieldLineageMetadataProvider

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);
}
Also used : IFieldLineageMetadataProvider(org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider) IFieldMapping(org.pentaho.metaverse.api.model.kettle.IFieldMapping) FieldMapping(org.pentaho.metaverse.api.model.kettle.FieldMapping) IFieldMapping(org.pentaho.metaverse.api.model.kettle.IFieldMapping) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 8 with IFieldLineageMetadataProvider

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);
}
Also used : IFieldLineageMetadataProvider(org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider) HashSet(java.util.HashSet) Set(java.util.Set) IStepAnalyzerProvider(org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzerProvider) GenericStepMetaAnalyzer(org.pentaho.metaverse.analyzer.kettle.step.GenericStepMetaAnalyzer) Test(org.junit.Test)

Example 9 with IFieldLineageMetadataProvider

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));
}
Also used : IFieldLineageMetadataProvider(org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IFieldInfo(org.pentaho.metaverse.api.model.kettle.IFieldInfo) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) Matchers.anyString(org.mockito.Matchers.anyString) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 10 with IFieldLineageMetadataProvider

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);
}
Also used : IFieldLineageMetadataProvider(org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider) ComponentDerivationRecord(org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

IFieldLineageMetadataProvider (org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider)10 Test (org.junit.Test)6 HashSet (java.util.HashSet)5 ArrayList (java.util.ArrayList)3 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)3 GenericStepMetaAnalyzer (org.pentaho.metaverse.analyzer.kettle.step.GenericStepMetaAnalyzer)3 MetaverseAnalyzerException (org.pentaho.metaverse.api.MetaverseAnalyzerException)3 IStepAnalyzerProvider (org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzerProvider)3 Set (java.util.Set)2 Matchers.anyString (org.mockito.Matchers.anyString)2 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)2 ComponentDerivationRecord (org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord)2 IStepAnalyzer (org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer)2 IFieldMapping (org.pentaho.metaverse.api.model.kettle.IFieldMapping)2 HashMap (java.util.HashMap)1 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)1 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)1 StepAnalyzer (org.pentaho.metaverse.api.analyzer.kettle.step.StepAnalyzer)1 FieldMapping (org.pentaho.metaverse.api.model.kettle.FieldMapping)1 IFieldInfo (org.pentaho.metaverse.api.model.kettle.IFieldInfo)1