本文整理了Java中io.sphere.sdk.models.Reference.getObj
方法的一些代码示例,展示了Reference.getObj
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Reference.getObj
方法的具体详情如下:
包路径:io.sphere.sdk.models.Reference
类名称:Reference
方法名:getObj
[英]The nullable value of the referenced object. This value is by default null on requests: io.sphere.sdk.models.ReferenceIntegrationTest#referencesAreNotByDefaultExpanded()But it can be expanded with using io.sphere.sdk.expansion.ReferenceExpansionDsl#withExpansionPaths(List) on requests: io.sphere.sdk.models.ReferenceIntegrationTest#howToExpandReferences()Refer to io.sphere.sdk.expansion.ReferenceExpansionDsl which endpoints support reference expansion.
[中]被引用对象的可空值。对于请求:io,该值默认为null。球sdk。模型。ReferenceIntegrationTest#referencesAreNotByDefaultExpanded(),但可以使用io进行扩展。球sdk。膨胀请求上带有扩展路径(列表)的ReferenceExpansionDsl#:io。球sdk。模型。ReferenceIntegrationTest#howToExpandReferences()参考io。球sdk。膨胀ReferenceExpansionDsl哪些端点支持引用扩展。
代码示例来源:origin: io.sphere.sdk.jvm/sphere-test-lib
@Override
public boolean matches(final T value) {
return value.getObj() != null;
}
};
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Override
public boolean matches(final T value) {
return value.getObj() != null;
}
};
代码示例来源:origin: io.sphere.sdk.jvm/sphere-test-lib
@Override
public boolean matches(final T value) {
return value.getObj() != null && value.getObj().equals(expected);
}
};
代码示例来源:origin: io.sphere.sdk.jvm/sphere-test-lib
public void checkIsExpanded() {
if (actual.getObj() == null) {
failWithMessage(format("The reference %s is not expanded.", actual));
}
}
代码示例来源:origin: io.sphere.sdk.jvm/sphere-test-lib
public ReferenceAssert hasAnExpanded(final Resource<?> model) {
checkIsExpanded();
if (!actual.getObj().equals(model)) {
failWithMessage(format("%s does not contain an expanded %s.", actual, model));
}
return this;
}
代码示例来源:origin: io.sphere.sdk.jvm/test-lib
public void checkIsExpanded() {
if (!actual.getObj().isPresent()) {
failIfCustomMessageIsSet();
throw failure(String.format("The reference %s is not expanded.", actual));
}
}
代码示例来源:origin: io.sphere.jvmsdk/javaintegrationtestlib
public void checkIsExpanded() {
if (!actual.getObj().isPresent()) {
failIfCustomMessageIsSet();
throw failure(String.format("The reference %s is not expanded.", actual));
}
}
代码示例来源:origin: io.sphere.sdk.jvm/test-lib
public ReferenceAssert hasAnExpanded(final DefaultModel<?> model) {
checkIsExpanded();
if (!actual.getObj().get().equals(model)) {
failIfCustomMessageIsSet();
throw failure(String.format("%s does not contain an expanded %s.", actual, model));
}
return this;
}
代码示例来源:origin: io.sphere.jvmsdk/javaintegrationtestlib
public ReferenceAssert hasAnExpanded(final DefaultModel<?> model) {
checkIsExpanded();
if (!actual.getObj().get().equals(model)) {
failIfCustomMessageIsSet();
throw failure(String.format("%s does not contain an expanded %s.", actual, model));
}
return this;
}
代码示例来源:origin: com.commercetools.sunrise/common
protected void fillShippingInfoDescription(final ShippingInfoBean bean, final CartLike<?> cartLike) {
if (cartLike.getShippingInfo() != null) {
final Reference<ShippingMethod> ref = cartLike.getShippingInfo().getShippingMethod();
if (ref != null && ref.getObj() != null) {
bean.setDescription(ref.getObj().getDescription());
}
}
}
代码示例来源:origin: com.commercetools.sdk.jvm.core/commercetools-models
static <T> Attribute of(final NamedAttributeAccess<T> namedAttributeAccess, final T value) {
final String name = namedAttributeAccess.getName();
//here is not the attributeMapper used to keep LocalizedEnum values which
//are transformed to just the key so the attribute could not be read anymore
final JsonNode jsonNode = SphereJsonUtils.toJsonNode(value);
if (value instanceof Reference && jsonNode instanceof ObjectNode) {
final Reference<?> reference = (Reference<?>) value;
if (reference.getObj() != null) {
((ObjectNode) jsonNode).replace("obj", SphereJsonUtils.toJsonNode(reference.getObj()));
}
}
return of(name, jsonNode);
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void createFilledReference() throws Exception {
final Reference<TestEntity> reference = newFilledReference();
assertThat(reference.getId()).isEqualTo(id);
assertThat(reference.getTypeId()).isEqualTo(typeId);
assertThat(reference.getObj()).isEqualTo(new TestEntity("value"));
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void execution() throws Exception {
withShippingMethod(client(), shippingMethod -> {
final ShippingMethodByIdGet fetch = ShippingMethodByIdGet.of(shippingMethod)
.withExpansionPaths(m -> m.taxCategory());
final ShippingMethod loadedShippingMethod = client().executeBlocking(fetch);
final String actualFetchedId = loadedShippingMethod.getId();
assertThat(actualFetchedId).isEqualTo(shippingMethod.getId());
assertThat(loadedShippingMethod.getTaxCategory().getObj()).isNotNull();
});
}
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void expandedDiscountedPrice() throws Exception {
final Product product = SphereJsonUtils.readObjectFromResource("product-with-expanded-discounted-price.json", Product.typeReference());
final Price price = product.getMasterData().getStaged().getMasterVariant().getPrices().get(0);
final DiscountedPrice discountedPrice = price.getDiscounted();
final ProductDiscount productDiscount = discountedPrice.getDiscount().getObj();
assertThat(productDiscount.getName().get(Locale.ENGLISH)).isEqualTo("demo product discount");
assertThat(productDiscount.getValue()).isInstanceOf(AbsoluteProductDiscountValue.class);
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void execution() throws Exception {
withInventoryEntryAndSupplyChannel(client(), INVENTORY_SUPPLY, (entry, channel) -> {
final SphereRequest<InventoryEntry> sphereRequest = InventoryEntryByIdGet.of(entry)
.withExpansionPaths(m -> m.supplyChannel());
final InventoryEntry actual = client().executeBlocking(sphereRequest);
assertThat(actual.getId()).contains(entry.getId());
assertThat(actual.getSupplyChannel().getObj().getId()).isEqualTo(channel.getId());
});
}
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void referencesAreNotByDefaultExpanded() {
withCustomerInGroup(client(), (customer, customerGroup) -> {
final CustomerByIdGet customerByIdGet = CustomerByIdGet.of(customer);
final Customer loadedCustomer = client().executeBlocking(customerByIdGet);
final Reference<CustomerGroup> customerGroupReference = loadedCustomer.getCustomerGroup();
assertThat(customerGroupReference.getId()).isEqualTo(customerGroup.getId());
assertThat(customerGroupReference.getObj())
.as("reference is not expanded")
.isNull();
});
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void canExpandItsCategories() throws Exception {
withProductInCategory(client(), (product, category) -> {
final Query<Product> query = query(product)
.withExpansionPaths(ProductExpansionModel.of().masterData().staged().categories());
assertThat(client().executeBlocking(query).head().get().getMasterData().getStaged().getCategories().stream().anyMatch(reference -> reference.getObj() != null))
.isTrue();
});
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void execution() throws Exception {
withCustomerInGroup(client(), (customer, customerGroup) -> {
final Get<Customer> fetch = CustomerByIdGet.of(customer)
.withExpansionPaths(CustomerExpansionModel.of().customerGroup());
final Customer fetchedCustomer = client().executeBlocking(fetch);
assertThat(fetchedCustomer.getId()).isEqualTo(customer.getId());
assertThat(fetchedCustomer.getCustomerGroup().getObj().getId()).isEqualTo(customerGroup.getId());
});
}
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void referenceExpansion() throws Exception {
withOrder(client(), order -> {
assertThat(order.getOrderNumber()).isNull();
final String orderNumber = randomString();
final OrderUpdateCommand orderUpdateCommand = OrderUpdateCommand.of(order, SetOrderNumber.of(orderNumber)).plusExpansionPaths(m -> m.cart());
final Order updatedOrder = client().executeBlocking(orderUpdateCommand);
assertThat(updatedOrder.getCart().getObj()).isNotNull();
return updatedOrder;
});
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void referenceExpansion() throws Exception {
final Category parent = client().executeBlocking(CategoryCreateCommand.of(CategoryDraftBuilder.of(randomSlug(), randomSlug()).build()));
final Category category = client().executeBlocking(CategoryCreateCommand.of(CategoryDraftBuilder.of(randomSlug(), randomSlug()).parent(parent).build()));
final CategoryDeleteCommand deleteCommand = CategoryDeleteCommand.of(category).plusExpansionPaths(m -> m.parent());
final Category deletedCategory = client().executeBlocking(deleteCommand);
assertThat(deletedCategory.getParent().getObj()).isNotNull().isEqualTo(parent);
client().executeBlocking(CategoryDeleteCommand.of(parent));
}
内容来源于网络,如有侵权,请联系作者删除!