Search in sources :

Example 1 with MetaverseObjectFactory

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

the class JsonInputAnalyzerTest method setUp.

@Before
public void setUp() throws Exception {
    mockFactory = new MetaverseObjectFactory();
    when(mockBuilder.getMetaverseObjectFactory()).thenReturn(mockFactory);
    when(mockNamespace.getParentNamespace()).thenReturn(mockNamespace);
    analyzer = new JsonInputAnalyzer() {

        @Override
        public Set<String> getInputStepNames(final JsonInputMeta meta, final String fieldName) {
            Set<String> inputFieldStepNames = new HashSet<>();
            inputFieldStepNames.add("previousStep");
            return inputFieldStepNames;
        }
    };
    analyzer.setMetaverseBuilder(mockBuilder);
    when(mockJsonInput.getStepMetaInterface()).thenReturn(meta);
    when(mockJsonInput.getStepMeta()).thenReturn(mockStepMeta);
    when(mockStepMeta.getStepMetaInterface()).thenReturn(meta);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) IMetaverseObjectFactory(org.pentaho.metaverse.api.IMetaverseObjectFactory) MetaverseObjectFactory(org.pentaho.metaverse.api.MetaverseObjectFactory) JsonInputMeta(org.pentaho.di.trans.steps.jsoninput.JsonInputMeta) Before(org.junit.Before)

Example 2 with MetaverseObjectFactory

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

the class BaseKettleMetaverseComponentTest method testCreateNodeFromDescriptor.

@Test
public void testCreateNodeFromDescriptor() throws Exception {
    String namespaceId = "{namespace: 'my namespace', name: 'my name', type: 'my type'}";
    ILogicalIdGenerator idGenerator = DictionaryConst.LOGICAL_ID_GENERATOR_DEFAULT;
    IComponentDescriptor descriptor = mock(IComponentDescriptor.class);
    INamespace ns = mock(INamespace.class);
    when(descriptor.getParentNamespace()).thenReturn(mock(INamespace.class));
    when(descriptor.getNamespace()).thenReturn(ns);
    when(ns.getNamespaceId()).thenReturn(namespaceId);
    component.metaverseObjectFactory = spy(new MetaverseObjectFactory());
    IMetaverseNode node = component.createNodeFromDescriptor(descriptor, idGenerator);
    assertNotNull(node);
    assertTrue(node.getLogicalId().contains(namespaceId));
}
Also used : IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) ILogicalIdGenerator(org.pentaho.metaverse.api.ILogicalIdGenerator) INamespace(org.pentaho.metaverse.api.INamespace) MetaverseObjectFactory(org.pentaho.metaverse.api.MetaverseObjectFactory) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 3 with MetaverseObjectFactory

use of org.pentaho.metaverse.api.MetaverseObjectFactory 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 4 with MetaverseObjectFactory

use of org.pentaho.metaverse.api.MetaverseObjectFactory 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 5 with MetaverseObjectFactory

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

the class StepAnalyzerTest method testGetStepFieldOriginDescriptor.

@Test
public void testGetStepFieldOriginDescriptor() throws Exception {
    when(mockStepFields.getFieldNames()).thenReturn(new String[] { "field1", "field2" });
    analyzer.stepFields = mockStepFields;
    IMetaverseNode rootNode = mock(IMetaverseNode.class);
    when(rootNode.getProperty(DictionaryConst.PROPERTY_NAMESPACE)).thenReturn("{}");
    analyzer.rootNode = rootNode;
    analyzer.setMetaverseObjectFactory(new MetaverseObjectFactory());
    assertNotNull(analyzer.getStepFieldOriginDescriptor(mockDescriptor, "field1"));
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) MetaverseObjectFactory(org.pentaho.metaverse.api.MetaverseObjectFactory) Test(org.junit.Test)

Aggregations

MetaverseObjectFactory (org.pentaho.metaverse.api.MetaverseObjectFactory)7 Before (org.junit.Before)4 HashSet (java.util.HashSet)3 Test (org.junit.Test)3 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)3 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)3 StepField (org.pentaho.metaverse.api.StepField)3 IComponentDescriptor (org.pentaho.metaverse.api.IComponentDescriptor)2 INamespace (org.pentaho.metaverse.api.INamespace)2 IExternalResourceInfo (org.pentaho.metaverse.api.model.IExternalResourceInfo)2 Set (java.util.Set)1 Matchers.anyString (org.mockito.Matchers.anyString)1 JsonInputMeta (org.pentaho.di.trans.steps.jsoninput.JsonInputMeta)1 ILogicalIdGenerator (org.pentaho.metaverse.api.ILogicalIdGenerator)1 IMetaverseBuilder (org.pentaho.metaverse.api.IMetaverseBuilder)1 IMetaverseObjectFactory (org.pentaho.metaverse.api.IMetaverseObjectFactory)1