.as("result of getThriftFieldIsLegacyId on " + f) .isEqualTo(expected);
.as("result of getThriftFieldIsLegacyId on " + f) .isEqualTo(expected);
private static void compareFieldDefinitions(final JsonField expectedField, final JsonField actualField) { final Optional<JsonFieldDefinition> expectedFieldDefinition = expectedField.getDefinition(); final Optional<JsonFieldDefinition> actualFieldDefinition = actualField.getDefinition(); if (expectedFieldDefinition.isPresent()) { Assertions.assertThat(actualFieldDefinition) .overridingErrorMessage("Expected JsonField <%s> to have definition <%s> but it had " + "none", expectedField.getKey(), expectedFieldDefinition.get()) .isPresent(); Assertions.assertThat(expectedFieldDefinition) .as("Definitions of JsonField <%s> are equal", expectedField.getKey()) .contains(actualFieldDefinition.get()); } }
private <T> void optional(final LoanBuilder builder, final Function<T, LoanBuilder> setter, final Supplier<Optional<T>> getter, final T value) { assertThat(getter.get()).isEmpty(); final LoanBuilder newBuilder = setter.apply(value); assertSoftly(softly -> { softly.assertThat(newBuilder).as("Setter returned itself.").isSameAs(builder); softly.assertThat(getter.get()).as("Correct value was set.").contains(value); }); }
private <T> void optional(final DevelopmentBuilder builder, final Function<T, DevelopmentBuilder> setter, final Supplier<Optional<T>> getter, final T value) { assertThat(getter.get()).isEmpty(); final DevelopmentBuilder newBuilder = setter.apply(value); assertSoftly(softly -> { softly.assertThat(newBuilder).as("Setter returned itself.").isSameAs(builder); softly.assertThat(getter.get()).as("Correct value was set.").contains(value); }); }
private <T> void optional(final InvestmentBuilder builder, final Function<T, InvestmentBuilder> setter, final Supplier<Optional<T>> getter, final T value) { assertThat(getter.get()).isEmpty(); final InvestmentBuilder newBuilder = setter.apply(value); assertSoftly(softly -> { softly.assertThat(newBuilder).as("Setter returned itself.").isSameAs(builder); softly.assertThat(getter.get()).as("Correct value was set.").contains(value); }); }
final String actionId = expectedAction.getId().get().replace("_id_", generated.getId().get()); final Optional<ConnectorAction> maybeGeneratedAction = generated.actionById(actionId); assertThat(maybeGeneratedAction).as("No action with id: " + actionId + " was generated").isPresent();
final String actionId = expectedAction.getId().get().replace("_id_", generated.getId().get()); final Optional<ConnectorAction> maybeGeneratedAction = generated.findActionById(actionId); assertThat(maybeGeneratedAction).as("No action with id: " + actionId + " was generated").isPresent();
final String actionId = expectedAction.getId().get().replace("_id_", generated.getId().get()); final Optional<ConnectorAction> maybeGeneratedAction = generated.findActionById(actionId); assertThat(maybeGeneratedAction).as("No action with id: " + actionId + " was generated").isPresent();
@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 recalculateAndUpdateProductData() throws Exception { withEmptyCartAndProduct(client(), (emptyCart, product) -> { //create cart with line item final AddLineItem action = AddLineItem.of(product.getId(), MASTER_VARIANT_ID, 1L); final Cart cartWithLineItem = client().executeBlocking(CartUpdateCommand.of(emptyCart, action)); final NamedAttributeAccess<LocalizedEnumValue> colorAttribute = Colors.ATTRIBUTE; final LocalizedEnumValue oldColor = cartWithLineItem.getLineItems().get(0).getVariant().findAttribute(colorAttribute).get(); //update the product final LocalizedEnumValue newValueForColor = Colors.RED; final SetAttribute localizedEnumUpdate = SetAttribute.of(MASTER_VARIANT_ID, colorAttribute, newValueForColor); final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(product, asList(localizedEnumUpdate, Publish.of()))); assertThat(updatedProduct.getMasterData().getCurrent().getMasterVariant().findAttribute(colorAttribute)).contains(newValueForColor); //check the line item in the cart, the product data will not be updated final LineItem lineItemOfTheChangedProduct = client().executeBlocking(CartByIdGet.of(cartWithLineItem)).getLineItems().get(0); assertThat(lineItemOfTheChangedProduct.getVariant().findAttribute(colorAttribute)) .as("the new product attribute value is not automatically propagated to the line item in the cart") .contains(oldColor); //use recalculate with updateProductData flag, the product data will be updated final Cart recalculatedCart = client().executeBlocking(CartUpdateCommand.of(cartWithLineItem, Recalculate.of().withUpdateProductData(Boolean.TRUE))); assertThat(recalculatedCart.getLineItems().get(0).getVariant().findAttribute(colorAttribute)) .contains(newValueForColor); }); }