Skip to content

Commit 1c181f9

Browse files
Merge pull request #290 from commercetools/101-price
101 price sync support
2 parents 5e973a5 + 0ae121b commit 1c181f9

85 files changed

Lines changed: 4475 additions & 748 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'com.jfrog.bintray' version '1.8.3'
2+
id 'com.jfrog.bintray' version '1.8.4'
33
id 'org.ajoberstar.git-publish' version '1.0.1'
44
id 'com.adarshr.test-logger' version '1.3.1'
55
id 'org.ajoberstar.grgit' version '2.2.1'
@@ -13,6 +13,7 @@ apply from: "$rootDir/gradle-scripts/package.gradle"
1313
apply from: "$rootDir/gradle-scripts/java-compile.gradle"
1414
apply from: "$rootDir/gradle-scripts/repositories.gradle"
1515
apply from: "$rootDir/gradle-scripts/integration-tests.gradle"
16+
apply from: "$rootDir/gradle-scripts/test.gradle"
1617
apply from: "$rootDir/gradle-scripts/benchmark.gradle"
1718
apply from: "$rootDir/gradle-scripts/test-logger.gradle"
1819
apply from: "$rootDir/gradle-scripts/dependencies.gradle"

config/checkstyle/checkstyle.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
<property name="ignorePattern"
4444
value="^package.*|^import.*|a href|href|http://|https://|ftp://" />
4545
</module>
46-
<module name="AvoidStarImport" />
4746
<module name="UnusedImports"/>
4847
<module name="OneTopLevelClass" />
4948
<module name="NoLineWrap" />
@@ -69,6 +68,12 @@
6968
<message key="ws.notPreceded"
7069
value="WhitespaceAround: ''{0}'' is not preceded with whitespace." />
7170
</module>
71+
<module name="AvoidStarImport">
72+
<property name="excludes" value="com.commercetools.sync.products.utils.productvariantupdateactionutils.prices.PriceDraftFixtures,
73+
com.commercetools.sync.products.utils.productvariantupdateactionutils.prices.PriceFixtures"/>
74+
<property name="allowClassImports" value="false"/>
75+
<property name="allowStaticMemberImports" value="false"/>
76+
</module>
7277
<module name="OneStatementPerLine" />
7378
<module name="MultipleVariableDeclarations" />
7479
<module name="ArrayTypeStyle" />

docs/RELEASE_NOTES.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
3434

3535

36+
- [v1.0.0-M13 - Jul 26, 2018](#v100-m13----jul-26-2018)
3637
- [v1.0.0-M12 - Jun 05, 2018](#v100-m12----jun-05-2018)
3738
- [v1.0.0-M11 - Mar 08, 2018](#v100-m11----mar-08-2018)
3839
- [v1.0.0-M10 - Feb 13, 2018](#v100-m10----feb-13-2018)
@@ -49,18 +50,46 @@
4950

5051
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
5152

52-
5353
<!--
54-
### v1.0.0-M13 - Mar 30, 2018
54+
### v1.0.0-M14 - Aug 10, 2018
55+
[Commits](https://github.com/commercetools/commercetools-sync-java/compare/v1.0.0-M13...v1.0.0-M14) |
56+
[Javadoc](https://commercetools.github.io/commercetools-sync-java/v/v1.0.0-M14/) |
57+
[Jar](https://bintray.com/commercetools/maven/commercetools-sync-java/v1.0.0-M14)
58+
-->
59+
60+
### v1.0.0-M13 - Jul 26, 2018
5561
[Commits](https://github.com/commercetools/commercetools-sync-java/compare/v1.0.0-M12...v1.0.0-M13) |
5662
[Javadoc](https://commercetools.github.io/commercetools-sync-java/v/v1.0.0-M13/) |
5763
[Jar](https://bintray.com/commercetools/maven/commercetools-sync-java/v1.0.0-M13)
58-
-->
64+
65+
**New Features** (6)
66+
- **Product Sync** - Support for syncing product prices. [#101](https://github.com/commercetools/commercetools-sync-java/issues/101)
67+
- **Product Sync** - `ProductSyncUtils#buildActions` now also calculates variants' all price update actions needed. [#101](https://github.com/commercetools/commercetools-sync-java/issues/101)
68+
- **Product Sync** - `ProductUpdateActionUtils#buildVariantsUpdateActions` now also calculates variants' all price update actions needed. [#101](https://github.com/commercetools/commercetools-sync-java/issues/101)
69+
- **Product Sync** - Introduced new update action build utility for building all needed update actions between two variants' prices `ProductVariantUpdateActionUtils#buildProductVariantPricesUpdateActions`. [#101](https://github.com/commercetools/commercetools-sync-java/issues/101)
70+
- **ProductSync** - `PriceReferenceResolver` now resolves prices' CustomerGroup references on prices. [#101](https://github.com/commercetools/commercetools-sync-java/issues/101)
71+
- **InventoryEntry Sync** - `InventoryReferenceReplacementUtils#replaceInventoriesReferenceIdsWithKeys` now supports replacing channel reference ids with keys. [#101](https://github.com/commercetools/commercetools-sync-java/issues/101)
72+
73+
**Enhancements** (4)
74+
- **Commons** - Bumped gradle to version [gradle-4.9](https://docs.gradle.org/4.9/release-notes.html).
75+
- **Commons** - Bumped `com.jfrog.bintray` to 1.8.4.
76+
- **Commons** - Bumped `mockito` dependency to 2.19.1.
77+
- **Commons** - Switched to Junit5 using both `junit-jupiter-engine` and `junit-vintage-engine` for backward compatibility.
78+
79+
**Changes** (3)
80+
- **Product Sync** - Removed redundant `ProductUpdateActionUtils#buildRemoveVariantUpdateActions`. [#3](https://github.com/commercetools/commercetools-sync-java/issues/3)
81+
- **Commons** - Moved `SyncUtils#replaceCustomTypeIdWithKeys` to `CustomTypeReferenceReplacementUtils#replaceCustomTypeIdWithKeys`. [#101](https://github.com/commercetools/commercetools-sync-java/issues/101).
82+
- **Commons** - Moved `SyncUtils#replaceAssetsReferencesIdsWithKeys` to `AssetReferenceReplacementUtils#replaceAssetsReferencesIdsWithKeys`. [#101](https://github.com/commercetools/commercetools-sync-java/issues/101).
83+
84+
5985

6086
### v1.0.0-M12 - Jun 05, 2018
6187
[Commits](https://github.com/commercetools/commercetools-sync-java/compare/v1.0.0-M11...v1.0.0-M12) |
6288
[Javadoc](https://commercetools.github.io/commercetools-sync-java/v/v1.0.0-M12/) |
6389
[Jar](https://bintray.com/commercetools/maven/commercetools-sync-java/v1.0.0-M12)
90+
91+
**Enhancements** (13)
92+
- **Product Sync** - Support for syncing price custom fields. [#277](https://github.com/commercetools/commercetools-sync-java/issues/277)
6493
- **Product Sync** - `VariantReferenceResolver` now resolves prices' custom type references on all variants. [#277](https://github.com/commercetools/commercetools-sync-java/issues/277)
6594
- **Product Sync** - `ProductReferenceReplacementUtils#buildProductQuery` now expands custom types on prices. [#277](https://github.com/commercetools/commercetools-sync-java/issues/277)
6695
- **Product Sync** - `VariantReferenceReplacementUtils#replacePricesReferencesIdsWithKeys` now supports replacing price custom reference ids with keys. [#277](https://github.com/commercetools/commercetools-sync-java/issues/277)
@@ -270,7 +299,7 @@ to JSON parsing not throwing exception on parsing it to reference set. [#179](ht
270299
- **ProductSync** - Introduced Product State reference resolution and syncing. [#120](https://github.com/commercetools/commercetools-sync-java/issues/120).
271300
- **ProductSync** - Exposed `ProductReferenceReplacementUtils#buildProductQuery` util to create a product query with all needed reference expansions to fetch products from a source CTP project for the sync. [#120](https://github.com/commercetools/commercetools-sync-java/issues/120).
272301
- **ProductSync** - Exposed `VariantReferenceReplacementUtils#replaceVariantsReferenceIdsWithKeys` which provides utils to replace reference ids with keys on variants (price and attriute references) coming from a source CTP project to make it ready for reference resolution. [#160](https://github.com/commercetools/commercetools-sync-java/issues/160).
273-
- **ProductSync** - Exposed `VariantReferenceResolver` which is a helper that resolves the price and attriute references on a ProductVariantDraft. (Note: This is used now by the already existing ProductReferenceResolver) [#160](https://github.com/commercetools/commercetools-sync-java/issues/160).
302+
- **ProductSync** - Exposed `VariantReferenceResolver` which is a helper that resolves the price and attribute references on a ProductVariantDraft. (Note: This is used now by the already existing ProductReferenceResolver) [#160](https://github.com/commercetools/commercetools-sync-java/issues/160).
274303
- **CategorySync** - Exposed `CategoryReferenceReplacementUtils#buildCategoryQuery` util to create a category query with all needed reference expansions to fetch categories from a source CTP project for the sync. [#120](https://github.com/commercetools/commercetools-sync-java/issues/120).
275304
- **Commons** - Exposed `replaceCustomTypeIdWithKeys` and `replaceReferenceIdWithKey`. [#120](https://github.com/commercetools/commercetools-sync-java/issues/120).
276305

gradle-scripts/dependencies.gradle

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ext{
22
commercetoolsJvmSdkVersion = '1.33.0'
3-
mockitoVersion = '2.19.0'
4-
jUnitVersion = '4.12'
3+
mockitoVersion = '2.19.1'
4+
jupiterApiVersion = '5.2.0'
55
assertjVersion = '3.10.0'
66
checkstyleVersion = '8.10.1'
77
pmdVersion = '5.8.1'
@@ -15,6 +15,9 @@ dependencies {
1515
implementation "com.commercetools.sdk.jvm.core:commercetools-convenience:${commercetoolsJvmSdkVersion}"
1616
implementation "com.google.code.findbugs:annotations:${findbugsVersion}"
1717
testImplementation "org.mockito:mockito-core:${mockitoVersion}"
18-
testImplementation "junit:junit:${jUnitVersion}"
18+
testImplementation "org.junit.jupiter:junit-jupiter-api:${jupiterApiVersion}"
19+
testImplementation "org.junit.jupiter:junit-jupiter-params:${jupiterApiVersion}"
20+
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${jupiterApiVersion}"
21+
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:${jupiterApiVersion}"
1922
testImplementation "org.assertj:assertj-core:${assertjVersion}"
2023
}

gradle-scripts/integration-tests.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ sourceSets {
1111

1212
configurations {
1313
integrationTestImplementation.extendsFrom implementation, testImplementation
14+
integrationTestRuntimeOnly.extendsFrom testRuntimeOnly
1415
}
1516

1617
task integrationTest(type: Test) {
18+
useJUnitPlatform {
19+
includeEngines 'junit-jupiter', 'junit-vintage'
20+
}
1721
testClassesDirs = sourceSets.integrationTest.output.classesDirs
1822
classpath = sourceSets.integrationTest.runtimeClasspath
1923
outputs.upToDateWhen { false }

gradle-scripts/test.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
test {
2+
useJUnitPlatform {
3+
includeEngines 'junit-jupiter', 'junit-vintage'
4+
}
5+
6+
}

gradle/wrapper/gradle-wrapper.jar

0 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/benchmark/java/com/commercetools/sync/benchmark/InventorySyncBenchmark.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
import static com.commercetools.sync.benchmark.BenchmarkUtils.calculateDiff;
3232
import static com.commercetools.sync.benchmark.BenchmarkUtils.saveNewResult;
3333
import static com.commercetools.sync.commons.asserts.statistics.AssertionsForStatistics.assertThat;
34+
import static com.commercetools.sync.integration.commons.utils.ChannelITUtils.deleteChannels;
3435
import static com.commercetools.sync.integration.commons.utils.ITUtils.deleteTypes;
3536
import static com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_TARGET_CLIENT;
3637
import static com.commercetools.sync.integration.inventories.utils.InventoryITUtils.deleteInventoryEntries;
37-
import static com.commercetools.sync.integration.inventories.utils.InventoryITUtils.deleteSupplyChannels;
3838
import static com.commercetools.tests.utils.CompletionStageUtil.executeBlocking;
3939
import static java.lang.String.format;
4040
import static org.assertj.core.api.Assertions.assertThat;
@@ -45,14 +45,14 @@ public class InventorySyncBenchmark {
4545
public void setup() {
4646
deleteInventoryEntries(CTP_TARGET_CLIENT);
4747
deleteTypes(CTP_TARGET_CLIENT);
48-
deleteSupplyChannels(CTP_TARGET_CLIENT);
48+
deleteChannels(CTP_TARGET_CLIENT);
4949
}
5050

5151
@AfterClass
5252
public static void tearDown() {
5353
deleteInventoryEntries(CTP_TARGET_CLIENT);
5454
deleteTypes(CTP_TARGET_CLIENT);
55-
deleteSupplyChannels(CTP_TARGET_CLIENT);
55+
deleteChannels(CTP_TARGET_CLIENT);
5656
}
5757

5858
@Test
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package com.commercetools.sync.integration.commons.utils;
2+
3+
import io.sphere.sdk.channels.Channel;
4+
import io.sphere.sdk.channels.ChannelDraft;
5+
import io.sphere.sdk.channels.ChannelDraftBuilder;
6+
import io.sphere.sdk.channels.commands.ChannelCreateCommand;
7+
import io.sphere.sdk.channels.commands.ChannelDeleteCommand;
8+
import io.sphere.sdk.channels.queries.ChannelQuery;
9+
import io.sphere.sdk.client.SphereClient;
10+
11+
import javax.annotation.Nonnull;
12+
13+
import static com.commercetools.sync.integration.commons.utils.ITUtils.queryAndExecute;
14+
import static com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_SOURCE_CLIENT;
15+
import static com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_TARGET_CLIENT;
16+
import static com.commercetools.tests.utils.CompletionStageUtil.executeBlocking;
17+
18+
public final class ChannelITUtils {
19+
/**
20+
* Deletes all Channels from CTP projects defined by the {@code CTP_SOURCE_CLIENT} and
21+
* {@code CTP_TARGET_CLIENT}.
22+
*/
23+
public static void deleteChannelsFromTargetAndSource() {
24+
deleteChannels(CTP_TARGET_CLIENT);
25+
deleteChannels(CTP_SOURCE_CLIENT);
26+
}
27+
28+
/**
29+
* Deletes all Channels from the CTP project defined by the {@code ctpClient}.
30+
*
31+
* @param ctpClient defines the CTP project to delete the Channels from.
32+
*/
33+
public static void deleteChannels(@Nonnull final SphereClient ctpClient) {
34+
queryAndExecute(ctpClient, ChannelQuery.of(), ChannelDeleteCommand::of);
35+
}
36+
37+
/**
38+
* Creates a {@link Channel} in the CTP project defined by the {@code ctpClient} in a blocking fashion.
39+
*
40+
* @param ctpClient defines the CTP project to create the Channels in.
41+
* @param name the name of the channel to create.
42+
* @param key the key of the channel to create.
43+
* @return the created Channel.
44+
*/
45+
public static Channel createChannel(@Nonnull final SphereClient ctpClient, @Nonnull final String name,
46+
@Nonnull final String key) {
47+
final ChannelDraft channelDraft = ChannelDraftBuilder.of(name)
48+
.key(key)
49+
.build();
50+
51+
return executeBlocking(ctpClient.execute(ChannelCreateCommand.of(channelDraft)));
52+
}
53+
54+
private ChannelITUtils() {
55+
}
56+
}

0 commit comments

Comments
 (0)