public MultiValueSortSearchModel<ProductProjection> ofNumberSet(final String attributeName) { return ofNumber(attributeName); }
public MultiValueSortSearchModel<ProductProjection> ofNumberSet(final String attributeName) { return ofNumber(attributeName); }
public MultiValueSortSearchModel<ProductProjection> 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 onNumberAttributes() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().attribute().ofNumber(ATTR_NAME_NUMBER).desc(), ids -> assertThat(ids).containsExactly(product2.getId(), product1.getId())); }
@Test public void sortByAttributeAscending() throws Exception { final ProductProjectionSearch search = ProductProjectionSearch.ofStaged() .withSort(productModel -> productModel.allVariants().attribute().ofNumber(ATTR_NAME_SIZE).asc()); testResultIds(search, resultIds -> assertThat(resultIds).containsExactly(product2.getId(), product1.getId(), product3.getId())); }
@Test public void sortWithAdditionalParameterByAttributeDescending() throws Exception { final ProductProjectionSearch search = ProductProjectionSearch.ofStaged() .withSort(productModel -> productModel.allVariants().attribute().ofNumber(ATTR_NAME_SIZE).descWithMinValue()); testResultIds(search, resultIds -> assertThat(resultIds).containsExactly(product3.getId(), product1.getId(), product2.getId())); }
@Test public void sortWithAdditionalParameterByAttributeAscending() throws Exception { final ProductProjectionSearch search = ProductProjectionSearch.ofStaged() .withSort(productModel -> productModel.allVariants().attribute().ofNumber(ATTR_NAME_SIZE).ascWithMaxValue()); testResultIds(search, resultIds -> assertThat(resultIds).containsExactly(product3.getId(), product2.getId(), product1.getId())); }
@Test public void sortByAttributeDescending() throws Exception { final ProductProjectionSearch search = ProductProjectionSearch.ofStaged() .withSort(productModel -> productModel.allVariants().attribute().ofNumber(ATTR_NAME_SIZE).desc()); testResultIds(search, resultIds -> assertThat(resultIds).containsExactly(product1.getId(), product2.getId(), product3.getId())); }
@Ignore // HTTP API still not having sort associated to matching variant flag @Test public void findMatchingVariantBySort() throws Exception { final ProductProjectionSearch search = ProductProjectionSearch.ofStaged() .withSort(productModel -> productModel.allVariants().attribute().ofNumber(ATTR_NAME_SIZE).ascWithMaxValue()); testResult(search, result -> assertThat(result.getResults()).are(productWithMatchingVariantsHavingMaxSize())); }