@Test public void onNumberSetAttributes() throws Exception { testTermStats(FACET.allVariants().attribute().ofNumberSet(ATTR_NAME_NUMBER_SET).allTerms(), termStats -> assertThat(termStats).containsExactly( TermStats.of("5.0", 2L), TermStats.of("10.0", 1L))); }
@Test public void onDateSetAttributes() throws Exception { testTermStats(FACET.allVariants().attribute().ofDateSet(ATTR_NAME_DATE_SET).allTerms(), termStats -> assertThat(termStats).containsExactly( TermStats.of("2001-09-11", 2L), TermStats.of("2002-10-12", 1L))); }
@Test public void onBooleanSetAttributes() throws Exception { testTermStats(FACET.allVariants().attribute().ofBooleanSet(ATTR_NAME_BOOLEAN_SET).allTerms(), termStats -> assertThat(termStats).containsExactly( TermStats.of(BOOL_TRUE, 2L), TermStats.of(BOOL_FALSE, 1L))); }
@Test public void onMoneyAmountSetAttributes() throws Exception { testTermStats(FACET.allVariants().attribute().ofMoneySet(ATTR_NAME_MONEY_SET).centAmount().allTerms(), termStats -> assertThat(termStats).containsExactly( TermStats.of("50000", 2L), TermStats.of("100000", 1L))); }
@Test public void onLocTextSetAttributes() throws Exception { testTermStats(FACET.allVariants().attribute().ofLocalizedStringSet(ATTR_NAME_LOC_TEXT_SET).locale(ENGLISH).allTerms(), termStats -> assertThat(termStats).containsExactly( TermStats.of(LOC_TEXT_FOO.get(ENGLISH), 2L), TermStats.of(LOC_TEXT_BAR.get(ENGLISH), 1L))); }
@Test public void onEnumLabelSetAttributes() throws Exception { testTermStats(FACET.allVariants().attribute().ofEnumSet(ATTR_NAME_ENUM_SET).label().allTerms(), termStats -> assertThat(termStats).containsExactly( TermStats.of(ENUM_TWO.getLabel(), 2L), TermStats.of(ENUM_THREE.getLabel(), 1L))); }
@Test public void onLocEnumKeySetAttributes() throws Exception { testTermStats(FACET.allVariants().attribute().ofLocalizedEnumSet(ATTR_NAME_LOC_ENUM_SET).key().allTerms(), termStats -> assertThat(termStats).containsExactly( TermStats.of(LOC_ENUM_TWO.getKey(), 2L), TermStats.of(LOC_ENUM_THREE.getKey(), 1L))); }
@Test public void onReferenceSetAttributes() throws Exception { testTermStats(FACET.allVariants().attribute().ofReferenceSet(ATTR_NAME_REF_SET).id().allTerms(), termStats -> assertThat(termStats).containsExactly( TermStats.of(productA.getId(), 2L), TermStats.of(productB.getId(), 1L))); }
@Test public void onNumberAttributes() throws Exception { testTermStats(FACET.allVariants().attribute().ofNumber(ATTR_NAME_NUMBER).allTerms(), termStats -> assertThat(termStats).containsOnly( TermStats.of("5.0", 1L), TermStats.of("10.0", 1L))); }
@Test public void onDatetimeAttributes() throws Exception { testTermStats(FACET.allVariants().attribute().ofDateTime(ATTR_NAME_DATE_TIME).allTerms(), termStats -> assertThat(termStats).containsOnly( TermStats.of("2002-10-12T23:06:10.204+0000", 1L), TermStats.of("2001-09-11T22:05:09.203+0000", 1L))); }
@Test public void onDateAttributes() throws Exception { testTermStats(FACET.allVariants().attribute().ofDate(ATTR_NAME_DATE).allTerms(), termStats -> assertThat(termStats).containsOnly( TermStats.of("2001-09-11", 1L), TermStats.of("2002-10-12", 1L))); }
@Test public void onMoneyCurrencyAttributes() throws Exception { testTermStats(FACET.allVariants().attribute().ofMoney(ATTR_NAME_MONEY).currency().allTerms(), termStats -> assertThat(termStats).containsOnly( TermStats.of("EUR", 1L), TermStats.of("USD", 1L))); }
@Test public void onLocEnumLabelSetAttributes() throws Exception { testTermStats(FACET.allVariants().attribute().ofLocalizedEnumSet(ATTR_NAME_LOC_ENUM_SET).label().locale(GERMAN).allTerms(), termStats -> assertThat(termStats).containsExactly( TermStats.of(LOC_ENUM_TWO.getLabel().get(GERMAN), 2L), TermStats.of(LOC_ENUM_THREE.getLabel().get(GERMAN), 1L))); }
@Test public void onLocTextAttributes() throws Exception { testTermStats(FACET.allVariants().attribute().ofLocalizedString(ATTR_NAME_LOC_TEXT).locale(ENGLISH).allTerms(), termStats -> assertThat(termStats).containsOnly( TermStats.of(LOC_TEXT_FOO.get(ENGLISH), 1L), TermStats.of(LOC_TEXT_BAR.get(ENGLISH), 1L))); }
@Test public void onEnumKeyAttributes() throws Exception { testTermStats(FACET.allVariants().attribute().ofEnum(ATTR_NAME_ENUM).key().allTerms(), termStats -> assertThat(termStats).containsOnly( TermStats.of(ENUM_TWO.getKey(), 1L), TermStats.of(ENUM_THREE.getKey(), 1L))); }
@Test public void onEnumLabelAttributes() throws Exception { testTermStats(FACET.allVariants().attribute().ofEnum(ATTR_NAME_ENUM).label().allTerms(), termStats -> assertThat(termStats).containsOnly( TermStats.of(ENUM_TWO.getLabel(), 1L), TermStats.of(ENUM_THREE.getLabel(), 1L))); }
@Test public void onLocEnumKeyAttributes() throws Exception { testTermStats(FACET.allVariants().attribute().ofLocalizedEnum(ATTR_NAME_LOC_ENUM).key().allTerms(), termStats -> assertThat(termStats).containsOnly( TermStats.of(LOC_ENUM_TWO.getKey(), 1L), TermStats.of(LOC_ENUM_THREE.getKey(), 1L))); }
@Test public void onReferenceAttributes() throws Exception { testTermStats(FACET.allVariants().attribute().ofReference(ATTR_NAME_REF).id().allTerms(), termStats -> assertThat(termStats).containsOnly( TermStats.of(productA.getId(), 1L), TermStats.of(productB.getId(), 1L))); }
@Test public void facetedSearchVerboseExample() throws Exception { final ProductProjectionSearch search = ProductProjectionSearch.ofStaged() .plusFacets(facet -> facet.allVariants().attribute().ofString(ATTR_NAME_COLOR).allTerms()) .plusFacets(facet -> facet.allVariants().attribute().ofNumber(ATTR_NAME_SIZE).allTerms()) .plusResultFilters(filter -> filter.allVariants().attribute().ofString(ATTR_NAME_COLOR).is("red")) .plusFacetFilters(filter -> filter.allVariants().attribute().ofString(ATTR_NAME_COLOR).is("red")); testResult(search, ids -> assertThat(ids).containsOnly(product2.getId()), colors -> assertThat(colors).containsOnly(TermStats.of("blue", 2L), TermStats.of("red", 1L)), sizes -> assertThat(sizes).containsOnly(TermStats.of("36.0", 1L))); }
@Test public void onLocEnumLabelAttributes() throws Exception { testTermStats(FACET.allVariants().attribute().ofLocalizedEnum(ATTR_NAME_LOC_ENUM).label().locale(GERMAN).allTerms(), termStats -> assertThat(termStats).containsOnly( TermStats.of(LOC_ENUM_TWO.getLabel().get(GERMAN), 1L), TermStats.of(LOC_ENUM_THREE.getLabel().get(GERMAN), 1L))); }