Skip to content

Commit 9232b22

Browse files
authored
Add equals and hashcode to base sync statistics (#1108)
1 parent c0cbae0 commit 9232b22

File tree

5 files changed

+64
-17
lines changed

5 files changed

+64
-17
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# commercetools sync java
33
[![CI](https://github.com/commercetools/commercetools-sync-java/workflows/CI/badge.svg)](https://github.com/commercetools/commercetools-sync-java/actions?query=workflow%3ACI)
44
[![codecov](https://codecov.io/gh/commercetools/commercetools-sync-java/branch/master/graph/badge.svg)](https://codecov.io/gh/commercetools/commercetools-sync-java)
5-
[![Javadoc](https://javadoc.io/badge2/com.commercetools/commercetools-sync-java/javadoc.svg?label=Javadoc)](https://commercetools.github.io/commercetools-sync-java/v/10.0.0-beta.3-beta.3/)
5+
[![Javadoc](https://javadoc.io/badge2/com.commercetools/commercetools-sync-java/javadoc.svg?label=Javadoc)](https://commercetools.github.io/commercetools-sync-java/v/10.0.0/)
66
[![Known Vulnerabilities](https://snyk.io/test/github/commercetools/commercetools-sync-java/4b2e26113d591bda158217c5dc1cf80a88665646/badge.svg)](https://snyk.io/test/github/commercetools/commercetools-sync-java/4b2e26113d591bda158217c5dc1cf80a88665646)
77

88

@@ -60,26 +60,26 @@ Here are the most popular ones:
6060
<dependency>
6161
<groupId>com.commercetools</groupId>
6262
<artifactId>commercetools-sync-java</artifactId>
63-
<version>10.0.0-beta.3</version>
63+
<version>10.0.0</version>
6464
</dependency>
6565
````
6666

6767
#### Gradle
6868

6969
````groovy
70-
implementation 'com.commercetools:commercetools-sync-java:10.0.0-beta.3'
70+
implementation 'com.commercetools:commercetools-sync-java:10.0.0'
7171
````
7272

7373
#### SBT
7474

7575
````
76-
libraryDependencies += "com.commercetools" % "commercetools-sync-java" % "10.0.0-beta.3"
76+
libraryDependencies += "com.commercetools" % "commercetools-sync-java" % "10.0.0"
7777
````
7878

7979
#### Ivy
8080

8181
````xml
82-
<dependency org="com.commercetools" name="commercetools-sync-java" rev="10.0.0-beta.3"/>
82+
<dependency org="com.commercetools" name="commercetools-sync-java" rev="10.0.0"/>
8383
````
8484

8585
**Note**: To avoid `commercetools JVM SDK` libraries version mismatch between projects.

docs/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# commercetools sync
33
[![CI](https://github.com/commercetools/commercetools-sync-java/workflows/CI/badge.svg)](https://github.com/commercetools/commercetools-sync-java/actions?query=workflow%3ACI)
44
[![codecov](https://codecov.io/gh/commercetools/commercetools-sync-java/branch/master/graph/badge.svg)](https://codecov.io/gh/commercetools/commercetools-sync-java)
5-
[![Benchmarks 10.0.0-beta.3](https://img.shields.io/badge/Benchmarks-10.0.0-beta.3-orange.svg)](https://commercetools.github.io/commercetools-sync-java/benchmarks/)
6-
[![Download from Maven Central](https://img.shields.io/badge/Maven_Central-10.0.0-beta.3-blue.svg)](https://search.maven.org/artifact/com.commercetools/commercetools-sync-java/10.0.0-beta.3/jar)
7-
[![Javadoc](https://javadoc.io/badge2/com.commercetools/commercetools-sync-java/javadoc.svg?label=Javadoc)](https://commercetools.github.io/commercetools-sync-java/v/10.0.0-beta.3/)
5+
[![Benchmarks 10.0.0](https://img.shields.io/badge/Benchmarks-10.0.0-orange.svg)](https://commercetools.github.io/commercetools-sync-java/benchmarks/)
6+
[![Download from Maven Central](https://img.shields.io/badge/Maven_Central-10.0.0-blue.svg)](https://search.maven.org/artifact/com.commercetools/commercetools-sync-java/10.0.0/jar)
7+
[![Javadoc](https://javadoc.io/badge2/com.commercetools/commercetools-sync-java/javadoc.svg?label=Javadoc)](https://commercetools.github.io/commercetools-sync-java/v/10.0.0/)
88
[![Known Vulnerabilities](https://snyk.io/test/github/commercetools/commercetools-sync-java/4b2e26113d591bda158217c5dc1cf80a88665646/badge.svg)](https://snyk.io/test/github/commercetools/commercetools-sync-java/4b2e26113d591bda158217c5dc1cf80a88665646)
99

1010

@@ -40,18 +40,18 @@ Here are the most popular ones:
4040
<dependency>
4141
<groupId>com.commercetools</groupId>
4242
<artifactId>commercetools-sync-java</artifactId>
43-
<version>10.0.0-beta.3</version>
43+
<version>10.0.0</version>
4444
</dependency>
4545
````
4646
#### Gradle
4747
````groovy
48-
implementation 'com.commercetools:commercetools-sync-java:10.0.0-beta.3'
48+
implementation 'com.commercetools:commercetools-sync-java:10.0.0'
4949
````
5050
#### SBT
5151
````
52-
libraryDependencies += "com.commercetools" % "commercetools-sync-java" % "10.0.0-beta.3"
52+
libraryDependencies += "com.commercetools" % "commercetools-sync-java" % "10.0.0"
5353
````
5454
#### Ivy
5555
````xml
56-
<dependency org="com.commercetools" name="commercetools-sync-java" rev="10.0.0-beta.3"/>
56+
<dependency org="com.commercetools" name="commercetools-sync-java" rev="10.0.0"/>
5757
````

docs/RELEASE_NOTES.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
7. Add Migration guide section which specifies explicitly if there are breaking changes and how to tackle them.
2828
-->
2929

30-
### 10.0.0-beta.1 - Sep 8, 2023
31-
[Commits](https://github.com/commercetools/commercetools-sync-java/compare/9.2.3...10.0.0-beta.3) |
32-
[Javadoc](https://commercetools.github.io/commercetools-sync-java/v/10.0.0-beta.3/) |
33-
[Jar](https://search.maven.org/artifact/com.commercetools/commercetools-sync-java/10.0.0-beta.3/jar)
30+
### 10.0.0 - Nov 6, 2023
31+
[Commits](https://github.com/commercetools/commercetools-sync-java/compare/9.2.3...10.0.0) |
32+
[Javadoc](https://commercetools.github.io/commercetools-sync-java/v/10.0.0/) |
33+
[Jar](https://search.maven.org/artifact/com.commercetools/commercetools-sync-java/10.0.0/jar)
34+
-
3435
- 🚧 **Breaking Changes** (1)
3536
- commercetools-sync-java is now fully migrated to `commercetools-sdk-java-v2`. See [Migration Guide](./MIGRATION_GUIDE.md) on how to use this library version.
3637

37-
3838
### 9.2.3 - Mar 21, 2023
3939
[Commits](https://github.com/commercetools/commercetools-sync-java/compare/9.2.1...9.2.3) |
4040
[Javadoc](https://commercetools.github.io/commercetools-sync-java/v/9.2.3/) |

src/main/java/com/commercetools/sync/commons/helpers/BaseSyncStatistics.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static java.lang.String.format;
44

5+
import java.util.Objects;
56
import java.util.concurrent.TimeUnit;
67
import java.util.concurrent.atomic.AtomicInteger;
78
import javax.annotation.Nonnull;
@@ -303,6 +304,44 @@ public String getSyncStatisticsClassName() {
303304
*/
304305
protected abstract SyncStatisticsT getThis();
305306

307+
@Override
308+
public boolean equals(final Object o) {
309+
if (this == o) return true;
310+
if (o == null || getClass() != o.getClass()) return false;
311+
final BaseSyncStatistics<?> that = (BaseSyncStatistics<?>) o;
312+
return latestBatchStartTime == that.latestBatchStartTime
313+
&& Objects.equals(getSyncStatisticsClassName(), that.getSyncStatisticsClassName())
314+
&& getLatestBatchProcessingTimeInDays() == that.getLatestBatchProcessingTimeInDays()
315+
&& getLatestBatchProcessingTimeInHours() == that.getLatestBatchProcessingTimeInHours()
316+
&& getLatestBatchProcessingTimeInMinutes() == that.getLatestBatchProcessingTimeInMinutes()
317+
&& getLatestBatchProcessingTimeInSeconds() == that.getLatestBatchProcessingTimeInSeconds()
318+
&& getLatestBatchProcessingTimeInMillis() == that.getLatestBatchProcessingTimeInMillis()
319+
&& getUpdated().get() == that.getUpdated().get()
320+
&& getCreated().get() == that.getCreated().get()
321+
&& getFailed().get() == that.getFailed().get()
322+
&& getProcessed().get() == that.getProcessed().get()
323+
&& Objects.equals(
324+
getLatestBatchHumanReadableProcessingTime(),
325+
that.getLatestBatchHumanReadableProcessingTime());
326+
}
327+
328+
@Override
329+
public int hashCode() {
330+
return Objects.hash(
331+
getSyncStatisticsClassName(),
332+
getUpdated().get(),
333+
getCreated().get(),
334+
getFailed().get(),
335+
getProcessed().get(),
336+
latestBatchStartTime,
337+
getLatestBatchProcessingTimeInDays(),
338+
getLatestBatchProcessingTimeInHours(),
339+
getLatestBatchProcessingTimeInMinutes(),
340+
getLatestBatchProcessingTimeInSeconds(),
341+
getLatestBatchProcessingTimeInMillis(),
342+
getLatestBatchHumanReadableProcessingTime());
343+
}
344+
306345
/**
307346
* Builds a proper summary message of the statistics report of a given {@code resourceString} in
308347
* following format:

src/test/java/com/commercetools/sync/commons/helpers/BaseSyncStatisticsTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,12 @@ void getDefaultReportMessageForResource_withResourceString_ShouldBuildCorrectSum
118118
"Summary: 0 resources were processed in total (0 created, 0 updated and 0 "
119119
+ "failed to sync).");
120120
}
121+
122+
@Test
123+
void twoSyncsStatistics_withSameProperties_ShouldBeEqual() {
124+
final CustomerSyncStatistics customerSyncStatistics = new CustomerSyncStatistics();
125+
final CustomerSyncStatistics customerSyncStatisticsIdentical = new CustomerSyncStatistics();
126+
127+
assertThat(customerSyncStatistics).isEqualTo(customerSyncStatisticsIdentical);
128+
}
121129
}

0 commit comments

Comments
 (0)