Package com.tinkerpop.gremlin.structure

Examples of com.tinkerpop.gremlin.structure.Vertex


        @Test
        @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
        @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
        public void shouldHaveGraphWrappedFromEdge() {
            final StrategyWrappedGraph swg = new StrategyWrappedGraph(g);
            final Vertex v = swg.addVertex();
            assertTrue(v.addEdge("self", v).graph() instanceof StrategyWrappedGraph);
        }
View Full Code Here


        @Test
        @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
        public void shouldReturnWrappedVertexToString() {
            final StrategyWrappedGraph swg = new StrategyWrappedGraph(g);
            final Vertex v1 = swg.addVertex(T.label, "Person");
            final Vertex originalVertex = ((StrategyWrappedVertex) v1).getBaseVertex();
            swg.getStrategy().setGraphStrategy(strategy);
            assertEquals(StringFactory.graphStrategyVertexString(strategy, originalVertex), v1.toString());
        }
View Full Code Here

        @Test
        @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
        public void shouldReturnWrappedEdgeToString() {
            final StrategyWrappedGraph swg = new StrategyWrappedGraph(g);
            final Vertex v1 = swg.addVertex(T.label, "Person");
            final Vertex v2 = swg.addVertex(T.label, "Person");
            final Edge e1 = v1.addEdge("friend", v2);
            final Edge originalEdge = ((StrategyWrappedEdge) e1).getBaseEdge();
            swg.getStrategy().setGraphStrategy(strategy);
            assertEquals(StringFactory.graphStrategyEdgeString(strategy, originalEdge), e1.toString());
        }
View Full Code Here

        @Test
        @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
        public void shouldReturnWrappedVertexPropertyToString() {
            final StrategyWrappedGraph swg = new StrategyWrappedGraph(g);
            final Vertex v1 = swg.addVertex(T.label, "Person", "age", "one");
            final VertexProperty age = v1.property("age");
            final Vertex originalVertex = ((StrategyWrappedVertex) v1).getBaseVertex();
            final VertexProperty originalVertexProperty = originalVertex.property("age");
            swg.getStrategy().setGraphStrategy(strategy);
            assertEquals(StringFactory.graphStrategyPropertyString(strategy, originalVertexProperty), age.toString());
        }
View Full Code Here

        @Test
        @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
        public void shouldReturnWrappedPropertyToString() {
            final StrategyWrappedGraph swg = new StrategyWrappedGraph(g);
            final Vertex v1 = swg.addVertex(T.label, "Person");
            final Vertex v2 = swg.addVertex(T.label, "Person");
            final Edge e1 = v1.addEdge("friend", v2, "weight", "fifty");
            final Property weight = e1.property("weight");
            final Edge originalEdge = ((StrategyWrappedEdge) e1).getBaseEdge();
            final Property originalProperty = originalEdge.property("weight");
            swg.getStrategy().setGraphStrategy(strategy);
View Full Code Here

            // but doesn't actually blow it away
            swg.getStrategy().setGraphStrategy(new GraphStrategy() {
                @Override
                public UnaryOperator<Supplier<Void>> getRemoveVertexStrategy(final Strategy.Context<StrategyWrappedVertex> ctx) {
                    return (t) -> () -> {
                        final Vertex v = ctx.getCurrent().getBaseVertex();
                        v.bothE().remove();
                        v.properties().forEachRemaining(Property::remove);
                        v.property("deleted", true);
                        return null;
                    };
                }
            });

            final Vertex toRemove = g.addVertex("name", "pieter");
            toRemove.addEdge("likes", g.addVertex("feature", "Strategy"));

            assertEquals(1, toRemove.properties().count().next().intValue());
            assertEquals(new Long(1), toRemove.bothE().count().next());
            assertFalse(toRemove.property("deleted").isPresent());

            swg.v(toRemove.id()).remove();

            final Vertex removed = g.v(toRemove.id());
            assertNotNull(removed);
            assertEquals(1, removed.properties().count().next().intValue());
            assertEquals(new Long(0), removed.bothE().count().next());
            assertTrue(removed.property("deleted").isPresent());
        }
View Full Code Here

                        return null;
                    };
                }
            });

            final Vertex v = g.addVertex("name", "pieter");
            final Edge e = v.addEdge("likes", g.addVertex("feature", "Strategy"), "this", "something");

            assertEquals(1, e.properties().count().next().intValue());
            assertFalse(e.property("deleted").isPresent());

            swg.e(e.id()).remove();
View Full Code Here

        @Test
        @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
        public void shouldWrap() {
            final StrategyWrappedGraph swg = new StrategyWrappedGraph(g);
            swg.strategy.setGraphStrategy(GraphStrategy.DefaultGraphStrategy.INSTANCE);
            final Vertex v = swg.addVertex();
            final Edge e = v.addEdge("to", v, "all", "a", "any", "something", Graph.Key.hide("hideme"), "hidden");

            final AtomicBoolean atLeastOne = new AtomicBoolean(false);
            assertTrue(streamGetter.apply(swg, e).allMatch(p -> {
                atLeastOne.set(true);
                return p instanceof StrategyWrappedProperty;
View Full Code Here

    @Test
    @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = FEATURE_ADD_VERTICES)
    @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = FEATURE_ADD_EDGES)
    public void shouldNotAllowRemoveEdge() {
        final Vertex v = g.addVertex();
        v.addEdge("friend", v);
        assertException(g -> {
            final Edge e = g.E().next();
            e.remove();
        });
    }
View Full Code Here

    @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = FEATURE_ADD_VERTICES)
    @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = FEATURE_ADD_EDGES)
    public void shouldNotAllowAddEdge() {
        g.addVertex();
        assertException(g -> {
            final Vertex v = g.V().next();
            v.addEdge("friend", v);
        });
    }
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.