default CategoryQuery bySlug(final Locale locale, final String slug) { return withPredicates(m -> m.slug().lang(locale).is(slug)); }
public LocalizedStringQuerySortingModel<Category> slug() { return LocalizedStringQuerySortingModel.<Category>of(this, "slug"); }
@Test public void execution2() throws Exception { withProduct(client(), product -> { final String slug = product.getMasterData().getStaged().getSlug().get(Locale.ENGLISH); final ProductProjectionQuery normalSphereRequest = ProductProjectionQuery.ofStaged() .withPredicates(m -> m.slug().locale(Locale.ENGLISH).is(slug)) .plusExpansionPaths(m -> m.productType()); final JsonNodeSphereRequest jsonNodeSphereRequest = JsonNodeSphereRequest.of(normalSphereRequest); assertThat(normalSphereRequest.httpRequestIntent()) .as("a JsonNodeSphereRequest creates the same request to the platform, but differs in the response") .isEqualTo(jsonNodeSphereRequest.httpRequestIntent()); final PagedQueryResult<ProductProjection> productProjectionPagedSearchResult = client().executeBlocking(normalSphereRequest); final JsonNode jsonNode = client().executeBlocking(jsonNodeSphereRequest);//all will be returned as JSON assertThat(jsonNode.get("results").get(0).get("productType").get("obj").get("description").asText()) .as("the expansion paths are honored") .isEqualTo("a 'T' shaped cloth"); }); } }
@BeforeClass public static void clean() { client().executeBlocking(ProductDiscountQuery.of().withPredicates(m -> m.name().locale(ENGLISH).is("example product discount"))) .getResults() .forEach(discount -> client().executeBlocking(ProductDiscountDeleteCommand.of(discount))); }
default CategoryQuery bySlug(final Locale locale, final String slug) { return withPredicates(m -> m.slug().lang(locale).is(slug)); }
@Test public void name() { final CategoryQueryBuilder builder = CategoryQueryBuilder.of() .predicates(m -> m.id().is("f")) .fetchTotal(true) .limit(2) .offset(5) .plusPredicates(m -> m.name().locale(Locale.ENGLISH).is("bar")) .sort(m -> m.slug().locale(Locale.ENGLISH).sort().desc()) .plusExpansionPaths(m -> m.parent()); final CategoryQuery actual = builder.build(); final CategoryQuery expected = CategoryQuery.of().byId("f") .withFetchTotal(true) .withLimit(2) .withOffset(5) .plusPredicates(m -> m.name().locale(Locale.ENGLISH).is("bar")) .withSort(m -> m.slug().locale(Locale.ENGLISH).sort().desc()) .plusExpansionPaths(m -> m.parent()); assertThat(actual).isEqualTo(expected); } }
public LocalizedStringQuerySortingModel<Category> name() { return LocalizedStringQuerySortingModel.<Category>of(this, "name"); }
default CategoryQuery byName(final Locale locale, final String name) { return withPredicates(m -> m.name().lang(locale).is(name)); }
@BeforeClass public static void clean() { deleteDiscountCodesAndCartDiscounts(client()); client().executeBlocking(CartDiscountQuery.of().withPredicates(m -> m.name().locale(ENGLISH).is("sample cart discount"))) .getResults().forEach(discount -> client().executeBlocking(CartDiscountDeleteCommand.of(discount))); }
default ProductProjectionQuery bySlug(final Locale locale, final String slug) { return withPredicates(m -> m.slug().lang(locale).is(slug)); }
.and(m.paymentMethodInfo().method().is(paymentMethodInfo.getMethod())) .and(m.paymentMethodInfo().paymentInterface().is(paymentMethodInfo.getPaymentInterface())) .and(m.paymentMethodInfo().name().locale(ENGLISH).is(paymentMethodInfo.getName().get(ENGLISH))) .and(m.custom().type().is(type)) .and(m.paymentStatus().interfaceCode().is(paymentStatus.getInterfaceCode()))
default CategoryQuery byName(final Locale locale, final String name) { return withPredicates(m -> m.name().lang(locale).is(name)); }
default ProductProjectionQuery bySlug(final Locale locale, final String slug) { return withPredicates(m -> m.slug().lang(locale).is(slug)); }
default ProductProjectionQuery bySlug(final Locale locale, final String slug) { return withPredicates(m -> m.slug().lang(locale).is(slug)); }
public QueryDsl<Category> bySlug(final Locale locale, final String slug) { return withPredicate(model().slug().lang(locale).is(slug)); }
public QueryDsl<Category> byName(final Locale locale, final String name) { return withPredicate(model().name().lang(locale).is(name)); }
@Test public void isIn() throws Exception { assertThat(model.lang(Locale.ENGLISH).isIn(asList("foo", "bar")).toSphereQuery()) .isEqualTo("thepath(en in (\"foo\", \"bar\"))"); }
@Test public void lang() throws Exception { assertThat(model.lang(Locale.ENGLISH).is("bar").toSphereQuery()) .isEqualTo("thepath(en=\"bar\")"); }
@Test public void isNot() throws Exception { assertThat(model.lang(Locale.ENGLISH).isNot("bar").toSphereQuery()) .isEqualTo("thepath(en<>\"bar\")"); } }
@Test public void isNotInPredicates() throws Exception { final QueryPredicate<Category> predicate = CategoryQueryModel.of().name().lang(Locale.ENGLISH).isNotIn(asList("x10", "x2")); final Consumer<List<Category>> assertions = categories -> { final List<String> names = categories.stream().map(c -> c.getName().get(Locale.ENGLISH)).collect(toList()); assertThat(names).contains("x1"); assertThat(names.contains("x2")).isFalse(); assertThat(names.contains("x10")).isFalse(); }; predicateTestCase(predicate, assertions); }