From 5c9144469af8cfb96888efccfd367b1cf349675e Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 18 Nov 2025 16:14:56 +0100 Subject: [PATCH 1/3] fix equals method of EnergyPriceValue --- CHANGELOG.md | 1 + .../edu/ie3/datamodel/models/value/EnergyPriceValue.java | 6 ++++-- .../timeseries/TimeBasedSimpleValueFactoryTest.groovy | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71ef88a3d..20391b0e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed the issues with rtd for Cylindrical thermal storage [#1273](https://github.com/ie3-institute/PowerSystemDataModel/issues/1273) - Updated Controlling_em for all the loads in readthedocs[#1447](https://github.com/ie3-institute/PowerSystemDataModel/issues/1447) - Included a doFirst clause into `checkJavaVersion.gradle` [#1462](https://github.com/ie3-institute/PowerSystemDataModel/issues/1462) +- Fixed `EnergyPriceValue.equals()` [#1479](https://github.com/ie3-institute/PowerSystemDataModel/issues/1479) ### Changed - Updated CI-Pipeline to run task `Deploy` and `Staging` only for `Main` [#1403](https://github.com/ie3-institute/PowerSystemDataModel/issues/1403) diff --git a/src/main/java/edu/ie3/datamodel/models/value/EnergyPriceValue.java b/src/main/java/edu/ie3/datamodel/models/value/EnergyPriceValue.java index 3cf8dafd8..94715f7c4 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/EnergyPriceValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/EnergyPriceValue.java @@ -32,12 +32,14 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; EnergyPriceValue that = (EnergyPriceValue) o; - return Objects.equals(price, that.price); + + return price.getValue().doubleValue() == that.price.getValue().doubleValue() + && price.getUnit().equals(that.price.getUnit()); } @Override public int hashCode() { - return Objects.hash(price); + return Objects.hash(price.getValue().doubleValue(), price.getUnit()); } @Override diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/TimeBasedSimpleValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/TimeBasedSimpleValueFactoryTest.groovy index 385073e97..89a8bd0f9 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/TimeBasedSimpleValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/TimeBasedSimpleValueFactoryTest.groovy @@ -110,7 +110,7 @@ class TimeBasedSimpleValueFactoryTest extends Specification { ) expect: - factory.buildModel(data) == expected + factory.buildModel(data).equals(expected) } def "The simple time based value factory builds correct heat and apparent power value"() { From 04399f39c51095dfca0d4d9f88a63f56cd90fffe Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Wed, 19 Nov 2025 14:07:52 +0100 Subject: [PATCH 2/3] include reviewers comments --- .../java/edu/ie3/datamodel/models/value/EnergyPriceValue.java | 4 ++-- .../factory/timeseries/TimeBasedSimpleValueFactoryTest.groovy | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/models/value/EnergyPriceValue.java b/src/main/java/edu/ie3/datamodel/models/value/EnergyPriceValue.java index 94715f7c4..9cfa37cf9 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/EnergyPriceValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/EnergyPriceValue.java @@ -33,8 +33,8 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; EnergyPriceValue that = (EnergyPriceValue) o; - return price.getValue().doubleValue() == that.price.getValue().doubleValue() - && price.getUnit().equals(that.price.getUnit()); + return Objects.equals(price.getValue(), that.price.getValue()) + && Objects.equals(price.getUnit(), that.price.getUnit()); } @Override diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/TimeBasedSimpleValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/TimeBasedSimpleValueFactoryTest.groovy index 89a8bd0f9..7e44776c7 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/TimeBasedSimpleValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/TimeBasedSimpleValueFactoryTest.groovy @@ -17,8 +17,6 @@ import spock.lang.Shared import spock.lang.Specification import tech.units.indriya.quantity.Quantities -import java.time.ZoneId - class TimeBasedSimpleValueFactoryTest extends Specification { @Shared TimeUtil defaultTimeUtil @@ -110,7 +108,7 @@ class TimeBasedSimpleValueFactoryTest extends Specification { ) expect: - factory.buildModel(data).equals(expected) + Objects.equals(factory.buildModel(data),expected) } def "The simple time based value factory builds correct heat and apparent power value"() { From 67d6acba53928d5d7f50569d5154b9dbc5017445 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Wed, 19 Nov 2025 14:10:31 +0100 Subject: [PATCH 3/3] use doubles --- .../java/edu/ie3/datamodel/models/value/EnergyPriceValue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/ie3/datamodel/models/value/EnergyPriceValue.java b/src/main/java/edu/ie3/datamodel/models/value/EnergyPriceValue.java index 9cfa37cf9..475b1b226 100644 --- a/src/main/java/edu/ie3/datamodel/models/value/EnergyPriceValue.java +++ b/src/main/java/edu/ie3/datamodel/models/value/EnergyPriceValue.java @@ -33,7 +33,7 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; EnergyPriceValue that = (EnergyPriceValue) o; - return Objects.equals(price.getValue(), that.price.getValue()) + return Objects.equals(price.getValue().doubleValue(), that.price.getValue().doubleValue()) && Objects.equals(price.getUnit(), that.price.getUnit()); }