Package com.tinkerpop.blueprints

Examples of com.tinkerpop.blueprints.Graph


        assertEquals(framedGraph.getAnnotationHandlers().size(), 0);
    }
   
   
  public void testDeprecatedConfigContainsCoreAnnotationHandlers() {
        Graph graph = TinkerGraphFactory.createTinkerGraph();
        FramedGraph<Graph> framedGraph = new FramedGraph<Graph>(graph);
        Collection<Class<?>> collections = Collections2.transform(framedGraph.getAnnotationHandlers(), new Function<AnnotationHandler<? extends Annotation>, Class<?>>() {
      @Override
      public Class<?> apply(AnnotationHandler<? extends Annotation> handler) {
        return handler.getClass();
View Full Code Here


            OutVertexAnnotationHandler.class,
            GremlinGroovyAnnotationHandler.class)));
    }
 
  public void testDeprecatedConfigRegisterAnnotationHandlers() {
        Graph graph = TinkerGraphFactory.createTinkerGraph();
        FramedGraph<Graph> framedGraph = new FramedGraph<Graph>(graph);
        framedGraph.getAnnotationHandlers().clear();
        AnnotationHandler<?> handler = new PropertyAnnotationHandler();
        framedGraph.registerAnnotationHandler(handler);
        Assert.assertEquals(1, framedGraph.getAnnotationHandlers().size());
View Full Code Here

       
    }


    public void testFrameEquality() {
        Graph graph = TinkerGraphFactory.createTinkerGraph();
        FramedGraph<Graph> framedGraph = new FramedGraphFactory().create(graph);

        assertEquals(framedGraph.frame(graph.getVertex(1), Person.class), framedGraph.getVertex(1, Person.class));
        assertEquals(framedGraph.frame(graph.getEdge(7), Knows.class), framedGraph.getEdge(7, Knows.class));
    }
View Full Code Here

        assertEquals(framedGraph.frame(graph.getVertex(1), Person.class), framedGraph.getVertex(1, Person.class));
        assertEquals(framedGraph.frame(graph.getEdge(7), Knows.class), framedGraph.getEdge(7, Knows.class));
    }

    public void testFrameVertices() {
        Graph graph = TinkerGraphFactory.createTinkerGraph();
        FramedGraph<Graph> framedGraph = new FramedGraphFactory().create(graph);

        int counter = 0;
        for (Person person : framedGraph.getVertices("name", "marko", Person.class)) {
            counter++;
            assertEquals(person.getName(), "marko");
        }
        assertEquals(counter, 1);

        counter = 0;
        for (Project project : framedGraph.frameVertices(graph.getVertices("lang", "java"), Project.class)) {
            counter++;
            assertTrue(project.getName().equals("lop") || project.getName().equals("ripple"));
        }
        assertEquals(counter, 2);
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

        }
    }
   
    @Test
  public void testVertexQuery() {
    Graph graph = TinkerGraphFactory.createTinkerGraph();
    FramedGraph<Graph> framedGraph = new FramedGraphFactory().create(graph);
    Assert.assertEquals(6, Iterables.size(framedGraph.query().has("name").vertices(VertexFrame.class)));
    Iterables.elementsEqual(
        framedGraph.query().has("name").vertices(),
        unwrapVertices(framedGraph.query().has("name")
View Full Code Here

  }

 
  @Test
  public void testEdgeQuery() {
    Graph graph = TinkerGraphFactory.createTinkerGraph();
   
    FramedGraph<Graph> framedGraph = new FramedGraphFactory().create(graph);
   
    Assert.assertEquals(6, Iterables.size(framedGraph.query().has("weight").edges(EdgeFrame.class)));
    Iterables.elementsEqual(
View Full Code Here

    private Knows knows;
    private Project lop;

    @Before
    public void setup() {
        Graph graph = TinkerGraphFactory.createTinkerGraph();
        framedGraph = new FramedGraphFactory().create(graph);

        marko = framedGraph.getVertex(1, Person.class);
        vadas = framedGraph.getVertex(2, Person.class);
        peter = framedGraph.getVertex(6, Person.class);
View Full Code Here

   * @param requiredType The type of graph required after configuration e.g. {@link TransactionalGraph}
   * @param baseGraph The base graph to get a configuration for.
   * @return The configuration.
   */
  protected <T extends Graph> FramedGraphConfiguration getConfiguration(Class<T> requiredType, T baseGraph) {
    Graph configuredGraph = baseGraph;
    FramedGraphConfiguration config = getBaseConfig();
    for (Module module : modules) {
      configuredGraph = module.configure(configuredGraph, config);
      if(!(requiredType.isInstance(configuredGraph))) {
        throw new UnsupportedOperationException("Module '" + module.getClass() + "' returned a '" + baseGraph.getClass().getName() + "' but factory requires '" + requiredType.getName() + "'");
View Full Code Here

TOP

Related Classes of com.tinkerpop.blueprints.Graph

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.