@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))); }
@Override public Facet getFacet(String facetName, Map<String, Set<Vertex>> values) { long lowerLimit = 0; long upperLimit = 0; for (String key : values.keySet()) { Datable datable = getDatable(key); if (datable.isValid()) { long fromDate = Long.valueOf(FORMAT.format(datable.getFromDate())); long toDate = Long.valueOf(FORMAT.format(datable.getToDate())); if (toDate > upperLimit) { upperLimit = toDate; } if (lowerLimit == 0 || fromDate < lowerLimit) { lowerLimit = fromDate; } } } return new Facet(facetName, Lists.newArrayList(new Facet.RangeOption(lowerLimit, upperLimit)), "RANGE"); }
DatableRangeFacetGetter implements FacetGetter { @Override public Facet getFacet(String facetName, Map<String, Set<Vertex>> values) { long lowerLimit = 0; long upperLimit = 0; for (String key : values.keySet()) { Datable datable = getDatable(key); if (datable.isValid()) { long fromDate = Long.valueOf(FORMAT.format(datable.getFromDate())); long toDate = Long.valueOf(FORMAT.format(datable.getToDate())); if (toDate > upperLimit) { upperLimit = toDate; } if (lowerLimit == 0 || fromDate < lowerLimit) { lowerLimit = fromDate; } } } return new Facet(facetName, Lists.newArrayList(new Facet.RangeOption(lowerLimit, upperLimit)), "RANGE"); } }
DatableRangeFacetGetter implements FacetGetter { @Override public Facet getFacet(String facetName, Map<String, Set<Vertex>> values) { long lowerLimit = 0; long upperLimit = 0; for (String key : values.keySet()) { Datable datable = getDatable(key); if (datable.isValid()) { long fromDate = Long.valueOf(FORMAT.format(datable.getFromDate())); long toDate = Long.valueOf(FORMAT.format(datable.getToDate())); if (toDate > upperLimit) { upperLimit = toDate; } if (lowerLimit == 0 || fromDate < lowerLimit) { lowerLimit = fromDate; } } } return new Facet(facetName, Lists.newArrayList(new Facet.RangeOption(lowerLimit, upperLimit)), "RANGE"); }  }
DatableRangeFacetGetter implements FacetGetter { @Override public Facet getFacet(String facetName, Map<String, Set<Vertex>> values) { long lowerLimit = 0; long upperLimit = 0; for (String key : values.keySet()) { Datable datable = getDatable(key); if (datable.isValid()) { long fromDate = Long.valueOf(FORMAT.format(datable.getFromDate())); long toDate = Long.valueOf(FORMAT.format(datable.getToDate())); if (toDate > upperLimit) { upperLimit = toDate; } if (lowerLimit == 0 || fromDate < lowerLimit) { lowerLimit = fromDate; } } } return new Facet(facetName, Lists.newArrayList(new Facet.RangeOption(lowerLimit, upperLimit)), "RANGE"); }  @Override Facet getFacet(String facetName, Map<String, Set<Vertex>> values); }
DatableRangeFacetGetter implements FacetGetter { @Override public Facet getFacet(String facetName, Map<String, Set<Vertex>> values) { long lowerLimit = 0; long upperLimit = 0; for (String key : values.keySet()) { Datable datable = getDatable(key); if (datable.isValid()) { long fromDate = Long.valueOf(FORMAT.format(datable.getFromDate())); long toDate = Long.valueOf(FORMAT.format(datable.getToDate())); if (toDate > upperLimit) { upperLimit = toDate; } if (lowerLimit == 0 || fromDate < lowerLimit) { lowerLimit = fromDate; } } } return new Facet(facetName, Lists.newArrayList(new Facet.RangeOption(lowerLimit, upperLimit)), "RANGE"); }  @Override Facet getFacet(String facetName, Map<String, Set<Vertex>> values);  }