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!");
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations