Java Code Examples for org.apache.tinkerpop.gremlin.structure.VertexProperty#label()
The following examples show how to use
org.apache.tinkerpop.gremlin.structure.VertexProperty#label() .
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: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES) public void shouldDetachPropertyOfVertexPropertyWhenChanged() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final VertexProperty vp = v.property("xxx","blah"); final String label = vp.label(); final Object value = vp.value(); vp.property("to-change", "dah"); final MutationListener listener = new AbstractMutationListener() { @Override public void vertexPropertyPropertyChanged(final VertexProperty element, final Property oldValue, final Object setValue) { assertThat(element, instanceOf(DetachedVertexProperty.class)); assertEquals(label, element.label()); assertEquals(value, element.value()); assertEquals("dah", oldValue.value()); assertEquals("to-change", oldValue.key()); assertEquals("bah", setValue); triggered.set(true); } }; final EventStrategy.Builder builder = EventStrategy.build().addListener(listener); if (graph.features().graph().supportsTransactions()) builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph)); final EventStrategy eventStrategy = builder.create(); final GraphTraversalSource gts = create(eventStrategy); gts.V(v).properties("xxx").property("to-change","bah").iterate(); tryCommit(graph); assertEquals(1, IteratorUtils.count(g.V(v).properties())); assertEquals(1, IteratorUtils.count(g.V(v).properties().properties())); assertThat(triggered.get(), is(true)); }
Example 2
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES) public void shouldDetachPropertyOfVertexPropertyWhenNew() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final VertexProperty vp = v.property("xxx","blah"); final String label = vp.label(); final Object value = vp.value(); vp.property("to-change", "dah"); final MutationListener listener = new AbstractMutationListener() { @Override public void vertexPropertyPropertyChanged(final VertexProperty element, final Property oldValue, final Object setValue) { assertThat(element, instanceOf(DetachedVertexProperty.class)); assertEquals(label, element.label()); assertEquals(value, element.value()); assertThat(oldValue, instanceOf(KeyedProperty.class)); assertEquals("new", oldValue.key()); assertEquals("yay!", setValue); triggered.set(true); } }; final EventStrategy.Builder builder = EventStrategy.build().addListener(listener); if (graph.features().graph().supportsTransactions()) builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph)); final EventStrategy eventStrategy = builder.create(); final GraphTraversalSource gts = create(eventStrategy); gts.V(v).properties("xxx").property("new","yay!").iterate(); tryCommit(graph); assertEquals(1, IteratorUtils.count(g.V(v).properties())); assertEquals(2, IteratorUtils.count(g.V(v).properties().properties())); assertThat(triggered.get(), is(true)); }
Example 3
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) public void shouldDetachVertexPropertyWhenRemoved() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final VertexProperty vp = v.property("to-remove","blah"); final String label = vp.label(); final Object value = vp.value(); final VertexProperty vpToKeep = v.property("to-keep","dah"); final MutationListener listener = new AbstractMutationListener() { @Override public void vertexPropertyRemoved(final VertexProperty element) { assertThat(element, instanceOf(DetachedVertexProperty.class)); assertEquals(label, element.label()); assertEquals(value, element.value()); triggered.set(true); } }; final EventStrategy.Builder builder = EventStrategy.build().addListener(listener); if (graph.features().graph().supportsTransactions()) builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph)); final EventStrategy eventStrategy = builder.create(); final GraphTraversalSource gts = create(eventStrategy); gts.V(v).properties("to-remove").drop().iterate(); tryCommit(graph); assertEquals(1, IteratorUtils.count(g.V(v).properties())); assertEquals(vpToKeep.value(), g.V(v).values("to-keep").next()); assertThat(triggered.get(), is(true)); }
Example 4
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES) public void shouldReferencePropertyOfVertexPropertyWhenChanged() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final VertexProperty vp = v.property("xxx","blah"); final String label = vp.label(); final Object value = vp.value(); vp.property("to-change", "dah"); final MutationListener listener = new AbstractMutationListener() { @Override public void vertexPropertyPropertyChanged(final VertexProperty element, final Property oldValue, final Object setValue) { assertThat(element, instanceOf(ReferenceVertexProperty.class)); assertEquals(label, element.label()); assertEquals(value, element.value()); assertEquals("dah", oldValue.value()); assertEquals("to-change", oldValue.key()); assertEquals("bah", 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).properties("xxx").property("to-change","bah").iterate(); tryCommit(graph); assertEquals(1, IteratorUtils.count(g.V(v).properties())); assertEquals(1, IteratorUtils.count(g.V(v).properties().properties())); assertThat(triggered.get(), is(true)); }
Example 5
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES) public void shouldReferencePropertyOfVertexPropertyWhenNew() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final VertexProperty vp = v.property("xxx","blah"); final String label = vp.label(); final Object value = vp.value(); vp.property("to-change", "dah"); final MutationListener listener = new AbstractMutationListener() { @Override public void vertexPropertyPropertyChanged(final VertexProperty element, final Property oldValue, final Object setValue) { assertThat(element, instanceOf(ReferenceVertexProperty.class)); assertEquals(label, element.label()); assertEquals(value, element.value()); assertThat(oldValue, instanceOf(KeyedProperty.class)); assertEquals("new", oldValue.key()); assertEquals("yay!", 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).properties("xxx").property("new","yay!").iterate(); tryCommit(graph); assertEquals(1, IteratorUtils.count(g.V(v).properties())); assertEquals(2, IteratorUtils.count(g.V(v).properties().properties())); assertThat(triggered.get(), is(true)); }
Example 6
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) public void shouldReferenceVertexPropertyWhenRemoved() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final VertexProperty vp = v.property("to-remove","blah"); final String label = vp.label(); final Object value = vp.value(); final VertexProperty vpToKeep = v.property("to-keep","dah"); final MutationListener listener = new AbstractMutationListener() { @Override public void vertexPropertyRemoved(final VertexProperty element) { assertThat(element, instanceOf(ReferenceVertexProperty.class)); assertEquals(label, element.label()); assertEquals(value, element.value()); 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).properties("to-remove").drop().iterate(); tryCommit(graph); assertEquals(1, IteratorUtils.count(g.V(v).properties())); assertEquals(vpToKeep.value(), g.V(v).values("to-keep").next()); assertThat(triggered.get(), is(true)); }
Example 7
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES) public void shouldUseActualPropertyOfVertexPropertyWhenChanged() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final VertexProperty vp = v.property("xxx","blah"); final String label = vp.label(); final Object value = vp.value(); vp.property("to-change", "dah"); final MutationListener listener = new AbstractMutationListener() { @Override public void vertexPropertyPropertyChanged(final VertexProperty element, final Property oldValue, final Object setValue) { assertEquals(vp, element); assertEquals(label, element.label()); assertEquals(value, element.value()); assertEquals("dah", oldValue.value()); assertEquals("to-change", oldValue.key()); assertEquals("bah", 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).properties("xxx").property("to-change","bah").iterate(); tryCommit(graph); assertEquals(1, IteratorUtils.count(g.V(v).properties())); assertEquals(1, IteratorUtils.count(g.V(v).properties().properties())); assertThat(triggered.get(), is(true)); }
Example 8
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES) public void shouldUseActualPropertyOfVertexPropertyWhenNew() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final VertexProperty vp = v.property("xxx","blah"); final String label = vp.label(); final Object value = vp.value(); vp.property("to-change", "dah"); final MutationListener listener = new AbstractMutationListener() { @Override public void vertexPropertyPropertyChanged(final VertexProperty element, final Property oldValue, final Object setValue) { assertEquals(vp, element); assertEquals(label, element.label()); assertEquals(value, element.value()); assertThat(oldValue, instanceOf(KeyedProperty.class)); assertEquals("new", oldValue.key()); assertEquals("yay!", 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).properties("xxx").property("new","yay!").iterate(); tryCommit(graph); assertEquals(1, IteratorUtils.count(g.V(v).properties())); assertEquals(2, IteratorUtils.count(g.V(v).properties().properties())); assertThat(triggered.get(), is(true)); }
Example 9
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) public void shouldUseActualVertexPropertyWhenRemoved() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final VertexProperty vp = v.property("to-remove","blah"); final String label = vp.label(); final Object value = vp.value(); final VertexProperty vpToKeep = v.property("to-keep","dah"); final MutationListener listener = new AbstractMutationListener() { @Override public void vertexPropertyRemoved(final VertexProperty element) { assertEquals(vp, element); assertEquals(label, element.label()); assertEquals(value, element.value()); 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).properties("to-remove").drop().iterate(); tryCommit(graph); assertEquals(1, IteratorUtils.count(g.V(v).properties())); assertEquals(vpToKeep.value(), g.V(v).values("to-keep").next()); assertThat(triggered.get(), is(true)); }