default ShippingMethodQuery byIsDefault() { return withPredicates(m -> m.isDefault().is(true)); } }
public BooleanQueryModel<ProductProjection> hasStagedChanges() { return new BooleanQueryModel<>(Optional.of(this), "hasStagedChanges"); } }
default ShippingMethodQuery byIsDefault() { return withPredicates(m -> m.isDefault().is(true)); }
public BooleanQueryModel<ShippingMethod> isDefault() { return new BooleanQueryModel<>(Optional.of(this), "isDefault"); } }
public QueryDsl<ShippingMethod> byIsDefault() { return withPredicate(model().isDefault().is(true)); } }
public BooleanQueryModel<Customer> isEmailVerified() { return new BooleanQueryModel<>(Optional.of(this), "isEmailVerified"); }
@Test public void queryByPlainBooleanValue() { final boolean value = true; checkSimpleQuery(value, Boolean.class, m -> m.value().ofJsonValue().ofBoolean().is(value), jsonNode -> assertThat(jsonNode.asBoolean()).isEqualTo(value)); }
public BooleanQueryModel<ProductProjection> hasStagedChanges() { return new BooleanQueryModel<>(Optional.of(this), "hasStagedChanges"); }
@Test public void queryByBoolean() { checkQuery(fields -> fields.ofBoolean(BOOLEAN_FIELD_NAME).is(true)); }
@Test public void isEmailVerified() throws Exception { check((model) -> model.isEmailVerified().is(false), false); }
private void checkIsFoundByPublishedFlag(final Product product, final boolean value) { final Optional<Product> productFromQuery = client().executeBlocking(ProductQuery.of() .withPredicates(m -> { return m.masterData().isPublished().is(value); }) .plusPredicates(m -> m.id().is(product.getId()))).head(); assertThat(productFromQuery.get().getId()).isEqualTo(product.getId()); }
@Test public void execution() throws Exception { withUpdateableProductDiscount(client(), productDiscount -> { final ProductDiscountQuery discountQuery = ProductDiscountQuery.of() .withPredicates(m -> m.active().is(true).and(m.id().is(productDiscount.getId()))) .withExpansionPaths(m -> m.references()); final ProductDiscount loadedDiscount = client().executeBlocking(discountQuery).head().get(); assertThat(loadedDiscount.getId()).isEqualTo(productDiscount.getId()); assertThat(loadedDiscount.getReferences().size()).isGreaterThanOrEqualTo(1); assertThat(loadedDiscount.getReferences().stream() .filter(ref -> ref.getTypeId().equals(Product.referenceTypeId())) .findFirst() .get() ) .overridingErrorMessage("one product is expanded") .matches(ref -> ref.getObj() != null); return productDiscount; }); } }
@Test public void getApprovedReviewsForOneProduct() { final String productId = product.getId(); final ReviewQuery reviewQuery = ReviewQuery.of() .withPredicates(review -> review.includedInStatistics().is(true).and(review.target().id().is(productId))) .withSort(m -> m.createdAt().sort().desc()) .withLimit(REVIEWS_PER_PRODUCT); final List<Review> reviews = client().executeBlocking(reviewQuery).getResults(); assertThat(reviews).hasSize(REVIEWS_PER_PRODUCT); assertThat(reviews).extracting(r -> r.getTarget().getId()).containsOnlyElementsOf(singletonList(productId)); assertThat(reviews).extracting(r -> r.isIncludedInStatistics()).containsOnlyElementsOf(singletonList(true)); }
.plusPredicates(m -> m.value().ofJsonObject().ofJsonObject("sub").ofString("sub-s").is("sub s value")) .plusPredicates(m -> m.value().ofJsonObject().ofJsonObject("sub").ofString("sub-nullable").isNotPresent()) .plusPredicates(m -> m.value().ofJsonObject().ofJsonObject("sub").ofBoolean("sub-boolean").is(true)) .plusPredicates(m -> m.value().ofJsonObject().ofJsonObject("sub").ofInteger("sub-number").is(5)) .plusPredicates(m -> m.value().ofJsonObject().ofJsonObject("sub").ofLong("sub-number").is(5L))
@Test public void queryByHasStagedChanges() throws Exception { withProduct(client(), product -> { final Product updated = client().executeBlocking(ProductUpdateCommand.of(product, ChangeName.of(randomSlug()))); final ProductProjectionQuery query = ProductProjectionQuery.of(STAGED) .withPredicates(m -> m.hasStagedChanges().is(true)) .withSort(m -> m.createdAt().sort().desc()); final PagedQueryResult<ProductProjection> pagedQueryResult = client().executeBlocking(query); assertThat(ids(pagedQueryResult)).contains(updated.getId()); }); }
@Test public void objectNodeInValue() { assertResult(m -> m.value().ofJsonObject().ofString("s").is("s value"), "value(s=\"s value\")"); assertResult(m -> m.value().ofJsonObject().ofJsonObject("sub").ofString("sub-s").is("sub s value"), "value(sub(sub-s=\"sub s value\"))"); assertResult(m -> m.value().ofJsonObject().ofJsonObject("sub").ofString("sub-nullable").isNotPresent(), "value(sub(sub-nullable is not defined))"); assertResult(m -> m.value().ofJsonObject().ofJsonObject("sub").ofBoolean("sub-boolean").is(true), "value(sub(sub-boolean=true))"); assertResult(m -> m.value().ofJsonObject().ofJsonObject("sub").ofStringCollection("arrno").containsAll(asList("foo", "bar")), "value(sub(arrno contains all (\"foo\", \"bar\")))"); }
.plusPredicates(m -> m.rating().is(100)) .plusPredicates(m -> m.state().is(state)) .plusPredicates(m -> m.includedInStatistics().is(true)) .plusPredicates(m -> m.customer().is(customer))
@Test public void shippingMethodQuery() throws Exception { withShippingMethodForGermany(client(), shippingMethod -> { withCart(client(), createCartWithShippingAddress(client()), cart -> { final CartUpdateCommand updateCommand = CartUpdateCommand.of(cart, SetShippingMethod.of(shippingMethod)) .plusExpansionPaths(m -> m.shippingInfo().shippingMethod().taxCategory()) .plusExpansionPaths(m -> m.shippingInfo().taxCategory()); final Cart cartWithShippingMethod = client().executeBlocking(updateCommand); final CartShippingInfo shippingInfo = cartWithShippingMethod.getShippingInfo(); final CartQuery query = CartQuery.of() .plusPredicates(m -> m.id().is(cart.getId())) .plusPredicates(m -> m.shippingInfo().shippingMethodName().is(shippingMethod.getName())) .plusPredicates(m -> m.shippingInfo().price().centAmount().is(MoneyImpl.centAmountOf(shippingInfo.getPrice()))) .plusPredicates(m -> m.shippingInfo().taxRate().name().is(shippingInfo.getTaxRate().getName())) .plusPredicates(m -> m.shippingInfo().taxRate().includedInPrice().is(shippingInfo.getTaxRate().isIncludedInPrice())) .plusPredicates(m -> m.shippingInfo().taxRate().country().is(shippingInfo.getTaxRate().getCountry())) .plusPredicates(m -> m.shippingInfo().shippingMethod().is(shippingMethod)) .plusPredicates(m -> m.shippingInfo().discountedPrice().isNotPresent()); assertThat(client().executeBlocking(query).head().get()).isEqualTo(cartWithShippingMethod); return cartWithShippingMethod; }); }); }