@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))); }
@Override public Facet getFacet(String facetName, Map<String, Set<Vertex>> values) { long lowerLimit = 0; long upperLimit = 0; for (String key : values.keySet()) { try { LocalDate localDate = getChangeLocalDate(key); long dateStamp = Long.valueOf(FORMATTER.format(localDate)); if (dateStamp > upperLimit) { upperLimit = dateStamp; } if (lowerLimit == 0 || dateStamp < lowerLimit) { lowerLimit = dateStamp; } } catch (IOException e) { LOG.error("'{}' is not a valid change.", key); } } return new Facet(facetName, Lists.newArrayList(new Facet.RangeOption(lowerLimit, upperLimit)), "RANGE"); }
ChangeRangeFacetGetter implements FacetGetter { @Override public Facet getFacet(String facetName, Map<String, Set<Vertex>> values) { long lowerLimit = 0; long upperLimit = 0; for (String key : values.keySet()) { try { LocalDate localDate = getChangeLocalDate(key); long dateStamp = Long.valueOf(FORMATTER.format(localDate)); if (dateStamp > upperLimit) { upperLimit = dateStamp; } if (lowerLimit == 0 || dateStamp < lowerLimit) { lowerLimit = dateStamp; } } catch (IOException e) { LOG.error("'{}' is not a valid change.", key); } } return new Facet(facetName, Lists.newArrayList(new Facet.RangeOption(lowerLimit, upperLimit)), "RANGE"); } }
ChangeRangeFacetGetter implements FacetGetter { @Override public Facet getFacet(String facetName, Map<String, Set<Vertex>> values) { long lowerLimit = 0; long upperLimit = 0; for (String key : values.keySet()) { try { LocalDate localDate = getChangeLocalDate(key); long dateStamp = Long.valueOf(FORMATTER.format(localDate)); if (dateStamp > upperLimit) { upperLimit = dateStamp; } if (lowerLimit == 0 || dateStamp < lowerLimit) { lowerLimit = dateStamp; } } catch (IOException e) { LOG.error("'{}' is not a valid change.", key); } } return new Facet(facetName, Lists.newArrayList(new Facet.RangeOption(lowerLimit, upperLimit)), "RANGE"); }  }
ChangeRangeFacetGetter implements FacetGetter { @Override public Facet getFacet(String facetName, Map<String, Set<Vertex>> values) { long lowerLimit = 0; long upperLimit = 0; for (String key : values.keySet()) { try { LocalDate localDate = getChangeLocalDate(key); long dateStamp = Long.valueOf(FORMATTER.format(localDate)); if (dateStamp > upperLimit) { upperLimit = dateStamp; } if (lowerLimit == 0 || dateStamp < lowerLimit) { lowerLimit = dateStamp; } } catch (IOException e) { LOG.error("'{}' is not a valid change.", key); } } return new Facet(facetName, Lists.newArrayList(new Facet.RangeOption(lowerLimit, upperLimit)), "RANGE"); }  @Override Facet getFacet(String facetName, Map<String, Set<Vertex>> values); }
ChangeRangeFacetGetter implements FacetGetter { @Override public Facet getFacet(String facetName, Map<String, Set<Vertex>> values) { long lowerLimit = 0; long upperLimit = 0; for (String key : values.keySet()) { try { LocalDate localDate = getChangeLocalDate(key); long dateStamp = Long.valueOf(FORMATTER.format(localDate)); if (dateStamp > upperLimit) { upperLimit = dateStamp; } if (lowerLimit == 0 || dateStamp < lowerLimit) { lowerLimit = dateStamp; } } catch (IOException e) { LOG.error("'{}' is not a valid change.", key); } } return new Facet(facetName, Lists.newArrayList(new Facet.RangeOption(lowerLimit, upperLimit)), "RANGE"); }  @Override Facet getFacet(String facetName, Map<String, Set<Vertex>> values); static final DateTimeFormatter FORMATTER; static final Logger LOG; }