use of com.tinkerpop.blueprints.Edge in project pentaho-metaverse by pentaho.
the class MetaverseBuilderTest method testAddLink2.
@Test
public void testAddLink2() {
MetaverseTransientNode node2 = new MetaverseTransientNode();
node2.setStringID("nodeToId");
node2.setName("to name");
builder.addLink(node, "uses", node2);
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 com.tinkerpop.blueprints.Edge 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 com.tinkerpop.blueprints.Edge in project pentaho-metaverse by pentaho.
the class MetaverseBuilderTest method testCopyLinkPropertiesToEdge.
@Test
public void testCopyLinkPropertiesToEdge() {
final String LABEL = "myLabel";
IMetaverseLink link = new MetaverseLink();
link.setLabel("sourceLabel");
// Create from/to nodes and an edge between them
Vertex fromNode = graph.addVertex("from");
Vertex toNode = graph.addVertex("to");
Edge edge = graph.addEdge("myId", fromNode, toNode, LABEL);
// Call with null for branch coverage (and to prove no NPE occurs)
builder.copyLinkPropertiesToEdge(null, edge);
builder.copyLinkPropertiesToEdge(link, null);
// Call with empty list for branch coverage (and to prove no NPE occurs)
builder.copyLinkPropertiesToEdge(link, edge);
// Set some properties on the source link
link.setProperty(DictionaryConst.PROPERTY_LABEL, "sourceLabel");
link.setProperty(DictionaryConst.PROPERTY_NAME, "sourceLink");
// Set some properties on the target edge (including the reserved one "label")
edge.setProperty(DictionaryConst.PROPERTY_NAME, "myEdge");
edge.setProperty(DictionaryConst.PROPERTY_TYPE, "relates to");
// Invoke the method under test and see that the appropriate properties are set on the target edge
builder.copyLinkPropertiesToEdge(link, edge);
assertEquals("sourceLink", edge.getProperty(DictionaryConst.PROPERTY_NAME));
assertEquals("relates to", edge.getProperty(DictionaryConst.PROPERTY_TYPE));
// The label should not be overridden (Blueprints does not allow it)
assertEquals(LABEL, edge.getLabel());
// The property "label" is not set on the edge by either setLabel() or the method under test
// It's a Blueprints thing
assertNull(edge.getProperty(DictionaryConst.PROPERTY_LABEL));
}
use of com.tinkerpop.blueprints.Edge in project wildfly-swarm by wildfly-swarm.
the class OrientDBArquillianTest method shouldAddAFriendshipToTheGraph.
@Test
public void shouldAddAFriendshipToTheGraph() {
String firstName = "test-name-" + LocalTime.now();
String secondName = "test-name-" + LocalTime.now();
OrientEdge edge = statefulTestBean.addFriend(firstName, secondName);
assertEquals(firstName, edge.getVertex(Direction.OUT).getProperty("name"));
assertEquals(secondName, edge.getVertex(Direction.IN).getProperty("name"));
assertEquals("knows", edge.getLabel());
List<Edge> edges = statefulTestBean.getFriends();
assertEquals(1, edges.size());
assertEquals(edge, edges.get(0));
}
use of com.tinkerpop.blueprints.Edge in project wildfly-swarm by wildfly-swarm.
the class TestPeopleDao method getFriends.
public List<Edge> getFriends() {
List<Edge> edges = new LinkedList<>();
OrientGraph database = new OrientGraph(databasePool);
try {
database.getEdges().forEach(edges::add);
} finally {
database.shutdown();
}
return edges;
}
Aggregations