use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class EdgeListFacetDescriptionTest method filterAddsNoFilterIfTheFacetValuesIsEmpty.
@Test
public void filterAddsNoFilterIfTheFacetValuesIsEmpty() {
List<FacetValue> facetValues = Lists.newArrayList(new ListFacetValue(FACET_NAME, Lists.newArrayList()));
SearchRequestV2_1 searchRequest = new SearchRequestV2_1();
searchRequest.setFacetValues(facetValues);
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withTimId("1")).withVertex(v -> v.withTimId("2")).build().traversal().V();
instance.filter(traversal, facetValues);
assertThat(traversal.toList(), containsInAnyOrder(VertexMatcher.likeVertex().withTimId("1"), VertexMatcher.likeVertex().withTimId("2")));
}
use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class EdgeListFacetDescriptionTest method filterAddsAFilterToFilterOutTheNonMatchingVertices.
@Test
public void filterAddsAFilterToFilterOutTheNonMatchingVertices() {
List<FacetValue> facetValues = Lists.newArrayList(new ListFacetValue(FACET_NAME, Lists.newArrayList(RELATION_NAME)));
SearchRequestV2_1 searchRequest = new SearchRequestV2_1();
searchRequest.setFacetValues(facetValues);
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex("v1", v -> v.withTimId("1")).withVertex("v2", v -> v.withTimId("2").withOutgoingRelation(RELATION_NAME, "v1")).build().traversal().V();
instance.filter(traversal, facetValues);
assertThat(traversal.toList(), contains(VertexMatcher.likeVertex().withTimId("1")));
}
use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class ListFacetDescriptionTest method filterLetsTheParserParseEachDatabaseValue.
@Test
public void filterLetsTheParserParseEachDatabaseValue() {
String value1 = "value1";
List<FacetValue> facetValues = Lists.newArrayList(new ListFacetValue(FACET_NAME, Lists.newArrayList(value1)));
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withProperty(PROPERTY, "value1").withTimId("1")).withVertex(v -> v.withProperty(PROPERTY, "value2").withTimId("2")).build().traversal().V();
instance.filter(traversal, facetValues);
// needed to verify the parser
traversal.toList();
verify(propertyParser).parse("value1");
verify(propertyParser).parse("value2");
}
use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class ListFacetDescriptionTest method filterAddsAFilterToFilterOutTheNonMatchingVertices.
@Test
public void filterAddsAFilterToFilterOutTheNonMatchingVertices() {
String value1 = "value1";
List<FacetValue> facetValues = Lists.newArrayList(new ListFacetValue(FACET_NAME, Lists.newArrayList(value1)));
SearchRequestV2_1 searchRequest = new SearchRequestV2_1();
searchRequest.setFacetValues(facetValues);
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withProperty(PROPERTY, value1).withTimId("1")).withVertex(v -> v.withProperty(PROPERTY, "value2").withTimId("2")).build().traversal().V();
instance.filter(traversal, facetValues);
assertThat(traversal.toList(), contains(VertexMatcher.likeVertex().withTimId("1")));
}
use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class MultiValueListFacetDescriptionTest method filterAddsAFilterThatChecksIfTheVerticesContainOnOfTheValues.
@Test
public void filterAddsAFilterThatChecksIfTheVerticesContainOnOfTheValues() {
String value3 = "value3";
String value4 = "value4";
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withTimId("id1").withProperty(PROPERTY_NAME, serializedListOf("value1", "value2"))).withVertex(v -> v.withTimId("id2").withProperty(PROPERTY_NAME, serializedListOf("value2", value3))).withVertex(v -> v.withTimId("id3").withProperty(PROPERTY_NAME, serializedListOf("value1", value4))).build().traversal().V();
List<String> values = Lists.newArrayList(value3, value4);
List<FacetValue> facetValues = Lists.newArrayList(new ListFacetValue(FACET_NAME, values));
instance.filter(traversal, facetValues);
assertThat(traversal.toList(), containsInAnyOrder(likeVertex().withTimId("id2"), likeVertex().withTimId("id3")));
}
Aggregations