diff --git a/CHANGELOG.md b/CHANGELOG.md index 65b54b7cf1..11a9a6b80b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - External simulation should provide information about next tick of MobSim [#776](https://github.com/ie3-institute/simona/issues/776) - Reverted temporary workaround in `spotless.gradle` [#681](https://github.com/ie3-institute/simona/issues/681) - Updated AUTHORS.md [#904](https://github.com/ie3-institute/simona/issues/904) +- Updated `Gradle` to version V8.10 [#829](https://github.com/ie3-institute/simona/issues/829) - Updated AUTHORS.md [#905](https://github.com/ie3-institute/simona/issues/905) - Prepare ThermalStorageTestData for Storage without storageVolumeLvlMin [#894](https://github.com/ie3-institute/simona/issues/894) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7f93135c49..a4b76b9530 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3fa8f862f7..9355b41557 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a4269..f5feea6d6b 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,8 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 93e3f59f13..9d21a21834 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala index e556bc0133..6a91ef120b 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala @@ -13,6 +13,7 @@ import edu.ie3.datamodel.models.result.thermal.{ CylindricalStorageResult, ThermalHouseResult, } +import edu.ie3.simona.exceptions.InvalidParameterException import edu.ie3.simona.exceptions.agent.InconsistentStateException import edu.ie3.simona.model.thermal.ThermalGrid.{ ThermalEnergyDemand, @@ -666,13 +667,12 @@ object ThermalGrid { def hasRequiredDemand: Boolean = required > zeroMWH - def hasAdditionalDemand: Boolean = possible > required + def hasAdditionalDemand: Boolean = possible > zeroMWH } object ThermalEnergyDemand { /** Builds a new instance of [[ThermalEnergyDemand]]. If the possible energy - * is less than the required energy, this is considered to be a bad state - * and the required energy is curtailed to the possible energy. + * is less than the required energy, this is considered to be a bad state. * @param required * The absolutely required energy to reach target state * @param possible @@ -684,8 +684,12 @@ object ThermalGrid { required: Energy, possible: Energy, ): ThermalEnergyDemand = { - if (possible < required) - new ThermalEnergyDemand(possible, possible) + if ( + math.abs(possible.toKilowattHours) < math.abs(required.toKilowattHours) + ) + throw new InvalidParameterException( + s"The possible amount of energy {$possible} is smaller than the required amount of energy {$required}. This is not supported." + ) else new ThermalEnergyDemand(required, possible) } diff --git a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridSpec.scala b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridSpec.scala index e4c1c14c70..b59e6000fb 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridSpec.scala @@ -6,6 +6,7 @@ package edu.ie3.simona.model.thermal +import edu.ie3.simona.exceptions.InvalidParameterException import edu.ie3.simona.model.thermal.ThermalGrid.ThermalEnergyDemand import edu.ie3.simona.test.common.UnitSpec import squants.energy.{MegawattHours, WattHours, Watts} @@ -20,14 +21,22 @@ class ThermalGridSpec extends UnitSpec { "Testing the thermal energy demand" when { "instantiating it from given values" should { - "correct non-sensible input" in { + "throw exception for non-sensible input (positive)" in { val possible = MegawattHours(40d) val required = MegawattHours(42d) - val energyDemand = ThermalEnergyDemand(required, possible) + intercept[InvalidParameterException] { + ThermalEnergyDemand(required, possible) + }.getMessage shouldBe s"The possible amount of energy {$possible} is smaller than the required amount of energy {$required}. This is not supported." + } - energyDemand.required should approximate(possible) - energyDemand.possible should approximate(possible) + "throw exception for non-sensible input (negative)" in { + val possible = MegawattHours(-40d) + val required = MegawattHours(-42d) + + intercept[InvalidParameterException] { + ThermalEnergyDemand(required, possible) + }.getMessage shouldBe s"The possible amount of energy {$possible} is smaller than the required amount of energy {$required}. This is not supported." } "set the correct values, if they are sensible" in { @@ -51,22 +60,30 @@ class ThermalGridSpec extends UnitSpec { } "checking for required and additional demand" should { - "return proper information, if no required but additional demand is apparent" in { + "return proper information, if no required and no additional demand is apparent" in { val required = MegawattHours(0d) - val possible = MegawattHours(45d) + val possible = MegawattHours(0d) val energyDemand = ThermalEnergyDemand(required, possible) energyDemand.hasRequiredDemand shouldBe false - energyDemand.hasAdditionalDemand shouldBe true + energyDemand.hasAdditionalDemand shouldBe false } - "return proper information, if required but no additional demand is apparent" in { - val required = MegawattHours(45d) + "return proper information, if no required but additional demand is apparent" in { + val required = MegawattHours(0d) val possible = MegawattHours(45d) val energyDemand = ThermalEnergyDemand(required, possible) - energyDemand.hasRequiredDemand shouldBe true - energyDemand.hasAdditionalDemand shouldBe false + energyDemand.hasRequiredDemand shouldBe false + energyDemand.hasAdditionalDemand shouldBe true + } + + "throw exception, if required demand is higher than possible demand" in { + val required = MegawattHours(1d) + val possible = MegawattHours(0d) + intercept[InvalidParameterException] { + ThermalEnergyDemand(required, possible) + }.getMessage shouldBe s"The possible amount of energy {$possible} is smaller than the required amount of energy {$required}. This is not supported." } "return proper information, if required and additional demand is apparent" in { @@ -77,6 +94,16 @@ class ThermalGridSpec extends UnitSpec { energyDemand.hasRequiredDemand shouldBe true energyDemand.hasAdditionalDemand shouldBe true } + + // FIXME: Think about "negative demand", maybe add more cases as well + "return proper information, if no required but additional demand is apparent (negative)" in { + val required = MegawattHours(-10d) + val possible = MegawattHours(-45d) + + val energyDemand = ThermalEnergyDemand(required, possible) + energyDemand.hasRequiredDemand shouldBe false + energyDemand.hasAdditionalDemand shouldBe true + } } "adding two demands" should {