#300: Add support for sync of custom types#304
Conversation
- Adds the core type sync implementations - Adds some unit tests
Codecov Report
@@ Coverage Diff @@
## master #304 +/- ##
============================================
+ Coverage 96.91% 97.09% +0.17%
- Complexity 1097 1203 +106
============================================
Files 104 116 +12
Lines 2693 2963 +270
Branches 129 137 +8
============================================
+ Hits 2610 2877 +267
- Misses 71 72 +1
- Partials 12 14 +2
Continue to review full report at Codecov.
|
lojzatran
left a comment
There was a problem hiding this comment.
Nice work with this PR! I found few things that needs to be addressed or answered.
Pls also update the product type sync if you address the changes, because it seems like you got a lot of inspirations from there.
| // remove enum value actions not exists for type resources | ||
| assertThat(updateActions).containsExactly( | ||
| ChangeLocalizedEnumValueOrder.of(FIELD_NAME_1, asList( | ||
| ENUM_VALUE_C.getKey(), |
There was a problem hiding this comment.
What about A? Don't you have to have all enums in this action?
There was a problem hiding this comment.
A should be removed but it's not supported by the API.
There was a problem hiding this comment.
I would keep a test that its failing for it but mark it with @ignore annotation and a TODO comment to fix it once the API provides it.
| - Retries on 5xx errors with a retry strategy. This can be achieved by decorating the `sphereClient` with the | ||
| [RetrySphereClientDecorator](http://commercetools.github.io/commercetools-jvm-sdk/apidocs/io/sphere/sdk/client/RetrySphereClientDecorator.html) | ||
|
|
||
| You can use the same client instantiating used in the integration tests for this library found |
There was a problem hiding this comment.
...You can use the same client instance in the integration tests
There was a problem hiding this comment.
There was a problem hiding this comment.
@ahalberkamp @ahmetoz no actually it's not meant to say you can use the "same client instance". It should be along the lines: "You can instantiate the client the same way it is instantiated in the integration tests for this library found.."
| @Nonnull final List<TypeDraft> typeDrafts) { | ||
|
|
||
| final List<List<TypeDraft>> batches = batchElements(typeDrafts, syncOptions.getBatchSize()); | ||
|
|
There was a problem hiding this comment.
I could not find a fancy name for it 😅 |
You should find a fancy name :) It's open-source repo and everybody can see our code. |
|
Usually I add a release notes entry for what has changed/added/enhances/fixed (that the user of the library needs to know) in the PR in the commented out section that it will be released in. The release notes file is: This also includes any public methods/utils that users from outside the library can use or cannot use anymore. Or are already using and some behaviour has changed for example. Please add entries related to your PR there too :) |
heshamMassoud
left a comment
There was a problem hiding this comment.
Good work @ahmetoz! I added a first review of this PR.
| [Javadoc](https://commercetools.github.io/commercetools-sync-java/v/v1.0.0-M14/) | | ||
| [Jar](https://bintray.com/commercetools/maven/commercetools-sync-java/v1.0.0-M14) | ||
|
|
||
| **New Features** (1) |
There was a problem hiding this comment.
Please add also entries for all the public utils that were added.
There was a problem hiding this comment.
|
|
||
| 1. Types are either created or updated. Currently the tool does not support type deletion. | ||
| 2. Updating the label of enum values and localized enum values of field definition is not supported yet. | ||
| 3. Removing the enum values from the field definition is not supported yet. |
There was a problem hiding this comment.
nice that you added them as caveats here 😊Would be great if you can also mention/link the CTP support tickets related to them (of course only if they are public) so we can cross relate them in the future.
There was a problem hiding this comment.
Tickets for the issues are not public 👎
|
|
||
| __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 not known by the sync which batch is going to be the last one supplied. |
There was a problem hiding this comment.
It is not not -> It is not
There was a problem hiding this comment.
|
|
||
| /** | ||
| * Creates new instance of {@link TypeSyncOptions} enriched with all fields provided to {@code this} | ||
| * builder. |
There was a problem hiding this comment.
builder doesn't have to be on a separate line 😉
There was a problem hiding this comment.
| import javax.annotation.Nonnull; | ||
|
|
||
| public final class TypeSyncOptionsBuilder extends BaseSyncOptionsBuilder<TypeSyncOptionsBuilder, | ||
| TypeSyncOptions, Type, TypeDraft> { |
There was a problem hiding this comment.
I think this line is extra indented..
There was a problem hiding this comment.
| * @return A list with the update actions or an empty list if the field definition fields are identical. | ||
| */ | ||
| @Nonnull | ||
| public static List<UpdateAction<Type>> buildActions( |
| final Map<String, Type> oldTypeMap = getKeysTypeMap(oldTypes); | ||
|
|
||
| return CompletableFuture.allOf(newTypes | ||
| .stream() |
There was a problem hiding this comment.
Its always more readable if you indent the chain dots of the same level with the same indentation level.
There was a problem hiding this comment.
| */ | ||
| @Nonnull | ||
| CompletionStage<Optional<String>> fetchCachedTypeId(@Nonnull final String key); | ||
|
|
There was a problem hiding this comment.
Please cover the newly added services with integration tests.
| // remove enum value actions not exists for type resources | ||
| assertThat(updateActions).containsExactly( | ||
| ChangeLocalizedEnumValueOrder.of(FIELD_NAME_1, asList( | ||
| ENUM_VALUE_C.getKey(), |
There was a problem hiding this comment.
I would keep a test that its failing for it but mark it with @ignore annotation and a TODO comment to fix it once the API provides it.
| ); | ||
|
|
||
| assertThat(updateActions).containsExactly( | ||
| RemoveFieldDefinition.of(FIELD_A), |
There was a problem hiding this comment.
In this test you are testing the fact the correct update actions have been built. Only in this test, the order doesn't matter. So you should actually assert with containsExactlyInAnyOrder not with containsExactly.
However, order definitely matters which update actions are generated before which. But this should have it's own unit test focusing on testing the order of the generated actions with a strict containsExactly assert. This way you don't test two things together.
|
In general I see a lot of code duplication between the Type sync and the Product Type sync especially with the enum implementations. I think we should move the common parts to the commons package and resuse:
|
….com/commercetools/commercetools-sync-java into 300-feature-type-sync # Conflicts: # docs/RELEASE_NOTES.md
…ols/commercetools-sync-java into 300-feature-type-sync
….com/commercetools/commercetools-sync-java into 300-feature-type-sync # Conflicts: # docs/RELEASE_NOTES.md # src/benchmark/java/com/commercetools/sync/benchmark/BenchmarkUtils.java
Summary
Adds implementations for the type sync.
Description
Relevant Issues
#300
Todo
Tests
Documentation
Add Release Notes entry.
Hints for Review