org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex Java Examples

The following examples show how to use org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EdgeSerializer.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
protected Edge readValue(final Buffer buffer, final GraphBinaryReader context) throws IOException {
    final Object id = context.read(buffer);
    final String label = context.readValue(buffer, String.class, false);

    final ReferenceVertex inV = new ReferenceVertex(context.read(buffer),
                                                    context.readValue(buffer, String.class, false));
    final ReferenceVertex outV = new ReferenceVertex(context.read(buffer),
                                                     context.readValue(buffer, String.class, false));

    // discard the parent vertex - we only send "references so this should always be null, but will we change our
    // minds someday????
    context.read(buffer);

    // discard the properties - as we only send "references" this should always be null, but will we change our
    // minds some day????
    context.read(buffer);

    return new ReferenceEdge(id, label, inV, outV);
}
 
Example #2
Source File: ActGraphTest.java    From act-platform with ISC License 5 votes vote down vote up
@Test
public void testIterateVerticesWithUuidIdSupportUsingReferenceVertex() {
  Vertex vertex1 = createVertex();
  Vertex vertex2 = getActGraph().vertices(ReferenceFactory.detach(vertex1)).next();
  assertEquals(vertex1.id(), vertex2.id());
  assertFalse(vertex2 instanceof ReferenceVertex);
}
 
Example #3
Source File: TestDropStep.java    From sqlg with MIT License 5 votes vote down vote up
@Test
public void shouldReferenceVertexWhenRemoved() {
    final AtomicBoolean triggered = new AtomicBoolean(false);
    final Vertex v = this.sqlgGraph.addVertex();
    final String label = v.label();
    final Object id = v.id();

    final MutationListener listener = new AbstractMutationListener() {
        @Override
        public void vertexRemoved(final Vertex element) {
            Assert.assertThat(element, IsInstanceOf.instanceOf(ReferenceVertex.class));
            Assert.assertEquals(id, element.id());
            Assert.assertEquals(label, element.label());
            triggered.set(true);
        }
    };
    final EventStrategy.Builder builder = EventStrategy.build().addListener(listener)
        .detach(EventStrategy.Detachment.REFERENCE);

    if (this.sqlgGraph.features().graph().supportsTransactions())
        builder.eventQueue(new EventStrategy.TransactionalEventQueue(this.sqlgGraph));

    final EventStrategy eventStrategy = builder.create();
    final GraphTraversalSource gts = this.sqlgGraph.traversal().withStrategies(eventStrategy);

    gts.V(v).drop().iterate();
    this.sqlgGraph.tx().commit();

    AbstractGremlinTest.assertVertexEdgeCounts(this.sqlgGraph, 0, 0);
    Assert.assertThat(triggered.get(), CoreMatchers.is(true));
}
 
Example #4
Source File: HaltedTraverserStrategyTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldReturnReferenceElements() {
    final Graph graph = TinkerFactory.createModern();
    GraphTraversalSource g = graph.traversal().withComputer().withStrategies(HaltedTraverserStrategy.reference());
    g.V().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
    g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(ReferenceVertexProperty.class, vertexProperty.getClass()));
    g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
    g.V().out().outE().forEachRemaining(edge -> assertEquals(ReferenceEdge.class, edge.getClass()));
    g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(ReferenceProperty.class, property.getClass()));
    g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
    g.V().out().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
    g.V().out().out().path().forEachRemaining(path -> assertEquals(ReferencePath.class, path.getClass()));
    g.V().out().pageRank().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
    g.V().out().pageRank().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
    // the default should be reference elements
    g = graph.traversal().withComputer();
    g.V().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
    g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(ReferenceVertexProperty.class, vertexProperty.getClass()));
    g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
    g.V().out().outE().forEachRemaining(edge -> assertEquals(ReferenceEdge.class, edge.getClass()));
    g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(ReferenceProperty.class, property.getClass()));
    g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
    g.V().out().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
    g.V().out().out().path().forEachRemaining(path -> assertEquals(ReferencePath.class, path.getClass()));
    g.V().out().pageRank().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
    g.V().out().pageRank().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
    // should handle nested collections
    g.V().out().fold().next().forEach(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
}
 
Example #5
Source File: EventStrategyProcessTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
public void shouldReferenceVertexWhenAdded() {
    final AtomicBoolean triggered = new AtomicBoolean(false);

    final MutationListener listener = new AbstractMutationListener() {
        @Override
        public void vertexAdded(final Vertex element) {
            assertThat(element, instanceOf(ReferenceVertex.class));
            assertEquals("thing", element.label());
            assertThat(element.properties("here").hasNext(), is(false));
            triggered.set(true);
        }
    };
    final EventStrategy.Builder builder = EventStrategy.build().addListener(listener).detach(EventStrategy.Detachment.REFERENCE);

    if (graph.features().graph().supportsTransactions())
        builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph));

    final EventStrategy eventStrategy = builder.create();
    final GraphTraversalSource gts = create(eventStrategy);

    gts.addV("thing").property("here", "there").iterate();
    tryCommit(graph);

    assertVertexEdgeCounts(graph, 1, 0);
    assertThat(triggered.get(), is(true));
}
 
Example #6
Source File: EventStrategyProcessTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
public void shouldReferenceVertexWhenRemoved() {
    final AtomicBoolean triggered = new AtomicBoolean(false);
    final Vertex v = graph.addVertex();
    final String label = v.label();
    final Object id = v.id();

    final MutationListener listener = new AbstractMutationListener() {
        @Override
        public void vertexRemoved(final Vertex element) {
            assertThat(element, instanceOf(ReferenceVertex.class));
            assertEquals(id, element.id());
            assertEquals(label, element.label());
            triggered.set(true);
        }
    };
    final EventStrategy.Builder builder = EventStrategy.build().addListener(listener).detach(EventStrategy.Detachment.REFERENCE);

    if (graph.features().graph().supportsTransactions())
        builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph));

    final EventStrategy eventStrategy = builder.create();
    final GraphTraversalSource gts = create(eventStrategy);

    gts.V(v).drop().iterate();
    tryCommit(graph);

    assertVertexEdgeCounts(graph, 0, 0);
    assertThat(triggered.get(), is(true));
}
 
Example #7
Source File: EventStrategyProcessTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
public void shouldReferenceVertexPropertyWhenNew() {
    final AtomicBoolean triggered = new AtomicBoolean(false);
    final Vertex v = graph.addVertex();
    final String label = v.label();
    final Object id = v.id();
    v.property("old","blah");

    final MutationListener listener = new AbstractMutationListener() {
        @Override
        public void vertexPropertyChanged(final Vertex element, final VertexProperty oldValue, final Object setValue, final Object... vertexPropertyKeyValues) {
            assertThat(element, instanceOf(ReferenceVertex.class));
            assertEquals(label, element.label());
            assertEquals(id, element.id());
            assertThat(oldValue, instanceOf(KeyedVertexProperty.class));
            assertEquals("new", oldValue.key());
            assertEquals("dah", setValue);
            triggered.set(true);
        }
    };
    final EventStrategy.Builder builder = EventStrategy.build().addListener(listener).detach(EventStrategy.Detachment.REFERENCE);

    if (graph.features().graph().supportsTransactions())
        builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph));

    final EventStrategy eventStrategy = builder.create();
    final GraphTraversalSource gts = create(eventStrategy);

    gts.V(v).property(VertexProperty.Cardinality.single, "new", "dah").iterate();
    tryCommit(graph);

    assertEquals(2, IteratorUtils.count(g.V(v).properties()));
    assertThat(triggered.get(), is(true));
}
 
Example #8
Source File: EventStrategyProcessTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
public void shouldReferenceVertexPropertyWhenChanged() {
    final AtomicBoolean triggered = new AtomicBoolean(false);
    final Vertex v = graph.addVertex();
    final String label = v.label();
    final Object id = v.id();
    v.property("to-change", "blah");

    final MutationListener listener = new AbstractMutationListener() {


        @Override
        public void vertexPropertyChanged(final Vertex element, final VertexProperty oldValue, final Object setValue, final Object... vertexPropertyKeyValues) {
            assertThat(element, instanceOf(ReferenceVertex.class));
            assertEquals(label, element.label());
            assertEquals(id, element.id());
            assertEquals("to-change", oldValue.key());
            assertEquals("blah", oldValue.value());
            assertEquals("dah", setValue);
            triggered.set(true);
        }
    };
    final EventStrategy.Builder builder = EventStrategy.build().addListener(listener).detach(EventStrategy.Detachment.REFERENCE);

    if (graph.features().graph().supportsTransactions())
        builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph));

    final EventStrategy eventStrategy = builder.create();
    final GraphTraversalSource gts = create(eventStrategy);

    gts.V(v).property(VertexProperty.Cardinality.single, "to-change", "dah").iterate();
    tryCommit(graph);

    assertEquals(1, IteratorUtils.count(g.V(v).properties()));
    assertThat(triggered.get(), is(true));
}
 
Example #9
Source File: GraphTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_STRING_IDS)
public void shouldIterateVerticesWithStringSupportUsingReferenceVertex() {
    // if the graph supports id assigned, it should allow it.  if the graph does not, it will generate one
    final Vertex v1 = graph.features().vertex().supportsUserSuppliedIds() ? graph.addVertex(T.id, "1") : graph.addVertex();
    graph.addVertex();
    tryCommit(graph, graph -> {
        final Vertex v = graph.vertices(ReferenceFactory.detach(v1)).next();
        assertEquals(v1.id(), v.id());
        assertThat(v, is(not(instanceOf(ReferenceVertex.class))));
    });
}
 
Example #10
Source File: GraphTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_NUMERIC_IDS)
public void shouldIterateVerticesWithNumericSupportUsingReferenceVertex() {
    // if the graph supports id assigned, it should allow it.  if the graph does not, it will generate one
    final Vertex v1 = graph.features().vertex().supportsUserSuppliedIds() ? graph.addVertex(T.id, 1l) : graph.addVertex();
    graph.addVertex();
    tryCommit(graph, graph -> {
        final Vertex v = graph.vertices(ReferenceFactory.detach(v1)).next();
        assertEquals(v1.id(), v.id());
        assertThat(v, is(not(instanceOf(ReferenceVertex.class))));
    });
}
 
Example #11
Source File: GraphTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_CUSTOM_IDS)
public void shouldIterateVerticesWithCustomIdSupportUsingReferenceVertex() {
    final Vertex v1 = graph.addVertex();
    graph.addVertex();
    tryCommit(graph, graph -> {
        final Vertex v = graph.vertices(ReferenceFactory.detach(v1)).next();
        assertEquals(v1.id(), v.id());
        assertThat(v, is(not(instanceOf(ReferenceVertex.class))));
    });
}
 
Example #12
Source File: GraphTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_UUID_IDS)
public void shouldIterateVerticesWithUuidIdSupportUsingReferenceVertex() {
    // if the graph supports id assigned, it should allow it.  if the graph does not, it will generate one
    final Vertex v1 = graph.features().vertex().supportsUserSuppliedIds() ? graph.addVertex(T.id, UUID.randomUUID()) : graph.addVertex();
    graph.addVertex();
    tryCommit(graph, graph -> {
        final Vertex v = graph.vertices(ReferenceFactory.detach(v1)).next();
        assertEquals(v1.id(), v.id());
        assertThat(v, is(not(instanceOf(ReferenceVertex.class))));
    });
}
 
Example #13
Source File: GremlinDriverIntegrateTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldWorkWithGraphBinaryV1Serialization() throws Exception {
    final Cluster cluster = TestClientFactory.build().serializer(Serializers.GRAPHBINARY_V1D0).create();
    final Client client = cluster.connect();

    final List<Result> r = client.submit("TinkerFactory.createModern().traversal().V(1)").all().join();
    assertEquals(1, r.size());

    final Vertex v = r.get(0).get(ReferenceVertex.class);
    assertEquals(1, v.id());
    assertEquals("person", v.label());

    cluster.close();
}
 
Example #14
Source File: VertexSerializer.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
protected Vertex readValue(final Buffer buffer, final GraphBinaryReader context) throws IOException {
    final Vertex v = new ReferenceVertex(context.read(buffer), 
                                         context.readValue(buffer, String.class, false));
    
    // discard the properties - as we only send "references" this should always be null, but will we change our
    // minds some day????
    context.read(buffer);
    return v;
}
 
Example #15
Source File: GryoClassResolverV3d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public Class coerceType(final Class clazz) {
    // force all instances of Vertex, Edge, VertexProperty, etc. to their respective interface
    final Class type;
    if (!ReferenceVertex.class.isAssignableFrom(clazz) && !DetachedVertex.class.isAssignableFrom(clazz) && Vertex.class.isAssignableFrom(clazz))
        type = Vertex.class;
    else if (!ReferenceEdge.class.isAssignableFrom(clazz) && !DetachedEdge.class.isAssignableFrom(clazz) && Edge.class.isAssignableFrom(clazz))
        type = Edge.class;
    else if (!ReferenceVertexProperty.class.isAssignableFrom(clazz) && !DetachedVertexProperty.class.isAssignableFrom(clazz) && VertexProperty.class.isAssignableFrom(clazz))
        type = VertexProperty.class;
    else if (!ReferenceProperty.class.isAssignableFrom(clazz) && !DetachedProperty.class.isAssignableFrom(clazz) && !DetachedVertexProperty.class.isAssignableFrom(clazz) && !ReferenceVertexProperty.class.isAssignableFrom(clazz) && Property.class.isAssignableFrom(clazz))
        type = Property.class;
    else if (!ReferencePath.class.isAssignableFrom(clazz) && !DetachedPath.class.isAssignableFrom(clazz) && Path.class.isAssignableFrom(clazz))
        type = Path.class;
    else if (Lambda.class.isAssignableFrom(clazz))
        type = Lambda.class;
    else if (ByteBuffer.class.isAssignableFrom(clazz))
        type = ByteBuffer.class;
    else if (Class.class.isAssignableFrom(clazz))
        type = Class.class;
    else if (InetAddress.class.isAssignableFrom(clazz))
        type = InetAddress.class;
    else if (ConnectiveP.class.isAssignableFrom(clazz))
        type = P.class;
    else if (Metrics.class.isAssignableFrom(clazz))
        type = Metrics.class;
    else if (TraversalMetrics.class.isAssignableFrom(clazz))
        type = TraversalMetrics.class;
    else
        type = clazz;

    return type;
}
 
Example #16
Source File: GryoClassResolverV1d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public Class coerceType(final Class clazz) {
    // force all instances of Vertex, Edge, VertexProperty, etc. to their respective interface
    final Class type;
    if (!ReferenceVertex.class.isAssignableFrom(clazz) && !DetachedVertex.class.isAssignableFrom(clazz) && Vertex.class.isAssignableFrom(clazz))
        type = Vertex.class;
    else if (!ReferenceEdge.class.isAssignableFrom(clazz) && !DetachedEdge.class.isAssignableFrom(clazz) && Edge.class.isAssignableFrom(clazz))
        type = Edge.class;
    else if (!ReferenceVertexProperty.class.isAssignableFrom(clazz) && !DetachedVertexProperty.class.isAssignableFrom(clazz) && VertexProperty.class.isAssignableFrom(clazz))
        type = VertexProperty.class;
    else if (!ReferenceProperty.class.isAssignableFrom(clazz) && !DetachedProperty.class.isAssignableFrom(clazz) && !DetachedVertexProperty.class.isAssignableFrom(clazz) && !ReferenceVertexProperty.class.isAssignableFrom(clazz) && Property.class.isAssignableFrom(clazz))
        type = Property.class;
    else if (!ReferencePath.class.isAssignableFrom(clazz) && !DetachedPath.class.isAssignableFrom(clazz) && Path.class.isAssignableFrom(clazz))
        type = Path.class;
    else if (Lambda.class.isAssignableFrom(clazz))
        type = Lambda.class;
    else if (ByteBuffer.class.isAssignableFrom(clazz))
        type = ByteBuffer.class;
    else if (Class.class.isAssignableFrom(clazz))
        type = Class.class;
    else if (InetAddress.class.isAssignableFrom(clazz))
        type = InetAddress.class;
    else if (ConnectiveP.class.isAssignableFrom(clazz))
        type = P.class;
    else
        type = clazz;

    return type;
}
 
Example #17
Source File: GryoLiteMessageSerializerV1d0Test.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSerializeVertexWithEmbeddedMap() throws Exception {
    final Graph g = TinkerGraph.open();
    final Vertex v = g.addVertex();
    final Map<String, Object> map = new HashMap<>();
    map.put("x", 500);
    map.put("y", "some");

    final ArrayList<Object> friends = new ArrayList<>();
    friends.add("x");
    friends.add(5);
    friends.add(map);

    v.property(VertexProperty.Cardinality.single, "friends", friends);

    final List list = IteratorUtils.list(g.vertices());

    final ResponseMessage response = convertBinary(list);
    assertCommon(response);

    final List<ReferenceVertex> vertexList = (List<ReferenceVertex>) response.getResult().getData();
    assertEquals(1, vertexList.size());

    final ReferenceVertex deserializedVertex = vertexList.get(0);
    assertEquals(0L, deserializedVertex.id());
    assertEquals(Vertex.DEFAULT_LABEL, deserializedVertex.label());

    assertEquals(0, IteratorUtils.count(deserializedVertex.properties()));
}
 
Example #18
Source File: TypeSerializerFailureTests.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Parameterized.Parameters(name = "Value={0}")
public static Collection input() {
    final Bytecode.Binding b = new Bytecode.Binding(null, "b");

    final ReferenceVertex vertex = new ReferenceVertex("a vertex", null);

    final Bytecode bytecode = new Bytecode();
    bytecode.addStep(null);

    final BulkSet<Object> bulkSet = new BulkSet<>();
    bulkSet.add(vertex, 1L);

    final MutableMetrics metrics = new MutableMetrics("a metric", null);

    final Tree<Vertex> tree = new Tree<>();
    tree.put(vertex, null);

    // Provide instances that are malformed for serialization to fail
    return Arrays.asList(
            b,
            vertex,
            Collections.singletonMap("one", b),
            bulkSet,
            bytecode,
            Collections.singletonList(vertex),
            new ReferenceEdge("an edge", null, vertex, vertex),
            Lambda.supplier(null),
            metrics,
            new DefaultTraversalMetrics(1L, Collections.singletonList(metrics)),
            new DefaultRemoteTraverser<>(new Object(), 1L),
            tree,
            new ReferenceVertexProperty<>("a prop", null, "value"),
            new InvalidPath()
    );
}
 
Example #19
Source File: HaltedTraverserStrategyTest.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldReturnReferenceElements() {
    final Graph graph = TinkerFactory.createModern();
    GraphTraversalSource g = graph.traversal().withComputer().withStrategies(HaltedTraverserStrategy.reference());
    g.V().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
    g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(ReferenceVertexProperty.class, vertexProperty.getClass()));
    g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
    g.V().out().outE().forEachRemaining(edge -> assertEquals(ReferenceEdge.class, edge.getClass()));
    g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(ReferenceProperty.class, property.getClass()));
    g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
    g.V().out().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
    g.V().out().out().path().forEachRemaining(path -> assertEquals(ReferencePath.class, path.getClass()));
    g.V().out().pageRank().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
    g.V().out().pageRank().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
    // the default should be reference elements
    g = graph.traversal().withComputer();
    g.V().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
    g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(ReferenceVertexProperty.class, vertexProperty.getClass()));
    g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
    g.V().out().outE().forEachRemaining(edge -> assertEquals(ReferenceEdge.class, edge.getClass()));
    g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(ReferenceProperty.class, property.getClass()));
    g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
    g.V().out().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
    g.V().out().out().path().forEachRemaining(path -> assertEquals(ReferencePath.class, path.getClass()));
    g.V().out().pageRank().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
    g.V().out().pageRank().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
    // should handle nested collections
    g.V().out().fold().next().forEach(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
}
 
Example #20
Source File: ActGraphTest.java    From act-platform with ISC License 5 votes vote down vote up
@Test
public void testIterateVerticesWithUuidIdSupportUsingReferenceVertex() {
  Vertex vertex1 = createVertex();
  Vertex vertex2 = getActGraph().vertices(ReferenceFactory.detach(vertex1)).next();
  assertEquals(vertex1.id(), vertex2.id());
  assertFalse(vertex2 instanceof ReferenceVertex);
}
 
Example #21
Source File: GremlinResultSetIntegrateTest.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldHandleVertexResult() throws Exception {
    final ResultSet results = client.submit("gmodern.V(1).next()");
    final Vertex v = results.all().get().get(0).getVertex();
    assertThat(v, instanceOf(ReferenceVertex.class));
}