Search in sources :

Example 81 with IMetaverseNode

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

the class MetaverseDocumentAnalyzerTest method testAnalyzeTransDocument.

@Test
public void testAnalyzeTransDocument() throws MetaverseAnalyzerException {
    IMetaverseNode node = (IMetaverseNode) analyzer.analyze(descriptor, transDoc);
    assertNotNull(node);
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) Test(org.junit.Test)

Example 82 with IMetaverseNode

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

the class MetaverseDocumentAnalyzerTest method testAnalyzeContentFromXml.

@Test
public void testAnalyzeContentFromXml() throws MetaverseAnalyzerException, KettleException {
    when(transDoc.getContent()).thenReturn(content.getXML());
    IMetaverseNode node = (IMetaverseNode) analyzer.analyze(descriptor, transDoc);
    assertNotNull(node);
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) Test(org.junit.Test)

Example 83 with IMetaverseNode

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

the class MongoDbConnectionAnalyzerTest method testAnalyze.

@Test
public void testAnalyze() throws Exception {
    when(mockBuilder.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 mockBuilder;
        }
    });
    IMetaverseNode node = analyzer.analyze(mockDescriptor, mongoDbMeta);
    assertNotNull(node);
    assertEquals("localhost", node.getProperty(MongoDbConnectionAnalyzer.HOST_NAMES));
    assertEquals("db", node.getProperty(MongoDbConnectionAnalyzer.DATABASE_NAME));
    assertEquals("user", node.getProperty(DictionaryConst.PROPERTY_USER_NAME));
    assertEquals("12345", node.getProperty(DictionaryConst.PROPERTY_PORT));
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Test(org.junit.Test)

Example 84 with IMetaverseNode

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

the class TransformationAnalyzerTest method testAnalyzerTransformWithStepsAndHop.

@Test
public void testAnalyzerTransformWithStepsAndHop() throws MetaverseAnalyzerException {
    StepMeta mockToStepMeta = mock(StepMeta.class);
    when(mockToStepMeta.getStepMetaInterface()).thenReturn(mockSelectValuesStepMeta);
    StepIOMetaInterface stepIO = mock(StepIOMetaInterface.class);
    when(stepIO.getInfoStepnames()).thenReturn(new String[] {});
    when(mockSelectValuesStepMeta.getStepIOMeta()).thenReturn(stepIO);
    when(mockToStepMeta.getParentTransMeta()).thenReturn(mockContent);
    when(mockContent.nrSteps()).thenReturn(2);
    when(mockContent.getStep(0)).thenReturn(mockStepMeta);
    when(mockContent.getStep(1)).thenReturn(mockToStepMeta);
    when(mockContent.nrTransHops()).thenReturn(1);
    final TransHopMeta hop = new TransHopMeta(mockStepMeta, mockToStepMeta, true);
    when(mockContent.getTransHop(0)).thenReturn(hop);
    IMetaverseNode node = analyzer.analyze(descriptor, mockTransDoc);
    assertNotNull(node);
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) StepIOMetaInterface(org.pentaho.di.trans.step.StepIOMetaInterface) TransHopMeta(org.pentaho.di.trans.TransHopMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Test(org.junit.Test)

Example 85 with IMetaverseNode

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

the class TransformationAnalyzerTest method testAnalyzerTransformWithParamException.

@Test(expected = MetaverseAnalyzerException.class)
public void testAnalyzerTransformWithParamException() throws Exception {
    when(mockContent.getParameterDefault(anyString())).thenThrow(UnknownParamException.class);
    // increases line code coverage by adding step to transformation
    IMetaverseNode node = analyzer.analyze(descriptor, mockTransDoc);
    assertNotNull(node);
}
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