@Test public void canAccessPriceAmount() throws Exception { assertThat(FACET_MODEL.allVariants().price().centAmount().allTerms().expression()).isEqualTo("variants.price.centAmount"); assertThat(FILTER_MODEL.allVariants().price().centAmount().is(1000L)).extracting(expression()).containsExactly("variants.price.centAmount:1000"); assertThat(SORT_MODEL.allVariants().price().descWithMinValue().expression()).isEqualTo("price desc.min"); }
@Test public void canAccessPriceCurrency() throws Exception { assertThat(FACET_MODEL.allVariants().price().currency().allTerms().expression()).isEqualTo("variants.price.currencyCode"); assertThat(FILTER_MODEL.allVariants().price().currency().is(currency("EUR"))).extracting(expression()).containsExactly("variants.price.currencyCode:\"EUR\""); }
@Test public void responseContainsRangeFacetsForAttributes() throws Exception { final RangeFacetExpression<ProductProjection> facetExpr = PRODUCT_MODEL.allVariants().price().centAmount().onlyGreaterThanOrEqualTo(0L); final ProductProjectionSearch search = ProductProjectionSearch.ofStaged().plusFacets(facetExpr); testResult(search, result -> assertThat(result.getFacetResult(facetExpr).getRanges().get(0).getCount()).isGreaterThan(0)); }
@Test public void searchRequestIsAsExpected() { final ProductProjectionSearch actual = ProductProjectionSearchBuilder.ofCurrent() .facets(m -> m.allVariants().price().centAmount().allRanges()) .queryFilters(m -> m.allVariants().price().centAmount().isGreaterThanOrEqualTo(4L)) .sort(m -> m.createdAt().asc()) .expansionPaths(m -> m.categories()) .build(); final ProductProjectionSearch expected = ProductProjectionSearch.ofCurrent() .withFacets(m -> m.allVariants().price().centAmount().allRanges()) .withQueryFilters(m -> m.allVariants().price().centAmount().isGreaterThanOrEqualTo(4L)) .withSort(m -> m.createdAt().asc()) .withExpansionPaths(m -> m.categories()); assertThat(actual).isEqualTo(expected); } }