Search in sources :

Example 1 with FacetGetter

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)));
}
Also used : FacetGetter(nl.knaw.huygens.timbuctoo.search.description.facet.FacetGetter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Set(java.util.Set) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Instant(java.time.Instant) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) ZoneId(java.time.ZoneId) List(java.util.List) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) LocalDate(java.time.LocalDate) DateTimeFormatter(java.time.format.DateTimeFormatter) Map(java.util.Map) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Change(nl.knaw.huygens.timbuctoo.model.Change) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Facet(nl.knaw.huygens.timbuctoo.search.description.facet.Facet) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Set(java.util.Set) FacetGetter(nl.knaw.huygens.timbuctoo.search.description.facet.FacetGetter) Facet(nl.knaw.huygens.timbuctoo.search.description.facet.Facet) Test(org.junit.Test)

Example 2 with FacetGetter

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)));
}
Also used : FacetGetter(nl.knaw.huygens.timbuctoo.search.description.facet.FacetGetter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Set(java.util.Set) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Instant(java.time.Instant) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) ZoneId(java.time.ZoneId) List(java.util.List) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) LocalDate(java.time.LocalDate) DateTimeFormatter(java.time.format.DateTimeFormatter) Map(java.util.Map) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Change(nl.knaw.huygens.timbuctoo.model.Change) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Facet(nl.knaw.huygens.timbuctoo.search.description.facet.Facet) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Set(java.util.Set) FacetGetter(nl.knaw.huygens.timbuctoo.search.description.facet.FacetGetter) Facet(nl.knaw.huygens.timbuctoo.search.description.facet.Facet) Test(org.junit.Test)

Example 3 with FacetGetter

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)));
}
Also used : FacetGetter(nl.knaw.huygens.timbuctoo.search.description.facet.FacetGetter) Set(java.util.Set) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) List(java.util.List) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Map(java.util.Map) Matchers.equalTo(org.hamcrest.Matchers.equalTo) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Facet(nl.knaw.huygens.timbuctoo.search.description.facet.Facet) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Set(java.util.Set) FacetGetter(nl.knaw.huygens.timbuctoo.search.description.facet.FacetGetter) Facet(nl.knaw.huygens.timbuctoo.search.description.facet.Facet) Test(org.junit.Test)

Example 4 with FacetGetter

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)));
}
Also used : FacetGetter(nl.knaw.huygens.timbuctoo.search.description.facet.FacetGetter) Set(java.util.Set) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) List(java.util.List) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Map(java.util.Map) Matchers.equalTo(org.hamcrest.Matchers.equalTo) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Facet(nl.knaw.huygens.timbuctoo.search.description.facet.Facet) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Set(java.util.Set) FacetGetter(nl.knaw.huygens.timbuctoo.search.description.facet.FacetGetter) Facet(nl.knaw.huygens.timbuctoo.search.description.facet.Facet) Test(org.junit.Test)

Example 5 with FacetGetter

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)));
}
Also used : FacetGetter(nl.knaw.huygens.timbuctoo.search.description.facet.FacetGetter) Set(java.util.Set) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) PropertyParserFactory(nl.knaw.huygens.timbuctoo.search.description.propertyparser.PropertyParserFactory) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) List(java.util.List) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Map(java.util.Map) Matchers.equalTo(org.hamcrest.Matchers.equalTo) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Gender(nl.knaw.huygens.timbuctoo.model.Gender) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Facet(nl.knaw.huygens.timbuctoo.search.description.facet.Facet) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Set(java.util.Set) FacetGetter(nl.knaw.huygens.timbuctoo.search.description.facet.FacetGetter) Facet(nl.knaw.huygens.timbuctoo.search.description.facet.Facet) Test(org.junit.Test)

Aggregations

Maps (com.google.common.collect.Maps)6 Sets (com.google.common.collect.Sets)6 List (java.util.List)6 Map (java.util.Map)6 Set (java.util.Set)6 Facet (nl.knaw.huygens.timbuctoo.search.description.facet.Facet)6 FacetGetter (nl.knaw.huygens.timbuctoo.search.description.facet.FacetGetter)6 TestGraphBuilder.newGraph (nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph)6 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)6 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)6 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)6 Matchers.equalTo (org.hamcrest.Matchers.equalTo)6 Test (org.junit.Test)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Instant (java.time.Instant)2 LocalDate (java.time.LocalDate)2 ZoneId (java.time.ZoneId)2 DateTimeFormatter (java.time.format.DateTimeFormatter)2 Change (nl.knaw.huygens.timbuctoo.model.Change)2 Gender (nl.knaw.huygens.timbuctoo.model.Gender)2