Search in sources :

Example 51 with IMetaverseNode

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

the class DatabaseConnectionAnalyzerTest method testAnalyze.

@Test
public void testAnalyze() {
    when(builder.addNode(any(IMetaverseNode.class))).thenAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            Object[] args = invocation.getArguments();
            // add the logicalId to the node like it does in the real builder
            IMetaverseNode node = (IMetaverseNode) args[0];
            node.setProperty(DictionaryConst.PROPERTY_LOGICAL_ID, node.getLogicalId());
            return builder;
        }
    });
    try {
        IMetaverseNode node = dbConnectionAnalyzer.analyze(mockDescriptor, databaseMeta);
        assertNotNull(node);
        assertEquals(14, node.getPropertyKeys().size());
    } catch (MetaverseAnalyzerException e) {
        fail("analyze() should not throw an exception!");
    }
}
Also used : MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Test(org.junit.Test)

Example 52 with IMetaverseNode

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

the class JobEntryAnalyzerTest method testAnalyze.

public void testAnalyze() throws MetaverseAnalyzerException {
    IMetaverseNode node = analyzer.analyze(mockDescriptor, mockJobEntryInterface);
    assertNotNull(node);
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode)

Example 53 with IMetaverseNode

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

the class JobEntryAnalyzerTest method setUp.

/**
 * @throws Exception
 */
@Before
public void setUp() throws Exception {
    IMetaverseObjectFactory factory = MetaverseTestUtils.getMetaverseObjectFactory();
    when(mockBuilder.getMetaverseObjectFactory()).thenReturn(factory);
    JobEntryAnalyzer baseAnalyzer = new JobEntryAnalyzer() {

        @Override
        public Set<Class<? super JobEntryCopy>> getSupportedEntries() {
            return null;
        }

        @Override
        protected void customAnalyze(JobEntryInterface entry, IMetaverseNode rootNode) throws MetaverseAnalyzerException {
        // TODO Auto-generated method stub
        }
    };
    analyzer = spy(baseAnalyzer);
    analyzer.setMetaverseBuilder(mockBuilder);
    when(mockEntry.getEntry()).thenReturn(mockJobEntryInterface);
    when(mockJobEntryInterface.getPluginId()).thenReturn("Base job entry");
    when(mockJobEntryInterface.getParentJob()).thenReturn(mockJob);
    when(mockJob.getJobMeta()).thenReturn(mockJobMeta);
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) IMetaverseObjectFactory(org.pentaho.metaverse.api.IMetaverseObjectFactory) AfterClass(org.junit.AfterClass) BeforeClass(org.junit.BeforeClass) Before(org.junit.Before)

Example 54 with IMetaverseNode

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

the class ConnectionExternalResourceStepAnalyzerTest method testCustomAnalyze_input.

@Test
public void testCustomAnalyze_input() throws Exception {
    // fake the super.analyze call
    doReturn(node).when((StepAnalyzer<BaseStepMeta>) analyzer).analyze(descriptor, meta);
    analyzer.setExternalResourceConsumer(erc);
    List<IExternalResourceInfo> resources = new ArrayList<>();
    IExternalResourceInfo resInfo = mock(IExternalResourceInfo.class);
    resources.add(resInfo);
    when(resInfo.isInput()).thenReturn(true);
    when(erc.getResourcesFromMeta(meta, context)).thenReturn(resources);
    IMetaverseNode connectionNode = mock(IMetaverseNode.class);
    doReturn(connectionNode).when(analyzer).getConnectionNode();
    doReturn(resourceNode).when(analyzer).createResourceNode(any(IExternalResourceInfo.class));
    when(erc.getResources(eq(meta), any(IAnalysisContext.class))).thenReturn(resources);
    analyzer.customAnalyze(meta, node);
    verify(builder).addNode(resourceNode);
    verify(builder).addLink(resourceNode, DictionaryConst.LINK_READBY, node);
    verify(builder).addNode(connectionNode);
    verify(builder).addLink(connectionNode, DictionaryConst.LINK_DEPENDENCYOF, node);
}
Also used : IExternalResourceInfo(org.pentaho.metaverse.api.model.IExternalResourceInfo) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) ArrayList(java.util.ArrayList) IAnalysisContext(org.pentaho.metaverse.api.IAnalysisContext) Test(org.junit.Test)

Example 55 with IMetaverseNode

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

the class ExternalResourceStepAnalyzerTest method testLinkChangeNodes.

@Test
public void testLinkChangeNodes() throws Exception {
    IMetaverseNode inputNode = mock(IMetaverseNode.class);
    IMetaverseNode outputNode = mock(IMetaverseNode.class);
    when(inputNode.getType()).thenReturn("A");
    when(outputNode.getType()).thenReturn("A");
    doReturn(true).when(analyzer).isInput();
    doReturn(false).when(analyzer).isOutput();
    analyzer.linkChangeNodes(inputNode, outputNode);
    verify(builder, never()).addLink(inputNode, DictionaryConst.LINK_POPULATES, outputNode);
    verify(builder).addLink(inputNode, analyzer.getInputToOutputLinkLabel(), outputNode);
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) Test(org.junit.Test)

Aggregations

IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)131 Test (org.junit.Test)77 IComponentDescriptor (org.pentaho.metaverse.api.IComponentDescriptor)30 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)23 MetaverseComponentDescriptor (org.pentaho.metaverse.api.MetaverseComponentDescriptor)16 ValueMeta (org.pentaho.di.core.row.ValueMeta)13 IExternalResourceInfo (org.pentaho.metaverse.api.model.IExternalResourceInfo)12 IAnalysisContext (org.pentaho.metaverse.api.IAnalysisContext)11 MetaverseAnalyzerException (org.pentaho.metaverse.api.MetaverseAnalyzerException)11 Vertex (com.tinkerpop.blueprints.Vertex)10 ArrayList (java.util.ArrayList)10 INamespace (org.pentaho.metaverse.api.INamespace)10 TransMeta (org.pentaho.di.trans.TransMeta)9 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)9 MetaverseTransientNode (org.pentaho.dictionary.MetaverseTransientNode)9 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)8 Namespace (org.pentaho.metaverse.api.Namespace)8 StepField (org.pentaho.metaverse.api.StepField)8 HashMap (java.util.HashMap)7 Matchers.anyString (org.mockito.Matchers.anyString)7