Search in sources :

Example 16 with StepField

use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.

the class SplitFieldsStepAnalyzerTest method testGetUsedFields.

@Test
public void testGetUsedFields() throws Exception {
    Set<StepField> fields = new HashSet<>();
    fields.add(new StepField("prev", "splitField"));
    doReturn(fields).when(analyzer).createStepFields(anyString(), any(StepNodes.class));
    Set<StepField> usedFields = analyzer.getUsedFields(meta);
    int expectedUsedFieldCount = 1;
    assertEquals(expectedUsedFieldCount, usedFields.size());
    verify(analyzer, times(expectedUsedFieldCount)).createStepFields(anyString(), any(StepNodes.class));
}
Also used : StepField(org.pentaho.metaverse.api.StepField) StepNodes(org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 17 with StepField

use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.

the class StringsReplaceStepAnalyzerTest method testGetUsedFields.

@Test
public void testGetUsedFields() {
    Set<StepField> usedFields = analyzer.getUsedFields(stringsReplaceMeta);
    List<String> inFields = Arrays.asList(stringsReplaceMeta.getFieldInStream());
    // This test class uses all incoming fields
    for (StepField usedField : usedFields) {
        assertTrue(inFields.contains(usedField.getFieldName()));
    }
}
Also used : StepField(org.pentaho.metaverse.api.StepField) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 18 with StepField

use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.

the class ValueMapperStepAnalyzerTest method testGetUsedFields.

@Test
public void testGetUsedFields() throws Exception {
    Set<StepField> fields = new HashSet<>();
    fields.add(new StepField("prev", "inField"));
    doReturn(fields).when(analyzer).createStepFields(anyString(), any(StepNodes.class));
    Set<StepField> usedFields = analyzer.getUsedFields(meta);
    int expectedUsedFieldCount = 1;
    assertEquals(expectedUsedFieldCount, usedFields.size());
    verify(analyzer, times(expectedUsedFieldCount)).createStepFields(anyString(), any(StepNodes.class));
}
Also used : StepField(org.pentaho.metaverse.api.StepField) StepNodes(org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 19 with StepField

use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.

the class ConnectionExternalResourceStepAnalyzerTest method setUp.

@Before
public void setUp() throws Exception {
    analyzer = spy(new ConnectionExternalResourceStepAnalyzer<BaseStepMeta>() {

        @Override
        protected IMetaverseNode createTableNode(IExternalResourceInfo resource) throws MetaverseAnalyzerException {
            return tableNode;
        }

        @Override
        public String getResourceInputNodeType() {
            return "INPUT_TYPE";
        }

        @Override
        public String getResourceOutputNodeType() {
            return "OUTPUT_TYPE";
        }

        @Override
        public boolean isOutput() {
            return false;
        }

        @Override
        public boolean isInput() {
            return true;
        }

        @Override
        protected Set<StepField> getUsedFields(BaseStepMeta meta) {
            Set<StepField> stepFields = new HashSet<>();
            stepFields.add(new StepField("prevStep", "filename"));
            return stepFields;
        }

        @Override
        public Set<Class<? extends BaseStepMeta>> getSupportedSteps() {
            return null;
        }
    });
    when(analyzer.getMetaverseBuilder()).thenReturn(builder);
    analyzer.descriptor = descriptor;
    when(descriptor.getContext()).thenReturn(context);
    analyzer.parentTransMeta = parentTransMeta;
    analyzer.parentStepMeta = parentStepMeta;
    analyzer.setMetaverseObjectFactory(new MetaverseObjectFactory());
}
Also used : IExternalResourceInfo(org.pentaho.metaverse.api.model.IExternalResourceInfo) MetaverseObjectFactory(org.pentaho.metaverse.api.MetaverseObjectFactory) StepField(org.pentaho.metaverse.api.StepField) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 20 with StepField

use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.

the class StepAnalyzerTest method testMapChange_noOperation.

@Test
public void testMapChange_noOperation() throws Exception {
    doReturn(outputs).when(analyzer).getOutputs();
    doReturn(inputs).when(analyzer).getInputs();
    StepField original = new StepField("previousStep", "address");
    StepField changed = new StepField("nextStep", "address");
    ComponentDerivationRecord cdr = new ComponentDerivationRecord(original, changed);
    ComponentDerivationRecord spyCdr = spy(cdr);
    analyzer.mapChange(spyCdr);
    // should only be called to see if there are any operations
    verify(spyCdr).getOperations();
    verify(analyzer).linkChangeNodes(any(IMetaverseNode.class), any(IMetaverseNode.class));
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) StepField(org.pentaho.metaverse.api.StepField) ComponentDerivationRecord(org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord) Test(org.junit.Test)

Aggregations

StepField (org.pentaho.metaverse.api.StepField)53 Test (org.junit.Test)33 HashSet (java.util.HashSet)23 StepNodes (org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes)11 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)10 ComponentDerivationRecord (org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord)10 Matchers.anyString (org.mockito.Matchers.anyString)6 Before (org.junit.Before)4 SelectMetadataChange (org.pentaho.di.trans.steps.selectvalues.SelectMetadataChange)4 Set (java.util.Set)3 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)3 MetaverseObjectFactory (org.pentaho.metaverse.api.MetaverseObjectFactory)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)2 IAnalysisContext (org.pentaho.metaverse.api.IAnalysisContext)2 IExternalResourceInfo (org.pentaho.metaverse.api.model.IExternalResourceInfo)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Graph (com.tinkerpop.blueprints.Graph)1 Vertex (com.tinkerpop.blueprints.Vertex)1