use of org.pentaho.dictionary.MetaverseTransientNode in project pentaho-metaverse by pentaho.
the class MetaverseBuilderTest method testAddLink_OneExistingNode.
@Test
public void testAddLink_OneExistingNode() {
// explicitly add the fromNode
builder.addNode(node);
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());
// we added this node explicitly through the addNode, it should be flagged as NOT virtual
assertFalse((Boolean) fromResult.getProperty(DictionaryConst.NODE_VIRTUAL));
// we added this node implicitly through the addLink, it should be flagged as virtual
assertTrue((Boolean) toResult.getProperty(DictionaryConst.NODE_VIRTUAL));
}
use of org.pentaho.dictionary.MetaverseTransientNode in project pentaho-metaverse by pentaho.
the class MetaverseBuilderTest method testAddLink.
@Test
public void testAddLink() {
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());
// we added this node implicitly through the addLink, it should be flagged as virtual
assertTrue((Boolean) fromResult.getProperty(DictionaryConst.NODE_VIRTUAL));
// we added this node implicitly through the addLink, it should be flagged as virtual
assertTrue((Boolean) toResult.getProperty(DictionaryConst.NODE_VIRTUAL));
assertNotNull(fromResult.getEdges(Direction.OUT, "uses"));
for (Edge e : fromResult.getEdges(Direction.OUT, "uses")) {
assertEquals(e.getVertex(Direction.OUT).getProperty("name"), node.getName());
assertEquals(e.getVertex(Direction.IN).getProperty("name"), node2.getName());
// we added this node implicitly through the addLink, it should be flagged as virtual
assertTrue((Boolean) e.getVertex(Direction.OUT).getProperty(DictionaryConst.NODE_VIRTUAL));
}
assertNotNull(toResult.getEdges(Direction.IN, "uses"));
for (Edge e : fromResult.getEdges(Direction.IN, "uses")) {
assertEquals(e.getVertex(Direction.OUT).getProperty("name"), node.getName());
assertEquals(e.getVertex(Direction.IN).getProperty("name"), node2.getName());
// we added this node implicitly through the addLink, it should be flagged as virtual
assertTrue((Boolean) e.getVertex(Direction.IN).getProperty(DictionaryConst.NODE_VIRTUAL));
}
}
use of org.pentaho.dictionary.MetaverseTransientNode in project pentaho-metaverse by pentaho.
the class MetaverseObjectFactory method createNodeObject.
@Override
public IMetaverseNode createNodeObject(INamespace namespace, ILogicalIdGenerator idGenerator, Map<String, Object> properties) {
MetaverseTransientNode node = new MetaverseTransientNode();
node.setProperties(properties);
node.setProperty(DictionaryConst.PROPERTY_NAMESPACE, namespace.getNamespaceId());
node.setLogicalIdGenerator(idGenerator);
node.setProperty(DictionaryConst.NODE_VIRTUAL, true);
String id = node.getLogicalId();
node.setStringID(id);
return node;
}
use of org.pentaho.dictionary.MetaverseTransientNode in project pentaho-metaverse by pentaho.
the class StepAnalyzerTest method testCreateFieldNode.
@Test
public void testCreateFieldNode() 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", true);
assertNotNull(fieldNode);
assertNotNull(fieldNode.getProperty(DictionaryConst.PROPERTY_KETTLE_TYPE));
assertEquals("nextStep", fieldNode.getProperty(DictionaryConst.PROPERTY_TARGET_STEP));
// make sure it got added to the graph
verify(builder).addNode(node);
}
use of org.pentaho.dictionary.MetaverseTransientNode in project pentaho-metaverse by pentaho.
the class JobJobEntryAnalyzerTest method setUp.
@Before
public void setUp() throws Exception {
when(metaverseBuilder.getMetaverseObjectFactory()).thenReturn(objectFactory);
when(objectFactory.createNodeObject(anyString(), anyString(), anyString())).thenReturn(new MetaverseTransientNode("name"));
when(jobEntryJob.getName()).thenReturn("job entry");
when(jobEntryJob.getSpecificationMethod()).thenReturn(ObjectLocationSpecificationMethod.FILENAME);
when(jobEntryJob.getFilename()).thenReturn(TEST_FILE_NAME);
when(jobEntryJob.getParentJob()).thenReturn(mockParentJob);
when(mockParentJob.getJobMeta()).thenReturn(mockParentJobMeta);
when(namespace.getParentNamespace()).thenReturn(namespace);
when(mockParentJobMeta.environmentSubstitute(anyString())).thenAnswer(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
return (String) invocation.getArguments()[0];
}
});
descriptor = new MetaverseComponentDescriptor("job entry", DictionaryConst.NODE_TYPE_JOB_ENTRY, namespace);
analyzer = new JobJobEntryAnalyzer();
spyAnalyzer = spy(analyzer);
spyAnalyzer.setMetaverseBuilder(metaverseBuilder);
spyAnalyzer.setDescriptor(descriptor);
doReturn(childJobMeta).when(spyAnalyzer).getSubJobMeta(anyString());
}
Aggregations