From fc543e86a01fb55bb763a8cd05300f9610862873 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 3 Nov 2025 17:36:23 +0100 Subject: [PATCH 1/5] enhance tests --- ...smoTimeBasedWeatherValueFactoryTest.groovy | 63 ++++++++++++++++++- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy index e85aebf3b..6f398a87a 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy @@ -5,6 +5,7 @@ */ package edu.ie3.datamodel.io.factory.timeseries +import edu.ie3.datamodel.exceptions.FactoryException import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue import edu.ie3.datamodel.models.value.WeatherValue @@ -57,10 +58,10 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { Map parameter = [ "time" : TimeUtil.withDefaults.toString(time), "uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1", - "diffuseIrradiance": "282.671997070312", + "diffuseIrradiance": "182.671997070312", "directIrradiance" : "286.872985839844", "temperature" : "278.019012451172", - "windDirection" : "0", + "windDirection" : "50", "windVelocity" : "1.66103506088257" ] @@ -80,4 +81,62 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { then: model == expectedResults } + + def "A PsdmTimeBasedWeatherValueFactory should throw FactoryException if required field is missing"() { + given: + def factory = new CosmoTimeBasedWeatherValueFactory() + def coordinate = CosmoWeatherTestData.COORDINATE_193186 + def time = TimeUtil.withDefaults.toZonedDateTime("2019-01-01T00:00:00Z") + + // Missing 'directIrradiance' field + Map parameter = [ + "time" : TimeUtil.withDefaults.toString(time), + "uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1", + "diffuseIrradiance": "182.671997070312", + "temperature" : "278.019012451172", + "windDirection" : "50", + "windVelocity" : "1.66103506088257" + ] + + def data = new TimeBasedWeatherValueData(parameter, coordinate) + + when: + factory.buildModel(data) + + then: + thrown(FactoryException) + } + + def "Smoke Test: This PsdmTimeBasedWeatherValueFactory should fail since expected results doesn't match input"() { + given: + def factory = new CosmoTimeBasedWeatherValueFactory() + def coordinate = CosmoWeatherTestData.COORDINATE_193186 + def time = TimeUtil.withDefaults.toZonedDateTime("2019-01-01T00:00:00Z") + + Map parameter = [ + "time" : TimeUtil.withDefaults.toString(time), + "uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1", + "diffuseIrradiance": "1.0", + "directIrradiance" : "2.0", + "temperature" : "3.0", + "windDirection" : "4", + "windVelocity" : "5.0" + ] + + def data = new TimeBasedWeatherValueData(parameter, coordinate) + + def expectedResults = new TimeBasedValue( + time, new WeatherValue(coordinate, + Quantities.getQuantity(5.0, StandardUnits.SOLAR_IRRADIANCE), + Quantities.getQuantity(4.0, StandardUnits.SOLAR_IRRADIANCE), + Quantities.getQuantity(3.0, StandardUnits.TEMPERATURE), + Quantities.getQuantity(2d, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(1.0, StandardUnits.WIND_VELOCITY))) + + when: + def model = factory.buildModel(data) + + then: + model != expectedResults + } } From e73b219bd10694decb176a6fe851810a8a8d2883 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 3 Nov 2025 17:43:26 +0100 Subject: [PATCH 2/5] rollback some changes --- .../timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy index 6f398a87a..4abe7077a 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy @@ -58,10 +58,10 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { Map parameter = [ "time" : TimeUtil.withDefaults.toString(time), "uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1", - "diffuseIrradiance": "182.671997070312", + "diffuseIrradiance": "282.671997070312", "directIrradiance" : "286.872985839844", "temperature" : "278.019012451172", - "windDirection" : "50", + "windDirection" : "0", "windVelocity" : "1.66103506088257" ] From 7ffc397e61a97ca67ceaa05e69978eb81daeeca1 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 3 Nov 2025 18:00:52 +0100 Subject: [PATCH 3/5] check also values --- ...smoTimeBasedWeatherValueFactoryTest.groovy | 121 +++++++++--------- .../TimeBasedSimpleValueFactoryTest.groovy | 18 ++- 2 files changed, 74 insertions(+), 65 deletions(-) diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy index 4abe7077a..d54eef54a 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy @@ -46,7 +46,8 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { def model = factory.buildModel(data) then: - model == expectedResults + model.time == expectedResults.time + model.value == expectedResults.value } def "A PsdmTimeBasedWeatherValueFactory should be able to create time series values"() { @@ -79,64 +80,66 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { def model = factory.buildModel(data) then: - model == expectedResults + model.time == expectedResults.time + model.value == expectedResults.value } - def "A PsdmTimeBasedWeatherValueFactory should throw FactoryException if required field is missing"() { - given: - def factory = new CosmoTimeBasedWeatherValueFactory() - def coordinate = CosmoWeatherTestData.COORDINATE_193186 - def time = TimeUtil.withDefaults.toZonedDateTime("2019-01-01T00:00:00Z") - - // Missing 'directIrradiance' field - Map parameter = [ - "time" : TimeUtil.withDefaults.toString(time), - "uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1", - "diffuseIrradiance": "182.671997070312", - "temperature" : "278.019012451172", - "windDirection" : "50", - "windVelocity" : "1.66103506088257" - ] - - def data = new TimeBasedWeatherValueData(parameter, coordinate) - - when: - factory.buildModel(data) - - then: - thrown(FactoryException) - } - - def "Smoke Test: This PsdmTimeBasedWeatherValueFactory should fail since expected results doesn't match input"() { - given: - def factory = new CosmoTimeBasedWeatherValueFactory() - def coordinate = CosmoWeatherTestData.COORDINATE_193186 - def time = TimeUtil.withDefaults.toZonedDateTime("2019-01-01T00:00:00Z") - - Map parameter = [ - "time" : TimeUtil.withDefaults.toString(time), - "uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1", - "diffuseIrradiance": "1.0", - "directIrradiance" : "2.0", - "temperature" : "3.0", - "windDirection" : "4", - "windVelocity" : "5.0" - ] - - def data = new TimeBasedWeatherValueData(parameter, coordinate) - - def expectedResults = new TimeBasedValue( - time, new WeatherValue(coordinate, - Quantities.getQuantity(5.0, StandardUnits.SOLAR_IRRADIANCE), - Quantities.getQuantity(4.0, StandardUnits.SOLAR_IRRADIANCE), - Quantities.getQuantity(3.0, StandardUnits.TEMPERATURE), - Quantities.getQuantity(2d, StandardUnits.WIND_DIRECTION), - Quantities.getQuantity(1.0, StandardUnits.WIND_VELOCITY))) - - when: - def model = factory.buildModel(data) - - then: - model != expectedResults - } + def "A PsdmTimeBasedWeatherValueFactory should throw FactoryException if required field is missing"() { + given: + def factory = new CosmoTimeBasedWeatherValueFactory() + def coordinate = CosmoWeatherTestData.COORDINATE_193186 + def time = TimeUtil.withDefaults.toZonedDateTime("2019-01-01T00:00:00Z") + + // Missing 'directIrradiance' field + Map parameter = [ + "time" : TimeUtil.withDefaults.toString(time), + "uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1", + "diffuseIrradiance": "182.671997070312", + "temperature" : "278.019012451172", + "windDirection" : "50", + "windVelocity" : "1.66103506088257" + ] + + def data = new TimeBasedWeatherValueData(parameter, coordinate) + + when: + factory.buildModel(data) + + then: + thrown(FactoryException) + } + + def "Smoke Test: This PsdmTimeBasedWeatherValueFactory should fail since expected results doesn't match input"() { + given: + def factory = new CosmoTimeBasedWeatherValueFactory() + def coordinate = CosmoWeatherTestData.COORDINATE_193186 + def time = TimeUtil.withDefaults.toZonedDateTime("2019-01-01T00:00:00Z") + + Map parameter = [ + "time" : TimeUtil.withDefaults.toString(time), + "uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1", + "diffuseIrradiance": "1.0", + "directIrradiance" : "2.0", + "temperature" : "3.0", + "windDirection" : "4", + "windVelocity" : "5.0" + ] + + def data = new TimeBasedWeatherValueData(parameter, coordinate) + + def expectedResults = new TimeBasedValue( + time, new WeatherValue(coordinate, + Quantities.getQuantity(5.0, StandardUnits.SOLAR_IRRADIANCE), + Quantities.getQuantity(4.0, StandardUnits.SOLAR_IRRADIANCE), + Quantities.getQuantity(3.0, StandardUnits.TEMPERATURE), + Quantities.getQuantity(2d, StandardUnits.WIND_DIRECTION), + Quantities.getQuantity(1.0, StandardUnits.WIND_VELOCITY))) + + when: + def model = factory.buildModel(data) + + then: + assert model.time == expectedResults.time + assert model.value != expectedResults.value + } } 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..84bd191f0 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,8 @@ class TimeBasedSimpleValueFactoryTest extends Specification { ) expect: - factory.buildModel(data) == expected + factory.buildModel(data).time == expected.time + factory.buildModel(data).value == expected.value } def "The simple time based value factory builds correct heat and apparent power value"() { @@ -130,7 +131,8 @@ class TimeBasedSimpleValueFactoryTest extends Specification { ) expect: - factory.buildModel(data) == expected + factory.buildModel(data).time == expected.time + factory.buildModel(data).value == expected.value } def "The simple time based value factory builds correct heat and active power value"() { @@ -149,7 +151,8 @@ class TimeBasedSimpleValueFactoryTest extends Specification { ) expect: - factory.buildModel(data) == expected + factory.buildModel(data).time == expected.time + factory.buildModel(data).value == expected.value } def "The simple time based value factory builds correct heat demand value"() { @@ -167,7 +170,8 @@ class TimeBasedSimpleValueFactoryTest extends Specification { ) expect: - factory.buildModel(data) == expected + factory.buildModel(data).time == expected.time + factory.buildModel(data).value == expected.value } def "The simple time based value factory builds correct apparent power value"() { @@ -186,7 +190,8 @@ class TimeBasedSimpleValueFactoryTest extends Specification { ) expect: - factory.buildModel(data) == expected + factory.buildModel(data).time == expected.time + factory.buildModel(data).value == expected.value } def "The simple time based value factory builds correct active power value"() { @@ -204,7 +209,8 @@ class TimeBasedSimpleValueFactoryTest extends Specification { ) expect: - factory.buildModel(data) == expected + factory.buildModel(data).time == expected.time + factory.buildModel(data).value == expected.value } def "The simple time based value factory throws a FactoryException upon build request, if a class is not supported"() { From 770ed3143dba9a3cdb104d5a846163707dbd8ab2 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 4 Nov 2025 13:12:26 +0100 Subject: [PATCH 4/5] changed some uuids --- .../timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy index d54eef54a..dcaf4fa48 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy @@ -58,7 +58,7 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { Map parameter = [ "time" : TimeUtil.withDefaults.toString(time), - "uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1", + "uuid" : "c0aaf6fc-693a-458d-8d1d-d0a5093f262a", "diffuseIrradiance": "282.671997070312", "directIrradiance" : "286.872985839844", "temperature" : "278.019012451172", @@ -93,7 +93,7 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { // Missing 'directIrradiance' field Map parameter = [ "time" : TimeUtil.withDefaults.toString(time), - "uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1", + "uuid" : "1fc66d18-ea7d-4690-890e-9ee946c8b7b5", "diffuseIrradiance": "182.671997070312", "temperature" : "278.019012451172", "windDirection" : "50", @@ -117,7 +117,7 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { Map parameter = [ "time" : TimeUtil.withDefaults.toString(time), - "uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1", + "uuid" : "1fc66d18-ea7d-4690-890e-9ee946c8b7b5", "diffuseIrradiance": "1.0", "directIrradiance" : "2.0", "temperature" : "3.0", From c7129d56619824b97208e04fc1e8deb84b312e50 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 4 Nov 2025 15:25:02 +0100 Subject: [PATCH 5/5] fix tests --- .../factory/timeseries/TimeBasedSimpleValueFactoryTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 84bd191f0..408f683c2 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 @@ -111,7 +111,7 @@ class TimeBasedSimpleValueFactoryTest extends Specification { expect: factory.buildModel(data).time == expected.time - factory.buildModel(data).value == expected.value + factory.buildModel(data).value.toString() == expected.value.toString() } def "The simple time based value factory builds correct heat and apparent power value"() {