Package com.tinkerpop.blueprints

Examples of com.tinkerpop.blueprints.Graph


        }

    }

  public void testAreEqualNullFirstArg() {
    Graph graph = new TinkerGraph();
    Vertex vertex = graph.addVertex(null);

    ElementHelper.areEqual(null, vertex);
  }
View Full Code Here


    ElementHelper.areEqual(null, vertex);
  }

  public void testAreEqualNullSecondArg() {
    Graph graph = new TinkerGraph();
    Vertex vertex = graph.addVertex(null);

    ElementHelper.areEqual(vertex, null);
  }
View Full Code Here

    ElementHelper.areEqual(vertex, null);
  }

  public void testAreEqualValid() {
    Graph graph = new TinkerGraph();
    Vertex vertex = graph.addVertex(null);

    ElementHelper.areEqual(vertex, vertex);
  }
View Full Code Here

    ElementHelper.areEqual(vertex, vertex);
  }

  public void testAreEqualInvalid() {
    Graph graph = new TinkerGraph();
    Vertex vertex1 = graph.addVertex(null);
    Vertex vertex2 = graph.addVertex(null);

    ElementHelper.areEqual(vertex2, vertex1);
  }
View Full Code Here

* @author Joshua Shinavier (http://fortytwo.net)
*/
public class IdGraphTest extends GraphTest {

    public void testElementClasses() throws Exception {
        Graph graph = this.generateGraph();
        Vertex v1 = graph.addVertex(null);
        Vertex v2 = graph.addVertex(null);
        Edge e = graph.addEdge(null, v1, v2, "knows");

        assertTrue(v1 instanceof IdVertex);
        assertTrue(e instanceof IdEdge);

        Iterator<Edge> outE = v1.getEdges(Direction.OUT).iterator();
        assertTrue(outE.hasNext());
        e = outE.next();
        assertTrue(e instanceof IdEdge);
        assertTrue(e.getVertex(Direction.IN) instanceof IdVertex);
        assertTrue(e.getVertex(Direction.OUT) instanceof IdVertex);

        Iterator<Vertex> vertices = graph.getVertices().iterator();
        assertTrue(vertices.hasNext());
        while (vertices.hasNext()) {
            assertTrue(vertices.next() instanceof IdVertex);
        }

        Iterator<Edge> edges = graph.getEdges().iterator();
        assertTrue(edges.hasNext());
        while (edges.hasNext()) {
            assertTrue(edges.next() instanceof IdEdge);
        }
        graph.shutdown();
    }
View Full Code Here

* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public class ReadOnlyGraphTest extends BaseTest {

    public void testWrappedElementUniqueness() {
        Graph graph = new ReadOnlyGraph<TinkerGraph>(TinkerGraphFactory.createTinkerGraph());
        assertEquals(graph.getVertex(1), graph.getVertex(1));
        Set<Vertex> set = new HashSet<Vertex>();
        set.add(graph.getVertex(2));
        set.add(graph.getVertex(2));
        assertEquals(set.size(), 1);
        assertEquals(graph.getEdge(7).hashCode(), graph.getEdge(7).hashCode());
        assertEquals(graph.getEdge(8), graph.getEdge(8));
    }
View Full Code Here

        assertTrue(graph.getIndexedKeys(Edge.class).contains(IdGraph.ID));
        graph.shutdown();
    }

    public void testDefaultIdFactory() throws Exception {
        Graph graph = this.generateGraph();
        Vertex v = graph.addVertex(null);
        String id = (String) v.getId();

        assertEquals(36, id.length());
        assertEquals(5, id.split("-").length);

        Vertex v2 = graph.addVertex(null);
        Edge e = graph.addEdge(null, v, v2, "knows");

        id = (String) e.getId();
        assertEquals(36, id.length());
        assertEquals(5, id.split("-").length);
        graph.shutdown();
    }
View Full Code Here

        assertEquals(graph.getEdge(7).hashCode(), graph.getEdge(7).hashCode());
        assertEquals(graph.getEdge(8), graph.getEdge(8));
    }

    public void testReadOnlyGraph() {
        Graph graph = new ReadOnlyGraph<TinkerGraph>(TinkerGraphFactory.createTinkerGraph());
        assertTrue(graph.getVertices() instanceof ReadOnlyVertexIterable);
        assertTrue(graph.getEdges() instanceof ReadOnlyEdgeIterable);
        assertEquals(count(graph.getVertices()), 6);
        assertEquals(count(graph.getEdges()), 6);
        try {
            graph.addVertex(null);
            assertTrue(false);
        } catch (UnsupportedOperationException e) {
            assertTrue(true);
        }
        try {
            graph.addEdge(null, null, null, "knows");
            assertTrue(false);
        } catch (UnsupportedOperationException e) {
            assertTrue(true);
        }
        try {
            graph.removeVertex(graph.getVertex(1));
            assertTrue(false);
        } catch (UnsupportedOperationException e) {
            assertTrue(true);
        }
        try {
            graph.removeEdge(graph.getEdge(10));
            assertTrue(false);
        } catch (UnsupportedOperationException e) {
            assertTrue(true);
        }
        try {
            graph.shutdown();
            assertTrue(false);
        } catch (UnsupportedOperationException e) {
            assertTrue(true);
        }
    }
View Full Code Here

        graph.shutdown();
    }


    public void testAddVertexWithSpecifiedId() throws Exception {
        Graph graph = this.generateGraph();
        Vertex v = graph.addVertex("forty-two");
        assertEquals("forty-two", v.getId());
        graph.shutdown();
    }
View Full Code Here

        assertEquals("forty-two", v.getId());
        graph.shutdown();
    }

    public void testProperties() throws Exception {
        Graph graph = this.generateGraph();
        Vertex v = graph.addVertex(null);
        v.setProperty("name", "Zaphod");
        v.setProperty("profession", "ex-president of the Galaxy");

        Set<String> keys = v.getPropertyKeys();
        assertEquals(2, keys.size());
        assertTrue(keys.contains("name"));
        assertTrue(keys.contains("profession"));
        assertEquals("Zaphod", v.getProperty("name"));
        graph.shutdown();
    }
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.