use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class SortDescriptionTest method sortAddsASortParametersThatSortsTheVertices.
@Test
@SuppressWarnings("unchecked")
public void sortAddsASortParametersThatSortsTheVertices() {
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withTimId("id1").withProperty(PROPERTY_1, "value1.2")).withVertex(v -> v.withTimId("id2").withProperty(PROPERTY_1, "value1.1")).withVertex(v -> v.withTimId("id3").withProperty(PROPERTY_1, "value1")).build().traversal().V();
List<SortParameter> sortParameters = Lists.newArrayList(new SortParameter(SORT_FIELD_1, asc));
instance.sort(traversal, sortParameters);
List<Vertex> actual = traversal.toList();
assertThat(actual, contains(likeVertex().withTimId("id3"), likeVertex().withTimId("id2"), likeVertex().withTimId("id1")));
}
use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class SortFieldDescriptionTest method getTraversalAddsATraversalWithADefaultValueForTheVerticesWithoutTheProperty.
@Test
public void getTraversalAddsATraversalWithADefaultValueForTheVerticesWithoutTheProperty() {
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withTimId("id1").withProperty(PROPERTY, "123")).withVertex(v -> v.withTimId("id2").withProperty(PROPERTY, "1234")).withVertex(v -> v.withTimId("id3")).build().traversal().V();
SortFieldDescription instance = newSortFieldDescription().withName("name").withDefaultValue("").withProperty(localProperty().withName(PROPERTY)).build();
GraphTraversal<?, ?> orderTraversal = instance.getTraversal().get(0);
List<Vertex> vertices = traversal.order().by(orderTraversal, Order.incr).toList();
assertThat(vertices, contains(likeVertex().withTimId("id3"), likeVertex().withTimId("id1"), likeVertex().withTimId("id2")));
}
use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class DatableRangeFacetDescriptionTest method filterAddFiltersTheVertices.
@Test
public void filterAddFiltersTheVertices() {
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withTimId("id1").withProperty(PROPERTY_NAME, asSerializedDatable("2015-01"))).withVertex(v -> v.withTimId("id2").withProperty(PROPERTY_NAME, asSerializedDatable("0015-01"))).withVertex(v -> v.withTimId("id3").withProperty(PROPERTY_NAME, asSerializedDatable("0190-01"))).build().traversal().V();
List<FacetValue> facetValues = Lists.newArrayList(new DateRangeFacetValue(FACET_NAME, 101101L, 10001231L));
instance.filter(traversal, facetValues);
assertThat(traversal.toList(), containsInAnyOrder(likeVertex().withTimId("id2"), likeVertex().withTimId("id3")));
}
use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class FullTextSearchDescriptionTest method filterFiltersTheVerticesOnTheValueOfTheProperty.
@Test
public void filterFiltersTheVerticesOnTheValueOfTheProperty() {
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(vertex -> vertex.withTimId("v1").withProperty(PROPERTY, "value1")).withVertex(vertex -> vertex.withTimId("v2").withProperty(PROPERTY, "number2")).withVertex(vertex -> vertex.withTimId("v3").withProperty(PROPERTY, "value1")).build().traversal().V();
FullTextSearchParameter searchParameter = new FullTextSearchParameter(NAME, "value1");
instance.filter(traversal, searchParameter);
assertThat(traversal.toList(), containsInAnyOrder(likeVertex().withTimId("v1"), likeVertex().withTimId("v3")));
}
use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class FullTextSearchDescriptionTest method filterFiltersAllTheVerticesFromTheTraversalWhenNoneMatch.
@Test
public void filterFiltersAllTheVerticesFromTheTraversalWhenNoneMatch() {
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(vertex -> vertex.withTimId("v1").withProperty(PROPERTY, "value1")).withVertex(vertex -> vertex.withTimId("v2").withProperty(PROPERTY, "value2")).withVertex(vertex -> vertex.withTimId("v3").withProperty(PROPERTY, "value").withProperty(BACKUP_PROPERTY, "value1")).build().traversal().V();
FullTextSearchParameter fullTextSearchParameter = new FullTextSearchParameter(NAME, "Not matching");
FullTextSearchDescription instance = createLocalFullTextSearchDescriptionWithBackupProperty(NAME, PROPERTY, BACKUP_PROPERTY);
instance.filter(traversal, fullTextSearchParameter);
assertThat(traversal.toList(), is(empty()));
}
Aggregations