本文整理匯總了Java中io.sphere.sdk.producttypes.ProductTypeDraft類的典型用法代碼示例。如果您正苦於以下問題:Java ProductTypeDraft類的具體用法?Java ProductTypeDraft怎麽用?Java ProductTypeDraft使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ProductTypeDraft類屬於io.sphere.sdk.producttypes包,在下文中一共展示了ProductTypeDraft類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fetchCachedProductTypeId_OnSecondTime_ShouldNotFindProductTypeInCache
import io.sphere.sdk.producttypes.ProductTypeDraft; //導入依賴的package包/類
@Test
public void fetchCachedProductTypeId_OnSecondTime_ShouldNotFindProductTypeInCache() {
// Fetch any product type to populate cache
productTypeService.fetchCachedProductTypeId("anyTypeKey").toCompletableFuture().join();
// Create new type
final String newProductTypeKey = "new_type_key";
final ProductTypeDraft draft = ProductTypeDraftBuilder
.of(newProductTypeKey, "typeName", "typeDescription", new ArrayList<>()).build();
CTP_TARGET_CLIENT.execute(ProductTypeCreateCommand.of(draft)).toCompletableFuture().join();
final Optional<String> newProductTypeId =
productTypeService.fetchCachedProductTypeId(newProductTypeKey).toCompletableFuture().join();
assertThat(newProductTypeId).isEmpty();
}
示例2: createProductType
import io.sphere.sdk.producttypes.ProductTypeDraft; //導入依賴的package包/類
/**
* This method blocks to create a product Type on the CTP project defined by the supplied {@code ctpClient} with
* the supplied data.
*
* @param productTypeKey the product type key
* @param locale the locale to be used for specifying the product type name and field definitions names.
* @param name the name of the product type.
* @param ctpClient defines the CTP project to create the product type on.
*/
public static void createProductType(@Nonnull final String productTypeKey,
@Nonnull final Locale locale,
@Nonnull final String name,
@Nonnull final SphereClient ctpClient) {
if (!productTypeExists(productTypeKey, ctpClient)) {
final ProductTypeDraft productTypeDraft = ProductTypeDraftBuilder
.of(productTypeKey, name, "description", buildAttributeDefinitions(locale))
.build();
ctpClient.execute(ProductTypeCreateCommand.of(productTypeDraft)).toCompletableFuture().join();
}
}
示例3: createProductType
import io.sphere.sdk.producttypes.ProductTypeDraft; //導入依賴的package包/類
public static ProductType createProductType(final BlockingSphereClient sphereClient) {
final ProductTypeDraft productTypeDraft =
ProductTypeDraft.of(RandomStringUtils.randomAlphabetic(10), "name", "a 'T' shaped cloth", Collections.emptyList());
final ProductType productType = sphereClient.executeBlocking(ProductTypeCreateCommand.of(productTypeDraft));
return productType;
}
示例4: withProductType
import io.sphere.sdk.producttypes.ProductTypeDraft; //導入依賴的package包/類
public static void withProductType(final BlockingSphereClient client, final ProductTypeDraft productTypeDraft, final Function<ProductType, ProductType> test) {
final ProductType productType = client.executeBlocking(ProductTypeCreateCommand.of(productTypeDraft));
final ProductType productTypeAfterTest = test.apply(productType);
deleteProductTypeWithRetry(client, productTypeAfterTest);
}
示例5: productTypeDraft
import io.sphere.sdk.producttypes.ProductTypeDraft; //導入依賴的package包/類
public static ProductTypeDraft productTypeDraft() {
return ProductTypeDraftBuilder.of(randomKey(), randomKey(), "Description", emptyList()).build();
}