Search in sources :

Example 6 with FacetGetter

use of nl.knaw.huygens.timbuctoo.search.description.facet.FacetGetter in project timbuctoo by HuygensING.

the class ListFacetGetterTest method getFacetReturnsParsedValueKeysAndTheirCounts.

@Test
public void getFacetReturnsParsedValueKeysAndTheirCounts() {
    FacetGetter instance = new ListFacetGetter(new PropertyParserFactory().getParser(Gender.class));
    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("\"MALE\"", Sets.newHashSet(vertices1));
    values.put("\"FEMALE\"", Sets.newHashSet(vertices2));
    Facet facet = instance.getFacet(FACET_NAME, values);
    assertThat(facet.getName(), equalTo(FACET_NAME));
    assertThat(facet.getOptions(), containsInAnyOrder(new Facet.DefaultOption("MALE", 2), new Facet.DefaultOption("FEMALE", 1)));
}
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) Gender(nl.knaw.huygens.timbuctoo.model.Gender) PropertyParserFactory(nl.knaw.huygens.timbuctoo.search.description.propertyparser.PropertyParserFactory) 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