HllSketchIsLessThan extends KoryphePredicate<HllSketch> { @Override public boolean test(final HllSketch input) { if (null == input) { return false; } final long cardinality = Math.round(input.getEstimate()); if (orEqualTo) { return cardinality <= controlValue; } else { return cardinality < controlValue; } } HllSketchIsLessThan();  HllSketchIsLessThan(final long controlValue);  HllSketchIsLessThan(final long controlValue, final boolean orEqualTo); @JsonProperty("value") long getControlValue(); void setControlValue(final long controlValue); boolean getOrEqualTo(); void setOrEqualTo(final boolean orEqualTo); @Override boolean test(final HllSketch input); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString();  }
@Test public void shouldAcceptWhenLessThan() { final HllSketchIsLessThan filter = new HllSketchIsLessThan(15); boolean accepted = filter.test(hllSketchWithCardinality5); assertTrue(accepted); }
@Test public void shouldRejectWhenEqualToAndEqualToIsFalse() { final HllSketchIsLessThan filter = new HllSketchIsLessThan(18); boolean accepted = filter.test(hllSketchWithCardinality18); assertFalse(accepted); }
@Test public void shouldAcceptWhenEqualToAndEqualToIsTrue() { final HllSketchIsLessThan filter = new HllSketchIsLessThan(18, true); boolean accepted = filter.test(hllSketchWithCardinality18); assertTrue(accepted); }
@Test public void shouldRejectWhenMoreThan() { final HllSketchIsLessThan filter = new HllSketchIsLessThan(15); boolean accepted = filter.test(hllSketchWithCardinality32); assertFalse(accepted); }
@Test public void shouldRejectWhenInputIsNull() { final HllSketchIsLessThan filter = new HllSketchIsLessThan(15); boolean accepted = filter.test(null); assertFalse(accepted); }