use of com.tinkerpop.frames.modules.typedgraph.TypedGraphModuleBuilder 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.frames.modules.typedgraph.TypedGraphModuleBuilder in project frames by tinkerpop.
the class TypedGraphModuleTest method testDeserializeEdgeType.
public void testDeserializeEdgeType() {
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);
Edge cE = graph.addEdge(null, v1, v2, "label");
cE.setProperty("type", "C");
Base c = framedGraph.getEdge(cE.getId(), Direction.OUT, Base.class);
assertTrue(c instanceof C);
}
use of com.tinkerpop.frames.modules.typedgraph.TypedGraphModuleBuilder 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.frames.modules.typedgraph.TypedGraphModuleBuilder in project frames by tinkerpop.
the class TypedGraphModuleTest method testWildcard.
public void testWildcard() {
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);
v2.setProperty("type", "A");
Edge cE = graph.addEdge(null, v1, v2, "label");
cE.setProperty("type", "C");
Base c = framedGraph.getEdge(cE.getId(), Direction.OUT, Base.class);
assertTrue(c instanceof C);
assertTrue(((C) c).getInVertex() instanceof A);
}
use of com.tinkerpop.frames.modules.typedgraph.TypedGraphModuleBuilder in project frames by tinkerpop.
the class TypedGraphModuleTest method testSerializeVertexType.
public void testSerializeVertexType() {
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);
A a = framedGraph.addVertex(null, A.class);
C c = framedGraph.addVertex(null, C.class);
assertEquals("A", ((VertexFrame) a).asVertex().getProperty("type"));
assertEquals("C", ((VertexFrame) c).asVertex().getProperty("type"));
}
Aggregations