-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement utility class and helper classes for CustomObjectSync (#561)
* Implement utility class and helper classes for CustomObjectSync * Enhance the CustomObjectSyncUtilsTest to check JsonNode in different datatypes. * Remove non-null annotation in CustomObjectSyncUtils * Fix incorrect javadoc in CustomObjectSyncStatistics * Remove unused variable in CustomObjectSyncUtilsTest * Refactor CustomObjectSyncUtilsTest * Revert "Refactor CustomObjectSyncUtilsTest" This reverts commit 1e6b7b4. * Remove blank line * Refactor CustomObjectSyncUtilsTest * Remove batchElements from CustomObjectSyncUtils * Remove unused import and change the class variables to be local variables * Remove spaces in CustomObjectSyncUtilsTest * Add customobjects sync (#569) * Implement CustomObjectSync * Enhance the CustomObjectSyncUtilsTest to check JsonNode in different datatypes. * Inherit CustomObjetSync from BaseSync * Remove batchElements from CustomObjectSyncUtils * Remove non-null annotation in CustomObjectSyncUtils * Fix import problem in CustomObjectSync * Add override methods for equals and hashCode * Add assertion for CustomObjectSyncStatistics * Create CustomObjectSyncStatisticsAssert class * Add first unit test scenario to CustomObjectSyncTest * Add unit test scenario * Implement unit test for custom object update in CustomObjectSyncTest * Change the deprecated method * Fix checkstyle problem * Fix unit case problem in mocking composite identifier * Remove unused import in CustomObjectCompositeIdentifier * Remove unused import in CustomObjectSyncTest * Revert the change on CustomObjectSyncUtilsTest * Revert the change in CustomObjectSyncUtilsTest * Refactor sync class to increase coverage * Remove unused import in CustomObjectSyncTest * Apply correct style formatting * Fix checkstyleMain issues * Fix checkStyle issue * Add public constructor in CustomObjectSync * Remove blank line after javadoc * Apply method reference in lambda in CustomObjectSync * Update error message * Change javadoc for method CustomObjectSync.validateDraft() * Change error messages * Avoid calling CTP when two custom objects are identical. * Fix unit test expected error message * Correct the javadoc for updateCustomObject() * Add unit test cases and fix bugs * Rename unit test method * Add unit test case to cover update retry failure * Fix expected result in unit test * Remove blank lines * Refactor CustomObjectSyncTest * Fix findbugs problem * Rename Response to be ResponseEntry * Remove blank lines and fix indentation * Fix indentation in CustomObjectServiceImpl * Remove blank lines * Add equals() and hashCode() in CustomObjectCompositeIdentifier * Add unit test cases * Fix indentation in CustomObjectSyncTest * Add CustomObjectCompositeIdentifierTest Co-authored-by: ninalindl <[email protected]> * CustomObject sync finalization (#573) * Add integration tests in CustomObjectSyncIT * Fix integration test case for update custom object * Fix CustomObjectSync for ConcurrentModificationException handling * Fix refactoring problem in BaseService * Delete newly created custom object between every test case * Update README.md * Update README.md * Add CUSTOM_OBJECT_SYNC.md * Add release note for v2.1.0 * Update release notes * Update version number to v2.1.0 * Fix documentation * Remove redundant java comment * Fix javadoc and java comments * Remove empty line in BaseService * Remove empty lines in CustomObjectSyncIT * Add javadoc for CustomObjectServiceImpl.executeCreateCommand() * Revert "Add javadoc for CustomObjectServiceImpl.executeCreateCommand()" This reverts commit 390680b. * Add javadoc to describe CustomObjectServiceImpl.executeCreateCommand() * Modify test case method naming in CustomObjectSyncIT * Update RELEASE_NOTES.md * Update CUSTOM_OBJECT_SYNC.md * Remove unused import * Modify javadoc for CustomObjectServiceImpl.executeCreateCommand() * Revert "Modify javadoc for CustomObjectServiceImpl.executeCreateCommand()" This reverts commit 9ad46a0. * Modify javadoc for CustomObjectSerivceImpl.executeCreateCommand() Co-authored-by: ninalindl <[email protected]> * Add unit test case for CustomObjectServiceImpl to increase coverage rate * Fix indentation * Add link in mkdocs.yml * Add private constructor to increase coverage * Revert "Add private constructor to increase coverage" This reverts commit 6e71275. * Update RELEASE_NOTES Co-authored-by: ninalindl <[email protected]>
- Loading branch information
1 parent
fc5a9a9
commit 4c5234c
Showing
36 changed files
with
2,255 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Custom Object Sync | ||
|
||
Module used for importing/syncing CustomObject into a commercetools project. | ||
It also provides utilities for correlating a custom object to a given custom object draft based on the | ||
comparison of a [CustomObject](https://docs.commercetools.com/http-api-projects-custom-objects#customobject) | ||
against a [CustomObjectDraft](https://docs.commercetools.com/http-api-projects-custom-objects#customobjectdraft). | ||
|
||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
||
|
||
- [Usage](#usage) | ||
- [Sync list of CustomObjectDrafts](#sync-list-of-customobjectdrafts) | ||
- [Prerequisites](#prerequisites) | ||
- [Running the sync](#running-the-sync) | ||
- [More examples of how to use the sync](#more-examples-of-how-to-use-the-sync) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
## Usage | ||
### Sync list of CustomObjectDrafts | ||
|
||
#### Prerequisites | ||
1. The sync expects a list of `CustomObjectDraft`s that have their `key` and `container` fields set to be matched with | ||
custom objects in the target CTP project. Therefore, the custom objects in the target project are expected to have the | ||
same `key` and `container` fields set, otherwise they won't be matched. | ||
|
||
2. Create a `sphereClient` [as described here](IMPORTANT_USAGE_TIPS.md#sphereclient-creation). | ||
|
||
3. After the `sphereClient` is set up, a `CustomObjectSyncOptions` should be be built as follows: | ||
````java | ||
// instantiating a CustomObjectSyncOptions | ||
final CustomObjectSyncOptions customObjectSyncOptions = CustomObjectSyncOptionsBuilder.of(sphereClient).build(); | ||
```` | ||
|
||
[More information about Sync Options](SYNC_OPTIONS.md). | ||
|
||
#### Running the sync | ||
After all the aforementioned points in the previous section have been fulfilled, to run the sync: | ||
````java | ||
// instantiating a CustomObjectSync | ||
final CustomObjectSync customObjectSync = new CustomObjectSync(customObjectSyncOptions); | ||
|
||
// execute the sync on your list of custom object drafts | ||
CompletionStage<CustomObjectSyncStatistics> syncStatisticsStage = customObjectSync.sync(customObjectDrafts); | ||
```` | ||
The result of the completing the `syncStatisticsStage` in the previous code snippet contains a `CustomObjectSyncStatistics` | ||
which contains all the stats of the sync process; which includes a report message, the total number of updated, created, | ||
failed, processed custom objects and the processing time of the last sync batch in different time units and in a | ||
human-readable format. | ||
|
||
````java | ||
final CustomObjectSyncStatistics stats = syncStatisticsStage.toCompletebleFuture().join(); | ||
stats.getReportMessage(); | ||
/*"Summary: 2000 custom objects were processed in total (1000 created, 995 updated, 5 failed to sync)."*/ | ||
```` | ||
|
||
__Note__ The statistics object contains the processing time of the last batch only. This is due to two reasons: | ||
|
||
1. The sync processing time should not take into account the time between supplying batches to the sync. | ||
2. It is not known by the sync which batch is going to be the last one supplied. | ||
|
||
#### More examples of how to use the sync | ||
|
||
- [Sync from an external source](https://github.com/commercetools/commercetools-sync-java/tree/master/src/integration-test/java/com/commercetools/sync/integration/externalsource/customobjects/CustomObjectSyncIT.java). | ||
|
||
*Make sure to read the [Important Usage Tips](IMPORTANT_USAGE_TIPS.md) for optimal performance.* | ||
|
||
More examples of those utils for different custom objects can be found [here](https://github.com/commercetools/commercetools-sync-java/tree/master/src/test/java/com/commercetools/sync/customobjects/utils/CustomObjectSyncUtilsTest.java). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.