use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project frames by tinkerpop.
the class TypedGraphModuleTest method testDeserializeVertexType.
public void testDeserializeVertexType() {
Graph graph = new TinkerGraph();
FramedGraphFactory factory = new FramedGraphFactory(new TypedGraphModuleBuilder().withClass(A.class).withClass(B.class).withClass(C.class).build());
FramedGraph<Graph> framedGraph = factory.create(graph);
Vertex cV = graph.addVertex(null);
cV.setProperty("type", "C");
cV.setProperty("label", "C Label");
Base c = framedGraph.getVertex(cV.getId(), Base.class);
assertTrue(c instanceof C);
assertEquals("C Label", c.getLabel());
((C) c).setLabel("new label");
assertEquals("new label", cV.getProperty("label"));
}
use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project frames by tinkerpop.
the class TypedGraphModuleTest method testSerializeEdgeType.
public void testSerializeEdgeType() {
Graph graph = new TinkerGraph();
FramedGraphFactory factory = new FramedGraphFactory(new TypedGraphModuleBuilder().withClass(A.class).withClass(B.class).withClass(C.class).build());
FramedGraph<Graph> framedGraph = factory.create(graph);
Vertex v1 = graph.addVertex(null);
Vertex v2 = graph.addVertex(null);
A a = framedGraph.addEdge(null, v1, v2, "label", Direction.OUT, A.class);
C c = framedGraph.addEdge(null, v1, v2, "label", Direction.OUT, C.class);
assertEquals("A", ((EdgeFrame) a).asEdge().getProperty("type"));
assertEquals("C", ((EdgeFrame) c).asEdge().getProperty("type"));
}
use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project frames by tinkerpop.
the class FramedElementTest method testEquality.
@Test
public void testEquality() {
TinkerGraph graph = TinkerGraphFactory.createTinkerGraph();
FramedGraph<TinkerGraph> framedGraph = new FramedGraphFactory().create(graph);
assertEquals(framedGraph.getVertex(1, Person.class), framedGraph.frame(graph.getVertex(1), Person.class));
}
use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project frames by tinkerpop.
the class FramedGraphTest method testCreateFrameForNonexistantElements.
public void testCreateFrameForNonexistantElements() {
Graph graph = new TinkerGraph();
FramedGraph<Graph> framedGraph = new FramedGraphFactory().create(graph);
Person vertex = framedGraph.getVertex(-1, Person.class);
Assert.assertNull(vertex);
vertex = framedGraph.frame((Vertex) null, Person.class);
Assert.assertNull(vertex);
Knows edge = framedGraph.getEdge(-1, Knows.class);
Assert.assertNull(edge);
edge = framedGraph.frame((Edge) null, Knows.class);
Assert.assertNull(edge);
}
use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project frames by tinkerpop.
the class FramedGraphTest method generateGraph.
public Graph generateGraph() {
final TinkerGraph baseGraph = new TinkerGraph();
baseGraph.getFeatures().isPersistent = false;
return new FramedGraph<TinkerGraph>(baseGraph);
}
Aggregations