Search in sources :

Example 66 with TinkerGraph

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

the class MetaverseUtilTest method testEnhanceEdge.

@Test
public void testEnhanceEdge() {
    Graph graph = new TinkerGraph();
    Vertex v1 = graph.addVertex(1);
    Vertex v2 = graph.addVertex(2);
    Edge edge = graph.addEdge(3, v1, v2, "testLabel");
    MetaverseUtil.enhanceEdge(edge);
}
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) Edge(com.tinkerpop.blueprints.Edge) Test(org.junit.Test)

Example 67 with TinkerGraph

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

the class MetaverseUtilTest method testEnhanceVertex.

@Test
public void testEnhanceVertex() {
    Graph graph = new TinkerGraph();
    Vertex v1 = graph.addVertex(1);
    MetaverseUtil.enhanceVertex(v1);
}
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 68 with TinkerGraph

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

the class TypedGraphModuleTest method testSerializeVertexType.

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);
    assertEquals("A", ((VertexFrame) a).asVertex().getProperty("type"));
    assertEquals("C", ((VertexFrame) c).asVertex().getProperty("type"));
}
Also used : TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) TypedGraphModuleBuilder(com.tinkerpop.frames.modules.typedgraph.TypedGraphModuleBuilder)

Example 69 with TinkerGraph

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

the class JavaHandlerTest method setup.

@Before
public void setup() {
    TinkerGraph base = TinkerGraphFactory.createTinkerGraph();
    g = new FramedGraphFactory(new JavaHandlerModule()).create(base);
}
Also used : TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) FramedGraphFactory(com.tinkerpop.frames.FramedGraphFactory) Before(org.junit.Before)

Example 70 with TinkerGraph

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

the class GremlinGroovyScriptEngineTest method testBindings.

public void testBindings() throws Exception {
    final TinkerGraph g = TinkerGraphFactory.createTinkerGraph();
    final ScriptEngine engine = new GremlinGroovyScriptEngine();
    assertTrue(engine.eval("g = TinkerGraphFactory.createTinkerGraph()") instanceof TinkerGraph);
    assertTrue(engine.get("g") instanceof TinkerGraph);
    assertEquals(engine.eval("g.v(1)"), g.getVertex(1));
    final Bindings bindings = engine.createBindings();
    bindings.put("g", g);
    bindings.put("s", "marko");
    bindings.put("f", 0.5f);
    bindings.put("i", 1);
    bindings.put("b", true);
    bindings.put("l", 100l);
    bindings.put("d", 1.55555d);
    assertEquals(g.getEdge(7), engine.eval("g.E.has('weight',f).next()", bindings));
    assertEquals(g.getVertex(1), engine.eval("g.V.has('name',s).next()", bindings));
    assertEquals(g.getVertex(1), engine.eval("g.V.sideEffect{it.bbb=it.name=='marko'}.iterate();g.V.has('bbb',b).next()", bindings));
    assertEquals(g.getVertex(1), engine.eval("g.V.sideEffect{it.iii=it.name=='marko'?1:0}.iterate();g.V.has('iii',i).next()", bindings));
    assertEquals(g.getVertex(1), engine.eval("g.V.sideEffect{it.lll=it.name=='marko'?100l:0l}.iterate();g.V.has('lll',l).next()", bindings));
    assertEquals(g.getVertex(1), engine.eval("g.V.sideEffect{it.ddd=it.name=='marko'?1.55555d:0}.iterate();g.V.has('ddd',d).next()", bindings));
}
Also used : TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Bindings(javax.script.Bindings) ScriptEngine(javax.script.ScriptEngine)

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