From 1370dab12912f4ffa4a0a808069f68c493bf52e1 Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Tue, 28 Jun 2022 22:59:20 +0200 Subject: [PATCH 1/4] Simplifying ParticipantConfigUtil --- .../agent/grid/GridAgentController.scala | 10 +- .../edu/ie3/simona/util/ConfigUtil.scala | 166 +++----- ...FixedFeedInAgentModelCalculationSpec.scala | 7 +- .../LoadAgentFixedModelCalculationSpec.scala | 7 +- ...LoadAgentProfileModelCalculationSpec.scala | 7 +- .../PVAgentModelCalculationSpec.scala | 2 +- .../WecAgentModelCalculationSpec.scala | 4 +- .../participant/FixedFeedInModelSpec.scala | 3 +- .../test/common/input/EvcsInputTestData.scala | 2 +- .../edu/ie3/simona/util/ConfigUtilsSpec.scala | 393 +++++++++--------- 10 files changed, 283 insertions(+), 318 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala index 3379d9333c..f1441b41f6 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala @@ -221,7 +221,7 @@ class GridAgentController( case input: FixedFeedInInput => buildFixedFeedIn( input, - participantConfigUtil.getFixedFeedConfigOrDefault(input.getUuid), + participantConfigUtil.getConfigOrDefault(input.getUuid), environmentRefs.primaryServiceProxy, simulationStartDate, simulationEndDate, @@ -232,7 +232,7 @@ class GridAgentController( case input: LoadInput => buildLoad( input, - participantConfigUtil.getLoadConfigOrDefault(input.getUuid), + participantConfigUtil.getConfigOrDefault(input.getUuid), environmentRefs.primaryServiceProxy, simulationStartDate, simulationEndDate, @@ -243,7 +243,7 @@ class GridAgentController( case input: PvInput => buildPV( input, - participantConfigUtil.getPvConfigOrDefault(input.getUuid), + participantConfigUtil.getConfigOrDefault(input.getUuid), environmentRefs.primaryServiceProxy, environmentRefs.weather, simulationStartDate, @@ -255,7 +255,7 @@ class GridAgentController( case input: WecInput => buildWec( input, - participantConfigUtil.getWecConfigOrDefault(input.getUuid), + participantConfigUtil.getConfigOrDefault(input.getUuid), environmentRefs.primaryServiceProxy, environmentRefs.weather, simulationStartDate, @@ -267,7 +267,7 @@ class GridAgentController( case input: EvcsInput => buildEvcs( input, - participantConfigUtil.getEvcsConfigOrDefault(input.getUuid), + participantConfigUtil.getConfigOrDefault(input.getUuid), environmentRefs.primaryServiceProxy, environmentRefs.evDataService.getOrElse( throw new GridAgentInitializationException( diff --git a/src/main/scala/edu/ie3/simona/util/ConfigUtil.scala b/src/main/scala/edu/ie3/simona/util/ConfigUtil.scala index ceef9abbdd..2e4133dd95 100644 --- a/src/main/scala/edu/ie3/simona/util/ConfigUtil.scala +++ b/src/main/scala/edu/ie3/simona/util/ConfigUtil.scala @@ -12,8 +12,6 @@ import edu.ie3.datamodel.io.connectors.{ InfluxDbConnector, SqlConnector } - -import java.util.{Properties, UUID} import edu.ie3.datamodel.models.result.connector.{ LineResult, SwitchResult, @@ -30,91 +28,43 @@ import org.apache.kafka.common.KafkaException import java.io.File import java.util.concurrent.ExecutionException +import java.util.{Properties, UUID} import scala.collection.mutable import scala.jdk.CollectionConverters._ +import scala.reflect.ClassTag import scala.util.{Failure, Success, Try, Using} object ConfigUtil { final case class ParticipantConfigUtil private ( private val configs: Map[UUID, SimonaConfig.BaseRuntimeConfig], - private val defaultLoadConfig: LoadRuntimeConfig, - private val defaultFixedFeedInConfig: FixedFeedInRuntimeConfig, - private val defaultPvConfig: PvRuntimeConfig, - private val defaultWecConfig: WecRuntimeConfig, - private val defaultEvcsConfig: EvcsRuntimeConfig + private val defaultConfigs: Map[Class[_], BaseRuntimeConfig] ) { - /** Queries for a [[LoadRuntimeConfig]], that applies for the given uuid and - * either returns the config for the requested uuid or the default config. - * If the requested uuid is valid, but the return type is not of type - * [[LoadRuntimeConfig]] the default config for this type is returned. - * - * @param uuid - * Identifier of the requested load model - * @return - * the requested [[LoadRuntimeConfig]] or a default value - */ - def getLoadConfigOrDefault(uuid: UUID): LoadRuntimeConfig = - configs.get(uuid) match { - case Some(loadConfig: LoadRuntimeConfig) => loadConfig - case _ => defaultLoadConfig - } - - /** Queries for a [[PvRuntimeConfig]], that applies for the given uuid and - * either returns the config for the requested uuid or the default config. - * If the requested uuid is valid, but the return type is not of type - * [[PvRuntimeConfig]] the default config for this type is returned. + /** Queries for a [[BaseRuntimeConfig]] of type [[T]], that applies for the + * given uuid and either returns the config for the requested uuid or the + * default config for type [[T]]. * * @param uuid * Identifier of the requested load model * @return - * the requested [[PvRuntimeConfig]] or a default value + * the requested config or a default value of type [[T]] */ - def getPvConfigOrDefault(uuid: UUID): PvRuntimeConfig = + def getConfigOrDefault[T <: BaseRuntimeConfig]( + uuid: UUID + )(implicit tag: ClassTag[T]): T = configs.get(uuid) match { - case Some(pvRuntimeConfig: PvRuntimeConfig) => pvRuntimeConfig - case _ => defaultPvConfig - } - - def getWecConfigOrDefault(uuid: UUID): WecRuntimeConfig = - configs.get(uuid) match { - case Some(wecRuntimeConfig: WecRuntimeConfig) => wecRuntimeConfig - case _ => defaultWecConfig - } - - /** Queries for a [[FixedFeedInRuntimeConfig]], that applies for the given - * uuid and either returns the config for the requested uuid or the default - * config. If the requested uuid is valid, but the return type is not of - * type [[FixedFeedInRuntimeConfig]] the default config for this type is - * returned. - * - * @param uuid - * Identifier of the requested fixed feed in model - * @return - * the requested [[FixedFeedInRuntimeConfig]] or a default value - */ - def getFixedFeedConfigOrDefault(uuid: UUID): FixedFeedInRuntimeConfig = - configs.get(uuid) match { - case Some(ffinConfig: FixedFeedInRuntimeConfig) => ffinConfig - case _ => defaultFixedFeedInConfig + case Some(conf: T) => conf + case _ => + defaultConfigs.get(tag.runtimeClass) match { + case Some(conf: T) => conf + case _ => + throw new RuntimeException( + s"No config found for $uuid of type ${tag.runtimeClass.getSimpleName}." + ) + } } - /** Queries for a [[EvcsRuntimeConfig]], that applies for the given uuid and - * either returns the config for the requested uuid or the default config. - * If the requested uuid is valid, but the return type is not of type - * [[EvcsRuntimeConfig]] the default config for this type is returned. - * - * @param uuid - * Identifier of the requested Evcs model - * @return - * the requested [[EvcsRuntimeConfig]] or a default value - */ - def getEvcsConfigOrDefault(uuid: UUID): EvcsRuntimeConfig = - configs.get(uuid) match { - case Some(evcsConfig: EvcsRuntimeConfig) => evcsConfig - case _ => defaultEvcsConfig - } } object ParticipantConfigUtil { @@ -131,24 +81,28 @@ object ConfigUtil { def apply( subConfig: SimonaConfig.Simona.Runtime.Participant ): ParticipantConfigUtil = { - new ParticipantConfigUtil( + ParticipantConfigUtil( buildUuidMapping( - subConfig.load.individualConfigs ++ - subConfig.fixedFeedIn.individualConfigs ++ - subConfig.pv.individualConfigs ++ - subConfig.evcs.individualConfigs ++ + Seq( + subConfig.load.individualConfigs, + subConfig.fixedFeedIn.individualConfigs, + subConfig.pv.individualConfigs, + subConfig.evcs.individualConfigs, subConfig.wec.individualConfigs + ).reduceOption(_ ++ _).getOrElse(Seq.empty) ), - subConfig.load.defaultConfig, - subConfig.fixedFeedIn.defaultConfig, - subConfig.pv.defaultConfig, - subConfig.wec.defaultConfig, - subConfig.evcs.defaultConfig + Seq( + subConfig.load.defaultConfig, + subConfig.fixedFeedIn.defaultConfig, + subConfig.pv.defaultConfig, + subConfig.evcs.defaultConfig, + subConfig.wec.defaultConfig + ).map { conf => conf.getClass -> conf }.toMap ) } private def buildUuidMapping( - configs: List[BaseRuntimeConfig] + configs: Seq[BaseRuntimeConfig] ): Map[UUID, BaseRuntimeConfig] = configs .flatMap(modelConfig => @@ -480,33 +434,31 @@ object ConfigUtil { properties.put("bootstrap.servers", kafkaParams.bootstrapServers) properties.put("default.api.timeout.ms", 2000) properties.put("request.timeout.ms", 1000) - try { - Using(AdminClient.create(properties)) { client => - val existingTopics = client.listTopics.names().get().asScala - topics.filterNot(existingTopics.contains) - } match { - case Failure(ke: KafkaException) => - throw new InvalidConfigParameterException( - s"Exception creating kafka client for broker ${kafkaParams.bootstrapServers}.", - ke - ) - case Failure(ee: ExecutionException) => - throw new InvalidConfigParameterException( - s"Connection with kafka broker ${kafkaParams.bootstrapServers} failed.", - ee - ) - case Failure(other) => - throw new InvalidConfigParameterException( - s"Checking kafka config failed with unexpected exception.", - other - ) - case Success(missingTopics) if missingTopics.nonEmpty => - throw new InvalidConfigParameterException( - s"Required kafka topics {${missingTopics.mkString}} do not exist." - ) - case Success(_) => - // testing connection succeeded, do nothing - } + Using(AdminClient.create(properties)) { client => + val existingTopics = client.listTopics.names().get().asScala + topics.filterNot(existingTopics.contains) + } match { + case Failure(ke: KafkaException) => + throw new InvalidConfigParameterException( + s"Exception creating kafka client for broker ${kafkaParams.bootstrapServers}.", + ke + ) + case Failure(ee: ExecutionException) => + throw new InvalidConfigParameterException( + s"Connection with kafka broker ${kafkaParams.bootstrapServers} failed.", + ee + ) + case Failure(other) => + throw new InvalidConfigParameterException( + s"Checking kafka config failed with unexpected exception.", + other + ) + case Success(missingTopics) if missingTopics.nonEmpty => + throw new InvalidConfigParameterException( + s"Required kafka topics {${missingTopics.mkString}} do not exist." + ) + case Success(_) => + // testing connection succeeded, do nothing } } } diff --git a/src/test/scala/edu/ie3/simona/agent/participant/FixedFeedInAgentModelCalculationSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/FixedFeedInAgentModelCalculationSpec.scala index 66f28b4c41..cc39f352cf 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/FixedFeedInAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/FixedFeedInAgentModelCalculationSpec.scala @@ -99,9 +99,10 @@ class FixedFeedInAgentModelCalculationSpec private val fixedFeedConfigUtil = ConfigUtil.ParticipantConfigUtil( simonaConfig.simona.runtime.participant ) - private val modelConfig = fixedFeedConfigUtil.getFixedFeedConfigOrDefault( - voltageSensitiveInput.getUuid - ) + private val modelConfig = + fixedFeedConfigUtil.getConfigOrDefault[FixedFeedInRuntimeConfig]( + voltageSensitiveInput.getUuid + ) private val services = None private val resolution = simonaConfig.simona.powerflow.resolution.getSeconds diff --git a/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentFixedModelCalculationSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentFixedModelCalculationSpec.scala index 3af3a4cc79..f4dcb77495 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentFixedModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentFixedModelCalculationSpec.scala @@ -87,9 +87,10 @@ class LoadAgentFixedModelCalculationSpec private val loadConfigUtil = ConfigUtil.ParticipantConfigUtil( simonaConfig.simona.runtime.participant ) - private val modelConfig = loadConfigUtil.getLoadConfigOrDefault( - voltageSensitiveInput.getUuid - ) + private val modelConfig = + loadConfigUtil.getConfigOrDefault[LoadRuntimeConfig]( + voltageSensitiveInput.getUuid + ) private val services = None private val resolution = simonaConfig.simona.powerflow.resolution.getSeconds diff --git a/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentProfileModelCalculationSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentProfileModelCalculationSpec.scala index f6c3cd2748..15235d2ec2 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentProfileModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentProfileModelCalculationSpec.scala @@ -87,9 +87,10 @@ class LoadAgentProfileModelCalculationSpec private val loadConfigUtil = ConfigUtil.ParticipantConfigUtil( simonaConfig.simona.runtime.participant ) - private val modelConfig = loadConfigUtil.getLoadConfigOrDefault( - voltageSensitiveInput.getUuid - ) + private val modelConfig = + loadConfigUtil.getConfigOrDefault[LoadRuntimeConfig]( + voltageSensitiveInput.getUuid + ) private val services = None private val resolution = simonaConfig.simona.powerflow.resolution.getSeconds diff --git a/src/test/scala/edu/ie3/simona/agent/participant/PVAgentModelCalculationSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/PVAgentModelCalculationSpec.scala index 39edbf6921..e5252d988a 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/PVAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/PVAgentModelCalculationSpec.scala @@ -113,7 +113,7 @@ class PVAgentModelCalculationSpec private val configUtil = ConfigUtil.ParticipantConfigUtil( simonaConfig.simona.runtime.participant ) - private val modelConfig = configUtil.getPvConfigOrDefault( + private val modelConfig = configUtil.getConfigOrDefault[PvRuntimeConfig]( voltageSensitiveInput.getUuid ) private val noServices = None diff --git a/src/test/scala/edu/ie3/simona/agent/participant/WecAgentModelCalculationSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/WecAgentModelCalculationSpec.scala index 9b284a2cba..bc6e5ecbce 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/WecAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/WecAgentModelCalculationSpec.scala @@ -117,7 +117,9 @@ class WecAgentModelCalculationSpec simonaConfig.simona.runtime.participant ) private val modelConfig = - configUtil.getWecConfigOrDefault(voltageSensitiveInput.getUuid) + configUtil.getConfigOrDefault[WecRuntimeConfig]( + voltageSensitiveInput.getUuid + ) private val withServices = Some( Vector(ActorWeatherService(weatherService.ref)) diff --git a/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala index 79a6e02890..f3b7d992f3 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala @@ -7,6 +7,7 @@ package edu.ie3.simona.model.participant import edu.ie3.simona.config.SimonaConfig +import edu.ie3.simona.config.SimonaConfig.FixedFeedInRuntimeConfig import edu.ie3.simona.model.participant.control.QControl import edu.ie3.simona.model.participant.load.{LoadModelBehaviour, LoadReference} import edu.ie3.simona.test.common.input.FixedFeedInputTestData @@ -39,7 +40,7 @@ class FixedFeedInModelSpec .ParticipantConfigUtil( simonaConfig.simona.runtime.participant ) - .getFixedFeedConfigOrDefault(fixedFeedInput.getUuid) + .getConfigOrDefault[FixedFeedInRuntimeConfig](fixedFeedInput.getUuid) val actualModel = FixedFeedInModel.apply( fixedFeedInput, diff --git a/src/test/scala/edu/ie3/simona/test/common/input/EvcsInputTestData.scala b/src/test/scala/edu/ie3/simona/test/common/input/EvcsInputTestData.scala index c64f3f0f2b..60789126bc 100644 --- a/src/test/scala/edu/ie3/simona/test/common/input/EvcsInputTestData.scala +++ b/src/test/scala/edu/ie3/simona/test/common/input/EvcsInputTestData.scala @@ -56,7 +56,7 @@ trait EvcsInputTestData extends DefaultTestData with NodeInputTestData { ) protected val modelConfig: SimonaConfig.EvcsRuntimeConfig = - configUtil.getEvcsConfigOrDefault( + configUtil.getConfigOrDefault[SimonaConfig.EvcsRuntimeConfig]( evcsInputModel.getUuid ) diff --git a/src/test/scala/edu/ie3/simona/util/ConfigUtilsSpec.scala b/src/test/scala/edu/ie3/simona/util/ConfigUtilsSpec.scala index b3ef2d98b9..ca5cc10277 100644 --- a/src/test/scala/edu/ie3/simona/util/ConfigUtilsSpec.scala +++ b/src/test/scala/edu/ie3/simona/util/ConfigUtilsSpec.scala @@ -55,27 +55,30 @@ class ConfigUtilsSpec simonaConfig.simona.runtime.participant ) - inside(actual) { - case ParticipantConfigUtil(configs, defaultLoadConfig, _, _, _, _) => - configs shouldBe Map.empty[UUID, SimonaConfig.LoadRuntimeConfig] - inside(defaultLoadConfig) { - case LoadRuntimeConfig( + inside(actual) { case ParticipantConfigUtil(configs, defaultConfigs) => + configs shouldBe Map.empty[UUID, SimonaConfig.LoadRuntimeConfig] + defaultConfigs.size shouldBe 5 + + inside(defaultConfigs.get(classOf[LoadRuntimeConfig])) { + case Some( + LoadRuntimeConfig( calculateMissingReactivePowerWithModel, scaling, uuids, modelBehaviour, reference - ) => - calculateMissingReactivePowerWithModel shouldBe false - modelBehaviour shouldBe "fix" - reference shouldBe "power" - scaling shouldBe 1.0 - uuids shouldBe List("default") - } - case unexpected => - fail( - s"The input is supposed to be converted to ${ParticipantConfigUtil.getClass.getSimpleName}. I got '$unexpected" - ) + ) + ) => + calculateMissingReactivePowerWithModel shouldBe false + modelBehaviour shouldBe "fix" + reference shouldBe "power" + scaling shouldBe 1.0 + uuids shouldBe List("default") + case unexpected => + fail( + s"Expected a default $LoadRuntimeConfig. I got '$unexpected" + ) + } } } @@ -108,16 +111,33 @@ class ConfigUtilsSpec simonaConfig.simona.runtime.participant ) - inside(actual) { - case ParticipantConfigUtil(configs, _, _, _, _, _) => - configs.size shouldBe 1 - configs.contains( - UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") - ) - case unexpected => - fail( - s"The input is supposed to be converted to ${ParticipantConfigUtil.getClass.getSimpleName}. I got '$unexpected" - ) + inside(actual) { case ParticipantConfigUtil(configs, defaultConfigs) => + configs.size shouldBe 1 + configs.contains( + UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") + ) + + defaultConfigs.size shouldBe 5 + inside(defaultConfigs.get(classOf[LoadRuntimeConfig])) { + case Some( + LoadRuntimeConfig( + calculateMissingReactivePowerWithModel, + scaling, + uuids, + modelBehaviour, + reference + ) + ) => + calculateMissingReactivePowerWithModel shouldBe false + modelBehaviour shouldBe "profile" + reference shouldBe "power" + scaling shouldBe 1.3 + uuids shouldBe List("default") + case unexpected => + fail( + s"Expected a default $LoadRuntimeConfig. I got '$unexpected" + ) + } } } @@ -150,25 +170,21 @@ class ConfigUtilsSpec simonaConfig.simona.runtime.participant ) - inside(actual) { - case ParticipantConfigUtil(configs, _, _, _, _, _) => - configs.size shouldBe 2 - configs.contains( - UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") - ) - configs.contains( - UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") - ) - actual.getLoadConfigOrDefault( - UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") - ) shouldBe actual.getLoadConfigOrDefault( - UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") - ) - case unexpected => - fail( - s"The input is supposed to be converted to ${ParticipantConfigUtil.getClass.getSimpleName}. I got '$unexpected" - ) + inside(actual) { case ParticipantConfigUtil(configs, _) => + configs.size shouldBe 2 + configs.contains( + UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") + ) + configs.contains( + UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") + ) } + + actual.getConfigOrDefault[LoadRuntimeConfig]( + UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") + ) shouldBe actual.getConfigOrDefault[LoadRuntimeConfig]( + UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") + ) } "setup on multiple correct load input configs correctly" in { @@ -207,40 +223,36 @@ class ConfigUtilsSpec simonaConfig.simona.runtime.participant ) - inside(actual) { - case ParticipantConfigUtil(configs, _, _, _, _, _) => - configs.size shouldBe 2 - configs.contains( - UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") - ) - configs.contains( - UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") - ) - actual.getLoadConfigOrDefault( - UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") - ) shouldBe - LoadRuntimeConfig( - calculateMissingReactivePowerWithModel = false, - 1.3, - List("49f250fa-41ff-4434-a083-79c98d260a76"), - "profile", - "power" - ) - actual.getLoadConfigOrDefault( - UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") - ) shouldBe - LoadRuntimeConfig( - calculateMissingReactivePowerWithModel = false, - 1.5, - List("fb8f1443-1843-4ecd-a94a-59be8148397f"), - "random", - "energy" - ) - case unexpected => - fail( - s"The input is supposed to be converted to ${ParticipantConfigUtil.getClass.getSimpleName}. I got '$unexpected" - ) + inside(actual) { case ParticipantConfigUtil(configs, _) => + configs.size shouldBe 2 + configs.contains( + UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") + ) + configs.contains( + UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") + ) } + + actual.getConfigOrDefault[LoadRuntimeConfig]( + UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") + ) shouldBe + LoadRuntimeConfig( + calculateMissingReactivePowerWithModel = false, + 1.3, + List("49f250fa-41ff-4434-a083-79c98d260a76"), + "profile", + "power" + ) + actual.getConfigOrDefault[LoadRuntimeConfig]( + UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") + ) shouldBe + LoadRuntimeConfig( + calculateMissingReactivePowerWithModel = false, + 1.5, + List("fb8f1443-1843-4ecd-a94a-59be8148397f"), + "random", + "energy" + ) } } @@ -264,31 +276,26 @@ class ConfigUtilsSpec simonaConfig.simona.runtime.participant ) - inside(actual) { - case ParticipantConfigUtil( - configs, - _, - defaultFixedFeedInConfig, - _, - _, - _ - ) => - configs shouldBe Map - .empty[UUID, SimonaConfig.FixedFeedInRuntimeConfig] - inside(defaultFixedFeedInConfig) { - case FixedFeedInRuntimeConfig( + inside(actual) { case ParticipantConfigUtil(configs, defaultConfigs) => + configs shouldBe Map + .empty[UUID, SimonaConfig.FixedFeedInRuntimeConfig] + + inside(defaultConfigs.get(classOf[FixedFeedInRuntimeConfig])) { + case Some( + FixedFeedInRuntimeConfig( calculateMissingReactivePowerWithModel, scaling, uuids - ) => - calculateMissingReactivePowerWithModel shouldBe false - scaling shouldBe 1.0 - uuids shouldBe List("default") - } - case unexpected => - fail( - s"The input is supposed to be converted to ${ParticipantConfigUtil.getClass.getSimpleName}. I got '$unexpected" - ) + ) + ) => + calculateMissingReactivePowerWithModel shouldBe false + scaling shouldBe 1.0 + uuids shouldBe List("default") + case unexpected => + fail( + s"Expected a default $FixedFeedInRuntimeConfig. I got '$unexpected" + ) + } } } @@ -317,16 +324,29 @@ class ConfigUtilsSpec simonaConfig.simona.runtime.participant ) - inside(actual) { - case ParticipantConfigUtil(fixedFeedInConfigs, _, _, _, _, _) => - fixedFeedInConfigs.size shouldBe 1 - fixedFeedInConfigs.contains( - UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") - ) - case unexpected => - fail( - s"The input is supposed to be converted to ${ParticipantConfigUtil.getClass.getSimpleName}. I got '$unexpected" - ) + inside(actual) { case ParticipantConfigUtil(configs, defaultConfigs) => + configs.size shouldBe 1 + configs.contains( + UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") + ) + + defaultConfigs.size shouldBe 5 + inside(defaultConfigs.get(classOf[FixedFeedInRuntimeConfig])) { + case Some( + FixedFeedInRuntimeConfig( + calculateMissingReactivePowerWithModel, + scaling, + uuids + ) + ) => + calculateMissingReactivePowerWithModel shouldBe false + scaling shouldBe 1.3 + uuids shouldBe List("default") + case unexpected => + fail( + s"Expected a default $FixedFeedInRuntimeConfig. I got '$unexpected" + ) + } } } @@ -355,24 +375,20 @@ class ConfigUtilsSpec simonaConfig.simona.runtime.participant ) - inside(actual) { - case ParticipantConfigUtil(fixedFeedInConfigs, _, _, _, _, _) => - fixedFeedInConfigs.size shouldBe 2 - fixedFeedInConfigs.contains( - UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") - ) - fixedFeedInConfigs.contains( - UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") - ) - actual.getFixedFeedConfigOrDefault( - UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") - ) shouldBe actual.getFixedFeedConfigOrDefault( - UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") - ) - case unexpected => - fail( - s"The input is supposed to be converted to ${ParticipantConfigUtil.getClass.getSimpleName}. I got '$unexpected" - ) + inside(actual) { case ParticipantConfigUtil(configs, _) => + configs.size shouldBe 2 + configs.contains( + UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") + ) + configs.contains( + UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") + ) + + actual.getConfigOrDefault[FixedFeedInRuntimeConfig]( + UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") + ) shouldBe actual.getConfigOrDefault[FixedFeedInRuntimeConfig]( + UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") + ) } } @@ -406,36 +422,32 @@ class ConfigUtilsSpec simonaConfig.simona.runtime.participant ) - inside(actual) { - case ParticipantConfigUtil(fixedFeedInConfigs, _, _, _, _, _) => - fixedFeedInConfigs.size shouldBe 2 - fixedFeedInConfigs.contains( - UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") - ) - fixedFeedInConfigs.contains( - UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") - ) - actual.getFixedFeedConfigOrDefault( - UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") - ) shouldBe - FixedFeedInRuntimeConfig( - calculateMissingReactivePowerWithModel = false, - 1.3, - List("49f250fa-41ff-4434-a083-79c98d260a76") - ) - actual.getFixedFeedConfigOrDefault( - UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") - ) shouldBe - FixedFeedInRuntimeConfig( - calculateMissingReactivePowerWithModel = false, - 1.5, - List("fb8f1443-1843-4ecd-a94a-59be8148397f") - ) - case unexpected => - fail( - s"The input is supposed to be converted to ${ParticipantConfigUtil.getClass.getSimpleName}. I got '$unexpected" - ) + inside(actual) { case ParticipantConfigUtil(configs, _) => + configs.size shouldBe 2 + configs.contains( + UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") + ) + configs.contains( + UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") + ) } + + actual.getConfigOrDefault[FixedFeedInRuntimeConfig]( + UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") + ) shouldBe + FixedFeedInRuntimeConfig( + calculateMissingReactivePowerWithModel = false, + 1.3, + List("49f250fa-41ff-4434-a083-79c98d260a76") + ) + actual.getConfigOrDefault[FixedFeedInRuntimeConfig]( + UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") + ) shouldBe + FixedFeedInRuntimeConfig( + calculateMissingReactivePowerWithModel = false, + 1.5, + List("fb8f1443-1843-4ecd-a94a-59be8148397f") + ) } } @@ -514,46 +526,41 @@ class ConfigUtilsSpec simonaConfig.simona.runtime.participant ) - inside(actual) { - case ParticipantConfigUtil(configs, _, _, _, _, _) => - configs.size shouldBe 4 - // return default if a request for fix feed is done, but a load config is found - actual.getFixedFeedConfigOrDefault( - UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") - ) shouldBe - FixedFeedInRuntimeConfig( - calculateMissingReactivePowerWithModel = false, - 1.0, - List("default") - ) + inside(actual) { case ParticipantConfigUtil(configs, _) => + configs.size shouldBe 4 + } - // return default if a request for load is done, but fixed feed is found - actual.getLoadConfigOrDefault( - UUID.fromString("50f250fa-41ff-4434-a083-79c98d260a76") - ) shouldBe - LoadRuntimeConfig( - calculateMissingReactivePowerWithModel = false, - 1.0, - List("default"), - "profile", - "power" - ) + // return default if a request for fix feed is done, but a load config is found + actual.getConfigOrDefault[FixedFeedInRuntimeConfig]( + UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") + ) shouldBe + FixedFeedInRuntimeConfig( + calculateMissingReactivePowerWithModel = false, + 1.0, + List("default") + ) - // return default if a request for pv is done, but fixed feed is found - actual.getPvConfigOrDefault( - UUID.fromString("50f250fa-41ff-4434-a083-79c98d260a76") - ) shouldBe - PvRuntimeConfig( - calculateMissingReactivePowerWithModel = false, - 1.0, - List("default") - ) + // return default if a request for load is done, but fixed feed is found + actual.getConfigOrDefault[LoadRuntimeConfig]( + UUID.fromString("50f250fa-41ff-4434-a083-79c98d260a76") + ) shouldBe + LoadRuntimeConfig( + calculateMissingReactivePowerWithModel = false, + 1.0, + List("default"), + "profile", + "power" + ) - case unexpected => - fail( - s"The input is supposed to be converted to ${ParticipantConfigUtil.getClass.getSimpleName}. I got '$unexpected" - ) - } + // return default if a request for pv is done, but fixed feed is found + actual.getConfigOrDefault[PvRuntimeConfig]( + UUID.fromString("50f250fa-41ff-4434-a083-79c98d260a76") + ) shouldBe + PvRuntimeConfig( + calculateMissingReactivePowerWithModel = false, + 1.0, + List("default") + ) } } From efd555e0533c25919aff941f7a33dbc2a47646ec Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Tue, 28 Jun 2022 23:26:12 +0200 Subject: [PATCH 2/4] Fixing GridAgentController --- .../agent/grid/GridAgentController.scala | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala index f1441b41f6..5325219f56 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala @@ -221,7 +221,9 @@ class GridAgentController( case input: FixedFeedInInput => buildFixedFeedIn( input, - participantConfigUtil.getConfigOrDefault(input.getUuid), + participantConfigUtil.getConfigOrDefault[FixedFeedInRuntimeConfig]( + input.getUuid + ), environmentRefs.primaryServiceProxy, simulationStartDate, simulationEndDate, @@ -232,7 +234,9 @@ class GridAgentController( case input: LoadInput => buildLoad( input, - participantConfigUtil.getConfigOrDefault(input.getUuid), + participantConfigUtil.getConfigOrDefault[LoadRuntimeConfig]( + input.getUuid + ), environmentRefs.primaryServiceProxy, simulationStartDate, simulationEndDate, @@ -243,7 +247,9 @@ class GridAgentController( case input: PvInput => buildPV( input, - participantConfigUtil.getConfigOrDefault(input.getUuid), + participantConfigUtil.getConfigOrDefault[PvRuntimeConfig]( + input.getUuid + ), environmentRefs.primaryServiceProxy, environmentRefs.weather, simulationStartDate, @@ -255,7 +261,9 @@ class GridAgentController( case input: WecInput => buildWec( input, - participantConfigUtil.getConfigOrDefault(input.getUuid), + participantConfigUtil.getConfigOrDefault[WecRuntimeConfig]( + input.getUuid + ), environmentRefs.primaryServiceProxy, environmentRefs.weather, simulationStartDate, @@ -267,7 +275,9 @@ class GridAgentController( case input: EvcsInput => buildEvcs( input, - participantConfigUtil.getConfigOrDefault(input.getUuid), + participantConfigUtil.getConfigOrDefault[EvcsRuntimeConfig]( + input.getUuid + ), environmentRefs.primaryServiceProxy, environmentRefs.evDataService.getOrElse( throw new GridAgentInitializationException( From 85acee17de52c5c23158394a6b348ea0047749db Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Tue, 28 Jun 2022 23:27:47 +0200 Subject: [PATCH 3/4] Refactoring getConfigOrDefault method --- .../agent/grid/GridAgentController.scala | 10 ++++----- .../edu/ie3/simona/util/ConfigUtil.scala | 2 +- ...FixedFeedInAgentModelCalculationSpec.scala | 2 +- .../LoadAgentFixedModelCalculationSpec.scala | 2 +- ...LoadAgentProfileModelCalculationSpec.scala | 2 +- .../PVAgentModelCalculationSpec.scala | 2 +- .../WecAgentModelCalculationSpec.scala | 2 +- .../participant/FixedFeedInModelSpec.scala | 2 +- .../test/common/input/EvcsInputTestData.scala | 2 +- .../edu/ie3/simona/util/ConfigUtilsSpec.scala | 22 +++++++++---------- 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala index 5325219f56..a4c23b635b 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala @@ -221,7 +221,7 @@ class GridAgentController( case input: FixedFeedInInput => buildFixedFeedIn( input, - participantConfigUtil.getConfigOrDefault[FixedFeedInRuntimeConfig]( + participantConfigUtil.getOrDefault[FixedFeedInRuntimeConfig]( input.getUuid ), environmentRefs.primaryServiceProxy, @@ -234,7 +234,7 @@ class GridAgentController( case input: LoadInput => buildLoad( input, - participantConfigUtil.getConfigOrDefault[LoadRuntimeConfig]( + participantConfigUtil.getOrDefault[LoadRuntimeConfig]( input.getUuid ), environmentRefs.primaryServiceProxy, @@ -247,7 +247,7 @@ class GridAgentController( case input: PvInput => buildPV( input, - participantConfigUtil.getConfigOrDefault[PvRuntimeConfig]( + participantConfigUtil.getOrDefault[PvRuntimeConfig]( input.getUuid ), environmentRefs.primaryServiceProxy, @@ -261,7 +261,7 @@ class GridAgentController( case input: WecInput => buildWec( input, - participantConfigUtil.getConfigOrDefault[WecRuntimeConfig]( + participantConfigUtil.getOrDefault[WecRuntimeConfig]( input.getUuid ), environmentRefs.primaryServiceProxy, @@ -275,7 +275,7 @@ class GridAgentController( case input: EvcsInput => buildEvcs( input, - participantConfigUtil.getConfigOrDefault[EvcsRuntimeConfig]( + participantConfigUtil.getOrDefault[EvcsRuntimeConfig]( input.getUuid ), environmentRefs.primaryServiceProxy, diff --git a/src/main/scala/edu/ie3/simona/util/ConfigUtil.scala b/src/main/scala/edu/ie3/simona/util/ConfigUtil.scala index 2e4133dd95..37c0abdd8d 100644 --- a/src/main/scala/edu/ie3/simona/util/ConfigUtil.scala +++ b/src/main/scala/edu/ie3/simona/util/ConfigUtil.scala @@ -50,7 +50,7 @@ object ConfigUtil { * @return * the requested config or a default value of type [[T]] */ - def getConfigOrDefault[T <: BaseRuntimeConfig]( + def getOrDefault[T <: BaseRuntimeConfig]( uuid: UUID )(implicit tag: ClassTag[T]): T = configs.get(uuid) match { diff --git a/src/test/scala/edu/ie3/simona/agent/participant/FixedFeedInAgentModelCalculationSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/FixedFeedInAgentModelCalculationSpec.scala index cc39f352cf..a6e44bef27 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/FixedFeedInAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/FixedFeedInAgentModelCalculationSpec.scala @@ -100,7 +100,7 @@ class FixedFeedInAgentModelCalculationSpec simonaConfig.simona.runtime.participant ) private val modelConfig = - fixedFeedConfigUtil.getConfigOrDefault[FixedFeedInRuntimeConfig]( + fixedFeedConfigUtil.getOrDefault[FixedFeedInRuntimeConfig]( voltageSensitiveInput.getUuid ) private val services = None diff --git a/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentFixedModelCalculationSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentFixedModelCalculationSpec.scala index f4dcb77495..9e2891941f 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentFixedModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentFixedModelCalculationSpec.scala @@ -88,7 +88,7 @@ class LoadAgentFixedModelCalculationSpec simonaConfig.simona.runtime.participant ) private val modelConfig = - loadConfigUtil.getConfigOrDefault[LoadRuntimeConfig]( + loadConfigUtil.getOrDefault[LoadRuntimeConfig]( voltageSensitiveInput.getUuid ) private val services = None diff --git a/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentProfileModelCalculationSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentProfileModelCalculationSpec.scala index 15235d2ec2..da24d2f8c9 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentProfileModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentProfileModelCalculationSpec.scala @@ -88,7 +88,7 @@ class LoadAgentProfileModelCalculationSpec simonaConfig.simona.runtime.participant ) private val modelConfig = - loadConfigUtil.getConfigOrDefault[LoadRuntimeConfig]( + loadConfigUtil.getOrDefault[LoadRuntimeConfig]( voltageSensitiveInput.getUuid ) private val services = None diff --git a/src/test/scala/edu/ie3/simona/agent/participant/PVAgentModelCalculationSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/PVAgentModelCalculationSpec.scala index e5252d988a..a9037e8aca 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/PVAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/PVAgentModelCalculationSpec.scala @@ -113,7 +113,7 @@ class PVAgentModelCalculationSpec private val configUtil = ConfigUtil.ParticipantConfigUtil( simonaConfig.simona.runtime.participant ) - private val modelConfig = configUtil.getConfigOrDefault[PvRuntimeConfig]( + private val modelConfig = configUtil.getOrDefault[PvRuntimeConfig]( voltageSensitiveInput.getUuid ) private val noServices = None diff --git a/src/test/scala/edu/ie3/simona/agent/participant/WecAgentModelCalculationSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/WecAgentModelCalculationSpec.scala index bc6e5ecbce..4c88f0274b 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/WecAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/WecAgentModelCalculationSpec.scala @@ -117,7 +117,7 @@ class WecAgentModelCalculationSpec simonaConfig.simona.runtime.participant ) private val modelConfig = - configUtil.getConfigOrDefault[WecRuntimeConfig]( + configUtil.getOrDefault[WecRuntimeConfig]( voltageSensitiveInput.getUuid ) diff --git a/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala index f3b7d992f3..fed5968bd6 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala @@ -40,7 +40,7 @@ class FixedFeedInModelSpec .ParticipantConfigUtil( simonaConfig.simona.runtime.participant ) - .getConfigOrDefault[FixedFeedInRuntimeConfig](fixedFeedInput.getUuid) + .getOrDefault[FixedFeedInRuntimeConfig](fixedFeedInput.getUuid) val actualModel = FixedFeedInModel.apply( fixedFeedInput, diff --git a/src/test/scala/edu/ie3/simona/test/common/input/EvcsInputTestData.scala b/src/test/scala/edu/ie3/simona/test/common/input/EvcsInputTestData.scala index 60789126bc..a726e074b9 100644 --- a/src/test/scala/edu/ie3/simona/test/common/input/EvcsInputTestData.scala +++ b/src/test/scala/edu/ie3/simona/test/common/input/EvcsInputTestData.scala @@ -56,7 +56,7 @@ trait EvcsInputTestData extends DefaultTestData with NodeInputTestData { ) protected val modelConfig: SimonaConfig.EvcsRuntimeConfig = - configUtil.getConfigOrDefault[SimonaConfig.EvcsRuntimeConfig]( + configUtil.getOrDefault[SimonaConfig.EvcsRuntimeConfig]( evcsInputModel.getUuid ) diff --git a/src/test/scala/edu/ie3/simona/util/ConfigUtilsSpec.scala b/src/test/scala/edu/ie3/simona/util/ConfigUtilsSpec.scala index ca5cc10277..4d8ec57132 100644 --- a/src/test/scala/edu/ie3/simona/util/ConfigUtilsSpec.scala +++ b/src/test/scala/edu/ie3/simona/util/ConfigUtilsSpec.scala @@ -180,9 +180,9 @@ class ConfigUtilsSpec ) } - actual.getConfigOrDefault[LoadRuntimeConfig]( + actual.getOrDefault[LoadRuntimeConfig]( UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") - ) shouldBe actual.getConfigOrDefault[LoadRuntimeConfig]( + ) shouldBe actual.getOrDefault[LoadRuntimeConfig]( UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") ) } @@ -233,7 +233,7 @@ class ConfigUtilsSpec ) } - actual.getConfigOrDefault[LoadRuntimeConfig]( + actual.getOrDefault[LoadRuntimeConfig]( UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") ) shouldBe LoadRuntimeConfig( @@ -243,7 +243,7 @@ class ConfigUtilsSpec "profile", "power" ) - actual.getConfigOrDefault[LoadRuntimeConfig]( + actual.getOrDefault[LoadRuntimeConfig]( UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") ) shouldBe LoadRuntimeConfig( @@ -384,9 +384,9 @@ class ConfigUtilsSpec UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") ) - actual.getConfigOrDefault[FixedFeedInRuntimeConfig]( + actual.getOrDefault[FixedFeedInRuntimeConfig]( UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") - ) shouldBe actual.getConfigOrDefault[FixedFeedInRuntimeConfig]( + ) shouldBe actual.getOrDefault[FixedFeedInRuntimeConfig]( UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") ) } @@ -432,7 +432,7 @@ class ConfigUtilsSpec ) } - actual.getConfigOrDefault[FixedFeedInRuntimeConfig]( + actual.getOrDefault[FixedFeedInRuntimeConfig]( UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") ) shouldBe FixedFeedInRuntimeConfig( @@ -440,7 +440,7 @@ class ConfigUtilsSpec 1.3, List("49f250fa-41ff-4434-a083-79c98d260a76") ) - actual.getConfigOrDefault[FixedFeedInRuntimeConfig]( + actual.getOrDefault[FixedFeedInRuntimeConfig]( UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f") ) shouldBe FixedFeedInRuntimeConfig( @@ -531,7 +531,7 @@ class ConfigUtilsSpec } // return default if a request for fix feed is done, but a load config is found - actual.getConfigOrDefault[FixedFeedInRuntimeConfig]( + actual.getOrDefault[FixedFeedInRuntimeConfig]( UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76") ) shouldBe FixedFeedInRuntimeConfig( @@ -541,7 +541,7 @@ class ConfigUtilsSpec ) // return default if a request for load is done, but fixed feed is found - actual.getConfigOrDefault[LoadRuntimeConfig]( + actual.getOrDefault[LoadRuntimeConfig]( UUID.fromString("50f250fa-41ff-4434-a083-79c98d260a76") ) shouldBe LoadRuntimeConfig( @@ -553,7 +553,7 @@ class ConfigUtilsSpec ) // return default if a request for pv is done, but fixed feed is found - actual.getConfigOrDefault[PvRuntimeConfig]( + actual.getOrDefault[PvRuntimeConfig]( UUID.fromString("50f250fa-41ff-4434-a083-79c98d260a76") ) shouldBe PvRuntimeConfig( From 3e83e3990ee0717d039c169a3cfd18aa21c3efe6 Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Sun, 31 Jul 2022 16:27:32 +0200 Subject: [PATCH 4/4] Added to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fdab37eb7..40c358950c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Update Sphinx to 4.5.0 as well as extensions [#214](https://github.com/ie3-institute/simona/issues/214) - Improved code quality in and around DBFS algorithm [#265](https://github.com/ie3-institute/simona/issues/265) - Adapt test to new PowerSystemUtils snapshot [#294](https://github.com/ie3-institute/simona/issues/294) +- Simplified ParticipantConfigUtil [#273](https://github.com/ie3-institute/simona/issues/273) ### Fixed - Location of `vn_simona` test grid (was partially in Berlin and Dortmund) [#72](https://github.com/ie3-institute/simona/issues/72)