@Override public void remove() { this.baseProperty.remove(); }
@Override public void remove() { this.property.remove(); }
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE) public void shouldGetPropertyKeysOnEdge() { final Vertex v = graph.addVertex(); final Edge e = v.addEdge("friend", v, "name", "marko", "location", "desert", "status", "dope"); Set<String> keys = e.keys(); assertEquals(3, keys.size()); assertTrue(keys.contains("name")); assertTrue(keys.contains("location")); assertTrue(keys.contains("status")); final List<Property<Object>> m = IteratorUtils.list(e.properties()); assertEquals(3, m.size()); assertTrue(m.stream().anyMatch(p -> p.key().equals("name"))); assertTrue(m.stream().anyMatch(p -> p.key().equals("location"))); assertTrue(m.stream().anyMatch(p -> p.key().equals("status"))); assertEquals("marko", m.stream().filter(p -> p.key().equals("name")).map(Property::value).findAny().orElse(null)); assertEquals("desert", m.stream().filter(p -> p.key().equals("location")).map(Property::value).findAny().orElse(null)); assertEquals("dope", m.stream().filter(p -> p.key().equals("status")).map(Property::value).findAny().orElse(null)); e.property("status").remove(); keys = e.keys(); assertEquals(2, keys.size()); assertTrue(keys.contains("name")); assertTrue(keys.contains("location")); e.properties().forEachRemaining(Property::remove); keys = e.keys(); assertEquals(0, keys.size()); }
@Test public void testRemoveEdgePropertyOfSortKey() { Edge edge = initEdgeTransfer(); Assert.assertThrows(IllegalArgumentException.class, () -> { edge.property("id").remove(); }); }
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE) @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_REMOVE_PROPERTY) @FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_INTEGER_VALUES) public void shouldAllowRemovalFromEdgeWhenAlreadyRemoved() { final Vertex v = graph.addVertex("name", "marko"); tryCommit(graph); final Vertex v1 = graph.vertices(v.id()).next(); try { final Edge edge = v1.addEdge("knows", graph.addVertex()); final Property p = edge.property("stars", 5); p.remove(); p.remove(); edge.property("stars").remove(); edge.property("stars").remove(); } catch (Exception ex) { fail("Removing an edge property that was already removed should not throw an exception"); } } }
edge.property(key, value); } else { edge.property(key).remove();
@Test public void testRemoveEdgePropertyNonNullWithIndex() { HugeGraph graph = graph(); Vertex louise = graph.addVertex(T.label, "person", "name", "Louise", "city", "Beijing", "age", 21); Vertex sean = graph.addVertex(T.label, "person", "name", "Sean", "city", "Beijing", "age", 23); long current = System.currentTimeMillis(); Edge edge = louise.addEdge("strike", sean, "id", 1, "timestamp", current, "place", "park", "tool", "shovel", "reason", "jeer", "arrested", false); Assert.assertThrows(IllegalArgumentException.class, () -> { edge.property("timestamp").remove(); }); Assert.assertThrows(IllegalArgumentException.class, () -> { edge.property("place").remove(); }); }
@Test @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = EdgeFeatures.FEATURE_REMOVE_PROPERTY, supported = false) @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE) public void shouldSupportRemovePropertyIfAPropertyCanBeRemoved() throws Exception { try { final Vertex v = graph.addVertex(); final Edge e = v.addEdge("self", v, "name", "foo"); e.property("name").remove(); fail(String.format(INVALID_FEATURE_SPECIFICATION, EdgeFeatures.class.getSimpleName(), EdgeFeatures.FEATURE_REMOVE_PROPERTY)); } catch (Exception ex) { validateException(Property.Exceptions.propertyRemovalNotSupported(), ex); } } }
@Test @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = VertexPropertyFeatures.FEATURE_REMOVE_PROPERTY, supported = false) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = VertexFeatures.FEATURE_META_PROPERTIES) @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) public void shouldSupportRemovePropertyIfAPropertyCanBeRemoved() throws Exception { try { final Vertex v = graph.addVertex(); final VertexProperty p = v.property(VertexProperty.Cardinality.single, "name", "me", "test", "this"); p.property("test").remove(); fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), VertexPropertyFeatures.FEATURE_REMOVE_PROPERTY)); } catch (Exception ex) { validateException(Property.Exceptions.propertyRemovalNotSupported(), ex); } }
@Test public void testRemoveEdgePropertyNonNullWithoutIndex() { HugeGraph graph = graph(); Vertex louise = graph.addVertex(T.label, "person", "name", "Louise", "city", "Beijing", "age", 21); Vertex sean = graph.addVertex(T.label, "person", "name", "Sean", "city", "Beijing", "age", 23); long current = System.currentTimeMillis(); Edge edge = louise.addEdge("strike", sean, "id", 1, "timestamp", current, "place", "park", "tool", "shovel", "reason", "jeer", "arrested", false); Assert.assertThrows(IllegalArgumentException.class, () -> { edge.property("arrested").remove(); }); }
@Test public void testRemoveEdgePropertyNullableWithIndex() { HugeGraph graph = graph(); Vertex louise = graph.addVertex(T.label, "person", "name", "Louise", "city", "Beijing", "age", 21); Vertex sean = graph.addVertex(T.label, "person", "name", "Sean", "city", "Beijing", "age", 23); long current = System.currentTimeMillis(); Edge edge = louise.addEdge("strike", sean, "id", 1, "timestamp", current, "place", "park", "tool", "shovel", "reason", "jeer", "arrested", false); edge.property("tool").remove(); graph.tx().commit(); }
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_REMOVE_PROPERTY) public void shouldAllowRemovalFromVertexWhenAlreadyRemoved() { final Vertex v = graph.addVertex("name", "marko"); tryCommit(graph); final Vertex v1 = graph.vertices(v.id()).next(); try { final Property p = v1.property("name"); p.remove(); p.remove(); v1.property("name").remove(); v1.property("name").remove(); } catch (Exception ex) { fail("Removing a vertex property that was already removed should not throw an exception"); } }
@Test public void testRemoveEdgePropertyNullableWithoutIndex() { HugeGraph graph = graph(); Vertex louise = graph.addVertex(T.label, "person", "name", "Louise", "city", "Beijing", "age", 21); Vertex sean = graph.addVertex(T.label, "person", "name", "Sean", "city", "Beijing", "age", 23); long current = System.currentTimeMillis(); Edge edge = louise.addEdge("strike", sean, "id", 1, "timestamp", current, "place", "park", "tool", "shovel", "reason", "jeer", "hurt", true, "arrested", false); edge.property("hurt").remove(); graph.tx().commit(); }
@Test public void testUpdateEdgePropertyOfRemovingEdge() { Edge edge = initEdgeTransfer(); edge.remove(); Assert.assertThrows(IllegalArgumentException.class, () -> { edge.property("message").remove(); }); Assert.assertThrows(IllegalArgumentException.class, () -> { edge.property("message", "*"); }); }
@Test public void testRemoveEdgePropertyTwice() { HugeGraph graph = graph(); Edge edge = initEdgeTransfer(); Assert.assertEquals(500.00F, edge.property("amount").value()); Assert.assertEquals("Happy birthday!", edge.property("message").value()); // Remove property twice edge.property("message").remove(); edge.property("message").remove(); graph.tx().commit(); List<Edge> edges = graph.traversal().E().toList(); Assert.assertEquals(1, edges.size()); Assert.assertFalse(edges.get(0).property("message").isPresent()); }
@Test public void testRemoveEdgeProperty() { HugeGraph graph = graph(); Edge edge = initEdgeTransfer(); Assert.assertEquals("Happy birthday!", edge.property("message").value()); // Remove property edge.property("message").remove(); graph.tx().commit(); List<Edge> edges = graph.traversal().E().toList(); Assert.assertEquals(1, edges.size()); Assert.assertFalse(edges.get(0).property("message").isPresent()); }
toRemove.remove(); } else throw new IllegalStateException("The incoming object is not removable: " + s);
@Test public void testUpdateEdgePropertyWithRemoveAndSet() { HugeGraph graph = graph(); Vertex louise = graph.addVertex(T.label, "person", "name", "Louise", "city", "Beijing", "age", 21); Vertex sean = graph.addVertex(T.label, "person", "name", "Sean", "city", "Beijing", "age", 23); long current = System.currentTimeMillis(); Edge edge = louise.addEdge("transfer", sean, "id", 1, "amount", 500.00F, "timestamp", current, "message", "Happy birthday!"); graph.tx().commit(); edge.property("message").remove(); edge.property("message", "Happy birthday ^-^"); graph.tx().commit(); List<Edge> edges = graph.traversal().E().toList(); Assert.assertEquals(1, edges.size()); assertContains(edges, "transfer", louise, sean, "id", 1, "amount", 500.00F, "timestamp", current, "message", "Happy birthday ^-^"); }
@Test public void testUpdateEdgePropertyOfAddingEdge() { Edge edge = initEdgeTransfer(); Vertex louise = vertex("person", "name", "Louise"); Vertex sean = vertex("person", "name", "Sean"); louise.addEdge("transfer", sean, "id", 1, "amount", 500.00F, "timestamp", edge.value("timestamp"), "message", "Happy birthday!"); Assert.assertThrows(IllegalArgumentException.class, () -> { edge.property("message").remove(); }); Assert.assertThrows(IllegalArgumentException.class, () -> { edge.property("message", "*"); }); }
@Test public void testUpdateEdgePropertyOfRemovingEdgeWithDrop() { HugeGraph graph = graph(); Edge edge = initEdgeTransfer(); graph.traversal().E(edge.id()).drop().iterate(); // Update on dirty vertex Assert.assertThrows(IllegalArgumentException.class, () -> { edge.property("message").remove(); }); Assert.assertThrows(IllegalArgumentException.class, () -> { edge.property("message", "*"); }); }