use of nl.knaw.huygens.timbuctoo.search.description.facet.FacetGetter in project timbuctoo by HuygensING.
the class ChangeRangeFacetGetterTest method getFacetReturnsLowerAndUpperLimitAsZeroWhenValueKeyIsNotParsableAsModifiedProp.
@Test
public void getFacetReturnsLowerAndUpperLimitAsZeroWhenValueKeyIsNotParsableAsModifiedProp() {
FacetGetter instance = new ChangeRangeFacetGetter();
Map<String, Set<Vertex>> values = Maps.newHashMap();
List<Vertex> vertices1 = newGraph().withVertex(v -> v.withTimId("1")).withVertex(v -> v.withTimId("2")).build().traversal().V().toList();
List<Vertex> vertices2 = newGraph().withVertex(v -> v.withTimId("3")).build().traversal().V().toList();
values.put("val1", Sets.newHashSet(vertices1));
values.put("val2", Sets.newHashSet(vertices2));
Facet facet = instance.getFacet(FACET_NAME, values);
assertThat(facet.getName(), equalTo(FACET_NAME));
assertThat(facet.getOptions(), containsInAnyOrder(new Facet.RangeOption(0, 0)));
}
use of nl.knaw.huygens.timbuctoo.search.description.facet.FacetGetter in project timbuctoo by HuygensING.
the class ChangeRangeFacetGetterTest method getFacetReturnsLowerAndUpperLimit.
@Test
public void getFacetReturnsLowerAndUpperLimit() {
FacetGetter instance = new ChangeRangeFacetGetter();
Map<String, Set<Vertex>> values = Maps.newHashMap();
List<Vertex> vertices1 = newGraph().withVertex(v -> v.withTimId("1")).withVertex(v -> v.withTimId("2")).build().traversal().V().toList();
List<Vertex> vertices2 = newGraph().withVertex(v -> v.withTimId("3")).build().traversal().V().toList();
values.put(serializedChangeWithDate("20150101"), Sets.newHashSet(vertices1));
values.put("{\"nonParsable\": null}", Sets.newHashSet(vertices1));
values.put(serializedChangeWithDate("20121231"), Sets.newHashSet(vertices2));
values.put(serializedChangeWithDate("20131231"), Sets.newHashSet(vertices2));
Facet facet = instance.getFacet(FACET_NAME, values);
assertThat(facet.getName(), equalTo(FACET_NAME));
assertThat(facet.getOptions(), containsInAnyOrder(new Facet.RangeOption(20121231, 20150101)));
}
use of nl.knaw.huygens.timbuctoo.search.description.facet.FacetGetter in project timbuctoo by HuygensING.
the class DatableRangeFacetGetterTest method getFacetReturnsLowerAndUpperLimit.
@Test
public void getFacetReturnsLowerAndUpperLimit() {
FacetGetter instance = new DatableRangeFacetGetter();
Map<String, Set<Vertex>> values = Maps.newHashMap();
List<Vertex> vertices1 = newGraph().withVertex(v -> v.withTimId("1")).withVertex(v -> v.withTimId("2")).build().traversal().V().toList();
List<Vertex> vertices2 = newGraph().withVertex(v -> v.withTimId("3")).build().traversal().V().toList();
values.put(asSerializedDatable("2015-01-01"), Sets.newHashSet(vertices1));
values.put("{\"nonParsable\": null}", Sets.newHashSet(vertices1));
values.put(asSerializedDatable("1000-03-02"), Sets.newHashSet(vertices2));
values.put(asSerializedDatable("2100-03-02"), Sets.newHashSet(vertices2));
Facet facet = instance.getFacet(FACET_NAME, values);
assertThat(facet.getName(), equalTo(FACET_NAME));
assertThat(facet.getOptions(), containsInAnyOrder(new Facet.RangeOption(10000302, 21000302)));
}
use of nl.knaw.huygens.timbuctoo.search.description.facet.FacetGetter in project timbuctoo by HuygensING.
the class DatableRangeFacetGetterTest method getFacetReturnsLowerAndUpperLimitAsZeroWhenValueKeyIsNotParsableAsDatableProp.
@Test
public void getFacetReturnsLowerAndUpperLimitAsZeroWhenValueKeyIsNotParsableAsDatableProp() {
FacetGetter instance = new DatableRangeFacetGetter();
Map<String, Set<Vertex>> values = Maps.newHashMap();
List<Vertex> vertices1 = newGraph().withVertex(v -> v.withTimId("1")).withVertex(v -> v.withTimId("2")).build().traversal().V().toList();
List<Vertex> vertices2 = newGraph().withVertex(v -> v.withTimId("3")).build().traversal().V().toList();
values.put("val1", Sets.newHashSet(vertices1));
values.put("val2", Sets.newHashSet(vertices2));
Facet facet = instance.getFacet(FACET_NAME, values);
assertThat(facet.getName(), equalTo(FACET_NAME));
assertThat(facet.getOptions(), containsInAnyOrder(new Facet.RangeOption(0, 0)));
}
use of nl.knaw.huygens.timbuctoo.search.description.facet.FacetGetter in project timbuctoo by HuygensING.
the class ListFacetGetterTest method getFacetReturnsValueKeysAndTheirCounts.
@Test
public void getFacetReturnsValueKeysAndTheirCounts() {
FacetGetter instance = new ListFacetGetter();
Map<String, Set<Vertex>> values = Maps.newHashMap();
List<Vertex> vertices1 = newGraph().withVertex(v -> v.withTimId("1")).withVertex(v -> v.withTimId("2")).build().traversal().V().toList();
List<Vertex> vertices2 = newGraph().withVertex(v -> v.withTimId("3")).build().traversal().V().toList();
values.put("val1", Sets.newHashSet(vertices1));
values.put("val2", Sets.newHashSet(vertices2));
Facet facet = instance.getFacet(FACET_NAME, values);
assertThat(facet.getName(), equalTo(FACET_NAME));
assertThat(facet.getOptions(), containsInAnyOrder(new Facet.DefaultOption("val2", 1), new Facet.DefaultOption("val1", 2)));
}
Aggregations