Refine search
@Test public void testTinkerPopCardinality() { PropertyKey id = mgmt.makePropertyKey("id").cardinality(Cardinality.SINGLE).dataType(Integer.class).make(); PropertyKey name = mgmt.makePropertyKey("name").cardinality(Cardinality.SINGLE).dataType(String.class).make(); PropertyKey names = mgmt.makePropertyKey("names").cardinality(Cardinality.LIST).dataType(String.class).make(); mgmt.buildIndex("byId", Vertex.class).addKey(id).buildCompositeIndex(); finishSchema(); GraphTraversalSource gts; Vertex v; v = graph.addVertex("id", 1); v.property(single, "name", "t1"); graph.addVertex("id", 2, "names", "n1", "names", "n2"); graph.tx().commit(); gts = graph.traversal(); v = gts.V().has("id", 1).next(); v.property(single, "name", "t2"); v = gts.V().has("id", 1).next(); v.property(single, "name", "t3"); assertCount(1, gts.V(v).properties("name")); assertCount(2, gts.V().has("id", 2).properties("names")); assertCount(2, gts.V().hasLabel("vertex")); }
@Test public void testTinkerPopCardinality() { PropertyKey id = mgmt.makePropertyKey("id").cardinality(Cardinality.SINGLE).dataType(Integer.class).make(); PropertyKey name = mgmt.makePropertyKey("name").cardinality(Cardinality.SINGLE).dataType(String.class).make(); PropertyKey names = mgmt.makePropertyKey("names").cardinality(Cardinality.LIST).dataType(String.class).make(); mgmt.buildIndex("byId", Vertex.class).addKey(id).buildCompositeIndex(); finishSchema(); GraphTraversalSource gts; Vertex v; v = graph.addVertex("id", 1); v.property(single, "name", "t1"); graph.addVertex("id", 2, "names", "n1", "names", "n2"); graph.tx().commit(); gts = graph.traversal(); v = gts.V().has("id", 1).next(); v.property(single, "name", "t2"); v = gts.V().has("id", 1).next(); v.property(single, "name", "t3"); assertCount(1, gts.V(v).properties("name")); assertCount(2, gts.V().has("id", 2).properties("names")); assertCount(2, gts.V().hasLabel("vertex")); }
assertNumStep(numV / 5, 1, gts.V(sv[0]).outE("knows").has("weight", 1), TitanVertexStep.class); assertNumStep(numV, 1, gts.V(sv[0]).outE("knows"), TitanVertexStep.class); assertNumStep(numV, 1, gts.V(sv[0]).out("knows"), TitanVertexStep.class); assertNumStep(10, 1, gts.V(sv[0]).local(__.outE("knows").limit(10)), TitanVertexStep.class); assertNumStep(10, 1, gts.V(sv[0]).local(__.outE("knows").range(10, 20)), LocalStep.class); assertNumStep(numV / 5, 1, gts.V(sv[0]).properties("names").has("weight", 1), TitanPropertiesStep.class); assertNumStep(numV, 1, gts.V(sv[0]).properties("names"), TitanPropertiesStep.class); assertNumStep(10, 1, gts.V(sv[0]).local(__.properties("names").order().by("weight", decr).limit(10)), TitanPropertiesStep.class); assertNumStep(numV, 2, gts.V(sv[0]).outE("knows").values("weight"), TitanVertexStep.class, TitanPropertiesStep.class);
@Override public Traversal<Vertex, VertexProperty> get_g_V_properties_drop() { return (Traversal) g.V().properties().drop(); } }
@Override public Traversal<Vertex, VertexProperty<String>> get_g_V_hasXageX_propertiesXnameX() { return (Traversal<Vertex, VertexProperty<String>>) g.V().has("age").<String>properties("name"); }
assertNumStep(numV / 5, 1, gts.V(sv[0]).outE("knows").has("weight", 1), JanusGraphVertexStep.class); assertNumStep(numV, 1, gts.V(sv[0]).outE("knows"), JanusGraphVertexStep.class); assertNumStep(numV, 1, gts.V(sv[0]).out("knows"), JanusGraphVertexStep.class); assertNumStep(10, 1, gts.V(sv[0]).local(__.outE("knows").limit(10)), JanusGraphVertexStep.class); assertNumStep(10, 1, gts.V(sv[0]).local(__.outE("knows").range(10, 20)), LocalStep.class); assertNumStep(numV / 5, 1, gts.V(sv[0]).properties("names").has("weight", 1), JanusGraphPropertiesStep.class); assertNumStep(numV, 1, gts.V(sv[0]).properties("names"), JanusGraphPropertiesStep.class); assertNumStep(10, 0, gts.V(sv[0]).local(__.properties("names").order().by("weight", decr).limit(10)), LocalStep.class); assertNumStep(numV, 2, gts.V(sv[0]).outE("knows").values("weight"), JanusGraphVertexStep.class, JanusGraphPropertiesStep.class);
public GraphTraversal<Vertex, VertexProperty<Object>> convertToVertexProperty(final Graph graph, final String vertexName, final String vertexPropertyKey) { // all test graphs have "name" as a unique id which makes it easy to hardcode this...works for now return (GraphTraversal<Vertex, VertexProperty<Object>>) graphProvider.traversal(graph).V().has("name", vertexName).properties(vertexPropertyKey); }
@Override public Traversal<Vertex, Object> get_g_V_hasXageX_propertiesXname_ageX_value() { return g.V().has("age").properties("name", "age").value(); }
@Override public Traversal<Vertex, Object> get_g_V_hasXageX_propertiesXage_nameX_value() { return g.V().has("age").properties("age", "name").value(); }
@Override public Traversal<Vertex, String> get_g_V_properties_order_byXkey_descX_key() { return g.V().properties().order().by(T.key, Order.desc).key(); }
@Override public Traversal<VertexProperty<String>, String> get_g_injectXg_VX1X_propertiesXnameX_nextX_value(final Object v1Id) { return g.<VertexProperty<String>>inject((VertexProperty) g.V(v1Id).properties("name").next()).value(); } }
@Override public Traversal<Vertex, Object> get_g_V_hasXageX_properties_hasXid_nameIdX_value(final Object nameId) { return g.V().has("age").properties().has(T.id, nameId).value(); }
g.V().drop().iterate(); assertEquals(2, g.V().has(property, value1).toList().size()); g.V().properties().drop().iterate();
@Override public Traversal<Vertex, Integer> get_g_V_both_properties_dedup_hasKeyXageX_value() { return g.V().both().properties().dedup().hasKey("age").value(); }
@Parameterized.Parameters(name = "expectInterruption({0})") public static Iterable<Object[]> data() { return Arrays.asList(new Object[][]{ {"g_V", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V()}, {"g_V_out", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V().out()}, {"g_V_outE", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V().outE()}, {"g_V_in", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V().in()}, {"g_V_inE", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V().inE()}, {"g_V_properties", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V().properties()}, {"g_E", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.E()}, {"g_E_outV", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.E().outV()}, {"g_E_inV", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.E().inV()}, {"g_E_properties", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.E().properties()}, }); }
@Parameterized.Parameters(name = "expectInterruption({0})") public static Iterable<Object[]> data() { return Arrays.asList(new Object[][]{ {"g_V", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V(), (UnaryOperator<GraphTraversal<?,?>>) t -> t}, {"g_V_out", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.out()}, {"g_V_outE", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.outE()}, {"g_V_in", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.in()}, {"g_V_inE", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.inE()}, {"g_V_properties", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.properties()}, {"g_E", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.E(), (UnaryOperator<GraphTraversal<?,?>>) t -> t}, {"g_E_outV", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.E(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.outV()}, {"g_E_inV", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.E(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.inV()}, {"g_E_properties", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.E(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.properties()}, }); }
@Override public Traversal<Vertex, String> get_g_V_both_name_order_byXa_bX_dedup_value() { return g.V().both().<String>properties("name").order().by((a, b) -> a.value().compareTo(b.value())).dedup().value(); }
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_MULTI_PROPERTIES) public void shouldAppendPartitionToVertexPropertyOverMultiProperty() { final PartitionStrategy partitionStrategy = PartitionStrategy.build() .includeMetaProperties(true) .partitionKey(partition).writePartition("A").readPartitions("A").create(); final Vertex v = g.withStrategies(partitionStrategy).addV().property(VertexProperty.Cardinality.list, "any", "thing") .property(VertexProperty.Cardinality.list, "any", "more").next(); assertNotNull(v); assertThat((List<String>) IteratorUtils.asList(g.V(v).properties("any")).stream().map(p -> ((VertexProperty) p).value()).collect(Collectors.toList()), containsInAnyOrder("thing", "more")); assertEquals("A", v.property(partition).value()); assertThat((List<String>) IteratorUtils.asList(g.V(v).properties("any")).stream().map(p -> ((VertexProperty) p).value(partition)).collect(Collectors.toList()), containsInAnyOrder("A", "A")); }
@Override public Traversal<Vertex, Integer> get_g_V_both_properties_dedup_hasKeyXageX_hasValueXgtX30XX_value() { return g.V().both().properties().dedup().hasKey("age").hasValue(P.gt(30)).value(); }
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES) public void shouldNotAppendPartitionToVertexProperty() { final PartitionStrategy partitionStrategy = PartitionStrategy.build() .includeMetaProperties(false) .partitionKey(partition).writePartition("A").readPartitions("A").create(); final Vertex v = g.withStrategies(partitionStrategy).addV().property("any", "thing").next(); assertNotNull(v); assertEquals("thing", g.V(v).values("any").next()); assertEquals("A", g.V(v).values(partition).next()); assertThat(g.V(v).properties("any").properties().hasNext(), is(false)); }