{"action":"created","comment":{"url":"https://api.github.com/repos/commercetools/commercetools-sync-java/pulls/comments/146784996","pull_request_review_id":71565483,"id":146784996,"diff_hunk":"@@ -226,18 +239,73 @@ public ProductReferenceResolver(@Nonnull final ProductSyncOptions productSyncOpt\n      *         if it exists or empty if it doesn't.\n      */\n     @Nonnull\n-    private CompletionStage<Optional<String>> getProductTypeId(@Nonnull final ResourceIdentifier<ProductType>\n-                                                                   productTypeResourceIdentifier,\n-                                                               @Nonnull final String referenceResolutionErrorMessage) {\n+    private CompletionStage<Optional<String>> getProductTypeId(\n+            @Nonnull final ResourceIdentifier<ProductType> productTypeResourceIdentifier,\n+            @Nonnull final String referenceResolutionErrorMessage) {\n         try {\n             final String productTypeKey = getKeyFromResourceIdentifier(productTypeResourceIdentifier,\n                 options.shouldAllowUuidKeys());\n             return productTypeService.fetchCachedProductTypeId(productTypeKey);\n         } catch (ReferenceResolutionException exception) {\n-            return CompletableFutureUtils.exceptionallyCompletedFuture(\n+            return exceptionallyCompletedFuture(\n                 new ReferenceResolutionException(\n                     format(\"%s Reason: %s\", referenceResolutionErrorMessage, exception.getMessage()), exception));\n         }\n     }\n \n+    @Nonnull\n+    private CompletionStage<ProductDraftBuilder> resolveTaxCategoryReferences(\n+            @Nonnull final ProductDraftBuilder draftBuilder) {\n+        return resolveReference(draftBuilder, ProductDraftBuilder::getTaxCategory,\n+            taxCategoryService::fetchCachedTaxCategoryId, TaxCategory::referenceOfId, ProductDraftBuilder::taxCategory);\n+    }\n+\n+    @Nonnull\n+    private CompletionStage<ProductDraftBuilder> resolveStateReferences(\n+            @Nonnull final ProductDraftBuilder draftBuilder) {\n+        return resolveReference(draftBuilder,\n+            ProductDraftBuilder::getState, stateService::fetchCachedStateId, State::referenceOfId,\n+            ProductDraftBuilder::state);\n+    }\n+\n+    /**\n+     * Common function to resolve references from key.\n+     *\n+     * @param draftBuilder        {@link ProductDraftBuilder} to update\n+     * @param referenceProvider   function which returns the reference which should be resolver from the\n+     *                            {@code productDraft}\n+     * @param keyToIdMapper       function which calls respective service to fetch the reference by key\n+     * @param idToReferenceMapper function which creates {@link Reference} instance from fetched id\n+     * @param referenceSetter     function which will set the resolved reference to the {@code productDraft}\n+     * @param <T>                 type of reference (e.g. {@link State}, {@link TaxCategory}\n+     * @return {@link CompletionStage} containing {@link ProductDraft} with resolved &lt;T&gt; reference.","path":"src/main/java/com/commercetools/sync/products/helpers/ProductReferenceResolver.java","position":309,"original_position":309,"commit_id":"4486cd51796a226b5ae7dc9f82e6313a514f8c0b","original_commit_id":"4486cd51796a226b5ae7dc9f82e6313a514f8c0b","user":{"login":"heshamMassoud","id":9512131,"avatar_url":"https://avatars2.githubusercontent.com/u/9512131?v=4","gravatar_id":"","url":"https://api.github.com/users/heshamMassoud","html_url":"https://github.com/heshamMassoud","followers_url":"https://api.github.com/users/heshamMassoud/followers","following_url":"https://api.github.com/users/heshamMassoud/following{/other_user}","gists_url":"https://api.github.com/users/heshamMassoud/gists{/gist_id}","starred_url":"https://api.github.com/users/heshamMassoud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heshamMassoud/subscriptions","organizations_url":"https://api.github.com/users/heshamMassoud/orgs","repos_url":"https://api.github.com/users/heshamMassoud/repos","events_url":"https://api.github.com/users/heshamMassoud/events{/privacy}","received_events_url":"https://api.github.com/users/heshamMassoud/received_events","type":"User","site_admin":false},"body":"`ProductDraft` -> `ProductDraftBuilder`","created_at":"2017-10-25T08:24:49Z","updated_at":"2017-10-25T08:37:03Z","html_url":"https://github.com/commercetools/commercetools-sync-java/pull/153#discussion_r146784996","pull_request_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/pulls/153","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/commercetools/commercetools-sync-java/pulls/comments/146784996"},"html":{"href":"https://github.com/commercetools/commercetools-sync-java/pull/153#discussion_r146784996"},"pull_request":{"href":"https://api.github.com/repos/commercetools/commercetools-sync-java/pulls/153"}}},"pull_request":{"url":"https://api.github.com/repos/commercetools/commercetools-sync-java/pulls/153","id":147576608,"html_url":"https://github.com/commercetools/commercetools-sync-java/pull/153","diff_url":"https://github.com/commercetools/commercetools-sync-java/pull/153.diff","patch_url":"https://github.com/commercetools/commercetools-sync-java/pull/153.patch","issue_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/issues/153","number":153,"state":"open","locked":false,"title":"WIP: 120 tax category","user":{"login":"heshamMassoud","id":9512131,"avatar_url":"https://avatars2.githubusercontent.com/u/9512131?v=4","gravatar_id":"","url":"https://api.github.com/users/heshamMassoud","html_url":"https://github.com/heshamMassoud","followers_url":"https://api.github.com/users/heshamMassoud/followers","following_url":"https://api.github.com/users/heshamMassoud/following{/other_user}","gists_url":"https://api.github.com/users/heshamMassoud/gists{/gist_id}","starred_url":"https://api.github.com/users/heshamMassoud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heshamMassoud/subscriptions","organizations_url":"https://api.github.com/users/heshamMassoud/orgs","repos_url":"https://api.github.com/users/heshamMassoud/repos","events_url":"https://api.github.com/users/heshamMassoud/events{/privacy}","received_events_url":"https://api.github.com/users/heshamMassoud/received_events","type":"User","site_admin":false},"body":"#### Summary\r\n  - updated JVM SDK to 1.25.0\r\n    - re-factor `Category/Inventory/Price/ProductReferenceResolvers` to use `*DraftBuilder` instead of `*Draft`\r\n  - in [`ProductReferenceResolver`](https://github.com/commercetools/commercetools-sync-java/pull/153/files#diff-0a79a67e66112ba2c9dd95da412f7048): added [`resolveTaxCategoryReferences()`](https://github.com/commercetools/commercetools-sync-java/pull/153/files#diff-0a79a67e66112ba2c9dd95da412f7048R257) and [`resolveStateReferences()`](https://github.com/commercetools/commercetools-sync-java/pull/153/files#diff-0a79a67e66112ba2c9dd95da412f7048R264)\r\n    - [`ProductUpdateActionUtils`](https://github.com/commercetools/commercetools-sync-java/pull/153/files#diff-540361586e271c4157d1afe06f9c8636): [`buildSetTaxCategoryUpdateAction`](https://github.com/commercetools/commercetools-sync-java/pull/153/files#diff-540361586e271c4157d1afe06f9c8636R584) and [`buildTransitionStateUpdateAction`](https://github.com/commercetools/commercetools-sync-java/pull/153/files#diff-540361586e271c4157d1afe06f9c8636R606)\r\n\r\n#### Description\r\nImplemented products TaxCategory and State reference resolvers. Also, all other resolvers are refactored to use mutable DraftBuilders instead of rebuilding Drafts on each resolving step\r\n\r\n#### Relevant Issues\r\n#120 and #131\r\n\r\n- Tests\r\n  Implemented just couple of shallow unit tests to adjust, the rest is expected to be merged from `120-state-taxcategory-ref-res`\r\n","created_at":"2017-10-19T14:44:26Z","updated_at":"2017-10-25T08:37:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"98c92474a981dbb827b3928e87cb682475a4613d","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/pulls/153/commits","review_comments_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/pulls/153/comments","review_comment_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/issues/153/comments","statuses_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/statuses/4486cd51796a226b5ae7dc9f82e6313a514f8c0b","head":{"label":"commercetools:120-tax-category","ref":"120-tax-category","sha":"4486cd51796a226b5ae7dc9f82e6313a514f8c0b","user":{"login":"commercetools","id":1084585,"avatar_url":"https://avatars3.githubusercontent.com/u/1084585?v=4","gravatar_id":"","url":"https://api.github.com/users/commercetools","html_url":"https://github.com/commercetools","followers_url":"https://api.github.com/users/commercetools/followers","following_url":"https://api.github.com/users/commercetools/following{/other_user}","gists_url":"https://api.github.com/users/commercetools/gists{/gist_id}","starred_url":"https://api.github.com/users/commercetools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/commercetools/subscriptions","organizations_url":"https://api.github.com/users/commercetools/orgs","repos_url":"https://api.github.com/users/commercetools/repos","events_url":"https://api.github.com/users/commercetools/events{/privacy}","received_events_url":"https://api.github.com/users/commercetools/received_events","type":"Organization","site_admin":false},"repo":{"id":84962876,"name":"commercetools-sync-java","full_name":"commercetools/commercetools-sync-java","owner":{"login":"commercetools","id":1084585,"avatar_url":"https://avatars3.githubusercontent.com/u/1084585?v=4","gravatar_id":"","url":"https://api.github.com/users/commercetools","html_url":"https://github.com/commercetools","followers_url":"https://api.github.com/users/commercetools/followers","following_url":"https://api.github.com/users/commercetools/following{/other_user}","gists_url":"https://api.github.com/users/commercetools/gists{/gist_id}","starred_url":"https://api.github.com/users/commercetools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/commercetools/subscriptions","organizations_url":"https://api.github.com/users/commercetools/orgs","repos_url":"https://api.github.com/users/commercetools/repos","events_url":"https://api.github.com/users/commercetools/events{/privacy}","received_events_url":"https://api.github.com/users/commercetools/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/commercetools/commercetools-sync-java","description":null,"fork":false,"url":"https://api.github.com/repos/commercetools/commercetools-sync-java","forks_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/forks","keys_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/teams","hooks_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/hooks","issue_events_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/issues/events{/number}","events_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/events","assignees_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/assignees{/user}","branches_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/branches{/branch}","tags_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/tags","blobs_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/statuses/{sha}","languages_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/languages","stargazers_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/stargazers","contributors_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/contributors","subscribers_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/subscribers","subscription_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/subscription","commits_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/contents/{+path}","compare_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/merges","archive_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/downloads","issues_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/issues{/number}","pulls_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/pulls{/number}","milestones_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/milestones{/number}","notifications_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/labels{/name}","releases_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/releases{/id}","deployments_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/deployments","created_at":"2017-03-14T15:06:58Z","updated_at":"2017-10-18T14:06:54Z","pushed_at":"2017-10-24T14:09:16Z","git_url":"git://github.com/commercetools/commercetools-sync-java.git","ssh_url":"git@github.com:commercetools/commercetools-sync-java.git","clone_url":"https://github.com/commercetools/commercetools-sync-java.git","svn_url":"https://github.com/commercetools/commercetools-sync-java","homepage":null,"size":3194,"stargazers_count":5,"watchers_count":5,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":67,"forks":1,"open_issues":67,"watchers":5,"default_branch":"master"}},"base":{"label":"commercetools:master","ref":"master","sha":"13962ee8aec99e515ca80db70b6c0178eb813f18","user":{"login":"commercetools","id":1084585,"avatar_url":"https://avatars3.githubusercontent.com/u/1084585?v=4","gravatar_id":"","url":"https://api.github.com/users/commercetools","html_url":"https://github.com/commercetools","followers_url":"https://api.github.com/users/commercetools/followers","following_url":"https://api.github.com/users/commercetools/following{/other_user}","gists_url":"https://api.github.com/users/commercetools/gists{/gist_id}","starred_url":"https://api.github.com/users/commercetools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/commercetools/subscriptions","organizations_url":"https://api.github.com/users/commercetools/orgs","repos_url":"https://api.github.com/users/commercetools/repos","events_url":"https://api.github.com/users/commercetools/events{/privacy}","received_events_url":"https://api.github.com/users/commercetools/received_events","type":"Organization","site_admin":false},"repo":{"id":84962876,"name":"commercetools-sync-java","full_name":"commercetools/commercetools-sync-java","owner":{"login":"commercetools","id":1084585,"avatar_url":"https://avatars3.githubusercontent.com/u/1084585?v=4","gravatar_id":"","url":"https://api.github.com/users/commercetools","html_url":"https://github.com/commercetools","followers_url":"https://api.github.com/users/commercetools/followers","following_url":"https://api.github.com/users/commercetools/following{/other_user}","gists_url":"https://api.github.com/users/commercetools/gists{/gist_id}","starred_url":"https://api.github.com/users/commercetools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/commercetools/subscriptions","organizations_url":"https://api.github.com/users/commercetools/orgs","repos_url":"https://api.github.com/users/commercetools/repos","events_url":"https://api.github.com/users/commercetools/events{/privacy}","received_events_url":"https://api.github.com/users/commercetools/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/commercetools/commercetools-sync-java","description":null,"fork":false,"url":"https://api.github.com/repos/commercetools/commercetools-sync-java","forks_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/forks","keys_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/teams","hooks_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/hooks","issue_events_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/issues/events{/number}","events_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/events","assignees_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/assignees{/user}","branches_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/branches{/branch}","tags_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/tags","blobs_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/statuses/{sha}","languages_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/languages","stargazers_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/stargazers","contributors_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/contributors","subscribers_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/subscribers","subscription_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/subscription","commits_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/contents/{+path}","compare_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/merges","archive_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/downloads","issues_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/issues{/number}","pulls_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/pulls{/number}","milestones_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/milestones{/number}","notifications_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/labels{/name}","releases_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/releases{/id}","deployments_url":"https://api.github.com/repos/commercetools/commercetools-sync-java/deployments","created_at":"2017-03-14T15:06:58Z","updated_at":"2017-10-18T14:06:54Z","pushed_at":"2017-10-24T14:09:16Z","git_url":"git://github.com/commercetools/commercetools-sync-java.git","ssh_url":"git@github.com:commercetools/commercetools-sync-java.git","clone_url":"https://github.com/commercetools/commercetools-sync-java.git","svn_url":"https://github.com/commercetools/commercetools-sync-java","homepage":null,"size":3194,"stargazers_count":5,"watchers_count":5,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":67,"forks":1,"open_issues":67,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/commercetools/commercetools-sync-java/pulls/153"},"html":{"href":"https://github.com/commercetools/commercetools-sync-java/pull/153"},"issue":{"href":"https://api.github.com/repos/commercetools/commercetools-sync-java/issues/153"},"comments":{"href":"https://api.github.com/repos/commercetools/commercetools-sync-java/issues/153/comments"},"review_comments":{"href":"https://api.github.com/repos/commercetools/commercetools-sync-java/pulls/153/comments"},"review_comment":{"href":"https://api.github.com/repos/commercetools/commercetools-sync-java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/commercetools/commercetools-sync-java/pulls/153/commits"},"statuses":{"href":"https://api.github.com/repos/commercetools/commercetools-sync-java/statuses/4486cd51796a226b5ae7dc9f82e6313a514f8c0b"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"heshamMassoud"}}