use of nl.knaw.huygens.timbuctoo.search.FacetValue in project timbuctoo by HuygensING.
the class RelatedDatableRangeFacetDescriptionTest method filterAddsAFilterIgnoresLastFourNumbers.
@Test
public void filterAddsAFilterIgnoresLastFourNumbers() {
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> 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 RelatedDatableRangeFacetDescriptionTest method filterIncludesTheVerticesWhereOnlyTheEndFallsInTheRange.
@Test
public void filterIncludesTheVerticesWhereOnlyTheEndFallsInTheRange() {
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, 20160224L));
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 RelatedListFacetDescriptionTest method filterLetsTheParserParseEachDatabaseValue.
@Test
public void filterLetsTheParserParseEachDatabaseValue() {
RelatedListFacetDescription instance = new RelatedListFacetDescription(FACET_NAME, PROPERTY, parser, RELATION);
List<FacetValue> facets = Lists.newArrayList(new ListFacetValue(FACET_NAME, Lists.newArrayList(VALUE1)));
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);
// needed to verify the parser
traversal.toList();
verify(parser).parse(VALUE1);
verify(parser).parse(VALUE2);
}
use of nl.knaw.huygens.timbuctoo.search.FacetValue 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")));
}
Aggregations