Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfeismann committed Aug 21, 2024
1 parent 8ee3b77 commit ced3b55
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
18 changes: 14 additions & 4 deletions src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ package edu.ie3.simona.model.thermal
import com.typesafe.scalalogging.LazyLogging
import edu.ie3.datamodel.models.input.thermal.CylindricalStorageInput
import edu.ie3.datamodel.models.result.ResultEntity
import edu.ie3.datamodel.models.result.thermal.{CylindricalStorageResult, ThermalHouseResult}
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, ThermalGridState}
import edu.ie3.simona.model.thermal.ThermalGrid.{
ThermalEnergyDemand,
ThermalGridState,
}
import edu.ie3.simona.model.thermal.ThermalHouse.ThermalHouseState
import edu.ie3.simona.model.thermal.ThermalStorage.ThermalStorageState
import edu.ie3.simona.util.TickUtil.TickLong
Expand Down Expand Up @@ -495,8 +501,12 @@ object ThermalGrid {
required: Energy,
possible: Energy,
): ThermalEnergyDemand = {
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.")
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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ class ThermalGridSpec extends UnitSpec {
val possible = MegawattHours(40d)
val required = MegawattHours(42d)

intercept[InvalidParameterException] {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."
}

"throw exception for non-sensible input (negative)" in {
val possible = MegawattHours(-40d)
val required = MegawattHours(-42d)

intercept[InvalidParameterException] {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."
}


"set the correct values, if they are sensible" in {
val possible = MegawattHours(45d)
val required = MegawattHours(42d)
Expand Down Expand Up @@ -80,7 +81,8 @@ class ThermalGridSpec extends UnitSpec {
"throw exception, if required demand is higher than possible demand" in {
val required = MegawattHours(1d)
val possible = MegawattHours(0d)
intercept[InvalidParameterException] {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."
}

Expand All @@ -93,7 +95,7 @@ class ThermalGridSpec extends UnitSpec {
energyDemand.hasAdditionalDemand shouldBe true
}

//FIXME: Think about "negative demand", maybe add more cases as well
// 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)
Expand Down

0 comments on commit ced3b55

Please sign in to comment.