use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class RelatedMultiValueListFacetDescriptionTest method filterAddsAFilterToTheGraphTraversal.
@Test
public void filterAddsAFilterToTheGraphTraversal() {
RelatedMultiValueListFacetDescription instance = new RelatedMultiValueListFacetDescription(FACET_NAME, PROPERTY, RELATION);
List<FacetValue> facets = Lists.newArrayList(new ListFacetValue(FACET_NAME, Lists.newArrayList(FACET_VALUE)));
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex("v1", v -> v.withTimId("id1").withProperty(PROPERTY, VALUE1)).withVertex("v2", v -> v.withTimId("id2").withProperty(PROPERTY, VALUE2)).withVertex("v3", v -> v.withTimId("id3").withOutgoingRelation(RELATION, "v1")).withVertex("v4", v -> v.withTimId("id4").withOutgoingRelation(RELATION, "v2")).build().traversal().V();
instance.filter(traversal, facets);
List<Vertex> vertices = traversal.toList();
assertThat(vertices, contains(likeVertex().withTimId("id3")));
}
use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class SortDescriptionTest method sortAddsASortParameterToTheSearchResultsForEachOfTheSortParameters.
@Test
@SuppressWarnings("unchecked")
public void sortAddsASortParameterToTheSearchResultsForEachOfTheSortParameters() {
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withTimId("id1").withProperty(PROPERTY_1, "value1.2").withProperty(PROPERTY_2, "value2")).withVertex(v -> v.withTimId("id2").withProperty(PROPERTY_1, "value1").withProperty(PROPERTY_2, "value2.1")).withVertex(v -> v.withTimId("id3").withProperty(PROPERTY_1, "value1").withProperty(PROPERTY_2, "value2")).build().traversal().V();
List<SortParameter> sortParameters = Lists.newArrayList(new SortParameter(SORT_FIELD_1, asc), new SortParameter(SORT_FIELD_2, 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 getTraversalReturnsTheTraversalToOrderThePropertyValues.
@Test
public void getTraversalReturnsTheTraversalToOrderThePropertyValues() {
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").withProperty(PROPERTY, "12")).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 SortFieldDescriptionTest method getTraversalReturnsATraversalWithABackupTraversalWhenConfigured.
@Test
public void getTraversalReturnsATraversalWithABackupTraversalWhenConfigured() {
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withTimId("id1").withProperty(PROPERTY, "abc")).withVertex(v -> v.withTimId("id2").withProperty(PROPERTY, "abcd")).withVertex(v -> v.withTimId("id3").withProperty(PROPERTY_2, "efgh")).withVertex(v -> v.withTimId("id4").withProperty(PROPERTY_2, "ab")).build().traversal().V();
SortFieldDescription instance = newSortFieldDescription().withName("name").withDefaultValue("").withProperty(localProperty().withName(PROPERTY)).withBackupProperty(localProperty().withName(PROPERTY_2)).build();
GraphTraversal<?, ?> orderTraversal = instance.getTraversal().get(0);
List<Vertex> vertices = traversal.order().by(orderTraversal, Order.incr).toList();
assertThat(vertices, contains(likeVertex().withTimId("id4"), likeVertex().withTimId("id1"), 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 filterFiltersOnEachOfTheTermIndividuallyEachPropertyHasToContainOnlyOne.
@Test
public void filterFiltersOnEachOfTheTermIndividuallyEachPropertyHasToContainOnlyOne() {
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(vertex -> vertex.withTimId("v1").withProperty(PROPERTY, "value 12344324 value2")).withVertex(vertex -> vertex.withTimId("v2").withProperty(PROPERTY, "value value2")).withVertex(vertex -> vertex.withTimId("v3").withProperty(PROPERTY, "value1 value2")).build().traversal().V();
FullTextSearchParameter fullTextSearchParameter = new FullTextSearchParameter(NAME, "value value2");
instance.filter(traversal, fullTextSearchParameter);
assertThat(traversal.toList(), containsInAnyOrder(likeVertex().withTimId("v1"), likeVertex().withTimId("v2"), likeVertex().withTimId("v3")));
}
Aggregations