Search in sources :

Example 21 with StepField

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

the class StepAnalyzerTest method testIsPassthrough_noOutputs.

@Test
public void testIsPassthrough_noOutputs() throws Exception {
    doReturn(null).when(analyzer).getOutputs();
    StepField testField = new StepField("previousStep2", "occupation");
    assertFalse(analyzer.isPassthrough(testField));
}
Also used : StepField(org.pentaho.metaverse.api.StepField) Test(org.junit.Test)

Example 22 with StepField

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

the class StepAnalyzerTest method setUp.

@Before
public void setUp() throws Exception {
    StepAnalyzer stepAnalyzer = new StepAnalyzer() {

        @Override
        protected Set<StepField> getUsedFields(BaseStepMeta meta) {
            return null;
        }

        @Override
        protected void customAnalyze(BaseStepMeta meta, IMetaverseNode rootNode) throws MetaverseAnalyzerException {
        }

        @Override
        public Set<Class<? extends BaseStepMeta>> getSupportedSteps() {
            return null;
        }
    };
    analyzer = spy(stepAnalyzer);
    analyzer.rootNode = rootNode;
    analyzer.baseStepMeta = baseStepMeta;
    analyzer.descriptor = descriptor;
    analyzer.parentTransMeta = parentTransMeta;
    analyzer.parentStepMeta = parentStepMeta;
    usedFields = new HashSet<>();
    inputs = new StepNodes();
    inputs.addNode("prevStep", "name", fieldNode);
    inputs.addNode("prevStep", "address", fieldNode);
    inputs.addNode("prevStep", "email", fieldNode);
    inputs.addNode("prevStep", "birthday", fieldNode);
    inputs.addNode("prevStep2", "employeeNumber", fieldNode);
    inputs.addNode("prevStep2", "occupation", fieldNode);
    outputs = new StepNodes();
    outputs.addNode("nextStep", "full name", fieldNode);
    outputs.addNode("nextStep", "address", fieldNode);
    outputs.addNode("nextStep", "email", fieldNode);
    outputs.addNode("nextStep", "date of birth", fieldNode);
    outputs.addNode("nextStep", "ID", fieldNode);
    outputs.addNode("nextStep", "occupation", fieldNode);
    doReturn(builder).when(analyzer).getMetaverseBuilder();
    MetaverseObjectFactory factory = new MetaverseObjectFactory();
    doReturn(factory).when(analyzer).getMetaverseObjectFactory();
    when(descriptor.getContext()).thenReturn(context);
    when(parentStepMeta.getName()).thenReturn("STEP NAME");
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) MetaverseObjectFactory(org.pentaho.metaverse.api.MetaverseObjectFactory) StepField(org.pentaho.metaverse.api.StepField) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Before(org.junit.Before)

Example 23 with StepField

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

the class StepAnalyzerTest method testMapChange.

@Test
public void testMapChange() throws Exception {
    doReturn(outputs).when(analyzer).getOutputs();
    doReturn(inputs).when(analyzer).getInputs();
    Operation operation = new Operation("testOperation", "testOperation");
    StepField original = new StepField("previousStep", "address");
    StepField changed = new StepField("nextStep", "address");
    ComponentDerivationRecord cdr = new ComponentDerivationRecord(original, changed);
    cdr.addOperation(operation);
    ComponentDerivationRecord spyCdr = spy(cdr);
    analyzer.mapChange(spyCdr);
    // get operations to verify it is not null, then agains to toString it
    verify(spyCdr, times(1)).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) Operation(org.pentaho.metaverse.api.model.Operation) Test(org.junit.Test)

Example 24 with StepField

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

the class StepAnalyzerTest method testIsPassthrough_false.

@Test
public void testIsPassthrough_false() throws Exception {
    doReturn(outputs).when(analyzer).getOutputs();
    StepField testField = new StepField("previousStep2", "employeeNumber");
    assertFalse(analyzer.isPassthrough(testField));
}
Also used : StepField(org.pentaho.metaverse.api.StepField) Test(org.junit.Test)

Example 25 with StepField

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

the class StepAnalyzerTest method testProcessUsedFields.

@Test
public void testProcessUsedFields() throws Exception {
    StepField name = new StepField("prevStep", "name");
    StepField address = new StepField("prevStep", "birthday");
    StepField empNum = new StepField("prevStep2", "employeeNumber");
    usedFields.add(name);
    usedFields.add(address);
    usedFields.add(empNum);
    doReturn(inputs).when(analyzer).getInputs();
    analyzer.processUsedFields(usedFields);
    verify(builder, times(usedFields.size())).addLink(rootNode, DictionaryConst.LINK_USES, fieldNode);
}
Also used : StepField(org.pentaho.metaverse.api.StepField) 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