public PriceDraftBuilder countryCode(@Nullable final String countryCode) { return country(Optional.ofNullable(countryCode).map(CountryCode::valueOf).orElse(null)); }
public PriceDraftBuilder countryCode(@Nullable final String countryCode) { return country(Optional.ofNullable(countryCode).map(CountryCode::valueOf).orElse(null)); }
public PriceDraftDsl withCountry(@Nullable final CountryCode country) { return PriceDraftBuilder.of(this).country(country).build(); }
public PriceDraftDsl withCountry(@Nullable final CountryCode country) { return PriceDraftBuilder.of(this).country(country).build(); }
public PriceDraftDsl withCountry(@Nullable final CountryCode country) { return PriceDraftBuilder.of(this).country(country).build(); }
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 PriceDraftBuilder of(final PriceDraft template) { return of(template.getValue()) .country(template.getCountry()) .customerGroup(template.getCustomerGroup()) .channel(template.getChannel()) .validFrom(template.getValidFrom()) .validUntil(template.getValidUntil()) .custom(template.getCustom()); }
public static PriceDraftBuilder of(final PriceDraft template) { return of(template.getValue()) .country(template.getCountry()) .customerGroup(template.getCustomerGroup()) .channel(template.getChannel()) .validFrom(template.getValidFrom()) .validUntil(template.getValidUntil()) .custom(template.getCustom()); }
public static PriceDraftBuilder of(final PriceDraft template) { return of(template.getValue()) .country(template.getCountry()) .customerGroup(template.getCustomerGroup()) .channel(template.getChannel()) .validFrom(template.getValidFrom()) .validUntil(template.getValidUntil()) .custom(template.getCustom()); }
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(); }
@Test public void setPrices() throws Exception { final PriceDraft expectedPrice1 = PriceDraft.of(MoneyImpl.of(123, EUR)); final PriceDraft expectedPrice2 = PriceDraft.of(MoneyImpl.of(123, EUR)).withCountry(DE); final List<PriceTier> tiers = Arrays.asList(PriceTierBuilder.of(10, EURO_1).build()); final PriceDraft expectedPriceWithTiers = PriceDraftBuilder.of(MoneyImpl.of(123, EUR)) .country(CountryCode.AT) .tiers(tiers) .build(); final List<PriceDraft> expectedPriceList = asList(expectedPrice1, expectedPrice2, expectedPriceWithTiers); withUpdateableProduct(client(), product -> { assertThat(product.getMasterData().hasStagedChanges()).isFalse(); final Product updatedProduct = client() .executeBlocking(ProductUpdateCommand.of(product, SetPrices.of(1, expectedPriceList))); final List<Price> prices = updatedProduct.getMasterData().getStaged().getMasterVariant().getPrices(); List<PriceDraft> draftPricesList = prices.stream().map(PriceDraft::of).collect(toList()); assertThat(draftPricesList).containsOnly(expectedPrice1, expectedPrice2, expectedPriceWithTiers); assertThat(updatedProduct.getMasterData().hasStagedChanges()).isTrue(); return updatedProduct; }); }