InsuranceCondition extends MarketplaceFilterConditionImpl { @Override public Optional<String> getDescription() { return Optional.of("With insurance."); } private  InsuranceCondition(); @Override Optional<String> getDescription(); @Override boolean test(final Wrapper<?> wrapper); static final MarketplaceFilterCondition ACTIVE; }
@Test void basic() { final LoanImpl loan = new MockLoanBuilder() .set(LoanImpl::setInsuranceActive, true) .build(); final Wrapper<?> wrap = Wrapper.wrap(new LoanDescriptor(loan), FOLIO); assertSoftly(softly -> { softly.assertThat(InsuranceCondition.ACTIVE) .accepts(wrap); softly.assertThat(InsuranceCondition.ACTIVE.getDescription()) .contains("With insurance."); softly.assertThat(InsuranceCondition.INACTIVE) .rejects(wrap); }); }
@Test void negation() { final Optional<String> activeDescription = InsuranceCondition.ACTIVE.getDescription(); final Optional<String> inactiveDescription = InsuranceCondition.INACTIVE.getDescription(); assertThat(inactiveDescription).contains("NOT " + activeDescription.get()); }