use of nl.knaw.huygens.timbuctoo.search.FacetValue in project timbuctoo by HuygensING.
the class DatableRangeFacetDescriptionTest method filterAddsAFilterIgnoresLastFourNumbers.
@Test
public void filterAddsAFilterIgnoresLastFourNumbers() {
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withTimId("id1").withProperty(PROPERTY_NAME, asSerializedDatable("2015-01-01"))).withVertex(v -> v.withTimId("id2").withProperty(PROPERTY_NAME, asSerializedDatable("1000-03-02"))).withVertex(v -> v.withTimId("id3").withProperty(PROPERTY_NAME, asSerializedDatable("2100-03-02"))).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")));
}
use of nl.knaw.huygens.timbuctoo.search.FacetValue in project timbuctoo by HuygensING.
the class DatableRangeFacetDescriptionTest method filterIncludesTheVerticesWhereOnlyTheStartFallsInTheRange.
@Test
public void filterIncludesTheVerticesWhereOnlyTheStartFallsInTheRange() {
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withTimId("id1").withProperty(PROPERTY_NAME, asSerializedDatable("2015/2020"))).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, 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 DatableRangeFacetDescriptionTest method filterAddsAFilterThatIgnoresInvalidDatables.
@Test
public void filterAddsAFilterThatIgnoresInvalidDatables() {
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withTimId("id1").withProperty(PROPERTY_NAME, asSerializedDatable("2015-01-01"))).withVertex(v -> v.withTimId("id2").withProperty(PROPERTY_NAME, asSerializedDatable("invalidDatable"))).withVertex(v -> v.withTimId("id3").withProperty(PROPERTY_NAME, asSerializedDatable("2100-03-02"))).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")));
}
use of nl.knaw.huygens.timbuctoo.search.FacetValue 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 nl.knaw.huygens.timbuctoo.search.FacetValue 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")));
}
Aggregations