Search in sources :

Example 96 with TinkerGraph

use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project blueprints by tinkerpop.

the class GraphSONUtilityTest method vertexFromJsonStringValid.

@Test
public void vertexFromJsonStringValid() throws IOException, JSONException {
    Graph g = new TinkerGraph();
    ElementFactory factory = new GraphElementFactory(g);
    Vertex v = GraphSONUtility.vertexFromJson(vertexJson1, factory, GraphSONMode.NORMAL, null);
    Assert.assertSame(v, g.getVertex(1));
    // tinkergraph converts id to string
    Assert.assertEquals("1", v.getId());
    Assert.assertEquals("marko", v.getProperty("name"));
    Assert.assertEquals(29, v.getProperty("age"));
}
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) Test(org.junit.Test)

Example 97 with TinkerGraph

use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project blueprints by tinkerpop.

the class EventGraphTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    graphChangedListener = new StubGraphChangedListener();
    graph = new EventGraph<TinkerGraph>(TinkerGraphFactory.createTinkerGraph());
}
Also used : TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) StubGraphChangedListener(com.tinkerpop.blueprints.util.wrappers.event.listener.StubGraphChangedListener)

Example 98 with TinkerGraph

use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project blueprints by tinkerpop.

the class GraphHelperTest method testAddEdge.

public void testAddEdge() {
    Graph graph = new TinkerGraph();
    Edge edge = GraphHelper.addEdge(graph, null, graph.addVertex(null), graph.addVertex(null), "knows", "weight", 10.0f);
    assertEquals(edge.getProperty("weight"), 10.0f);
    assertEquals(edge.getLabel(), "knows");
    assertEquals(edge.getPropertyKeys().size(), 1);
    assertEquals(count(graph.getVertices()), 2);
    assertEquals(count(graph.getEdges()), 1);
    try {
        edge = GraphHelper.addEdge(graph, null, graph.addVertex(null), graph.addVertex(null), "knows", "weight");
        assertTrue(false);
    } catch (Exception e) {
        assertFalse(false);
        assertEquals(count(graph.getVertices()), 4);
        assertEquals(count(graph.getEdges()), 1);
    }
}
Also used : TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Edge(com.tinkerpop.blueprints.Edge)

Example 99 with TinkerGraph

use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project blueprints by tinkerpop.

the class ElementHelperTest method testAreEqualNullFirstArg.

public void testAreEqualNullFirstArg() {
    Graph graph = new TinkerGraph();
    Vertex vertex = graph.addVertex(null);
    ElementHelper.areEqual(null, vertex);
}
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)

Example 100 with TinkerGraph

use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project blueprints by tinkerpop.

the class ElementHelperTest method testSetPropertiesVarArgs.

public void testSetPropertiesVarArgs() {
    Graph graph = new TinkerGraph();
    Vertex vertex = graph.addVertex(null);
    ElementHelper.setProperties(vertex, "name", "pierre");
    assertEquals(vertex.getPropertyKeys().size(), 1);
    assertEquals(vertex.getProperty("name"), "pierre");
    ElementHelper.setProperties(vertex, "name", "dewilde", "country", "belgium", "age", 50);
    assertEquals(vertex.getPropertyKeys().size(), 3);
    assertEquals(vertex.getProperty("name"), "dewilde");
    assertEquals(vertex.getProperty("country"), "belgium");
    assertEquals(vertex.getProperty("age"), 50);
    try {
        ElementHelper.setProperties(vertex, "a", 12, "b");
        assertTrue(false);
    } catch (IllegalArgumentException e) {
        assertFalse(false);
    }
}
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)

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