@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 onBooleanSetAttributes() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().attribute().ofBooleanSet(ATTR_NAME_BOOLEAN_SET).asc(), ids -> assertThat(ids).containsExactly(product1.getId(), product2.getId())); }
@Test public void onDateAttributes() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().attribute().ofDate(ATTR_NAME_DATE).desc(), ids -> assertThat(ids).containsExactly(product2.getId(), product1.getId())); }
@Test public void onDateTimeAttributes() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().attribute().ofDateTime(ATTR_NAME_DATE_TIME).desc(), ids -> assertThat(ids).containsExactly(product2.getId(), product1.getId())); }
@Test public void onTextSetAttributes() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().attribute().ofStringSet(ATTR_NAME_TEXT_SET).asc(), ids -> assertThat(ids).containsExactly(product1.getId(), product2.getId())); }
@Test public void onDateSetAttributes() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().attribute().ofDateSet(ATTR_NAME_DATE_SET).desc(), ids -> assertThat(ids).containsExactly(product1.getId(), product2.getId())); }
@Test public void onNumberSetAttributes() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().attribute().ofNumberSet(ATTR_NAME_NUMBER_SET).desc(), ids -> assertThat(ids).containsExactly(product1.getId(), product2.getId())); }
@Test public void onTimeSetAttributes() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().attribute().ofTimeSet(ATTR_NAME_TIME_SET).desc(), ids -> assertThat(ids).containsExactly(product1.getId(), product2.getId())); }
@Test public void onDateTimeSetAttributes() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().attribute().ofDateTimeSet(ATTR_NAME_DATE_TIME_SET).desc(), ids -> assertThat(ids).containsExactly(product1.getId(), product2.getId())); }
@Test public void onLocEnumKeyAttributes() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().attribute().ofLocalizedEnum(ATTR_NAME_LOC_ENUM).key().asc(), ids -> assertThat(ids).containsExactly(product2.getId(), product1.getId())); }
@Test public void onMoneyAmountAttributes() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().attribute().ofMoney(ATTR_NAME_MONEY).centAmount().desc(), ids -> assertThat(ids).containsExactly(product2.getId(), product1.getId())); }
@Test public void onMoneyCurrencyAttributes() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().attribute().ofMoney(ATTR_NAME_MONEY).currency().desc(), ids -> assertThat(ids).containsExactly(product2.getId(), product1.getId())); }
@Test public void onLocTextSetAttributes() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().attribute().ofLocalizedStringSet(ATTR_NAME_LOC_TEXT_SET).locale(ENGLISH).asc(), ids -> assertThat(ids).containsExactly(product1.getId(), product2.getId())); }
@Test public void onEnumLabelAttributes() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().attribute().ofEnum(ATTR_NAME_ENUM).label().asc(), ids -> assertThat(ids).containsExactly(product2.getId(), product1.getId())); }
@Test public void onEnumLabelSetAttributes() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().attribute().ofEnumSet(ATTR_NAME_ENUM_SET).label().asc(), ids -> assertThat(ids).containsExactly(product1.getId(), product2.getId())); }
@Test public void onLocEnumLabelSetAttributes() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().attribute().ofLocalizedEnumSet(ATTR_NAME_LOC_ENUM_SET).label().locale(GERMAN).asc(), ids -> assertThat(ids).containsExactly(product1.getId(), product2.getId())); }
@Test public void onLocEnumLabelAttributes() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().attribute().ofLocalizedEnum(ATTR_NAME_LOC_ENUM).label().locale(GERMAN).asc(), 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 sortByMultipleAttributes() throws Exception { final ProductProjectionSearch singleSortedRequest = ProductProjectionSearch.ofStaged() .plusSort(productModel -> productModel.allVariants().attribute().ofString(ATTR_NAME_COLOR).asc()); final ProductProjectionSearch searchWithNameAsc = singleSortedRequest .plusSort(productModel -> productModel.name().locale(ENGLISH).asc()); testResultIds(searchWithNameAsc, resultIds -> assertThat(resultIds).containsExactly(product3.getId(), product1.getId(), product2.getId())); final ProductProjectionSearch searchWithNameDesc = singleSortedRequest .plusSort(productModel -> productModel.name().locale(ENGLISH).desc()); testResultIds(searchWithNameDesc, resultIds -> assertThat(resultIds).containsExactly(product1.getId(), product3.getId(), product2.getId())); }