@Test public void onSku() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().sku().asc(), ids -> assertThat(ids).containsExactly(product1.getId(), product2.getId())); } @Test
@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 onBooleanAttributes() throws Exception { testProductIds(PRODUCT_MODEL.allVariants().attribute().ofBoolean(ATTR_NAME_BOOLEAN).asc(), ids -> assertThat(ids).containsExactly(product2.getId(), product1.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 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 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 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 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 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 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 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 channelsRestockableSortDsl() { final StringHttpRequestBody body = (StringHttpRequestBody) ProductProjectionSearch.ofStaged(). plusSort(m -> m.allVariants().availability().channels().channelId("channel-id-500").restockableInDays().asc()).httpRequestIntent().getBody(); assertThat(body.getString()).contains("sort=variants.availability.channels.channel-id-500.restockableInDays+asc"); }