Skip to content

Commit 78aa890

Browse files
committed
Merge branch 'master' into 161-gradle-task-exec-order
# Conflicts: # docs/RELEASE_NOTES.md
2 parents 0313a10 + 7fbad35 commit 78aa890

61 files changed

Lines changed: 814 additions & 1044 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/RELEASE_NOTES.md

Lines changed: 96 additions & 82 deletions
Large diffs are not rendered by default.

docs/usage/CATEGORY_SYNC.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ events.
6767
a callback that is called whenever an event occurs during the sync process that represents a warning. Currently, these
6868
events.
6969
<!--
70-
- `removeOtherLocales`
71-
a flag which enables the sync module to add additional localizations without deleting existing ones, if set to `false`.
72-
If set to `true`, which is the default value of the option, it deletes the existing object properties.
7370
- `removeOtherSetEntries`
7471
a flag which enables the sync module to add additional Set entries without deleting existing ones, if set to `false`.
7572
If set to `true`, which is the default value of the option, it deletes the existing Set entries.
@@ -81,9 +78,9 @@ entries.
8178
a flag which enables the sync module to add additional object properties (e.g. custom fields, etc..) without deleting
8279
existing ones, if set to `false`. If set to `true`, which is the default value of the option, it deletes the existing
8380
object properties. -->
84-
- `updateActionsCallBack`
85-
a filter function which can be applied on generated list of update actions to produce a resultant list after the filter
86-
function has been applied.
81+
- `beforeUpdateCallback`
82+
a filter function which can be applied on a generated list of update actions. It allows the user to intercept category
83+
update and modify (add/remove) update actions just before they are send to CTP API.
8784
- `allowUuid`
8885
a flag, if set to `true`, enables the user to use keys with UUID format for references. By default, it is set to `false`.
8986

docs/usage/INVENTORY_SYNC.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,6 @@ An example of use can be found [here](https://github.com/commercetools/commercet
112112
- `warningCallBack`
113113
a callback that is called whenever an event occurs during the sync process that represents a warning.
114114

115-
- `removeOtherLocales`
116-
a flag which enables the sync module to add additional localizations without deleting existing ones, if set to `false`.
117-
If set to `true`, which is the default value of the option, it deletes the existing object properties.
118-
119115
- `removeOtherSetEntries`
120116
a flag which enables the sync module to add additional Set entries without deleting existing ones, if set to `false`.
121117
If set to `true`, which is the default value of the option, it deletes the existing Set entries.
@@ -133,6 +129,10 @@ object properties.
133129
- `allowUuid`
134130
a flag, if set to `true`, enables the user to use keys with UUID format for references. By default, it is set to `false`.
135131

132+
- `beforeUpdateCallback`
133+
a filter function which can be applied on a generated list of update actions. It allows the user to intercept inventory
134+
entry update and modify (add/remove) update actions just before they are send to CTP API.
135+
136136
<!-- TODO Update above options with links to tests. Tests should be written when inventory sync could actually use them (when custom update actions would use them). -->
137137

138138
## Under the hood

docs/usage/PRODUCT_SYNC.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ events.
6666
- `warningCallBack`
6767
a callback that is called whenever an event occurs during the sync process that represents a warning. Currently, these
6868
events.
69-
<!--
70-
- `removeOtherLocales`
71-
a flag which enables the sync module to add additional localizations without deleting existing ones, if set to `false`.
69+
<!--
7270
If set to `true`, which is the default value of the option, it deletes the existing object properties.
7371
- `removeOtherSetEntries`
7472
a flag which enables the sync module to add additional Set entries without deleting existing ones, if set to `false`.
@@ -95,9 +93,9 @@ object properties. -->
9593

9694
- The list of action groups allowed to be blacklist or whitelisted on products can be found [here](/src/main/java/com/commercetools/sync/products/ActionGroup.java).
9795

98-
- `updateActionsCallBack`
99-
a filter function which can be applied on generated list of update actions to produce a resultant list after the filter
100-
function has been applied.
96+
- `beforeUpdateCallback`
97+
a filter function which can be applied on a generated list of update actions. It allows the user to intercept product
98+
update and modify (add/remove) update actions just before they are send to CTP API.
10199
- `allowUuid`
102100
a flag, if set to `true`, enables the user to use keys with UUID format for references. By default, it is set to `false`.
103101

src/integration-test/java/com/commercetools/sync/integration/ctpprojectsource/categories/CategorySyncIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ public void setupTest() {
8282

8383
final CategorySyncOptions categorySyncOptions = CategorySyncOptionsBuilder
8484
.of(CTP_TARGET_CLIENT)
85-
.setErrorCallBack((errorMessage, exception) -> {
85+
.errorCallback((errorMessage, exception) -> {
8686
callBackErrorResponses.add(errorMessage);
8787
callBackExceptions.add(exception);
8888
})
89-
.setWarningCallBack((warningMessage) -> callBackWarningResponses.add(warningMessage))
89+
.warningCallback((warningMessage) -> callBackWarningResponses.add(warningMessage))
9090
.build();
9191
categorySync = new CategorySync(categorySyncOptions);
9292
}
@@ -168,14 +168,14 @@ public void syncDrafts_WithUpdatedCategoriesWithoutReferenceKeys_ShouldNotSyncCa
168168
+ " key:'%s'. Reason: %s: Failed to resolve custom type reference on "
169169
+ "CategoryDraft with key:'%s'. "
170170
+ "Reason: Found a UUID in the id field. Expecting a key without a UUID value. If you want to allow"
171-
+ " UUID values for reference keys, please use the setAllowUuidKeys(true) option in the sync options.",
171+
+ " UUID values for reference keys, please use the allowUuidKeys(true) option in the sync options.",
172172
key1, ReferenceResolutionException.class.getCanonicalName(), key1));
173173
final String key2 = categoryDrafts.get(1).getKey();
174174
assertThat(callBackErrorResponses.get(1)).isEqualTo(format("Failed to resolve references on CategoryDraft with"
175175
+ " key:'%s'. Reason: %s: Failed to resolve custom type reference on "
176176
+ "CategoryDraft with key:'%s'. Reason: "
177177
+ "Found a UUID in the id field. Expecting a key without a UUID value. If you want to allow UUID values"
178-
+ " for reference keys, please use the setAllowUuidKeys(true) option in the sync options.",
178+
+ " for reference keys, please use the allowUuidKeys(true) option in the sync options.",
179179
key2, ReferenceResolutionException.class.getCanonicalName(), key2));
180180

181181
assertThat(callBackExceptions).hasSize(2);

src/integration-test/java/com/commercetools/sync/integration/ctpprojectsource/categories/updateactionutils/ChangeOrderHintIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void setupTest() {
6060
deleteAllCategories(CTP_SOURCE_CLIENT);
6161
callBackResponses = new ArrayList<>();
6262
categorySyncOptions = CategorySyncOptionsBuilder.of(CTP_TARGET_CLIENT)
63-
.setWarningCallBack(callBackResponses::add)
63+
.warningCallback(callBackResponses::add)
6464
.build();
6565
}
6666

src/integration-test/java/com/commercetools/sync/integration/ctpprojectsource/categories/updateactionutils/ChangeParentIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void setupTest() {
7070
deleteAllCategories(CTP_SOURCE_CLIENT);
7171
callBackResponses = new ArrayList<>();
7272
categorySyncOptions = CategorySyncOptionsBuilder.of(CTP_TARGET_CLIENT)
73-
.setWarningCallBack(callBackResponses::add)
73+
.warningCallback(callBackResponses::add)
7474
.build();
7575
}
7676

src/integration-test/java/com/commercetools/sync/integration/ctpprojectsource/products/ProductReferenceResolverIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,14 @@ public void setupTest() {
108108
warningCallBackMessages = new ArrayList<>();
109109

110110
final ProductSyncOptions syncOptions = ProductSyncOptionsBuilder.of(CTP_TARGET_CLIENT)
111-
.setErrorCallBack(
111+
.errorCallback(
112112
(errorMessage, exception) -> {
113113
errorCallBackMessages
114114
.add(errorMessage);
115115
errorCallBackExceptions
116116
.add(exception);
117117
})
118-
.setWarningCallBack(warningMessage ->
118+
.warningCallback(warningMessage ->
119119
warningCallBackMessages
120120
.add(warningMessage))
121121
.build();

src/integration-test/java/com/commercetools/sync/integration/ctpprojectsource/products/ProductSyncIT.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ private void clearSyncTestCollections() {
149149

150150
private ProductSyncOptions buildSyncOptions() {
151151
return ProductSyncOptionsBuilder.of(CTP_TARGET_CLIENT)
152-
.setErrorCallBack(this::errorCallback)
153-
.setWarningCallBack(warningCallBackMessages::add)
154-
.setUpdateActionsFilterCallBack(this::updateActionsCallback)
152+
.errorCallback(this::errorCallback)
153+
.warningCallback(warningCallBackMessages::add)
154+
.beforeUpdateCallback(this::beforeUpdateCallback)
155155
.build();
156156
}
157157

@@ -160,9 +160,11 @@ private void errorCallback(@Nonnull final String errorMessage, @Nullable final T
160160
errorCallBackExceptions.add(exception);
161161
}
162162

163-
private List<UpdateAction<Product>> updateActionsCallback(@Nonnull final List<UpdateAction<Product>> builtActions) {
164-
updateActions.addAll(builtActions);
165-
return builtActions;
163+
private List<UpdateAction<Product>> beforeUpdateCallback(@Nonnull final List<UpdateAction<Product>> updateActions,
164+
@Nonnull final ProductDraft productDraft,
165+
@Nonnull final Product oldProduct) {
166+
this.updateActions.addAll(updateActions);
167+
return updateActions;
166168
}
167169

168170
@AfterClass
@@ -279,10 +281,10 @@ public void sync_withProductTypeReference_ShouldUpdateProducts() {
279281
// Create custom options with whitelisting and action filter callback..
280282
final ProductSyncOptions customSyncOptions =
281283
ProductSyncOptionsBuilder.of(CTP_TARGET_CLIENT)
282-
.setErrorCallBack(this::errorCallback)
283-
.setWarningCallBack(warningCallBackMessages::add)
284-
.setUpdateActionsFilterCallBack(this::updateActionsCallback)
285-
.setSyncFilter(SyncFilter.ofWhiteList(ATTRIBUTES))
284+
.errorCallback(this::errorCallback)
285+
.warningCallback(warningCallBackMessages::add)
286+
.beforeUpdateCallback(this::beforeUpdateCallback)
287+
.syncFilter(SyncFilter.ofWhiteList(ATTRIBUTES))
286288
.build();
287289
final ProductSync customSync = new ProductSync(customSyncOptions);
288290

src/integration-test/java/com/commercetools/sync/integration/externalsource/categories/CategorySyncIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public void syncDrafts_WithConcurrentModificationExceptionAndUnexpectedDelete_Sh
238238

239239
final CategorySyncOptions categorySyncOptions =
240240
CategorySyncOptionsBuilder.of(spyClient)
241-
.setErrorCallBack((errorMessage, error) -> {
241+
.errorCallback((errorMessage, error) -> {
242242
errorMessages.add(errorMessage);
243243
errors.add(error);
244244
})

0 commit comments

Comments
 (0)