Search in sources :

Example 31 with ComponentDerivationRecord

use of org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord in project pentaho-metaverse by pentaho.

the class MergeJoinStepAnalyzerTest method testGetChangeRecords.

@Test
public void testGetChangeRecords() throws Exception {
    Set<ComponentDerivationRecord> changeRecords = analyzer.getChangeRecords(mergeJoinMeta);
    assertNotNull(changeRecords);
    assertEquals(1, changeRecords.size());
    ComponentDerivationRecord cr = changeRecords.iterator().next();
    assertEquals(ChangeType.METADATA, cr.getChangeType());
    assertEquals(1, cr.getOperations().size());
}
Also used : ComponentDerivationRecord(org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord) Test(org.junit.Test)

Example 32 with ComponentDerivationRecord

use of org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord in project pentaho-metaverse by pentaho.

the class NumberRangeStepAnalyzerTest method testGetChangeRecords.

@Test
public void testGetChangeRecords() throws Exception {
    Set<ComponentDerivationRecord> changeRecords = analyzer.getChangeRecords(meta);
    assertEquals(1, changeRecords.size());
    ComponentDerivationRecord changeRecord = changeRecords.iterator().next();
    assertEquals("inField", changeRecord.getOriginalEntityName());
    assertEquals("outField", changeRecord.getChangedEntityName());
    Operations operations = changeRecord.getOperations();
    // Only data operations
    assertEquals(1, operations.size());
    List<IOperation> dataOperations = operations.get(ChangeType.DATA);
    assertEquals(2, dataOperations.size());
}
Also used : IOperation(org.pentaho.metaverse.api.model.IOperation) ComponentDerivationRecord(org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord) Operations(org.pentaho.metaverse.api.model.Operations) Test(org.junit.Test)

Example 33 with ComponentDerivationRecord

use of org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord in project pentaho-metaverse by pentaho.

the class SelectValuesStepAnalyzerTest method testGetChangeRecords_meta.

@Test
public void testGetChangeRecords_meta() throws Exception {
    SelectMetadataChange[] metadataChanges = new SelectMetadataChange[] { testChange1, testChange2 };
    when(selectValuesMeta.getMeta()).thenReturn(metadataChanges);
    ValueMetaInterface vmiFirst = mock(ValueMetaInterface.class);
    ValueMetaInterface vmiLast = mock(ValueMetaInterface.class);
    when(rmi.searchValueMeta("first")).thenReturn(vmiFirst);
    when(rmi.searchValueMeta("last")).thenReturn(vmiLast);
    when(vmiFirst.getName()).thenReturn("first");
    when(vmiFirst.getCurrencySymbol()).thenReturn("$");
    when(vmiFirst.getStorageType()).thenReturn(ValueMetaInterface.STORAGE_TYPE_NORMAL);
    when(vmiLast.getDateFormatLocale()).thenReturn(Locale.US);
    when(vmiLast.getGroupingSymbol()).thenReturn(",");
    when(vmiLast.getName()).thenReturn("last");
    when(vmiLast.getConversionMask()).thenReturn("000.##");
    when(vmiLast.getDateFormatTimeZone()).thenReturn(TimeZone.getDefault());
    when(vmiLast.getDecimalSymbol()).thenReturn(".");
    when(vmiLast.isDateFormatLenient()).thenReturn(false);
    Set<ComponentDerivationRecord> changeRecords = analyzer.getChangeRecords(selectValuesMeta);
    assertNotNull(changeRecords);
    assertEquals(metadataChanges.length, changeRecords.size());
}
Also used : ComponentDerivationRecord(org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord) SelectMetadataChange(org.pentaho.di.trans.steps.selectvalues.SelectMetadataChange) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 34 with ComponentDerivationRecord

use of org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord in project pentaho-metaverse by pentaho.

the class StreamLookupStepAnalyzerTest method testGetChangeRecords.

@Test
public void testGetChangeRecords() throws Exception {
    analyzer.setStepMeta(streamLookupMeta);
    Set<ComponentDerivationRecord> changeRecords = analyzer.getChangeRecords(streamLookupMeta);
    assertNotNull(changeRecords);
    assertEquals(1, changeRecords.size());
    ComponentDerivationRecord cr = changeRecords.iterator().next();
    assertEquals(ChangeType.METADATA, cr.getChangeType());
    assertEquals(1, cr.getOperations().size());
}
Also used : ComponentDerivationRecord(org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord) Test(org.junit.Test)

Example 35 with ComponentDerivationRecord

use of org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord in project pentaho-metaverse by pentaho.

the class StringOperationsStepAnalyzerTest method testGetChangeRecords.

@Test
public void testGetChangeRecords() throws Exception {
    Set<ComponentDerivationRecord> changeRecords = analyzer.getChangeRecords(stringOperationsMeta);
    assertEquals(changeRecords.size(), 3);
    List<String> inFields = Arrays.asList(stringOperationsMeta.getFieldInStream());
    for (ComponentDerivationRecord change : changeRecords) {
        assertTrue(inFields.contains(change.getOriginalEntityName()));
        assertEquals(1, change.getOperations(ChangeType.DATA).size());
        assertNull(change.getOperations(ChangeType.METADATA));
    }
}
Also used : ComponentDerivationRecord(org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

ComponentDerivationRecord (org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord)43 Test (org.junit.Test)23 HashSet (java.util.HashSet)21 StepField (org.pentaho.metaverse.api.StepField)11 Operation (org.pentaho.metaverse.api.model.Operation)11 Matchers.anyString (org.mockito.Matchers.anyString)5 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)5 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)5 IOperation (org.pentaho.metaverse.api.model.IOperation)3 Operations (org.pentaho.metaverse.api.model.Operations)3 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)2 SelectMetadataChange (org.pentaho.di.trans.steps.selectvalues.SelectMetadataChange)2 IAnalysisContext (org.pentaho.metaverse.api.IAnalysisContext)2 IFieldLineageMetadataProvider (org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider)2 StepNodes (org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes)2 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 Condition (org.pentaho.di.core.Condition)1 CalculatorMetaFunction (org.pentaho.di.trans.steps.calculator.CalculatorMetaFunction)1 NumberRangeRule (org.pentaho.di.trans.steps.numberrange.NumberRangeRule)1