Package com.tinkerpop.gremlin.structure

Examples of com.tinkerpop.gremlin.structure.Vertex


        swg.getStrategy().setGraphStrategy(new SequenceGraphStrategy(
                new GraphStrategy() {
                    @Override
                    public UnaryOperator<Function<Object[], Vertex>> getAddVertexStrategy(final Strategy.Context ctx) {
                        return (f) -> (args) -> {
                            final Vertex v = f.apply(args);
                            // this  means that the next strategy and those below it executed including
                            // the implementation
                            assertEquals("working2", v.property("anonymous").value());
                            // now do something with that vertex after the fact
                            v.properties("anonymous").remove();
                            v.property("anonymous", "working1");
                            return v;
                        };

                    }
                },
                new GraphStrategy() {
                    @Override
                    public UnaryOperator<Function<Object[], Vertex>> getAddVertexStrategy(final Strategy.Context ctx) {
                        return (f) -> (args) -> {
                            final Vertex v = f.apply(args);
                            // this  means that the next strategy and those below it executed including
                            // the implementation
                            assertEquals("working3", v.property("anonymous").value());
                            // now do something with that vertex after the fact
                            v.properties("anonymous").remove();
                            v.property("anonymous", "working2");
                            return v;
                        };
                    }
                },
                new GraphStrategy() {
                    @Override
                    public UnaryOperator<Function<Object[], Vertex>> getAddVertexStrategy(final Strategy.Context ctx) {
                        return (f) -> (args) -> {
                            final List<Object> o = new ArrayList<>(Arrays.asList(args));
                            o.addAll(Arrays.asList("anonymous", "working3"));
                            return f.apply(o.toArray());
                        };
                    }
                }
        ));

        final Vertex v = swg.addVertex("any", "thing");

        assertNotNull(v);
        assertEquals("thing", v.property("any").value());
        assertEquals("working1", v.property("anonymous").value());
    }
View Full Code Here


    }

    @Test
    @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
    public void shouldNotConstructNewWithSomethingAlreadyDetached() {
        final Vertex v = g.addVertex();
        final DetachedVertex dv = DetachedVertex.detach(v);
        assertSame(dv, DetachedVertex.detach(dv));
    }
View Full Code Here

    }

    @Test
    @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
    public void shouldConstructDetachedVertex() {
        final Vertex v = g.addVertex("test", "123", Graph.Key.hide("test"), "321");
        final DetachedVertex detachedVertex = DetachedVertex.detach(v);

        assertEquals(v.id(), detachedVertex.id());
        assertEquals(v.label(), detachedVertex.label());
        assertEquals("123", detachedVertex.value("test"));
        assertEquals("321", detachedVertex.iterators().hiddenPropertyIterator("test").next().value().toString());
        assertEquals(1, StreamFactory.stream(detachedVertex.iterators().propertyIterator()).count());
        assertEquals(1, StreamFactory.stream(detachedVertex.iterators().hiddenPropertyIterator()).count());
    }
View Full Code Here

    }

    @Test
    @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
    public void shouldConstructDetachedVertexAsReference() {
        final Vertex v = g.addVertex("test", "123", Graph.Key.hide("test"), "321");
        final DetachedVertex detachedVertex = DetachedVertex.detach(v, true);

        assertEquals(v.id(), detachedVertex.id());
        assertEquals(v.label(), detachedVertex.label());
        assertEquals(0, StreamFactory.stream(detachedVertex.iterators().propertyIterator()).count());
        assertEquals(0, StreamFactory.stream(detachedVertex.iterators().hiddenPropertyIterator()).count());
    }
View Full Code Here

    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
    @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
    @FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_INTEGER_VALUES)
    public void shouldNotEvaluateToEqualDifferentId() {
        final DetachedVertex originalMarko = DetachedVertex.detach(g.v(convertToVertexId("marko")));
        final Vertex secondMarko = g.addVertex("name", "marko", "age", 29);
        assertFalse(DetachedVertex.detach(secondMarko).equals(originalMarko));
    }
View Full Code Here


    @Test(expected = UnsupportedOperationException.class)
    @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
    public void shouldNotAllowAddEdge() {
        final Vertex v = g.addVertex();
        final DetachedVertex detachedVertex = DetachedVertex.detach(v);
        detachedVertex.addEdge("test", null);
    }
View Full Code Here

    }

    @Test(expected = UnsupportedOperationException.class)
    @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
    public void shouldNotAllowSetProperty() {
        final Vertex v = g.addVertex();
        final DetachedVertex detachedVertex = DetachedVertex.detach(v);
        detachedVertex.property("test", "test");
    }
View Full Code Here

    }

    @Test(expected = UnsupportedOperationException.class)
    @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
    public void shouldNotAllowRemove() {
        final Vertex v = g.addVertex();
        final DetachedVertex detachedVertex = DetachedVertex.detach(v);
        detachedVertex.remove();
    }
View Full Code Here

    }

    @Test(expected = UnsupportedOperationException.class)
    @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
    public void shouldNotTraverse() {
        final Vertex v = g.addVertex();
        final DetachedVertex detachedVertex = DetachedVertex.detach(v);
        detachedVertex.start();
    }
View Full Code Here

    }

    @Test
    @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
    public void shouldNotConstructNewWithSomethingAlreadyDetached() {
        final Vertex v = g.addVertex();
        final Edge e = v.addEdge("test", v, "xxx", "yyy");
        final DetachedProperty dp = DetachedProperty.detach(e.property("xxx"));
        assertSame(dp, DetachedProperty.detach(dp));
    }
View Full Code Here

TOP

Related Classes of com.tinkerpop.gremlin.structure.Vertex

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.