public ProductDraftDsl withName(final LocalizedString name) { return newBuilder().name(name).build(); }
@Test public void nameLocale() { checkFilter(builder -> builder.name(LocalizedString.of(Locale.GERMAN, "foo")), m -> m.name().locale(Locale.GERMAN)); }
@Test public void searchByFullLocale() { final Locale austria = Locale.forLanguageTag("de-AT"); final String marille = "Marille"; final LocalizedString apricot = LocalizedString .of(GERMAN, "Aprikose") .plus(austria, marille) .plus(ENGLISH, "apricot"); withProduct(client(), productBuilder -> productBuilder.name(apricot), product -> { final ProductProjectionSearch austrianSearchRequest = ProductProjectionSearch.ofStaged() .withText(austria, marille) .plusQueryFilters(productModel -> productModel.id().is(product.getId())); final ProductProjectionSearch germanSearchRequest = austrianSearchRequest.withText(GERMAN, marille); assertEventually(() -> { final List<ProductProjection> results = client().executeBlocking(austrianSearchRequest).getResults(); assertThat(results).isNotEmpty(); assertThat(results.get(0).getId()).isEqualTo(product.getId()); assertThat(client().executeBlocking(germanSearchRequest).head()) .as("word is for austria defined and should not be found for just 'de'") .isEmpty(); }); }); } }
@Test public void fuzzyLevel() { final String searchWord = "abcdfgh"; final String productName = "abcdefgh"; withProduct(client(), builder -> builder.name(ofEnglish(productName)), product -> { final ProductProjectionSearch request = ProductProjectionSearch.ofStaged() .withText(ENGLISH, searchWord) .withFuzzy(true); assertEventually(() -> { softAssert(s -> { s.assertThat(client().executeBlocking(request.withFuzzyLevel(0))) .as("level 0 matches not") .doesNotHave(product()); s.assertThat(client().executeBlocking(request.withFuzzyLevel(1))) .as("level 1 matches") .has(product()); s.assertThat(client().executeBlocking(request.withFuzzyLevel(2))) .as("level 2 matches") .has(product()); }); }); }); }