@Test
public void facetSearchByScopedPriceDiscounted() {
withProductOfPrices(asList(PriceDraft.of(EURO_20), PriceDraft.of(EURO_30).withCountry(DE)), product1 -> {
withProductOfPrices(asList(PriceDraft.of(EURO_30), PriceDraft.of(EURO_40).withCountry(DE)), product2 -> {
withProductOfPrices(asList(PriceDraft.of(EURO_40), PriceDraft.of(EURO_25).withCountry(DE)), product3 -> {
final ProductDiscountDraft productDiscountDraft1 = discountDraftOfAbsoluteValue(product1, EURO_5);
withProductDiscount(client(), productDiscountDraft1, productDiscount1 -> {
assertEventually(s -> {
final TermFacetExpression<ProductProjection> facetExpression = ProductProjectionSearchModel.of()
.facet().allVariants().scopedPriceDiscounted().allTerms();
final ProductProjectionSearch search = ProductProjectionSearch.ofStaged()
.withPriceSelection(PriceSelection.of(EUR).withPriceCountry(DE))
.plusQueryFilters(m -> m.id().isIn(asList(product1.getId(), product2.getId(), product3.getId())))
.withFacets(facetExpression);
final PagedSearchResult<ProductProjection> results = client().executeBlocking(search);
assertThat(results.getResults()).hasSize(3);
final List<TermStats> termStats = results.getFacetResult(facetExpression).getTerms();
s.assertThat(termStats).containsOnly(
TermStats.of(BOOL_TRUE, 1L),
TermStats.of(BOOL_FALSE, 2L));
});
});
});
});
});
}