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"));
}
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());
}
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);
}
}
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);
}
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);
}
}
Aggregations