use of org.pentaho.dictionary.MetaverseTransientNode in project pentaho-metaverse by pentaho.
the class MongoDbInputStepAnalyzerTest method testCustomAnalyze.
@Test
public void testCustomAnalyze() throws Exception {
when(meta.getJsonQuery()).thenReturn("{test:test}");
when(meta.getCollection()).thenReturn("myCollection");
when(meta.getQueryIsPipeline()).thenReturn(true);
IMetaverseNode node = new MetaverseTransientNode("new node");
analyzer.customAnalyze(meta, node);
assertNotNull(node);
assertEquals("{test:test}", node.getProperty(DictionaryConst.PROPERTY_QUERY));
assertEquals("myCollection", node.getProperty(MongoDbInputStepAnalyzer.COLLECTION));
assertTrue((Boolean) node.getProperty(MongoDbInputStepAnalyzer.AGG_PIPELINE));
}
use of org.pentaho.dictionary.MetaverseTransientNode in project pentaho-metaverse by pentaho.
the class MetaverseBuilderTest method testAddLink_existingLink.
@Test
public void testAddLink_existingLink() throws Exception {
// Retain current number of edges
int originalEdgeCount = 0;
for (Edge e : graph.getEdges()) {
originalEdgeCount++;
}
MetaverseTransientNode node2 = new MetaverseTransientNode();
node2.setStringID("nodeToId");
node2.setName("to name");
MetaverseLink link = new MetaverseLink(node, "uses", node2);
builder.addLink(link);
Vertex fromResult = graph.getVertex(node.getStringID());
Vertex toResult = graph.getVertex(node2.getStringID());
// make sure the edge exits before we try to add it again
assertNotNull(graph.getEdge(builder.getEdgeId(fromResult, link.getLabel(), toResult)));
// make sure we only added 1
int count = 0;
for (Edge e : graph.getEdges()) {
count++;
}
assertEquals(originalEdgeCount + 1, count);
// now lets add it again
builder.addLink(link);
// make sure we still only have one edge
count = 0;
for (Edge e : graph.getEdges()) {
count++;
}
assertEquals(originalEdgeCount + 1, count);
}
use of org.pentaho.dictionary.MetaverseTransientNode in project pentaho-metaverse by pentaho.
the class MetaverseObjectFactory method createNodeObject.
@Override
public IMetaverseNode createNodeObject(String id) {
MetaverseTransientNode node = new MetaverseTransientNode();
node.setStringID(id);
node.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_DEFAULT);
node.setProperty(DictionaryConst.NODE_VIRTUAL, true);
return node;
}
use of org.pentaho.dictionary.MetaverseTransientNode in project pentaho-metaverse by pentaho.
the class StepAnalyzerTest method testCreateInputFieldNode.
@Test
public void testCreateInputFieldNode() throws Exception {
doReturn("thisStepName").when(analyzer).getStepName();
MetaverseTransientNode node = new MetaverseTransientNode("node id");
doReturn(node).when(analyzer).createNodeFromDescriptor(any(IComponentDescriptor.class));
ValueMetaInterface vmi = new ValueMeta("name", 1);
IMetaverseNode inputFieldNode = analyzer.createInputFieldNode(descriptor.getContext(), vmi, "thisStepName", DictionaryConst.NODE_TYPE_TRANS_FIELD);
assertNotNull(inputFieldNode);
assertNotNull(inputFieldNode.getProperty(DictionaryConst.PROPERTY_KETTLE_TYPE));
assertEquals("thisStepName", inputFieldNode.getProperty(DictionaryConst.PROPERTY_TARGET_STEP));
// the input node should not be added by this step
verify(builder, never()).addNode(inputFieldNode);
}
use of org.pentaho.dictionary.MetaverseTransientNode in project pentaho-metaverse by pentaho.
the class StepAnalyzerTest method testCreateFieldNode_virtual.
@Test
public void testCreateFieldNode_virtual() throws Exception {
IComponentDescriptor fieldDescriptor = mock(IComponentDescriptor.class);
ValueMetaInterface fieldMeta = new ValueMeta("address");
MetaverseTransientNode node = new MetaverseTransientNode("hello");
doReturn(node).when(analyzer).createNodeFromDescriptor(fieldDescriptor);
IMetaverseNode fieldNode = analyzer.createFieldNode(fieldDescriptor, fieldMeta, "nextStep", false);
assertNotNull(fieldNode);
assertNotNull(fieldNode.getProperty(DictionaryConst.PROPERTY_KETTLE_TYPE));
assertEquals("nextStep", fieldNode.getProperty(DictionaryConst.PROPERTY_TARGET_STEP));
// make sure it did not added to the graph
verify(builder, never()).addNode(node);
}
Aggregations