- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中io.sphere.sdk.shippingmethods.ZoneRate.getShippingRates()
方法的一些代码示例,展示了ZoneRate.getShippingRates()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneRate.getShippingRates()
方法的具体详情如下:
包路径:io.sphere.sdk.shippingmethods.ZoneRate
类名称:ZoneRate
方法名:getShippingRates
暂无
代码示例来源:origin: io.sphere.sdk.jvm/models
default List<ShippingRate> getShippingRatesForZone(final Referenceable<Zone> zone) {
final Optional<ZoneRate> zoneRateOptional = getZoneRates().stream()
.filter(rate -> rate.getZone().hasSameIdAs(zone.toReference()))
.findFirst();
return zoneRateOptional
.map(rate -> rate.getShippingRates())
.orElse(Collections.emptyList());
}
代码示例来源:origin: io.sphere.sdk.jvm/sphere-models
default List<ShippingRate> getShippingRatesForZone(final Referenceable<Zone> zone) {
return getZoneRates().stream()
.filter(rate -> rate.getZone().hasSameIdAs(zone.toReference()))
.findFirst()
.map(rate -> rate.getShippingRates())
.orElse(Collections.emptyList());
}
代码示例来源:origin: com.commercetools.sdk.jvm.core/commercetools-models
default List<ShippingRate> getShippingRatesForZone(final Referenceable<Zone> zone) {
return getZoneRates().stream()
.filter(rate -> rate.getZone().hasSameIdAs(zone.toReference()))
.findFirst()
.map(rate -> rate.getShippingRates())
.orElse(Collections.emptyList());
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
default List<ShippingRate> getShippingRatesForZone(final Referenceable<Zone> zone) {
return getZoneRates().stream()
.filter(rate -> rate.getZone().hasSameIdAs(zone.toReference()))
.findFirst()
.map(rate -> rate.getShippingRates())
.orElse(Collections.emptyList());
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void execution() throws Exception {
withShippingMethodForGermany(client(), shippingMethod -> {
final SphereRequest<List<ShippingMethod>> sphereRequest =
new VrapRequestDecorator<>(ShippingMethodsByLocationGet.of(CountryCode.DE).withExpansionPaths(m -> m.zones()), "response");
final List<ShippingMethod> shippingMethodsByLocation =
client().executeBlocking(sphereRequest);
assertThat(shippingMethodsByLocation).isNotEmpty();
for (final ShippingMethod shippingMethodByLocation : shippingMethodsByLocation) {
final List<ShippingRate> shippingRates = shippingMethodByLocation.getZoneRates().stream()
.flatMap(zoneRate -> zoneRate.getShippingRates().stream())
.collect(Collectors.toList());
assertThat(shippingRates).areAtLeastOne(new Condition<>(ShippingRate::isMatching, "Shipping rate is matching"));
assertThat(shippingMethodByLocation.getZones()).isNotEmpty();
assertThat(shippingMethodByLocation.getZones().get(0).getObj()).isNotNull();
}
});
}
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void createByJson() {
withTaxCategory(client(), taxCategory -> {
withZone(client(), zone -> {
final JsonNodeReferenceResolver referenceResolver = new JsonNodeReferenceResolver();
referenceResolver.addResourceByKey("standard-tax", taxCategory);
referenceResolver.addResourceByKey("zone-id", zone);
final ShippingMethodDraft draft = draftFromJsonResource("drafts-tests/shippingMethod.json", ShippingMethodDraft.class, referenceResolver);
withShippingMethod(client(), draft, shippingMethod -> {
assertThat(shippingMethod.getName()).isEqualTo("demo shipping method");
assertThat(shippingMethod.getTaxCategory()).isEqualTo(taxCategory.toReference());
final ZoneRate zoneRate = shippingMethod.getZoneRates().get(0);
assertThat(zoneRate.getZone()).isEqualTo(zone.toReference());
final ShippingRate shippingRate = zoneRate.getShippingRates().get(0);
assertThat(shippingRate.getPrice()).isEqualTo(EURO_20);
});
}, COUNTRY_CODE);
});
}
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void execution() throws Exception {
withShippingMethodForGermany(client(), shippingMethod -> {
withCart(client(), cart -> {
final Cart cartWithShippingAddress = client().executeBlocking(CartUpdateCommand.of(cart, SetShippingAddress.of(GERMAN_ADDRESS)));
final SphereRequest<List<ShippingMethod>> sphereRequest =
new VrapRequestDecorator<>(ShippingMethodsByCartGet.of(cartWithShippingAddress).plusExpansionPaths(exp -> exp.taxCategory()), "response");
final List<ShippingMethod> shippingMethods =
client().executeBlocking(sphereRequest);
assertThat(shippingMethods).isNotEmpty();
for (final ShippingMethod cartShippingMethod : shippingMethods) {
final List<ShippingRate> shippingRates = cartShippingMethod.getZoneRates().stream()
.flatMap(zoneRate -> zoneRate.getShippingRates().stream())
.collect(Collectors.toList());
assertThat(shippingRates).areExactly(1, new Condition<>(ShippingRate::isMatching, "Shipping rate is matching"));
assertThat(cartShippingMethod.getTaxCategory().getObj()).isNotNull();
}
return cartWithShippingAddress;
});
});
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void shouldReturnShippingMethodWithMatchingPredicate() throws Exception {
final CartPredicate cartPredicate = CartPredicate.of("customer.email=\"john@example.com\"");
withUpdateableDynamicShippingMethodForGermany(client(), cartPredicate, shippingMethod -> {
withCart(client(), cart -> {
final List<UpdateActionImpl<Cart>> updateActions = Arrays.asList(SetShippingAddress.of(GERMAN_ADDRESS), SetCustomerEmail.of("john@example.com"));
final Cart updatedCart = client().executeBlocking(CartUpdateCommand.of(cart, updateActions));
final SphereRequest<List<ShippingMethod>> sphereRequest =
new VrapRequestDecorator<>(ShippingMethodsByCartGet.of(updatedCart), "response");
final List<ShippingMethod> shippingMethods =
client().executeBlocking(sphereRequest);
assertThat(shippingMethods).isNotEmpty();
for (final ShippingMethod cartShippingMethod : shippingMethods) {
final List<ShippingRate> shippingRates = cartShippingMethod.getZoneRates().stream()
.flatMap(zoneRate -> zoneRate.getShippingRates().stream())
.collect(Collectors.toList());
assertThat(shippingRates).areExactly(1, new Condition<>(ShippingRate::isMatching, "Shipping rate is matching"));
}
return updatedCart;
});
return shippingMethod;
});
}
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
.findFirst()
.get();
assertThat(zoneRate.getShippingRates()).isEmpty();
代码示例来源:origin: commercetools/commercetools-jvm-sdk
final ShippingRate oldShippingRate = zoneRate.getShippingRates().get(0);
final Reference<Zone> zone = zoneRate.getZone();
final ShippingMethod updatedShippingMethod = client().executeBlocking(ShippingMethodUpdateCommand.of(shippingMethod, asList(RemoveShippingRate.of(oldShippingRate, zone), AddShippingRate.of(ShippingRate.of(EURO_10, EURO_10), zone))));
本文整理了Java中io.sphere.sdk.shippingmethods.ZoneRate.getShippingRates()方法的一些代码示例,展示了ZoneRate.getShipping
我是一名优秀的程序员,十分优秀!