RelativeDiscountCondition extends AbstractRelativeRangeCondition { public static RelativeDiscountCondition lessThan(final Ratio threshold) { final RangeCondition<Ratio> c = RangeCondition.relativeLessThan(RelativeDiscountCondition::getDiscount, Wrapper::getRemainingPrincipal, threshold); return new RelativeDiscountCondition(c); } private  RelativeDiscountCondition(final RangeCondition<Ratio> condition); static RelativeDiscountCondition lessThan(final Ratio threshold); static RelativeDiscountCondition moreThan(final Ratio threshold); static RelativeDiscountCondition exact(final Ratio minimumThreshold, final Ratio maximumThreshold);  }
@Test void lessThan() { final MarketplaceFilterCondition condition = RelativeDiscountCondition.lessThan(Ratio.fromPercentage(10)); final Wrapper<?> w = mock(Wrapper.class); when(w.getDiscount()).thenReturn(Optional.of(BigDecimal.ONE)); when(w.getRemainingPrincipal()).thenReturn(BigDecimal.TEN); assertThat(condition).rejects(w); when(w.getRemainingPrincipal()).thenReturn(BigDecimal.valueOf(11)); assertThat(condition).accepts(w); }