use of nl.knaw.huygens.timbuctoo.search.FacetValue in project timbuctoo by HuygensING.
the class ListFacetDescriptionTest method filterAddsNoFilterIfTheFacetValueIsNotAListFacetValue.
@Test
public void filterAddsNoFilterIfTheFacetValueIsNotAListFacetValue() {
String value1 = "value1";
List<FacetValue> facetValues = Lists.newArrayList((FacetValue) () -> FACET_NAME);
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(), containsInAnyOrder(VertexMatcher.likeVertex().withTimId("1"), VertexMatcher.likeVertex().withTimId("2")));
}
use of nl.knaw.huygens.timbuctoo.search.FacetValue in project timbuctoo by HuygensING.
the class ListFacetDescriptionTest method filterAddsNoFilterIfTheFacetValuesIsEmpty.
@Test
public void filterAddsNoFilterIfTheFacetValuesIsEmpty() {
String value1 = "value1";
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.withProperty(PROPERTY, value1).withTimId("1")).withVertex(v -> v.withProperty(PROPERTY, "value2").withTimId("2")).build().traversal().V();
instance.filter(traversal, facetValues);
assertThat(traversal.toList(), containsInAnyOrder(VertexMatcher.likeVertex().withTimId("1"), VertexMatcher.likeVertex().withTimId("2")));
}
use of nl.knaw.huygens.timbuctoo.search.FacetValue in project timbuctoo by HuygensING.
the class RelatedDatableRangeFacetDescriptionTest method filterAddFiltersTheVertices.
@Test
public void filterAddFiltersTheVertices() {
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex("target1", v -> v.withTimId("id4").withProperty(PROPERTY_NAME, asSerializedDatable("2015-01"))).withVertex("target2", v -> v.withTimId("id5").withProperty(PROPERTY_NAME, asSerializedDatable("0015-01"))).withVertex("target3", v -> v.withTimId("id6").withProperty(PROPERTY_NAME, asSerializedDatable("0190-01"))).withVertex("source1", v -> v.withTimId("id1").withOutgoingRelation(RELATION, "target1")).withVertex("source2", v -> v.withTimId("id2").withOutgoingRelation(RELATION, "target2")).withVertex("source3", v -> v.withTimId("id3").withOutgoingRelation(RELATION, "target3")).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 nl.knaw.huygens.timbuctoo.search.FacetValue in project timbuctoo by HuygensING.
the class RelatedDatableRangeFacetDescriptionTest method filterIncludesTheVerticesWhereOnlyTheStartFallsInTheRange.
@Test
public void filterIncludesTheVerticesWhereOnlyTheStartFallsInTheRange() {
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex("target1", v -> v.withTimId("id4").withProperty(PROPERTY_NAME, asSerializedDatable("2015/2020"))).withVertex("target2", v -> v.withTimId("id5").withProperty(PROPERTY_NAME, asSerializedDatable("0015-01"))).withVertex("target3", v -> v.withTimId("id6").withProperty(PROPERTY_NAME, asSerializedDatable("0190-01"))).withVertex("source1", v -> v.withTimId("id1").withOutgoingRelation(RELATION, "target1")).withVertex("source2", v -> v.withTimId("id2").withOutgoingRelation(RELATION, "target2")).withVertex("source3", v -> v.withTimId("id3").withOutgoingRelation(RELATION, "target3")).build().traversal().V();
List<FacetValue> facetValues = Lists.newArrayList(new DateRangeFacetValue(FACET_NAME, 20140101L, 20160101L));
instance.filter(traversal, facetValues);
assertThat(traversal.toList(), contains(likeVertex().withTimId("id1")));
}
use of nl.knaw.huygens.timbuctoo.search.FacetValue in project timbuctoo by HuygensING.
the class RelatedDatableRangeFacetDescriptionTest method filterAddsAFilterThatIgnoresInvalidDatables.
@Test
public void filterAddsAFilterThatIgnoresInvalidDatables() {
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex("target1", v -> v.withTimId("id4").withProperty(PROPERTY_NAME, asSerializedDatable("2015-01"))).withVertex("target2", v -> v.withTimId("id5").withProperty(PROPERTY_NAME, asSerializedDatable("invalid"))).withVertex("target3", v -> v.withTimId("id6").withProperty(PROPERTY_NAME, asSerializedDatable("0190-01"))).withVertex("source1", v -> v.withTimId("id1").withOutgoingRelation(RELATION, "target1")).withVertex("source2", v -> v.withTimId("id2").withOutgoingRelation(RELATION, "target2")).withVertex("source3", v -> v.withTimId("id3").withOutgoingRelation(RELATION, "target3")).build().traversal().V();
List<FacetValue> facets = Lists.newArrayList(new DateRangeFacetValue(FACET_NAME, 20151001L, 20160101L));
instance.filter(traversal, facets);
assertThat(traversal.toList(), contains(likeVertex().withTimId("id1")));
}
Aggregations