Skip to content

Commit

Permalink
Update commercetools-sync-java to v10.0.0
Browse files Browse the repository at this point in the history
* Install sync-java-version 10 beta and change http client.

* Migrate abstract syncer (#484)

* Migrate abstract syncer, utils and tests (only compilable)

* Adjust javadoc

* Use consistent return type

* Make syncer implementation compilable (#485)

* Migrate abstract syncer, utils and tests (only compilable)

* Adjust javadoc

* Adjust signature of syncer subclasses and fix code

* Formatting

* Remove unused constant

* Comment not compilable unittests

* Migrate SyncerFactory and CliRunner (#496)

* Migrate SyncerFactory

* Migrate client utils and rename

* Migrate CliRunner

* Migrate unittests for SyncerFactory

* Migrate unittests for CLIRunner

* Cleanup test code

* Add final modifier

Co-authored-by: Lam Tran <[email protected]>

---------

Co-authored-by: Lam Tran <[email protected]>

* Approved tasks from syncer factory base (#497)

* Migrate SyncerFactory

* Migrate client utils and rename

* Migrate CliRunner

* Migrate unittests for SyncerFactory

* Migrate unittests for CLIRunner

* Cleanup test code

* DEVX-259 fix tests (#494)

* DEVX-246 migrate solution info (#491)

---------

Co-authored-by: Lam Tran <[email protected]>

* Fix spotbugs violations

* DEVX-247 migrate category syncer (#498)

* Revert "Fix spotbugs violations"

This reverts commit 31da628.

* Delete unused variable

* DEVX-248 migrate inventory sync (#499)

* Migrate SyncerFactory

* Migrate client utils and rename

* Migrate CliRunner

* Migrate unittests for SyncerFactory

* Migrate unittests for CLIRunner

* Cleanup test code

* DEVX-247 migrate category syncr

* DEVX-247 fix spotbugs

* DEVX-247 rename variable

* DEVX-247 rename variable

* DEVX-248 migrate inventory syncer

* DEVX-248 refactor category syncer test

* DEVX-248 refactor code

* DEVX-248 fix formatting

---------

Co-authored-by: salander85 <[email protected]>

* Migrate product syncer with unittests (#502)

* Migrate ITs for product syncer (#505)

* DEVX-250 migrate cart discount syncer (#504)

* DEVX-251 migrate customer syncer (#506)

* DEVX-253 migrate product type syncer (#509)

* Migrate shoppinglist syncer (#511)

* DEVX-252 migrate custom object syncer (#503)

* DEVX-252 migrate custom object syncer

* DEVX-252 disable test

* DEVX-245 fix category syncer IT (#514)

* DEVX-245 fix category syncer IT

* DEVX-245 fix formatting

* Update sync-java to newest version

* Revert "Update sync-java to newest version"

This reverts commit a278421.

* Migrate state-syncer incl. unittests (#512)

* Migrate state-syncer incl. unittests

* Make error-handling in transform consistent with other syncers

* Assert instance of method call

* Fix test

* Migrate tax category syncer (#513)

* Migrate type syncer (#515)

* Migrate type syncer

* Test type-sync fails with error callback

* Replace private method with utility method. Correct tests.

* Update sync-java to newest version (#517)

* Update sync-java to newest version

* Update http-client to newest version

* DEVX-276 add retry (#516)

* DEVX-276 add retry

* DEVX-276 update retry mechanism

* DEVX-276 fix tests

* Migrate CLI runner IT (#508)

* Update README.md

---------

Co-authored-by: Lam Tran <[email protected]>
  • Loading branch information
salander85 and lojzatran authored Nov 6, 2023
1 parent 37934f2 commit 4703758
Show file tree
Hide file tree
Showing 55 changed files with 4,323 additions and 3,711 deletions.
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ Example:
##### Download

```bash
docker pull commercetools/commercetools-project-sync:5.3.1
docker pull commercetools/commercetools-project-sync:5.4.0
```
##### Run

Expand All @@ -222,14 +222,14 @@ docker run \
-e TARGET_PROJECT_KEY=xxxx \
-e TARGET_CLIENT_ID=xxxx \
-e TARGET_CLIENT_SECRET=xxxx \
commercetools/commercetools-project-sync:5.3.1 -s all
commercetools/commercetools-project-sync:5.4.0 -s all
```


### Examples
- To run the all sync modules from a source project to a target project
```bash
docker run commercetools/commercetools-project-sync:5.3.1 -s all
docker run commercetools/commercetools-project-sync:5.4.0 -s all
```
This will run the following sync modules in the given order:
1. `Type` Sync and `ProductType` Sync and `States` Sync and `TaxCategory` Sync and `CustomObject` Sync in parallel.
Expand All @@ -239,70 +239,70 @@ commercetools/commercetools-project-sync:5.3.1 -s all

- To run the type sync
```bash
docker run commercetools/commercetools-project-sync:5.3.1 -s types
docker run commercetools/commercetools-project-sync:5.4.0 -s types
```

- To run the productType sync
```bash
docker run commercetools/commercetools-project-sync:5.3.1 -s productTypes
docker run commercetools/commercetools-project-sync:5.4.0 -s productTypes
```

- To run the states sync
```bash
docker run commercetools/commercetools-project-sync:5.3.1 -s states
docker run commercetools/commercetools-project-sync:5.4.0 -s states
```
- To run the taxCategory sync
```bash
docker run commercetools/commercetools-project-sync:5.3.1 -s taxCategories
docker run commercetools/commercetools-project-sync:5.4.0 -s taxCategories
```

- To run the category sync
```bash
docker run commercetools/commercetools-project-sync:5.3.1 -s categories
docker run commercetools/commercetools-project-sync:5.4.0 -s categories
```

- To run the product sync
```bash
docker run commercetools/commercetools-project-sync:5.3.1 -s products
docker run commercetools/commercetools-project-sync:5.4.0 -s products
```

- To run the cartDiscount sync
```bash
docker run commercetools/commercetools-project-sync:5.3.1 -s cartDiscounts
docker run commercetools/commercetools-project-sync:5.4.0 -s cartDiscounts
```

- To run the inventoryEntry sync
```bash
docker run commercetools/commercetools-project-sync:5.3.1 -s inventoryEntries
docker run commercetools/commercetools-project-sync:5.4.0 -s inventoryEntries
```

- To run the customObject sync
```bash
docker run commercetools/commercetools-project-sync:5.3.1 -s customObjects
docker run commercetools/commercetools-project-sync:5.4.0 -s customObjects
```

- To run the customer sync
```bash
docker run commercetools/commercetools-project-sync:5.3.1 -s customers
docker run commercetools/commercetools-project-sync:5.4.0 -s customers
```

- To run the shoppingList sync
```bash
docker run commercetools/commercetools-project-sync:5.3.1 -s shoppingLists
docker run commercetools/commercetools-project-sync:5.4.0 -s shoppingLists
```
- To run both products and shoppingList sync
```bash
docker run commercetools/commercetools-project-sync:5.3.1 -s products shoppingLists
docker run commercetools/commercetools-project-sync:5.4.0 -s products shoppingLists
```

- To run type, productType and shoppingList sync
```bash
docker run commercetools/commercetools-project-sync:5.3.1 -s types productTypes shoppingLists
docker run commercetools/commercetools-project-sync:5.4.0 -s types productTypes shoppingLists
```

- To run all sync modules using a runner name
```bash
docker run commercetools/commercetools-project-sync:5.3.1 -s all -r myRunnerName
docker run commercetools/commercetools-project-sync:5.4.0 -s all -r myRunnerName
```

## Scopes
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ ext {
assertjVersion = '3.24.2'
pmdVersion = '6.55.0'
jacocoVersion = '0.8.11'
commercetoolsSyncJava = '9.2.3'
commercetoolsSyncJava = '10.0.0-beta.4'
httpClientVersion = '17.0.0'
apacheCliVersion = '1.6.0'
jupiterApiVersion = '5.10.1'
asyncHttpClientVersion = '2.12.3'
logbackVersion = '1.4.11'
logstashLogbackEncoderVersion= '7.4'
}
Expand Down Expand Up @@ -65,7 +65,7 @@ tasks.withType(SpotlessTask) {

dependencies {
implementation "com.commercetools:commercetools-sync-java:${commercetoolsSyncJava}"
implementation "org.asynchttpclient:async-http-client:${asyncHttpClientVersion}"
implementation "com.commercetools.sdk:commercetools-okhttp-client4:${httpClientVersion}"
implementation "commons-cli:commons-cli:${apacheCliVersion}"
implementation "ch.qos.logback:logback-classic:${logbackVersion}"
implementation "ch.qos.logback:logback-core:${logbackVersion}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,29 @@
package com.commercetools.project.sync;

import static com.commercetools.project.sync.util.IntegrationTestUtils.assertCategoryExists;
import static com.commercetools.project.sync.util.IntegrationTestUtils.cleanUpProjects;
import static com.commercetools.project.sync.util.IntegrationTestUtils.createITSyncerFactory;
import static com.commercetools.project.sync.util.SphereClientUtils.CTP_SOURCE_CLIENT;
import static com.commercetools.project.sync.util.SphereClientUtils.CTP_TARGET_CLIENT;
import static io.sphere.sdk.models.LocalizedString.ofEnglish;
import static com.commercetools.api.models.common.LocalizedString.ofEnglish;
import static com.commercetools.project.sync.util.CtpClientUtils.CTP_SOURCE_CLIENT;
import static com.commercetools.project.sync.util.CtpClientUtils.CTP_TARGET_CLIENT;
import static com.commercetools.project.sync.util.IntegrationTestUtils.*;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;

import com.commercetools.api.client.ProjectApiRoot;
import com.commercetools.api.models.category.CategoryDraft;
import com.commercetools.api.models.category.CategoryDraftBuilder;
import com.commercetools.api.models.common.AssetDraft;
import com.commercetools.api.models.common.AssetDraftBuilder;
import com.commercetools.api.models.common.AssetSourceBuilder;
import com.commercetools.api.models.common.LocalizedStringBuilder;
import com.commercetools.api.models.type.CustomFieldsDraft;
import com.commercetools.api.models.type.CustomFieldsDraftBuilder;
import com.commercetools.api.models.type.FieldDefinition;
import com.commercetools.api.models.type.FieldDefinitionBuilder;
import com.commercetools.api.models.type.ResourceTypeId;
import com.commercetools.api.models.type.Type;
import com.commercetools.api.models.type.TypeDraft;
import com.commercetools.api.models.type.TypeDraftBuilder;
import com.commercetools.api.models.type.TypeTextInputHint;
import com.commercetools.project.sync.category.CategorySyncer;
import io.sphere.sdk.categories.CategoryDraft;
import io.sphere.sdk.categories.CategoryDraftBuilder;
import io.sphere.sdk.categories.commands.CategoryCreateCommand;
import io.sphere.sdk.client.SphereClient;
import io.sphere.sdk.models.AssetDraft;
import io.sphere.sdk.models.AssetDraftBuilder;
import io.sphere.sdk.models.AssetSourceBuilder;
import io.sphere.sdk.models.LocalizedString;
import io.sphere.sdk.models.TextInputHint;
import io.sphere.sdk.types.CustomFieldsDraft;
import io.sphere.sdk.types.FieldDefinition;
import io.sphere.sdk.types.ResourceTypeIdsSetBuilder;
import io.sphere.sdk.types.StringFieldType;
import io.sphere.sdk.types.Type;
import io.sphere.sdk.types.TypeDraft;
import io.sphere.sdk.types.TypeDraftBuilder;
import io.sphere.sdk.types.commands.TypeCreateCommand;
import java.util.Arrays;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -52,50 +45,51 @@ void setup() {
setupSourceProjectData(CTP_SOURCE_CLIENT);
}

private void setupSourceProjectData(SphereClient sourceProjectClient) {

private void setupSourceProjectData(ProjectApiRoot sourceProjectClient) {
final FieldDefinition FIELD_DEFINITION =
FieldDefinition.of(
StringFieldType.of(),
"field_name",
LocalizedString.ofEnglish("label_1"),
false,
TextInputHint.SINGLE_LINE);
FieldDefinitionBuilder.of()
.type(fieldTypeBuilder -> fieldTypeBuilder.stringBuilder())
.name("field_name")
.label(LocalizedStringBuilder.of().addValue("en", "label_1").build())
.required(false)
.inputHint(TypeTextInputHint.SINGLE_LINE)
.build();

final TypeDraft typeDraft =
TypeDraftBuilder.of(
TYPE_KEY,
LocalizedString.ofEnglish("name_1"),
ResourceTypeIdsSetBuilder.of().addCategories().addPrices().addAssets().build())
.description(LocalizedString.ofEnglish("description_1"))
.fieldDefinitions(Arrays.asList(FIELD_DEFINITION))
TypeDraftBuilder.of()
.key(TYPE_KEY)
.name(ofEnglish("name_1"))
.resourceTypeIds(
ResourceTypeId.CATEGORY, ResourceTypeId.PRODUCT_PRICE, ResourceTypeId.ASSET)
.description(ofEnglish("description_1"))
.fieldDefinitions(FIELD_DEFINITION)
.build();

final Type type =
sourceProjectClient.execute(TypeCreateCommand.of(typeDraft)).toCompletableFuture().join();
final Type type = sourceProjectClient.types().create(typeDraft).executeBlocking().getBody();

CTP_TARGET_CLIENT.execute(TypeCreateCommand.of(typeDraft)).toCompletableFuture().join();
CTP_TARGET_CLIENT.types().create(typeDraft).executeBlocking();

CustomFieldsDraft customFieldsDraft =
CustomFieldsDraft.ofTypeKeyAndJson(type.getKey(), emptyMap());
final CustomFieldsDraft customFieldsDraft =
CustomFieldsDraftBuilder.of().type(type.toResourceIdentifier()).build();

final AssetDraft assetDraft =
AssetDraftBuilder.of(emptyList(), LocalizedString.ofEnglish("assetName"))
AssetDraftBuilder.of()
.name(ofEnglish("assetName"))
.key("assetKey")
.sources(singletonList(AssetSourceBuilder.ofUri("sourceUri").build()))
.sources(AssetSourceBuilder.of().uri("sourceUri").build())
.custom(customFieldsDraft)
.build();

final CategoryDraft categoryDraft =
CategoryDraftBuilder.of(ofEnglish("t-shirts"), ofEnglish("t-shirts"))
CategoryDraftBuilder.of()
.name(ofEnglish("t-shirts"))
.slug(ofEnglish("t-shirts"))
.key(RESOURCE_KEY)
.assets(asList(assetDraft))
.custom(customFieldsDraft)
.build();
sourceProjectClient
.execute(CategoryCreateCommand.of(categoryDraft))
.toCompletableFuture()
.join();

sourceProjectClient.categories().create(categoryDraft).execute().toCompletableFuture().join();
}

@AfterAll
Expand Down
Loading

0 comments on commit 4703758

Please sign in to comment.