public RangeTermFilterSearchModel<ProductProjection, BigDecimal> ofNumberSet(final String attributeName) { return ofNumber(attributeName); }
public RangeTermFilterSearchModel<ProductProjection, BigDecimal> ofNumberSet(final String attributeName) { return ofNumber(attributeName); }
public RangeTermFilterSearchModel<ProductProjection, BigDecimal> ofNumberSet(final String attributeName) { return ofNumber(attributeName); }
@Test public void canAccessNumberCustomAttributes() throws Exception { final String attrName = "length"; assertThat(FACET_ATTR.ofNumber(attrName).allTerms().expression()).isEqualTo("variants.attributes.length"); assertThat(FILTER_ATTR.ofNumber(attrName).is(valueOf(4))).extracting(expression()).containsExactly("variants.attributes.length:4"); assertThat(SORT_ATTR.ofNumber(attrName).descWithMinValue().expression()).isEqualTo("variants.attributes.length desc.min"); }
@Test public void filtersByAnyTerm() throws Exception { final ProductProjectionSearch search = ProductProjectionSearch.ofStaged() .plusQueryFilters(productModel -> productModel.allVariants().attribute().ofNumber(ATTR_NAME_SIZE).isIn(asList(valueOf(36), valueOf(38)))); testResultIds(search, resultIds -> assertThat(resultIds).containsOnly(product1.getId(), product2.getId())); }
@Test public void filtersByAllRanges() throws Exception { final ProductProjectionSearch search = ProductProjectionSearch.ofStaged() .plusQueryFilters(productModel -> productModel.allVariants().attribute().ofNumber(ATTR_NAME_SIZE).isBetweenAll(asList(atLeast(valueOf(39)), atMost(valueOf(43))))); testResultIds(search, resultIds -> assertThat(resultIds).containsOnly(product3.getId())); }
@Test public void filtersByAnyRange() throws Exception { final ProductProjectionSearch search = ProductProjectionSearch.ofStaged() .plusQueryFilters(productModel -> productModel.allVariants().attribute().ofNumber(ATTR_NAME_SIZE).isBetweenAny(asList(atLeast(valueOf(46)), atMost(valueOf(36))))); testResultIds(search, resultIds -> assertThat(resultIds).containsOnly(product1.getId(), product2.getId())); }
@Test public void onNumberAttributes() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().attribute().ofNumber(ATTR_NAME_NUMBER).is(NUMBER_5), ids -> assertThat(ids).containsOnly(product1.getId())); }
@Test public void onNumberRangedAttributes() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().attribute().ofNumber(ATTR_NAME_NUMBER).isLessThanOrEqualTo(NUMBER_5), ids -> assertThat(ids).containsOnly(product1.getId())); }
@Test public void filterByValueAsString() throws Exception { final ProductProjectionSearch search = ProductProjectionSearch.ofStaged() .plusQueryFilters(productModel -> productModel.allVariants().attribute().ofNumber(ATTR_NAME_SIZE).containsAnyAsString(asList("36", "38"))); testResultIds(search, resultIds -> assertThat(resultIds).containsOnly(product1.getId(), product2.getId())); }
@Test public void filtersByRange() throws Exception { final ProductProjectionSearch search = ProductProjectionSearch.ofStaged() .plusQueryFilters(productModel -> productModel.allVariants().attribute().ofNumber(ATTR_NAME_SIZE).isGreaterThanOrEqualTo(valueOf(44))); testResultIds(search, resultIds -> assertThat(resultIds).containsOnly(product1.getId(), product2.getId())); }