Skip to content

Commit

Permalink
Refactoring getConfigOrDefault method
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-peter committed Jun 28, 2022
1 parent efd555e commit 85acee1
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class GridAgentController(
case input: FixedFeedInInput =>
buildFixedFeedIn(
input,
participantConfigUtil.getConfigOrDefault[FixedFeedInRuntimeConfig](
participantConfigUtil.getOrDefault[FixedFeedInRuntimeConfig](
input.getUuid
),
environmentRefs.primaryServiceProxy,
Expand All @@ -234,7 +234,7 @@ class GridAgentController(
case input: LoadInput =>
buildLoad(
input,
participantConfigUtil.getConfigOrDefault[LoadRuntimeConfig](
participantConfigUtil.getOrDefault[LoadRuntimeConfig](
input.getUuid
),
environmentRefs.primaryServiceProxy,
Expand All @@ -247,7 +247,7 @@ class GridAgentController(
case input: PvInput =>
buildPV(
input,
participantConfigUtil.getConfigOrDefault[PvRuntimeConfig](
participantConfigUtil.getOrDefault[PvRuntimeConfig](
input.getUuid
),
environmentRefs.primaryServiceProxy,
Expand All @@ -261,7 +261,7 @@ class GridAgentController(
case input: WecInput =>
buildWec(
input,
participantConfigUtil.getConfigOrDefault[WecRuntimeConfig](
participantConfigUtil.getOrDefault[WecRuntimeConfig](
input.getUuid
),
environmentRefs.primaryServiceProxy,
Expand All @@ -275,7 +275,7 @@ class GridAgentController(
case input: EvcsInput =>
buildEvcs(
input,
participantConfigUtil.getConfigOrDefault[EvcsRuntimeConfig](
participantConfigUtil.getOrDefault[EvcsRuntimeConfig](
input.getUuid
),
environmentRefs.primaryServiceProxy,
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/edu/ie3/simona/util/ConfigUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class WecAgentModelCalculationSpec
simonaConfig.simona.runtime.participant
)
private val modelConfig =
configUtil.getConfigOrDefault[WecRuntimeConfig](
configUtil.getOrDefault[WecRuntimeConfig](
voltageSensitiveInput.getUuid
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class FixedFeedInModelSpec
.ParticipantConfigUtil(
simonaConfig.simona.runtime.participant
)
.getConfigOrDefault[FixedFeedInRuntimeConfig](fixedFeedInput.getUuid)
.getOrDefault[FixedFeedInRuntimeConfig](fixedFeedInput.getUuid)

val actualModel = FixedFeedInModel.apply(
fixedFeedInput,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
22 changes: 11 additions & 11 deletions src/test/scala/edu/ie3/simona/util/ConfigUtilsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
}
Expand Down Expand Up @@ -233,7 +233,7 @@ class ConfigUtilsSpec
)
}

actual.getConfigOrDefault[LoadRuntimeConfig](
actual.getOrDefault[LoadRuntimeConfig](
UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76")
) shouldBe
LoadRuntimeConfig(
Expand All @@ -243,7 +243,7 @@ class ConfigUtilsSpec
"profile",
"power"
)
actual.getConfigOrDefault[LoadRuntimeConfig](
actual.getOrDefault[LoadRuntimeConfig](
UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f")
) shouldBe
LoadRuntimeConfig(
Expand Down Expand Up @@ -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")
)
}
Expand Down Expand Up @@ -432,15 +432,15 @@ class ConfigUtilsSpec
)
}

actual.getConfigOrDefault[FixedFeedInRuntimeConfig](
actual.getOrDefault[FixedFeedInRuntimeConfig](
UUID.fromString("49f250fa-41ff-4434-a083-79c98d260a76")
) shouldBe
FixedFeedInRuntimeConfig(
calculateMissingReactivePowerWithModel = false,
1.3,
List("49f250fa-41ff-4434-a083-79c98d260a76")
)
actual.getConfigOrDefault[FixedFeedInRuntimeConfig](
actual.getOrDefault[FixedFeedInRuntimeConfig](
UUID.fromString("fb8f1443-1843-4ecd-a94a-59be8148397f")
) shouldBe
FixedFeedInRuntimeConfig(
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down

0 comments on commit 85acee1

Please sign in to comment.