Skip to content

Commit ba3d9f8

Browse files
Merge pull request #173 from commercetools/172-Adjust-dependencies-configuration
172: adjust dependencies configuration
2 parents c6dfbbb + 6f3613e commit ba3d9f8

File tree

9 files changed

+36
-101
lines changed

9 files changed

+36
-101
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ most popular ones:
5757
````
5858
#### Gradle
5959
````groovy
60-
compile 'com.commercetools:commercetools-sync-java:v1.0.0-M2'
60+
implementation 'com.commercetools:commercetools-sync-java:v1.0.0-M2'
6161
````
6262
<!-- TODO #### SBT
6363
````java

docs/RELEASE_NOTES.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,23 @@ are breaking changes. If there are, then a migration guide should be provided.
5757
- **Category Sync** - Fixes an issue where retrying on concurrent modification exception wasn't re-fetching the latest
5858
Category and rebuilding build update actions. [#94](https://github.com/commercetools/commercetools-sync-java/issues/94)
5959
60-
**Doc Fixes** (4)
60+
**Doc Fixes** (5)
6161
- **Product Sync** - Document the reason behind having the latest batch processing time. [#119](https://github.com/commercetools/commercetools-sync-java/issues/119)
6262
- **Category Sync** - Document the reason behind having the latest batch processing time. [#119](https://github.com/commercetools/commercetools-sync-java/issues/119)
6363
- **Category Sync** - Fix the statistics summary string used in the documentation. [#119](https://github.com/commercetools/commercetools-sync-java/issues/119)
6464
- **Inventory Sync** - Document the reason behind having the latest batch processing time. [#119](https://github.com/commercetools/commercetools-sync-java/issues/119)
65+
- **Commons** - Provide inline example of how to use logging in callbacks. [#172](https://github.com/commercetools/commercetools-sync-java/issues/172)
6566
66-
**Compatibility notes** (7)
67+
**Compatibility notes** (9)
6768
- **Product Sync** - Move `replaceProductsReferenceIdsWithKeys` from `SyncUtils` to `ProductReferenceReplacementUtils`. [#120](https://github.com/commercetools/commercetools-sync-java/issues/120)
6869
- **Product Sync** - Remove `replaceProductDraftsCategoryReferenceIdsWithKeys` which is not needed anymore. [#120](https://github.com/commercetools/commercetools-sync-java/issues/120)
6970
- **Product Sync** - Remove `replaceProductDraftCategoryReferenceIdsWithKeys` which is not needed anymore. [#120](https://github.com/commercetools/commercetools-sync-java/issues/120)
7071
- **Product Sync** - Remove `replaceCategoryOrderHintCategoryIdsWithKeys` which is not needed anymore. [#120](https://github.com/commercetools/commercetools-sync-java/issues/120)
7172
- **Product Sync** - Move `getDraftBuilderFromStagedProduct` from `SyncUtils` to `ProductReferenceReplacementUtils`. [#120](https://github.com/commercetools/commercetools-sync-java/issues/120)
7273
- **Category Sync** - Move `replaceCategoriesReferenceIdsWithKeys` from `SyncUtils` to `CategoryReferenceReplacementUtils`. [#120](https://github.com/commercetools/commercetools-sync-java/issues/120)
7374
- **Inventory Sync** - Move `replaceInventoriesReferenceIdsWithKeys` from `SyncUtils` to `InventoryReferenceReplacementUtils`. [#120](https://github.com/commercetools/commercetools-sync-java/issues/120)
75+
- **Commons** - Remove slf4j-simple dependency. [#172](https://github.com/commercetools/commercetools-sync-java/issues/172)
76+
- **Commons** - Use implementation instead of compile configuration for dependencies. [#172](https://github.com/commercetools/commercetools-sync-java/issues/172)
7477
-->
7578

7679
### v1.0.0-M2 - Oct 12, 2017

docs/usage/CATEGORY_SYNC.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,14 @@ function has been applied.
8888
a flag, if set to `true`, enables the user to use keys with UUID format for references. By default, it is set to `false`.
8989

9090
Example of options usage, that sets the error and warning callbacks to output the message to the log error and warning
91-
streams, can be found [here](/src/integration-test/java/com/commercetools/sync/integration/externalsource/categories/CategorySyncIT.java#L79-L82).
91+
streams, would look as follows:
92+
```java
93+
final Logger logger = LoggerFactory.getLogger(MySync.class);
94+
final CategorySyncOptions categorySyncOptions = CategorySyncOptionsBuilder.of(sphereClient)
95+
.setErrorCallBack(logger::error)
96+
.setWarningCallBack(logger::warn)
97+
.build();
98+
```
9299

93100

94101
#### Running the sync

docs/usage/PRODUCT_SYNC.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,14 @@ function has been applied.
102102
a flag, if set to `true`, enables the user to use keys with UUID format for references. By default, it is set to `false`.
103103

104104
Example of options usage, that sets the error and warning callbacks to output the message to the log error and warning
105-
streams, can be found [here](/src/integration-test/java/com/commercetools/sync/integration/externalsource/products/ProductSyncIT.java#L121-L130)
106-
105+
streams, would look as follows:
106+
```java
107+
final Logger logger = LoggerFactory.getLogger(MySync.class);
108+
final ProductSyncOptions productsyncOptions = ProductSyncOptionsBuilder.of(sphereClient)
109+
.setErrorCallBack(logger::error)
110+
.setWarningCallBack(logger::warn)
111+
.build();
112+
```
107113

108114
#### Running the sync
109115
After all the aforementioned points in the previous section have been fulfilled, to run the sync:

gradle-scripts/dependencies.gradle

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
ext{
22
commercetoolsJvmSdkVersion = '1.25.0'
33
mockitoVersion = '2.8.9'
4-
slf4jVersion = '1.6.2'
54
jUnitVersion = '4.12'
65
assertjVersion = '3.6.1'
76
checkstyleVersion = '7.7'
@@ -11,12 +10,11 @@ ext{
1110
}
1211

1312
dependencies {
14-
compile "com.commercetools.sdk.jvm.core:commercetools-models:${commercetoolsJvmSdkVersion}"
15-
compile "com.commercetools.sdk.jvm.core:commercetools-java-client:${commercetoolsJvmSdkVersion}"
16-
compile "com.commercetools.sdk.jvm.core:commercetools-convenience:${commercetoolsJvmSdkVersion}"
17-
compile "com.google.code.findbugs:annotations:${findbugsVersion}"
18-
runtime "org.slf4j:slf4j-simple:${slf4jVersion}"
19-
testCompile "org.mockito:mockito-core:${mockitoVersion}"
20-
testCompile "junit:junit:${jUnitVersion}"
21-
testCompile "org.assertj:assertj-core:${assertjVersion}"
13+
implementation "com.commercetools.sdk.jvm.core:commercetools-models:${commercetoolsJvmSdkVersion}"
14+
implementation "com.commercetools.sdk.jvm.core:commercetools-java-client:${commercetoolsJvmSdkVersion}"
15+
implementation "com.commercetools.sdk.jvm.core:commercetools-convenience:${commercetoolsJvmSdkVersion}"
16+
implementation "com.google.code.findbugs:annotations:${findbugsVersion}"
17+
testImplementation "org.mockito:mockito-core:${mockitoVersion}"
18+
testImplementation "junit:junit:${jUnitVersion}"
19+
testImplementation "org.assertj:assertj-core:${assertjVersion}"
2220
}

gradle-scripts/integration-tests.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ sourceSets {
1010
}
1111

1212
configurations {
13-
integrationTestCompile.extendsFrom compile, testCompile
14-
integrationTestRuntime.extendsFrom runtime, testRuntime
13+
integrationTestImplementation.extendsFrom implementation, testImplementation
1514
}
1615

1716
task integrationTest(type: Test) {

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

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.commercetools.sync.categories.CategorySyncOptionsBuilder;
66
import com.commercetools.sync.categories.helpers.CategorySyncStatistics;
77
import com.commercetools.sync.commons.exceptions.ReferenceResolutionException;
8-
import com.fasterxml.jackson.core.JsonProcessingException;
98
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
109
import io.sphere.sdk.categories.Category;
1110
import io.sphere.sdk.categories.CategoryDraft;
@@ -18,8 +17,6 @@
1817
import org.junit.Before;
1918
import org.junit.BeforeClass;
2019
import org.junit.Test;
21-
import org.slf4j.Logger;
22-
import org.slf4j.LoggerFactory;
2320

2421
import java.util.ArrayList;
2522
import java.util.Collections;
@@ -43,14 +40,12 @@
4340
import static com.commercetools.sync.integration.commons.utils.CategoryITUtils.getCustomFieldsJsons;
4441
import static com.commercetools.sync.integration.commons.utils.CategoryITUtils.syncBatches;
4542
import static com.commercetools.sync.integration.commons.utils.ITUtils.deleteTypesFromTargetAndSource;
46-
import static com.commercetools.sync.integration.commons.utils.ITUtils.getStatisticsAsJSONString;
4743
import static com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_SOURCE_CLIENT;
4844
import static com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_TARGET_CLIENT;
4945
import static java.lang.String.format;
5046
import static org.assertj.core.api.Assertions.assertThat;
5147

5248
public class CategorySyncIT {
53-
private static final Logger LOGGER = LoggerFactory.getLogger(CategorySyncIT.class);
5449
private CategorySync categorySync;
5550

5651
private List<String> callBackErrorResponses = new ArrayList<>();
@@ -90,12 +85,8 @@ public void setupTest() {
9085
.setErrorCallBack((errorMessage, exception) -> {
9186
callBackErrorResponses.add(errorMessage);
9287
callBackExceptions.add(exception);
93-
LOGGER.error(errorMessage, exception);
94-
})
95-
.setWarningCallBack((warningMessage) -> {
96-
callBackWarningResponses.add(warningMessage);
97-
LOGGER.warn(warningMessage);
9888
})
89+
.setWarningCallBack((warningMessage) -> callBackWarningResponses.add(warningMessage))
9990
.build();
10091
categorySync = new CategorySync(categorySyncOptions);
10192
}
@@ -231,18 +222,8 @@ public void syncDrafts_withNewShuffledBatchOfCategories_ShouldCreateCategories()
231222
// Simulate batches of categories where not all parent references are supplied at once.
232223
final List<List<CategoryDraft>> batches = batchDrafts(categoryDrafts, 13);
233224

234-
final long startTime = System.currentTimeMillis();
235-
LOGGER.info("Starting to sync categories:");
236225
final CategorySyncStatistics syncStatistics = syncBatches(categorySync, batches,
237226
CompletableFuture.completedFuture(null)).toCompletableFuture().join();
238-
LOGGER.info(syncStatistics.getReportMessage());
239-
try {
240-
LOGGER.info(getStatisticsAsJSONString(syncStatistics));
241-
} catch (JsonProcessingException exception) {
242-
LOGGER.error("Failed to build JSON String of summary.", exception);
243-
}
244-
final long syncTimeTaken = System.currentTimeMillis() - startTime;
245-
LOGGER.info("Syncing categories took: " + syncTimeTaken + "ms");
246227

247228
assertThat(syncStatistics.getReportMessage())
248229
.isEqualTo(format("Summary: %d categories were processed in total (%d created, %d updated, %d failed to "
@@ -297,18 +278,8 @@ public void syncDrafts_withExistingShuffledCategoriesWithChangingCategoryHierarc
297278

298279
final List<List<CategoryDraft>> batches = batchDrafts(categoryDrafts, 13);
299280

300-
final long startTime = System.currentTimeMillis();
301-
LOGGER.info("Starting to sync categories:");
302281
final CategorySyncStatistics syncStatistics = syncBatches(categorySync, batches,
303282
CompletableFuture.completedFuture(null)).toCompletableFuture().join();
304-
LOGGER.info(syncStatistics.getReportMessage());
305-
try {
306-
LOGGER.info(getStatisticsAsJSONString(syncStatistics));
307-
} catch (JsonProcessingException exception) {
308-
LOGGER.error("Failed to build JSON String of summary.", exception);
309-
}
310-
final long syncTimeTaken = System.currentTimeMillis() - startTime;
311-
LOGGER.info("Syncing categories took: " + syncTimeTaken + "ms");
312283

313284
assertThat(syncStatistics.getReportMessage())
314285
.isEqualTo(format("Summary: %d categories were processed in total (%d created, %d updated, %d failed to "
@@ -353,18 +324,8 @@ public void syncDrafts_withExistingCategoriesThatChangeParents_ShouldUpdateCateg
353324

354325
final List<List<CategoryDraft>> batches = batchDrafts(categoryDrafts, 1);
355326

356-
final long startTime = System.currentTimeMillis();
357-
LOGGER.info("Starting to sync categories:");
358327
final CategorySyncStatistics syncStatistics = syncBatches(categorySync, batches,
359328
CompletableFuture.completedFuture(null)).toCompletableFuture().join();
360-
LOGGER.info(syncStatistics.getReportMessage());
361-
try {
362-
LOGGER.info(getStatisticsAsJSONString(syncStatistics));
363-
} catch (JsonProcessingException exception) {
364-
LOGGER.error("Failed to build JSON String of summary.", exception);
365-
}
366-
final long syncTimeTaken = System.currentTimeMillis() - startTime;
367-
LOGGER.info("Syncing categories took: " + syncTimeTaken + "ms");
368329

369330
assertThat(syncStatistics.getReportMessage())
370331
.isEqualTo(format("Summary: %d categories were processed in total (%d created, %d updated, %d failed to "
@@ -435,24 +396,13 @@ public void syncDrafts_withANonExistingNewParent_ShouldUpdateCategories() {
435396

436397
final List<List<CategoryDraft>> batches = batchDrafts(categoryDrafts, 1);
437398

438-
final long startTime = System.currentTimeMillis();
439-
LOGGER.info("Starting to sync categories:");
440399
final CategorySyncStatistics syncStatistics = syncBatches(categorySync, batches,
441400
CompletableFuture.completedFuture(null)).toCompletableFuture().join();
442-
LOGGER.info(syncStatistics.getReportMessage());
443-
try {
444-
LOGGER.info(getStatisticsAsJSONString(syncStatistics));
445-
} catch (JsonProcessingException exception) {
446-
LOGGER.error("Failed to build JSON String of summary.", exception);
447-
}
448-
final long syncTimeTaken = System.currentTimeMillis() - startTime;
449-
LOGGER.info("Syncing categories took: " + syncTimeTaken + "ms");
450401

451402
assertThat(syncStatistics.getReportMessage())
452403
.isEqualTo(format("Summary: %d categories were processed in total (%d created, %d updated, %d failed to "
453404
+ "sync and %s categories with a missing parent).", 2, 1, 1, 0, 0));
454405

455-
456406
assertThat(callBackErrorResponses).isEmpty();
457407
assertThat(callBackExceptions).isEmpty();
458408
assertThat(callBackWarningResponses).isEmpty();

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

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.commercetools.sync.categories.CategorySyncOptions;
55
import com.commercetools.sync.categories.CategorySyncOptionsBuilder;
66
import com.commercetools.sync.categories.helpers.CategorySyncStatistics;
7-
import com.fasterxml.jackson.core.JsonProcessingException;
87
import com.fasterxml.jackson.databind.JsonNode;
98
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
109
import io.sphere.sdk.categories.Category;
@@ -23,8 +22,6 @@
2322
import org.junit.Before;
2423
import org.junit.BeforeClass;
2524
import org.junit.Test;
26-
import org.slf4j.Logger;
27-
import org.slf4j.LoggerFactory;
2825

2926
import java.util.ArrayList;
3027
import java.util.Arrays;
@@ -47,7 +44,6 @@
4744
import static com.commercetools.sync.integration.commons.utils.CategoryITUtils.getCustomFieldsDraft;
4845
import static com.commercetools.sync.integration.commons.utils.CategoryITUtils.getCustomFieldsJsons;
4946
import static com.commercetools.sync.integration.commons.utils.ITUtils.deleteTypes;
50-
import static com.commercetools.sync.integration.commons.utils.ITUtils.getStatisticsAsJSONString;
5147
import static com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_TARGET_CLIENT;
5248
import static com.commercetools.tests.utils.CompletionStageUtil.executeBlocking;
5349
import static java.lang.String.format;
@@ -59,9 +55,8 @@
5955

6056

6157
public class CategorySyncIT {
62-
private static final Logger LOGGER = LoggerFactory.getLogger(CategorySyncIT.class);
6358
private CategorySync categorySync;
64-
private final String oldCategoryKey = "oldCategoryKey";
59+
private static final String oldCategoryKey = "oldCategoryKey";
6560

6661
/**
6762
* Delete all categories and types from target project. Then create custom types for target CTP project categories.
@@ -82,8 +77,6 @@ public void setupTest() {
8277
deleteAllCategories(CTP_TARGET_CLIENT);
8378

8479
final CategorySyncOptions categorySyncOptions = CategorySyncOptionsBuilder.of(CTP_TARGET_CLIENT)
85-
.setErrorCallBack(LOGGER::error)
86-
.setWarningCallBack(LOGGER::warn)
8780
.build();
8881
categorySync = new CategorySync(categorySyncOptions);
8982

@@ -193,8 +186,6 @@ public void syncDrafts_WithConcurrentModificationException_ShouldRetryToUpdateNe
193186

194187
final CategorySyncOptions categorySyncOptions =
195188
CategorySyncOptionsBuilder.of(CTP_TARGET_CLIENT)
196-
.setErrorCallBack(LOGGER::error)
197-
.setWarningCallBack(LOGGER::warn)
198189
.build();
199190
final CategorySync categorySync1 = new CategorySync(categorySyncOptions);
200191
final CategorySync categorySync2 = new CategorySync(categorySyncOptions);
@@ -251,7 +242,6 @@ public void syncDrafts_WithConcurrentModificationExceptionAndUnexpectedDelete_Sh
251242
errorMessages.add(errorMessage);
252243
errors.add(error);
253244
})
254-
.setWarningCallBack(LOGGER::warn)
255245
.build();
256246
final CategorySync categorySync = new CategorySync(categorySyncOptions);
257247

@@ -733,24 +723,13 @@ public void syncDrafts_WithDraftWithAMissingParentKey_ShouldNotSyncIt() {
733723
categoryDrafts.add(categoryDraft);
734724
categoryDrafts.add(categoryDraftWithMissingParent);
735725

736-
final long startTime = System.currentTimeMillis();
737-
LOGGER.info("Starting to sync categories:");
726+
738727
final CategorySyncStatistics syncStatistics = categorySync.sync(categoryDrafts)
739728
.toCompletableFuture().join();
740-
LOGGER.info(syncStatistics.getReportMessage());
741-
try {
742-
LOGGER.info(getStatisticsAsJSONString(syncStatistics));
743-
} catch (JsonProcessingException exception) {
744-
LOGGER.error("Failed to build JSON String of summary.", exception);
745-
}
746-
final long syncTimeTaken = System.currentTimeMillis() - startTime;
747-
LOGGER.info("Syncing categories took: " + syncTimeTaken + "ms");
748-
749729
assertThat(syncStatistics.getReportMessage())
750730
.isEqualTo(format("Summary: %d categories were processed in total (%d created, %d updated, %d failed to"
751731
+ " sync and %d categories with a missing parent).", 2, 2, 0, 0, 1));
752732

753-
754733
assertThat(syncStatistics.getCategoryKeysWithMissingParents()).hasSize(1);
755734
final ArrayList<String> missingParentsChildren = syncStatistics.getCategoryKeysWithMissingParents()
756735
.get(nonExistingParentKey);

0 commit comments

Comments
 (0)