diff --git a/README.md b/README.md index 63098d307f..bc37caa383 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ # commercetools sync [![Build Status](https://travis-ci.org/commercetools/commercetools-sync-java.svg?branch=master)](https://travis-ci.org/commercetools/commercetools-sync-java) [![codecov](https://codecov.io/gh/commercetools/commercetools-sync-java/branch/master/graph/badge.svg)](https://codecov.io/gh/commercetools/commercetools-sync-java) -[![Benchmarks 2.1.0](https://img.shields.io/badge/Benchmarks-2.1.0-orange.svg)](https://commercetools.github.io/commercetools-sync-java/benchmarks/) +[![Benchmarks 2.2.0](https://img.shields.io/badge/Benchmarks-2.2.0-orange.svg)](https://commercetools.github.io/commercetools-sync-java/benchmarks/) [![Download](https://api.bintray.com/packages/commercetools/maven/commercetools-sync-java/images/download.svg) ](https://bintray.com/commercetools/maven/commercetools-sync-java/_latestVersion) -[![Javadoc](http://javadoc-badge.appspot.com/com.commercetools/commercetools-sync-java.svg?label=Javadoc)](https://commercetools.github.io/commercetools-sync-java/v/2.1.0/) +[![Javadoc](http://javadoc-badge.appspot.com/com.commercetools/commercetools-sync-java.svg?label=Javadoc)](https://commercetools.github.io/commercetools-sync-java/v/2.2.0/) [![Known Vulnerabilities](https://snyk.io/test/github/commercetools/commercetools-sync-java/4b2e26113d591bda158217c5dc1cf80a88665646/badge.svg)](https://snyk.io/test/github/commercetools/commercetools-sync-java/4b2e26113d591bda158217c5dc1cf80a88665646) More at https://commercetools.github.io/commercetools-sync-java @@ -37,7 +37,7 @@ The library supports synchronising the following entities in commercetools - [Ivy](#ivy) - [Roadmap](#roadmap) - [Release Notes](/docs/RELEASE_NOTES.md) -- [Javadoc](https://commercetools.github.io/commercetools-sync-java/v/2.1.0/) +- [Javadoc](https://commercetools.github.io/commercetools-sync-java/v/2.2.0/) - [Benchmarks](https://commercetools.github.io/commercetools-sync-java/benchmarks/) @@ -64,7 +64,7 @@ commercetools sync is a Java library that imports commercetools platform data in - Make sure you have `JDK 8` installed. - [commercetools-jvm-sdk](https://github.com/commercetools/commercetools-jvm-sdk) as a dependency in your JVM-based - application. (Make sure to use a version `>= 1.47.0`). + application. (Make sure to use a version `>= 1.53.0`). - a target commercetools project for syncing your source data to. @@ -79,26 +79,26 @@ Here are the most popular ones: com.commercetools commercetools-sync-java - 2.1.0 + 2.2.0 ```` #### Gradle ````groovy -implementation 'com.commercetools:commercetools-sync-java:2.1.0' +implementation 'com.commercetools:commercetools-sync-java:2.2.0' ```` #### SBT ```` -libraryDependencies += "com.commercetools" % "commercetools-sync-java" % "2.1.0" +libraryDependencies += "com.commercetools" % "commercetools-sync-java" % "2.2.0" ```` #### Ivy ````xml - + ```` diff --git a/docs/README.md b/docs/README.md index fcb4f6328b..6b42335fae 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2,9 +2,9 @@ # commercetools sync [![Build Status](https://travis-ci.org/commercetools/commercetools-sync-java.svg?branch=master)](https://travis-ci.org/commercetools/commercetools-sync-java) [![codecov](https://codecov.io/gh/commercetools/commercetools-sync-java/branch/master/graph/badge.svg)](https://codecov.io/gh/commercetools/commercetools-sync-java) -[![Benchmarks 2.1.0](https://img.shields.io/badge/Benchmarks-2.1.0-orange.svg)](https://commercetools.github.io/commercetools-sync-java/benchmarks/) +[![Benchmarks 2.2.0](https://img.shields.io/badge/Benchmarks-2.2.0-orange.svg)](https://commercetools.github.io/commercetools-sync-java/benchmarks/) [![Download](https://api.bintray.com/packages/commercetools/maven/commercetools-sync-java/images/download.svg) ](https://bintray.com/commercetools/maven/commercetools-sync-java/_latestVersion) -[![Javadoc](http://javadoc-badge.appspot.com/com.commercetools/commercetools-sync-java.svg?label=Javadoc)](https://commercetools.github.io/commercetools-sync-java/v/2.1.0/) +[![Javadoc](http://javadoc-badge.appspot.com/com.commercetools/commercetools-sync-java.svg?label=Javadoc)](https://commercetools.github.io/commercetools-sync-java/v/2.2.0/) [![Known Vulnerabilities](https://snyk.io/test/github/commercetools/commercetools-sync-java/4b2e26113d591bda158217c5dc1cf80a88665646/badge.svg)](https://snyk.io/test/github/commercetools/commercetools-sync-java/4b2e26113d591bda158217c5dc1cf80a88665646) @@ -56,18 +56,18 @@ Here are the most popular ones: com.commercetools commercetools-sync-java - 2.1.0 + 2.2.0 ```` #### Gradle ````groovy -implementation 'com.commercetools:commercetools-sync-java:2.1.0' +implementation 'com.commercetools:commercetools-sync-java:2.2.0' ```` #### SBT ```` -libraryDependencies += "com.commercetools" % "commercetools-sync-java" % "2.1.0" +libraryDependencies += "com.commercetools" % "commercetools-sync-java" % "2.2.0" ```` #### Ivy ````xml - + ```` diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index 16a0b1511f..254e1b4f1c 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -28,9 +28,7 @@ --> - + +- 🛠️ **Dependency Updates** (1) + - `mockito-junit-jupiter` `3.5.11` -> [`3.5.13`](https://github.com/mockito/mockito/releases/tag/v3.5.13) + ### 2.1.0 - Sep 21, 2020 [Commits](https://github.com/commercetools/commercetools-sync-java/compare/2.0.0...2.1.0) | diff --git a/docs/usage/CART_DISCOUNT_SYNC.md b/docs/usage/CART_DISCOUNT_SYNC.md index cefa731158..631ba8385d 100644 --- a/docs/usage/CART_DISCOUNT_SYNC.md +++ b/docs/usage/CART_DISCOUNT_SYNC.md @@ -32,7 +32,7 @@ fields set, otherwise they won't be matched. Types are matched by their `key`s. Therefore, in order for the sync to resolve the actual ids of the type reference, the `key` of the `Type` has to be supplied. - - When syncing from a source commercetools project, you can use [`mapToCartDiscountDrafts`](https://commercetools.github.io/commercetools-sync-java/v/2.1.0/com/commercetools/sync/cartdiscounts/utils/CartDiscountReferenceResolutionUtils.html#mapToCartDiscountDrafts-java.util.List-) + - When syncing from a source commercetools project, you can use [`mapToCartDiscountDrafts`](https://commercetools.github.io/commercetools-sync-java/v/2.2.0/com/commercetools/sync/cartdiscounts/utils/CartDiscountReferenceResolutionUtils.html#mapToCartDiscountDrafts-java.util.List-) method that maps from a `CartDiscount` to `CartDiscountDraft` in order to make them ready for reference resolution by the sync: ````java diff --git a/docs/usage/CATEGORY_SYNC.md b/docs/usage/CATEGORY_SYNC.md index a114cb5f35..f605864244 100644 --- a/docs/usage/CATEGORY_SYNC.md +++ b/docs/usage/CATEGORY_SYNC.md @@ -34,7 +34,7 @@ otherwise they won't be matched. These references are matched by their `key`s. Therefore, in order for the sync to resolve the actual ids of the references, their `key`s has to be supplied. - - When syncing from a source commercetools project, you can use [`mapToCategoryDrafts`](https://commercetools.github.io/commercetools-sync-java/v/2.1.0/com/commercetools/sync/categories/utils/CategoryReferenceResolutionUtils.html#mapToCategoryDrafts-java.util.List-) + - When syncing from a source commercetools project, you can use [`mapToCategoryDrafts`](https://commercetools.github.io/commercetools-sync-java/v/2.2.0/com/commercetools/sync/categories/utils/CategoryReferenceResolutionUtils.html#mapToCategoryDrafts-java.util.List-) method that maps from a `Category` to `CategoryDraft` in order to make them ready for reference resolution by the sync: ````java final List categoryDrafts = CategoryReferenceResolutionUtils.mapToCategoryDrafts(categories); diff --git a/docs/usage/IMPORTANT_USAGE_TIPS.md b/docs/usage/IMPORTANT_USAGE_TIPS.md index 444a993add..a08afe9750 100644 --- a/docs/usage/IMPORTANT_USAGE_TIPS.md +++ b/docs/usage/IMPORTANT_USAGE_TIPS.md @@ -31,7 +31,7 @@ productSync.sync(batch1) By design, scaling the sync process should **not** be done by executing the batches themselves in parallel. However, it can be done either by: - Changing the number of [max parallel requests](https://github.com/commercetools/commercetools-sync-java/tree/master/src/main/java/com/commercetools/sync/commons/utils/ClientConfigurationUtils.java#L116) within the `sphereClient` configuration. It defines how many requests the client can execute in parallel. - - or changing the draft [batch size](https://commercetools.github.io/commercetools-sync-java/v/2.1.0/com/commercetools/sync/commons/BaseSyncOptionsBuilder.html#batchSize-int-). It defines how many drafts can one batch contain. + - or changing the draft [batch size](https://commercetools.github.io/commercetools-sync-java/v/2.2.0/com/commercetools/sync/commons/BaseSyncOptionsBuilder.html#batchSize-int-). It defines how many drafts can one batch contain. The current overridable default [configuration](https://github.com/commercetools/commercetools-sync-java/tree/master/src/main/java/com/commercetools/sync/commons/utils/ClientConfigurationUtils.java#L45) of the `sphereClient` is the recommended good balance for stability and performance for the sync process. diff --git a/docs/usage/INVENTORY_SYNC.md b/docs/usage/INVENTORY_SYNC.md index 0840f13bc1..efe7f5f1f4 100644 --- a/docs/usage/INVENTORY_SYNC.md +++ b/docs/usage/INVENTORY_SYNC.md @@ -32,7 +32,7 @@ against a [InventoryEntryDraft](https://docs.commercetools.com/http-api-projects references are matched by their `key`s. Therefore, in order for the sync to resolve the actual ids of those references, their `key`s has to be supplied. - - When syncing from a source commercetools project, you can use [`mapToInventoryEntryDrafts`](https://commercetools.github.io/commercetools-sync-java/v/2.1.0/com/commercetools/sync/inventories/utils/InventoryReferenceResolutionUtils.html#mapToInventoryEntryDrafts-java.util.List-) + - When syncing from a source commercetools project, you can use [`mapToInventoryEntryDrafts`](https://commercetools.github.io/commercetools-sync-java/v/2.2.0/com/commercetools/sync/inventories/utils/InventoryReferenceResolutionUtils.html#mapToInventoryEntryDrafts-java.util.List-) method that that maps from a `InventoryEntry` to `InventoryEntryDraft` in order to make them ready for reference resolution by the sync: ````java final List inventoryEntryDrafts = InventoryReferenceResolutionUtils.mapToInventoryEntryDrafts(inventoryEntries); diff --git a/docs/usage/PRODUCT_SYNC.md b/docs/usage/PRODUCT_SYNC.md index 04b3633283..1e11d8a53a 100644 --- a/docs/usage/PRODUCT_SYNC.md +++ b/docs/usage/PRODUCT_SYNC.md @@ -38,7 +38,7 @@ all the variants in the target project are expected to have the `sku` fields set of the product also have prices, where each price also has some references including a reference to the `Type` of its custom fields and a reference to a `channel`. All these referenced resources are matched by their `key`s. Therefore, in order for the sync to resolve the actual ids of those references, those `key`s have to be supplied in the following way: - - When syncing from a source commercetools project, you can use [`mapToProductDrafts`](https://commercetools.github.io/commercetools-sync-java/v/2.1.0/com/commercetools/sync/products/utils/ProductReferenceResolutionUtils.html#mapToProductDrafts-java.util.List-) + - When syncing from a source commercetools project, you can use [`mapToProductDrafts`](https://commercetools.github.io/commercetools-sync-java/v/2.2.0/com/commercetools/sync/products/utils/ProductReferenceResolutionUtils.html#mapToProductDrafts-java.util.List-) method that maps from a `Product` to `ProductDraft` in order to make them ready for reference resolution by the sync: ````java final List productDrafts = ProductReferenceResolutionUtils.mapToProductDrafts(products); diff --git a/docs/usage/PRODUCT_TYPE_SYNC.md b/docs/usage/PRODUCT_TYPE_SYNC.md index 7772bb76ec..3567aa60e4 100644 --- a/docs/usage/PRODUCT_TYPE_SYNC.md +++ b/docs/usage/PRODUCT_TYPE_SYNC.md @@ -38,7 +38,7 @@ references, those `key`s have to be supplied in the following way: - Provide the `key` value on the `id` field of the reference. This means that calling `getId()` on the reference would return its `key`. - **Note**: When syncing from a source commercetools project, you can use [`mapToProductTypeDrafts`](https://commercetools.github.io/commercetools-sync-java/v/2.1.0/com/commercetools/sync/producttypes/utils/ProductTypeReferenceResolutionUtils.html#mapToProductTypeDrafts-java.util.List-) + **Note**: When syncing from a source commercetools project, you can use [`mapToProductTypeDrafts`](https://commercetools.github.io/commercetools-sync-java/v/2.2.0/com/commercetools/sync/producttypes/utils/ProductTypeReferenceResolutionUtils.html#mapToProductTypeDrafts-java.util.List-) that replaces the references id fields with keys, in order to make them ready for reference resolution by the sync: ````java diff --git a/docs/usage/QUICK_START.md b/docs/usage/QUICK_START.md index 64feaa1952..b0a348bd58 100644 --- a/docs/usage/QUICK_START.md +++ b/docs/usage/QUICK_START.md @@ -37,7 +37,7 @@ com.commercetools commercetools-sync-java - 2.1.0 + 2.2.0 ```` - For Gradle users: @@ -48,7 +48,7 @@ implementation 'com.commercetools.sdk.jvm.core:commercetools-java-client:1.53.0' implementation 'com.commercetools.sdk.jvm.core:commercetools-convenience:1.53.0' // Add commercetools-sync-java dependency. -implementation 'com.commercetools:commercetools-sync-java:2.1.0' +implementation 'com.commercetools:commercetools-sync-java:2.2.0' ```` ### 2. Setup Syncing Options @@ -88,4 +88,5 @@ implementation 'com.commercetools:commercetools-sync-java:2.1.0' *[Product Sync](PRODUCT_SYNC.md), [ProductType Sync](PRODUCT_TYPE_SYNC.md), [Category Sync](CATEGORY_SYNC.md), [Inventory Sync](INVENTORY_SYNC.md), [Type Sync](TYPE_SYNC.md), [CartDiscount Sync](CART_DISCOUNT_SYNC.md), -[TaxCategory Sync](/docs/usage/TAX_CATEGORY_SYNC.md), [State Sync](/docs/usage/STATE_SYNC.md)* +[TaxCategory Sync](/docs/usage/TAX_CATEGORY_SYNC.md), [State Sync](/docs/usage/STATE_SYNC.md), +[CustomObject Sync](/docs/usage/CUSTOM_OBJECT_SYNC.md)* diff --git a/mkdocs.yml b/mkdocs.yml index 361eaec1fe..5651c7dfc0 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -59,7 +59,7 @@ nav: - Advanced: - Sync Options: usage/SYNC_OPTIONS.md - Usage Tips: usage/IMPORTANT_USAGE_TIPS.md - - Javadoc: https://commercetools.github.io/commercetools-sync-java/v/2.1.0/ + - Javadoc: https://commercetools.github.io/commercetools-sync-java/v/2.2.0/ - Release notes: RELEASE_NOTES.md - Roadmap: https://github.com/commercetools/commercetools-sync-java/milestones - Issues: https://github.com/commercetools/commercetools-sync-java/issues diff --git a/src/main/java/com/commercetools/sync/inventories/helpers/InventoryReferenceResolver.java b/src/main/java/com/commercetools/sync/inventories/helpers/InventoryReferenceResolver.java index 45062c23b0..18bd4e9d0f 100644 --- a/src/main/java/com/commercetools/sync/inventories/helpers/InventoryReferenceResolver.java +++ b/src/main/java/com/commercetools/sync/inventories/helpers/InventoryReferenceResolver.java @@ -32,6 +32,7 @@ public final class InventoryReferenceResolver + "InventoryEntryDraft with SKU:'%s'."; private static final String FAILED_TO_RESOLVE_SUPPLY_CHANNEL = "Failed to resolve supply channel " + "resource identifier on InventoryEntryDraft with SKU:'%s'. Reason: %s"; + private static final String FAILED_TO_CREATE_SUPPLY_CHANNEL = "Failed to create supply channel with key: '%s'"; private final ChannelService channelService; private final TypeService typeService; @@ -206,7 +207,7 @@ private CompletionStage createChannelAndSetReference return setChannelReference(createdChannelOptional.get().getId(), draftBuilder); } else { final ReferenceResolutionException referenceResolutionException = - new ReferenceResolutionException(format(CHANNEL_DOES_NOT_EXIST, channelKey)); + new ReferenceResolutionException(format(FAILED_TO_CREATE_SUPPLY_CHANNEL, channelKey)); return CompletableFutureUtils.exceptionallyCompletedFuture(referenceResolutionException); } }); diff --git a/src/main/java/com/commercetools/sync/products/helpers/ProductBatchValidator.java b/src/main/java/com/commercetools/sync/products/helpers/ProductBatchValidator.java index 38574c2fcb..c6e3fe4a22 100644 --- a/src/main/java/com/commercetools/sync/products/helpers/ProductBatchValidator.java +++ b/src/main/java/com/commercetools/sync/products/helpers/ProductBatchValidator.java @@ -194,7 +194,12 @@ private void collectReferencedKeysInAttributes( @Nonnull private List getVariantDraftErrorsInAllVariants(@Nonnull final ProductDraft productDraft) { final List errorMessages = new ArrayList<>(); - final List allVariants = getAllVariants(productDraft); + + // don't filter the nulls + final List allVariants = new ArrayList<>(); + allVariants.add(productDraft.getMasterVariant()); + allVariants.addAll(productDraft.getVariants()); + for (int i = 0; i < allVariants.size(); i++) { errorMessages.addAll(getVariantDraftErrorsInAllVariants(allVariants.get(i), i, requireNonNull(productDraft.getKey()))); diff --git a/src/main/java/com/commercetools/sync/products/helpers/ProductReferenceResolver.java b/src/main/java/com/commercetools/sync/products/helpers/ProductReferenceResolver.java index 3f975637d0..1d1471b385 100644 --- a/src/main/java/com/commercetools/sync/products/helpers/ProductReferenceResolver.java +++ b/src/main/java/com/commercetools/sync/products/helpers/ProductReferenceResolver.java @@ -133,12 +133,9 @@ public CompletionStage resolveReferences(@Nonnull final ProductDra private CompletionStage resolveAllVariantsReferences( @Nonnull final ProductDraftBuilder draftBuilder) { final ProductVariantDraft masterVariantDraft = draftBuilder.getMasterVariant(); - if (masterVariantDraft != null) { - return variantReferenceResolver.resolveReferences(masterVariantDraft) - .thenApply(draftBuilder::masterVariant) - .thenCompose(this::resolveVariantsReferences); - } - return resolveVariantsReferences(draftBuilder); + return variantReferenceResolver.resolveReferences(masterVariantDraft) + .thenApply(draftBuilder::masterVariant) + .thenCompose(this::resolveVariantsReferences); } @Nonnull diff --git a/src/test/java/com/commercetools/sync/inventories/InventorySyncTest.java b/src/test/java/com/commercetools/sync/inventories/InventorySyncTest.java index d6cbed3f59..2b8b7266f2 100644 --- a/src/test/java/com/commercetools/sync/inventories/InventorySyncTest.java +++ b/src/test/java/com/commercetools/sync/inventories/InventorySyncTest.java @@ -37,7 +37,6 @@ import static com.commercetools.sync.inventories.InventorySyncMockUtils.getMockInventoryEntry; import static com.commercetools.sync.inventories.InventorySyncMockUtils.getMockInventoryService; import static com.commercetools.sync.inventories.InventorySyncMockUtils.getMockSupplyChannel; -import static io.sphere.sdk.utils.CompletableFutureUtils.failed; import static io.sphere.sdk.utils.SphereInternalUtils.asSet; import static java.lang.String.format; import static java.util.Arrays.asList; @@ -395,7 +394,8 @@ void sync_WithExceptionWhenCreatingNewSupplyChannel_ShouldTriggerErrorCallbackAn final ChannelService channelService = getMockChannelService(getMockSupplyChannel(REF_3, KEY_3)); when(channelService.fetchCachedChannelId(anyString())) .thenReturn(CompletableFuture.completedFuture(Optional.empty())); - when(channelService.createAndCacheChannel(anyString())).thenReturn(failed(new SphereException())); + when(channelService.createAndCacheChannel(anyString())) + .thenReturn(CompletableFuture.completedFuture(Optional.empty())); final InventoryEntryDraft newInventoryDraft = InventoryEntryDraftBuilder .of(SKU_1, QUANTITY_1, DATE_1, RESTOCKABLE_1, ResourceIdentifier.ofKey(KEY_3)) @@ -410,13 +410,12 @@ void sync_WithExceptionWhenCreatingNewSupplyChannel_ShouldTriggerErrorCallbackAn assertThat(stats).hasValues(1, 0, 0, 1); assertThat(errorCallBackMessages).isNotEmpty(); assertThat(errorCallBackMessages.get(0)).contains(format("Failed to resolve supply channel resource identifier" - + " on InventoryEntryDraft with SKU:'%s'.", SKU_1)); + + " on InventoryEntryDraft with SKU:'%s'. Reason: Failed to create supply channel with key: '%s'", SKU_1, + "channel-key_3")); assertThat(errorCallBackExceptions).isNotEmpty(); assertThat(errorCallBackExceptions.get(0)).isExactlyInstanceOf(CompletionException.class); assertThat(errorCallBackExceptions.get(0).getCause()).isExactlyInstanceOf(ReferenceResolutionException.class); assertThat(errorCallBackExceptions.get(0).getCause().getCause()).isExactlyInstanceOf(CompletionException.class); - assertThat(errorCallBackExceptions.get(0).getCause() - .getCause().getCause()).isExactlyInstanceOf(SphereException.class); } @Test