Search in sources :

Example 16 with TinkerGraph

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"));
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) TypedGraphModuleBuilder(com.tinkerpop.frames.modules.typedgraph.TypedGraphModuleBuilder)

Example 17 with TinkerGraph

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"));
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) TypedGraphModuleBuilder(com.tinkerpop.frames.modules.typedgraph.TypedGraphModuleBuilder)

Example 18 with TinkerGraph

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));
}
Also used : TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Person(com.tinkerpop.frames.domain.classes.Person) Test(org.junit.Test)

Example 19 with TinkerGraph

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);
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Knows(com.tinkerpop.frames.domain.incidences.Knows) Person(com.tinkerpop.frames.domain.classes.Person) Edge(com.tinkerpop.blueprints.Edge)

Example 20 with TinkerGraph

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);
}
Also used : TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph)

Aggregations

TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)105 Vertex (com.tinkerpop.blueprints.Vertex)66 Graph (com.tinkerpop.blueprints.Graph)58 Test (org.junit.Test)42 Edge (com.tinkerpop.blueprints.Edge)33 ByteArrayOutputStream (java.io.ByteArrayOutputStream)12 ByteArrayInputStream (java.io.ByteArrayInputStream)11 JSONObject (org.codehaus.jettison.json.JSONObject)10 IMetaverseBuilder (org.pentaho.metaverse.api.IMetaverseBuilder)10 InputStream (java.io.InputStream)9 HashSet (java.util.HashSet)9 JSONTokener (org.codehaus.jettison.json.JSONTokener)8 KeyIndexableGraph (com.tinkerpop.blueprints.KeyIndexableGraph)7 Map (java.util.Map)6 MetaverseBuilder (org.pentaho.metaverse.impl.MetaverseBuilder)6 TypedGraphModuleBuilder (com.tinkerpop.frames.modules.typedgraph.TypedGraphModuleBuilder)5 HashMap (java.util.HashMap)5 Before (org.junit.Before)5 IndexableGraph (com.tinkerpop.blueprints.IndexableGraph)4 IgnoreIdTinkerGraph (com.tinkerpop.blueprints.impls.tg.IgnoreIdTinkerGraph)4