public static PriceDraftBuilder of(final Price template) { return of(template.getValue()) .country(template.getCountry()) .customerGroup(template.getCustomerGroup()) .channel(Optional.ofNullable(template.getChannel()).map(Referenceable::toResourceIdentifier).orElse(null)) .validFrom(template.getValidFrom()) .validUntil(template.getValidUntil()) .custom(copyCustom(template)); } }
public static PriceDraftBuilder of(final Price template) { return of(template.getValue()) .country(template.getCountry()) .customerGroup(template.getCustomerGroup()) .channel(Optional.ofNullable(template.getChannel()).map(Referenceable::toResourceIdentifier).orElse(null)) .validFrom(template.getValidFrom()) .validUntil(template.getValidUntil()) .custom(copyCustom(template)); } }
public static PriceDraftDsl of(final Price template) { final ResourceIdentifier<Channel> channelResourceIdentifier = Optional.ofNullable(template.getChannel()).map(Referenceable::toResourceIdentifier).orElse(null); return PriceDraftBuilder.of(template.getValue()) .country(template.getCountry()) .customerGroup(template.getCustomerGroup()) .channel(channelResourceIdentifier) .validFrom(template.getValidFrom()) .validUntil(template.getValidUntil()) .custom(customFieldsDraftOrNull(template)) .tiers(template.getTiers()) .build(); }
public static PriceDraftDsl of(final Price template) { final ResourceIdentifier<Channel> channelResourceIdentifier = Optional.ofNullable(template.getChannel()).map(Referenceable::toResourceIdentifier).orElse(null); return PriceDraftBuilder.of(template.getValue()) .country(template.getCountry()) .customerGroup(template.getCustomerGroup()) .channel(channelResourceIdentifier) .validFrom(template.getValidFrom()) .validUntil(template.getValidUntil()) .custom(customFieldsDraftOrNull(template)) .tiers(template.getTiers()) .build(); }
public static PriceBuilder of(final Price template) { return of(template.getValue()) .country(template.getCountry()) .customerGroup(template.getCustomerGroup()) .channel(template.getChannel()) .discounted(template.getDiscounted()); }
public static PriceBuilder of(final Price template) { return of(template.getValue()) .country(template.getCountry()) .customerGroup(template.getCustomerGroup()) .channel(template.getChannel()) .discounted(template.getDiscounted()); }
/** * Creates a new object initialized with the fields of the template parameter. * * @param template the template * @return a new object initialized from the template */ public static PriceBuilder of(final Price template) { return new PriceBuilder(template.getChannel(), template.getCountry(), template.getCustom(), template.getCustomerGroup(), template.getDiscounted(), template.getId(), template.getTiers(), template.getValidFrom(), template.getValidUntil(), template.getValue()); } }
public static PriceDraftDsl of(final Price template) { return PriceDraftBuilder.of(template.getValue()) .country(template.getCountry()) .customerGroup(template.getCustomerGroup()) .channel(template.getChannel()) .validFrom(template.getValidFrom()) .validUntil(template.getValidUntil()) .custom(customFieldsDraftOrNull(template)) .build(); }
public static PriceBuilder of(final Price template) { return of(template.getValue()) .country(template.getCountry()) .customerGroup(template.getCustomerGroup()) .channel(template.getChannel()) .discounted(template.getDiscounted()) .validFrom(template.getValidFrom()) .validUntil(template.getValidUntil()) .id(template.getId()); }
@Test public void lineItemModel() throws Exception { withFilledCart(client(), cart -> { final LineItem lineItem = cart.getLineItems().get(0); final String englishName = lineItem.getName().get(Locale.ENGLISH); final Price price = lineItem.getPrice(); final Long centAmount = price.getValue().query(MonetaryQueries.convertMinorPart()); final ItemState itemState = lineItem.getState().stream().findFirst().get(); final CartQuery query = CartQuery.of() .withLimit(1L) .withPredicates(m -> m.lineItems().id().is(lineItem.getId()) .and(m.lineItems().quantity().is(lineItem.getQuantity())) .and(m.lineItems().productId().is(lineItem.getProductId())) .and(m.lineItems().name().locale(ENGLISH).is(englishName)) .and(m.lineItems().variant().sku().is(lineItem.getVariant().getSku())) .and(m.lineItems().price().discounted().isNotPresent()) .and(m.lineItems().price().id().is(price.getId())) .and(m.lineItems().price().value().centAmount().is(centAmount)) .and(m.lineItems().price().country().is(price.getCountry())) .and(m.lineItems().state().quantity().is(itemState.getQuantity())) .and(m.lineItems().state().state().is(itemState.getState())) ); final CartQuery cartQuery = query.plusPredicates(m -> m.id().is(cart.getId())); final Cart loadedCart = client().executeBlocking(cartQuery).head().get(); assertThat(loadedCart.getId()).isEqualTo(cart.getId()); }); }