io.sphere.sdk.models.Reference.toReference()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中io.sphere.sdk.models.Reference.toReference方法的一些代码示例,展示了Reference.toReference的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Reference.toReference方法的具体详情如下:
包路径:io.sphere.sdk.models.Reference
类名称:Reference
方法名:toReference

Reference.toReference介绍

暂无

代码示例

代码示例来源:origin: io.sphere.sdk.jvm/models

@Override
  public JsonNode serialize(final T t) {
    return mapper().valueToTree(t.toReference().filled(Optional.empty()));
  }
}

代码示例来源:origin: io.sphere.sdk.jvm/products

@Override
  public JsonNode serialize(final T t) {
    return mapper().valueToTree(t.toReference().filled(Optional.empty()));
  }
}

代码示例来源:origin: io.sphere.sdk.jvm/sphere-models

@Override
  public JsonNode serialize(final T t) {
    return mapper().valueToTree(t.toReference().filled(null));
  }
}

代码示例来源:origin: com.commercetools.sdk.jvm.core/commercetools-models

@Override
  public JsonNode serialize(final T t) {
    return mapper().valueToTree(t.toReference().filled(null));
  }
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Override
  public JsonNode serialize(final T t) {
    return mapper().valueToTree(t.toReference().filled(null));
  }
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
public void addLineItemOfDraftOfSku() throws Exception {
  withEmptyCartAndProduct(client(), (cart, product) -> {
    assertThat(cart.getLineItems()).isEmpty();
    final long quantity = 3;
    final Channel inventorySupplyChannel = ChannelFixtures.persistentChannelOfRole(client(), ChannelRole.INVENTORY_SUPPLY);
    final Channel distributionChannel = ChannelFixtures.persistentChannelOfRole(client(), ChannelRole.PRODUCT_DISTRIBUTION);
    final String sku = product.getMasterData().getStaged().getMasterVariant().getSku();
    final LineItemDraft lineItemDraft =
        io.sphere.sdk.carts.LineItemDraftBuilder.ofSku(sku, quantity)
            .distributionChannel(distributionChannel)
            .supplyChannel(inventorySupplyChannel)
            .build();
    final AddLineItem action = AddLineItem.of(lineItemDraft);
    final Cart updatedCart = client().executeBlocking(CartUpdateCommand.of(cart, action));
    assertThat(updatedCart.getLineItems()).hasSize(1);
    final LineItem lineItem = updatedCart.getLineItems().get(0);
    assertThat(lineItem.getName()).isEqualTo(product.getMasterData().getStaged().getName());
    assertThat(lineItem.getQuantity()).isEqualTo(quantity);
    assertThat(lineItem.getProductSlug()).isEqualTo(product.getMasterData().getStaged().getSlug());
    assertThat(lineItem.getVariant().getIdentifier()).isEqualTo(ByIdVariantIdentifier.of(lineItem.getProductId(), lineItem.getVariant().getId()));
    assertThat(lineItem.getSupplyChannel().toReference()).isEqualTo(inventorySupplyChannel.toReference());
    assertThat(lineItem.getDistributionChannel().toReference()).isEqualTo(distributionChannel.toReference());
    assertThat(lineItem.getDiscountedPricePerQuantity()).isNotNull().isEmpty();
  });
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
public void setCustomerGroup() throws Exception {
  withB2cCustomerGroup(client(), customerGroup -> {
    final Cart cart = createCartWithCountry(client());
    assertThat(cart.getCustomerGroup()).isNull();
    Cart updatedCart = client().executeBlocking(CartUpdateCommand.of(cart, SetCustomerGroup.of(customerGroup)));
    assertThat(updatedCart.getCustomerGroup().toReference()).isEqualTo(customerGroup.toReference());
    client().executeBlocking(CartDeleteCommand.of(updatedCart));
  });
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
public void addLineItemOfDraftOfVariantIdentifier() throws Exception {
  withEmptyCartAndProduct(client(), (cart, product) -> {
    assertThat(cart.getLineItems()).isEmpty();
    final long quantity = 3;
    final Channel inventorySupplyChannel = ChannelFixtures.persistentChannelOfRole(client(), ChannelRole.INVENTORY_SUPPLY);
    final Channel distributionChannel = ChannelFixtures.persistentChannelOfRole(client(), ChannelRole.PRODUCT_DISTRIBUTION);
    ByIdVariantIdentifier variantIdentifier = product.getMasterData().getStaged().getMasterVariant().getIdentifier();
    final LineItemDraft lineItemDraft =
        io.sphere.sdk.carts.LineItemDraftBuilder.ofVariantIdentifier(variantIdentifier, quantity)
            .distributionChannel(distributionChannel)
            .supplyChannel(inventorySupplyChannel)
            .build();
    final AddLineItem action = AddLineItem.of(lineItemDraft);
    final Cart updatedCart = client().executeBlocking(CartUpdateCommand.of(cart, action));
    assertThat(updatedCart.getLineItems()).hasSize(1);
    final LineItem lineItem = updatedCart.getLineItems().get(0);
    assertThat(lineItem.getName()).isEqualTo(product.getMasterData().getStaged().getName());
    assertThat(lineItem.getQuantity()).isEqualTo(quantity);
    assertThat(lineItem.getProductSlug()).isEqualTo(product.getMasterData().getStaged().getSlug());
    assertThat(lineItem.getVariant().getIdentifier()).isEqualTo(ByIdVariantIdentifier.of(lineItem.getProductId(), lineItem.getVariant().getId()));
    assertThat(lineItem.getSupplyChannel().toReference()).isEqualTo(inventorySupplyChannel.toReference());
    assertThat(lineItem.getDistributionChannel().toReference()).isEqualTo(distributionChannel.toReference());
    assertThat(lineItem.getDiscountedPricePerQuantity()).isNotNull().isEmpty();
  });
}

相关文章