Package com.tinkerpop.blueprints.impls.tg

Examples of com.tinkerpop.blueprints.impls.tg.TinkerGraph


    }
  }

  @Before
  public void setup() {
    TinkerGraph base = TinkerGraphFactory.createTinkerGraph();
    g = new FramedGraphFactory(new JavaHandlerModule()).create(base);
   
  }
View Full Code Here


        assertEquals(counter, 2);

    }

    public void testCreateFrame() {
        Graph graph = new TinkerGraph();
        FramedGraph<Graph> framedGraph = new FramedGraphFactory().create(graph);
        Person person = framedGraph.addVertex(null, Person.class);
        assertEquals(person.asVertex(), graph.getVertices().iterator().next());
        int counter = 0;
        for (Vertex v : graph.getVertices()) {
            counter++;
        }
        assertEquals(counter, 1);
        counter = 0;
        for (Edge e : graph.getEdges()) {
            counter++;
        }
        assertEquals(counter, 0);
        Person person2 = framedGraph.addVertex("aPerson", Person.class);
        assertEquals(person2.asVertex().getId(), "aPerson");
        counter = 0;
        for (Vertex v : graph.getVertices()) {
            counter++;
        }
        assertEquals(counter, 2);

View Full Code Here


    }

    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);
View Full Code Here

        doTestSuite(new GraphSONReaderTestSuite(this));
        printTestPerformance("GraphSONReaderTestSuite", this.stopWatch());
    }

    public Graph generateGraph() {
        final TinkerGraph baseGraph = new TinkerGraph();
        baseGraph.getFeatures().isPersistent = false;
        return new FramedGraph<TinkerGraph>(baseGraph);
    }
View Full Code Here

        assertEquals("e[9][1-created->3]", markoCreatedLop.toString());
    }

    @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));

    }
View Full Code Here

        @InVertex
        <T extends Base> T getInVertex();
  };

  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);
View Full Code Here

    assertEquals("A", ((VertexFrame) a).asVertex().getProperty("type"));
    assertEquals("C", ((VertexFrame) c).asVertex().getProperty("type"));
  }

  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);
View Full Code Here

    ((C) c).setLabel("new label");
    assertEquals("new label", cV.getProperty("label"));
  }

  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"));
  }
View Full Code Here

    assertEquals("A", ((EdgeFrame) a).asEdge().getProperty("type"));
    assertEquals("C", ((EdgeFrame) c).asEdge().getProperty("type"));
  }

  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);
  }
View Full Code Here

    Base c = framedGraph.getEdge(cE.getId(), Direction.OUT, Base.class);
    assertTrue(c instanceof C);
  }

    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);
View Full Code Here

TOP

Related Classes of com.tinkerpop.blueprints.impls.tg.TinkerGraph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.