
com.tinkerpop.gremlin.structure.strategy.ReadOnlyStrategyTest Maven / Gradle / Ivy
The newest version!
package com.tinkerpop.gremlin.structure.strategy;
import com.tinkerpop.gremlin.AbstractGremlinTest;
import com.tinkerpop.gremlin.FeatureRequirement;
import com.tinkerpop.gremlin.FeatureRequirementSet;
import com.tinkerpop.gremlin.structure.Edge;
import com.tinkerpop.gremlin.structure.Graph;
import com.tinkerpop.gremlin.structure.Property;
import com.tinkerpop.gremlin.structure.Vertex;
import com.tinkerpop.gremlin.structure.VertexProperty;
import com.tinkerpop.gremlin.util.function.ThrowingConsumer;
import org.junit.Test;
import static com.tinkerpop.gremlin.structure.Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES;
import static com.tinkerpop.gremlin.structure.Graph.Features.VariableFeatures.FEATURE_VARIABLES;
import static com.tinkerpop.gremlin.structure.Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
* @author Stephen Mallette (http://stephen.genoprime.com)
*/
public class ReadOnlyStrategyTest extends AbstractGremlinTest {
public ReadOnlyStrategyTest() {
}
@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = FEATURE_ADD_VERTICES)
public void shouldNotAllowAddVertex() {
assertException(g -> g.addVertex());
}
@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = FEATURE_ADD_VERTICES)
public void shouldNotAllowRemoveVertex() {
g.addVertex();
assertException(g -> g.V().next().remove());
}
@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();
});
}
@Test
@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);
});
}
@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
public void shouldNotAllowVertexSetProperties() {
g.addVertex();
assertException(g -> g.V().next().property("test", "test"));
}
@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
public void shouldNotAllowVertexSetProperty() {
g.addVertex();
assertException(g -> g.V().next().property("test", "test"));
}
@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES)
public void shouldNotAllowVertexPropertySetProperty() {
g.addVertex();
assertException(g -> {
final VertexProperty p = g.V().next().property("test", "test");
p.property("property", "on-a-property");
});
}
@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
public void shouldNotAllowEdgeSetProperties() {
final Vertex v = g.addVertex();
v.addEdge("friend", v);
assertException(g -> g.E().next().property("test", "test"));
}
@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
public void shouldNotAllowEdgeSetProperty() {
final Vertex v = g.addVertex();
v.addEdge("friend", v);
assertException(g -> g.E().next().property("test", "test"));
}
@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
public void shouldNotAllowVertexPropertyRemoval() {
final Vertex v = g.addVertex();
v.property("test", "test");
final Property p = v.property("test");
assertEquals("test", p.value());
assertException(g -> {
final VertexProperty
© 2015 - 2025 Weber Informatics LLC | Privacy Policy