From a4ae17b730fb962d6696b4d023b1b7f4dfe6bca2 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Tue, 7 Jan 2025 13:34:48 +0100 Subject: [PATCH 1/3] Converting pekko classic to typed. --- CHANGELOG.md | 3 + build.gradle | 5 +- .../api/data/ExtInputDataConnection.java | 8 ++- .../api/data/ExtOutputDataConnection.java | 11 +++- .../api/data/em/ExtEmDataConnection.java | 21 ++++--- .../api/data/ev/ExtEvDataConnection.java | 16 ++--- .../ontology/ScheduleDataServiceMessage.java | 12 ++-- .../primarydata/ExtPrimaryDataConnection.java | 16 ++--- .../data/results/ExtResultDataConnection.java | 18 +++--- .../api/simulation/ExtSimAdapterData.java | 11 ++-- .../data/em/ExtEmDataConnectionTest.groovy | 37 ++++++------ .../data/ev/ExtEvDataConnectionTest.groovy | 60 ++++++++----------- .../ExtPrimaryDataConnectionTest.groovy | 33 +++++----- .../ExtResultDataConnectionTest.groovy | 31 +++++----- .../api/simulation/ExtSimulationSpec.groovy | 32 ++++------ 15 files changed, 161 insertions(+), 153 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f12bc04..6f3f3637 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added Bao and Staudt to the list of reviewers [#216](https://github.com/ie3-institute/simonaAPI/issues/216) +### Changed +- Converting pekko classic to typed [#232](https://github.com/ie3-institute/simonaAPI/issues/232) + ## [0.6.0] - 2024-12-02 ### Added diff --git a/build.gradle b/build.gradle index 501f5266..0cb378a0 100644 --- a/build.gradle +++ b/build.gradle @@ -74,8 +74,9 @@ dependencies{ implementation 'org.apache.logging.log4j:log4j-slf4j-impl' // log4j -> slf4j // pekko - implementation "org.apache.pekko:pekko-actor_${scalaVersion}:${pekkoVersion}" - testImplementation "org.apache.pekko:pekko-testkit_${scalaVersion}:${pekkoVersion}" // pekko testkit + implementation "org.apache.pekko:pekko-actor-typed_${scalaVersion}:${pekkoVersion}" + + testImplementation "org.apache.pekko:pekko-actor-testkit-typed_${scalaVersion}:${pekkoVersion}" // pekko typed testkit // TESTING testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0' diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataConnection.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataConnection.java index d8a29a75..e01ea258 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtInputDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataConnection.java @@ -6,9 +6,11 @@ package edu.ie3.simona.api.data; -import org.apache.pekko.actor.ActorRef; +import edu.ie3.simona.api.data.ontology.DataMessageFromExt; +import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; +import org.apache.pekko.actor.typed.ActorRef; -public interface ExtInputDataConnection extends ExtDataConnection { +public interface ExtInputDataConnection extends ExtDataConnection { /** * Sets the actor refs for data and control flow. @@ -17,5 +19,5 @@ public interface ExtInputDataConnection extends ExtDataConnection { * messages * @param extSimAdapter actor ref to the extSimAdapter */ - void setActorRefs(ActorRef dataService, ActorRef extSimAdapter); + void setActorRefs(ActorRef dataService, ActorRef> extSimAdapter); } diff --git a/src/main/java/edu/ie3/simona/api/data/ExtOutputDataConnection.java b/src/main/java/edu/ie3/simona/api/data/ExtOutputDataConnection.java index 6ac15e75..01e05ad3 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtOutputDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtOutputDataConnection.java @@ -6,13 +6,16 @@ package edu.ie3.simona.api.data; -import org.apache.pekko.actor.ActorRef; +import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; +import edu.ie3.simona.api.data.results.ontology.ResultDataMessageFromExt; +import org.apache.pekko.actor.typed.ActorRef; /** * Interface for a connection between SIMONA and an external simulation with data flow from SIMONA * to external */ -public interface ExtOutputDataConnection extends ExtDataConnection { +public interface ExtOutputDataConnection + extends ExtDataConnection { /** * Sets the actor refs for data and control flow @@ -23,5 +26,7 @@ public interface ExtOutputDataConnection extends ExtDataConnection { * @param extSimAdapter actor ref to the extSimAdapter */ void setActorRefs( - ActorRef extResultDataService, ActorRef dataServiceActivation, ActorRef extSimAdapter); + ActorRef extResultDataService, + ActorRef dataServiceActivation, + ActorRef> extSimAdapter); } diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataConnection.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataConnection.java index 5a0bbaa6..7538e5f6 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataConnection.java @@ -12,19 +12,22 @@ import edu.ie3.simona.api.data.em.ontology.EmDataMessageFromExt; import edu.ie3.simona.api.data.em.ontology.ProvideEmSetPointData; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; -import java.util.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; import java.util.stream.Collectors; -import org.apache.pekko.actor.ActorRef; +import org.apache.pekko.actor.typed.ActorRef; import org.slf4j.Logger; /** Enables data connection of em data between SIMONA and SimonaAPI */ -public class ExtEmDataConnection implements ExtInputDataConnection { +public class ExtEmDataConnection implements ExtInputDataConnection { /** Actor reference to service that handles ev data within SIMONA */ - private ActorRef emDataService; + private ActorRef emDataService; /** Actor reference to adapter that handles scheduler control flow in SIMONA */ - private ActorRef extSimAdapter; + private ActorRef> extSimAdapter; /** Assets that provide primary data to SIMONA */ private final Map extEmMapping; @@ -34,7 +37,9 @@ public ExtEmDataConnection(Map extEmMapping) { } @Override - public void setActorRefs(ActorRef emDataService, ActorRef extSimAdapter) { + public void setActorRefs( + ActorRef emDataService, + ActorRef> extSimAdapter) { this.emDataService = emDataService; this.extSimAdapter = extSimAdapter; } @@ -74,8 +79,8 @@ public void provideEmData(Long tick, Map emData, Optional ma * @param msg the data/information that is sent to SIMONA's external primary data service */ public void sendExtMsg(EmDataMessageFromExt msg) { - emDataService.tell(msg, ActorRef.noSender()); + emDataService.tell(msg); // we need to schedule data receiver activation with scheduler - extSimAdapter.tell(new ScheduleDataServiceMessage(emDataService), ActorRef.noSender()); + extSimAdapter.tell(new ScheduleDataServiceMessage<>(emDataService)); } } diff --git a/src/main/java/edu/ie3/simona/api/data/ev/ExtEvDataConnection.java b/src/main/java/edu/ie3/simona/api/data/ev/ExtEvDataConnection.java index 53a71e87..42ff6ca6 100644 --- a/src/main/java/edu/ie3/simona/api/data/ev/ExtEvDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/ev/ExtEvDataConnection.java @@ -15,21 +15,23 @@ import java.util.Optional; import java.util.UUID; import java.util.concurrent.LinkedBlockingQueue; -import org.apache.pekko.actor.ActorRef; +import org.apache.pekko.actor.typed.ActorRef; -public class ExtEvDataConnection implements ExtInputDataConnection { +public class ExtEvDataConnection implements ExtInputDataConnection { /** Data message queue containing messages from SIMONA */ public final LinkedBlockingQueue receiveTriggerQueue = new LinkedBlockingQueue<>(); /** Actor reference to service that handles ev data within SIMONA */ - private ActorRef dataService; + private ActorRef dataService; /** Actor reference to adapter that handles scheduler control flow in SIMONA */ - private ActorRef extSimAdapter; + private ActorRef> extSimAdapter; @Override - public void setActorRefs(ActorRef dataService, ActorRef extSimAdapter) { + public void setActorRefs( + ActorRef dataService, + ActorRef> extSimAdapter) { this.dataService = dataService; this.extSimAdapter = extSimAdapter; } @@ -99,9 +101,9 @@ public void provideArrivingEvs(Map> arrivals, Optional * @param msg the data/information that is sent to SIMONA's ev data service */ public void sendExtMsg(EvDataMessageFromExt msg) { - dataService.tell(msg, ActorRef.noSender()); + dataService.tell(msg); // we need to schedule data receiver activation with scheduler - extSimAdapter.tell(new ScheduleDataServiceMessage(dataService), ActorRef.noSender()); + extSimAdapter.tell(new ScheduleDataServiceMessage<>(dataService)); } /** diff --git a/src/main/java/edu/ie3/simona/api/data/ontology/ScheduleDataServiceMessage.java b/src/main/java/edu/ie3/simona/api/data/ontology/ScheduleDataServiceMessage.java index 903e5e03..4e365f0a 100644 --- a/src/main/java/edu/ie3/simona/api/data/ontology/ScheduleDataServiceMessage.java +++ b/src/main/java/edu/ie3/simona/api/data/ontology/ScheduleDataServiceMessage.java @@ -7,16 +7,16 @@ package edu.ie3.simona.api.data.ontology; import java.util.Objects; -import org.apache.pekko.actor.ActorRef; +import org.apache.pekko.actor.typed.ActorRef; -public class ScheduleDataServiceMessage { - private final ActorRef dataService; +public class ScheduleDataServiceMessage { + private final ActorRef dataService; - public ScheduleDataServiceMessage(ActorRef dataService) { + public ScheduleDataServiceMessage(ActorRef dataService) { this.dataService = dataService; } - public ActorRef getDataService() { + public ActorRef getDataService() { return dataService; } @@ -24,7 +24,7 @@ public ActorRef getDataService() { public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - ScheduleDataServiceMessage that = (ScheduleDataServiceMessage) o; + ScheduleDataServiceMessage that = (ScheduleDataServiceMessage) o; return dataService.equals(that.dataService); } diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnection.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnection.java index 10fe1842..96f61ddd 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnection.java @@ -13,17 +13,17 @@ import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData; import java.util.*; import java.util.stream.Collectors; -import org.apache.pekko.actor.ActorRef; +import org.apache.pekko.actor.typed.ActorRef; import org.slf4j.Logger; /** Enables data connection of primary data between SIMONA and SimonaAPI */ -public class ExtPrimaryDataConnection implements ExtInputDataConnection { +public class ExtPrimaryDataConnection implements ExtInputDataConnection { /** Actor reference to service that handles primary data within SIMONA */ - private ActorRef dataService; + private ActorRef dataService; /** Actor reference to adapter that handles scheduler control flow in SIMONA */ - private ActorRef extSimAdapter; + private ActorRef> extSimAdapter; /** Assets that provide primary data to SIMONA */ private final Map extPrimaryDataMapping; @@ -33,7 +33,9 @@ public ExtPrimaryDataConnection(Map extPrimaryDataMapping) { } @Override - public void setActorRefs(ActorRef dataService, ActorRef extSimAdapter) { + public void setActorRefs( + ActorRef dataService, + ActorRef> extSimAdapter) { this.dataService = dataService; this.extSimAdapter = extSimAdapter; } @@ -74,8 +76,8 @@ public void providePrimaryData( * @param msg the data/information that is sent to SIMONA's external primary data service */ public void sendExtMsg(PrimaryDataMessageFromExt msg) { - dataService.tell(msg, ActorRef.noSender()); + dataService.tell(msg); // we need to schedule data receiver activation with scheduler - extSimAdapter.tell(new ScheduleDataServiceMessage(dataService), ActorRef.noSender()); + extSimAdapter.tell(new ScheduleDataServiceMessage<>(dataService)); } } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataConnection.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataConnection.java index de90fa41..36a783f5 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataConnection.java @@ -20,23 +20,23 @@ import java.util.Map; import java.util.UUID; import java.util.concurrent.LinkedBlockingQueue; -import org.apache.pekko.actor.ActorRef; +import org.apache.pekko.actor.typed.ActorRef; /** Enables data connection of results between SIMONA and SimonaAPI */ -public class ExtResultDataConnection implements ExtOutputDataConnection { +public class ExtResultDataConnection implements ExtOutputDataConnection { /** Data message queue containing messages from SIMONA */ public final LinkedBlockingQueue receiveTriggerQueue = new LinkedBlockingQueue<>(); /** Actor reference to service that handles result data within SIMONA */ - private ActorRef extResultDataService; + private ActorRef extResultDataService; /** Actor reference to the dataServiceAdapter */ - private ActorRef dataServiceActivation; + private ActorRef dataServiceActivation; /** Actor reference to adapter that handles scheduler control flow in SIMONA */ - private ActorRef extSimAdapter; + private ActorRef> extSimAdapter; /** Map uuid to external id of grid related entities */ private final Map gridResultAssetMapping; @@ -59,7 +59,9 @@ public ExtResultDataConnection( * @param extSimAdapter actor ref to the extSimAdapter */ public void setActorRefs( - ActorRef extResultDataService, ActorRef dataServiceActivation, ActorRef extSimAdapter) { + ActorRef extResultDataService, + ActorRef dataServiceActivation, + ActorRef> extSimAdapter) { this.extResultDataService = extResultDataService; this.dataServiceActivation = dataServiceActivation; this.extSimAdapter = extSimAdapter; @@ -112,9 +114,9 @@ protected Map createResultMap(List * @param msg the data/information that is sent to SIMONA's result data service */ public void sendExtMsg(ResultDataMessageFromExt msg) { - extResultDataService.tell(msg, ActorRef.noSender()); + extResultDataService.tell(msg); // we need to schedule data receiver activation with scheduler - extSimAdapter.tell(new ScheduleDataServiceMessage(dataServiceActivation), ActorRef.noSender()); + extSimAdapter.tell(new ScheduleDataServiceMessage<>(dataServiceActivation)); } /** Queues message from SIMONA that should be handled by the external simulation. */ diff --git a/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java b/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java index e0906ce8..59f81b1e 100644 --- a/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java +++ b/src/main/java/edu/ie3/simona/api/simulation/ExtSimAdapterData.java @@ -9,7 +9,7 @@ import edu.ie3.simona.api.simulation.ontology.ControlMessageToExt; import edu.ie3.simona.api.simulation.ontology.ControlResponseMessageFromExt; import java.util.concurrent.LinkedBlockingQueue; -import org.apache.pekko.actor.ActorRef; +import org.apache.pekko.actor.typed.ActorRef; public class ExtSimAdapterData { @@ -18,19 +18,20 @@ public class ExtSimAdapterData { new LinkedBlockingQueue<>(); /** Actor reference to the adapter for the phases that handles scheduler control flow in SIMONA */ - private final ActorRef extSimAdapter; + private final ActorRef extSimAdapter; /** CLI arguments with which SIMONA is initiated */ private final String[] mainArgs; // important trigger queue must be the same as held in actor // to make it safer one might consider asking the actor for a reference on its trigger queue?! - public ExtSimAdapterData(ActorRef extSimAdapter, String[] mainArgs) { + public ExtSimAdapterData( + ActorRef extSimAdapter, String[] mainArgs) { this.extSimAdapter = extSimAdapter; this.mainArgs = mainArgs; } - public ActorRef getAdapter() { + public ActorRef getAdapter() { return extSimAdapter; } @@ -52,7 +53,7 @@ public void queueExtMsg(ControlMessageToExt msg) throws InterruptedException { * @param msg the message to send */ public void send(ControlResponseMessageFromExt msg) { - extSimAdapter.tell(msg, ActorRef.noSender()); + extSimAdapter.tell(msg); } public String[] getMainArgs() { diff --git a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataConnectionTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataConnectionTest.groovy index d8f798f5..0fa5cf6b 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataConnectionTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataConnectionTest.groovy @@ -2,22 +2,19 @@ package edu.ie3.simona.api.data.em import edu.ie3.datamodel.models.value.PValue import edu.ie3.datamodel.models.value.Value +import edu.ie3.simona.api.data.em.ontology.EmDataMessageFromExt import edu.ie3.simona.api.data.em.ontology.ProvideEmSetPointData +import edu.ie3.simona.api.data.ev.ontology.EvDataMessageFromExt import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage -import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData import edu.ie3.simona.api.test.common.DataServiceTestData -import org.apache.pekko.actor.ActorSystem -import org.apache.pekko.testkit.TestProbe -import org.apache.pekko.testkit.javadsl.TestKit -import org.slf4j.Logger -import org.slf4j.LoggerFactory +import org.apache.pekko.actor.testkit.typed.javadsl.ActorTestKit import spock.lang.Shared import spock.lang.Specification class ExtEmDataConnectionTest extends Specification implements DataServiceTestData { @Shared - ActorSystem actorSystem + ActorTestKit testKit @Shared Map extEmDataMapping = Map.of( @@ -26,18 +23,18 @@ class ExtEmDataConnectionTest extends Specification implements DataServiceTestDa ) def setupSpec() { - actorSystem = ActorSystem.create() + testKit = ActorTestKit.create() } def cleanupSpec() { - TestKit.shutdownActorSystem(actorSystem) - actorSystem = null + testKit.shutdownTestKit() + testKit = null } def "ExtEmDataConnection should provide em data correctly"() { given: - def dataService = new TestProbe(actorSystem) - def extSimAdapter = new TestProbe(actorSystem) + def dataService = testKit.createTestProbe(EmDataMessageFromExt) + def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extEmDataConnection = new ExtEmDataConnection(extEmDataMapping) extEmDataConnection.setActorRefs( dataService.ref(), @@ -54,14 +51,14 @@ class ExtEmDataConnectionTest extends Specification implements DataServiceTestDa extEmDataConnection.provideEmData(0L, convertedEmData, Optional.of(900L)) then: - dataService.expectMsg(new ProvideEmSetPointData(0, convertedEmData, Optional.of(900L))) - extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) + dataService.expectMessage(new ProvideEmSetPointData(0, convertedEmData, Optional.of(900L))) + extSimAdapter.expectMessage(new ScheduleDataServiceMessage(dataService.ref())) } def "ExtEmDataConnection should convert input data correctly"() { given: - def dataService = new TestProbe(actorSystem) - def extSimAdapter = new TestProbe(actorSystem) + def dataService = testKit.createTestProbe(EmDataMessageFromExt) + def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extEmDataConnection = new ExtEmDataConnection(extEmDataMapping) extEmDataConnection.setActorRefs( dataService.ref(), @@ -73,14 +70,14 @@ class ExtEmDataConnectionTest extends Specification implements DataServiceTestDa extEmDataConnection.convertAndSend(0L, inputDataMap, Optional.of(900L), log) then: - dataService.expectMsg(new ProvideEmSetPointData(0L, Map.of(inputUuid, pValue), Optional.of(900L))) - extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) + dataService.expectMessage(new ProvideEmSetPointData(0L, Map.of(inputUuid, pValue), Optional.of(900L))) + extSimAdapter.expectMessage(new ScheduleDataServiceMessage(dataService.ref())) } def "ExtEmDataConnection should send no message, if input data for a not requested asset was provided"() { given: - def dataService = new TestProbe(actorSystem) - def extSimAdapter = new TestProbe(actorSystem) + def dataService = testKit.createTestProbe(EmDataMessageFromExt) + def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extEmDataConnection = new ExtEmDataConnection(extEmDataMapping) extEmDataConnection.setActorRefs( dataService.ref(), diff --git a/src/test/groovy/edu/ie3/simona/api/data/ev/ExtEvDataConnectionTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/ev/ExtEvDataConnectionTest.groovy index 8487efc3..a75aab6c 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/ev/ExtEvDataConnectionTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/ev/ExtEvDataConnectionTest.groovy @@ -1,38 +1,30 @@ package edu.ie3.simona.api.data.ev -import org.apache.pekko.actor.ActorSystem -import org.apache.pekko.testkit.TestProbe -import org.apache.pekko.testkit.javadsl.TestKit import edu.ie3.simona.api.data.ev.model.EvModel -import edu.ie3.simona.api.data.ev.ontology.ProvideArrivingEvs -import edu.ie3.simona.api.data.ev.ontology.ProvideCurrentPrices -import edu.ie3.simona.api.data.ev.ontology.ProvideDepartingEvs -import edu.ie3.simona.api.data.ev.ontology.ProvideEvcsFreeLots -import edu.ie3.simona.api.data.ev.ontology.RequestCurrentPrices -import edu.ie3.simona.api.data.ev.ontology.RequestDepartingEvs -import edu.ie3.simona.api.data.ev.ontology.RequestEvcsFreeLots +import edu.ie3.simona.api.data.ev.ontology.* import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage +import org.apache.pekko.actor.testkit.typed.javadsl.ActorTestKit import spock.lang.Shared import spock.lang.Specification class ExtEvDataConnectionTest extends Specification { @Shared - ActorSystem actorSystem + ActorTestKit testKit def setupSpec() { - actorSystem = ActorSystem.create() + testKit = ActorTestKit.create() } def cleanupSpec() { - TestKit.shutdownActorSystem(actorSystem) - actorSystem = null + testKit.shutdownTestKit() + testKit = null } def "ExtEvDataConnection should request and receive free evcs lots correctly"() { given: - def dataService = new TestProbe(actorSystem) - def extSimAdapter = new TestProbe(actorSystem) + def dataService = testKit.createTestProbe(EvDataMessageFromExt) + def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extEvDataConnection = new ExtEvDataConnection() extEvDataConnection.setActorRefs(dataService.ref(), extSimAdapter.ref()) @@ -44,15 +36,15 @@ class ExtEvDataConnectionTest extends Specification { def actualReceivedEvcs = extEvDataConnection.requestAvailablePublicEvcs() then: - dataService.expectMsg(new RequestEvcsFreeLots()) - extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) + dataService.expectMessage(new RequestEvcsFreeLots()) + extSimAdapter.expectMessage(new ScheduleDataServiceMessage(dataService.ref())) actualReceivedEvcs == sentMsg.evcs() } def "ExtEvDataConnection should request and receive current charging prices correctly"() { given: - def dataService = new TestProbe(actorSystem) - def extSimAdapter = new TestProbe(actorSystem) + def dataService = testKit.createTestProbe(EvDataMessageFromExt) + def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extEvDataConnection = new ExtEvDataConnection() extEvDataConnection.setActorRefs(dataService.ref(), extSimAdapter.ref()) @@ -64,15 +56,15 @@ class ExtEvDataConnectionTest extends Specification { def actualReceivedPrices = extEvDataConnection.requestCurrentPrices() then: - dataService.expectMsg(new RequestCurrentPrices()) - extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) + dataService.expectMessage(new RequestCurrentPrices()) + extSimAdapter.expectMessage(new ScheduleDataServiceMessage(dataService.ref())) actualReceivedPrices == sentMsg.prices() } def "ExtEvDataConnection should request and receive departing EVs correctly"() { given: - def dataService = new TestProbe(actorSystem) - def extSimAdapter = new TestProbe(actorSystem) + def dataService = testKit.createTestProbe(EvDataMessageFromExt) + def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extEvDataConnection = new ExtEvDataConnection() extEvDataConnection.setActorRefs(dataService.ref(), extSimAdapter.ref()) @@ -86,15 +78,15 @@ class ExtEvDataConnectionTest extends Specification { def actualReceivedEvs = extEvDataConnection.requestDepartingEvs(requestedDepartingEvs) then: - dataService.expectMsg(new RequestDepartingEvs(requestedDepartingEvs)) - extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) + dataService.expectMessage(new RequestDepartingEvs(requestedDepartingEvs)) + extSimAdapter.expectMessage(new ScheduleDataServiceMessage(dataService.ref())) actualReceivedEvs == sentMsg.departedEvs() } def "ExtEvDataConnection should provide arriving EVs correctly"() { given: - def dataService = new TestProbe(actorSystem) - def extSimAdapter = new TestProbe(actorSystem) + def dataService = testKit.createTestProbe(EvDataMessageFromExt) + def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extEvDataConnection = new ExtEvDataConnection() extEvDataConnection.setActorRefs(dataService.ref(), extSimAdapter.ref()) @@ -105,14 +97,14 @@ class ExtEvDataConnectionTest extends Specification { extEvDataConnection.provideArrivingEvs(arrivingEvs, Optional.of(60L)) then: - dataService.expectMsg(new ProvideArrivingEvs(arrivingEvs, Optional.of(60L))) - extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) + dataService.expectMessage(new ProvideArrivingEvs(arrivingEvs, Optional.of(60L))) + extSimAdapter.expectMessage(new ScheduleDataServiceMessage(dataService.ref())) } def "ExtEvDataConnection should fail if wrong response is sent"() { given: - def dataService = new TestProbe(actorSystem) - def extSimAdapter = new TestProbe(actorSystem) + def dataService = testKit.createTestProbe(EvDataMessageFromExt) + def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extEvDataConnection = new ExtEvDataConnection() extEvDataConnection.setActorRefs(dataService.ref(), extSimAdapter.ref()) @@ -124,8 +116,8 @@ class ExtEvDataConnectionTest extends Specification { extEvDataConnection.requestAvailablePublicEvcs() then: - dataService.expectMsg(new RequestEvcsFreeLots()) - extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) + dataService.expectMessage(new RequestEvcsFreeLots()) + extSimAdapter.expectMessage(new ScheduleDataServiceMessage(dataService.ref())) thrown RuntimeException } } diff --git a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnectionTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnectionTest.groovy index 5aba77d4..fb07ef52 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnectionTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnectionTest.groovy @@ -2,18 +2,17 @@ package edu.ie3.simona.api.data.primarydata import edu.ie3.datamodel.models.value.Value import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage +import edu.ie3.simona.api.data.primarydata.ontology.PrimaryDataMessageFromExt import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData import edu.ie3.simona.api.test.common.DataServiceTestData -import org.apache.pekko.actor.ActorSystem -import org.apache.pekko.testkit.TestProbe -import org.apache.pekko.testkit.javadsl.TestKit +import org.apache.pekko.actor.testkit.typed.javadsl.ActorTestKit import spock.lang.Shared import spock.lang.Specification class ExtPrimaryDataConnectionTest extends Specification implements DataServiceTestData { @Shared - ActorSystem actorSystem + ActorTestKit testKit @Shared Map extPrimaryDataMapping = Map.of( @@ -22,18 +21,18 @@ class ExtPrimaryDataConnectionTest extends Specification implements DataServiceT ) def setupSpec() { - actorSystem = ActorSystem.create() + testKit = ActorTestKit.create() } def cleanupSpec() { - TestKit.shutdownActorSystem(actorSystem) - actorSystem = null + testKit.shutdownTestKit() + testKit = null } def "ExtPrimaryDataConnection should provide primary data correctly"() { given: - def dataService = new TestProbe(actorSystem) - def extSimAdapter = new TestProbe(actorSystem) + def dataService = testKit.createTestProbe(PrimaryDataMessageFromExt) + def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extPrimaryDataConnection = new ExtPrimaryDataConnection(extPrimaryDataMapping) extPrimaryDataConnection.setActorRefs( dataService.ref(), @@ -50,14 +49,14 @@ class ExtPrimaryDataConnectionTest extends Specification implements DataServiceT extPrimaryDataConnection.providePrimaryData(0L, convertedPrimaryData, Optional.of(900L)) then: - dataService.expectMsg(new ProvidePrimaryData(0L, convertedPrimaryData, Optional.of(900L))) - extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) + dataService.expectMessage(new ProvidePrimaryData(0L, convertedPrimaryData, Optional.of(900L))) + extSimAdapter.expectMessage(new ScheduleDataServiceMessage(dataService.ref())) } def "ExtPrimaryDataConnection should convert input data correctly"() { given: - def dataService = new TestProbe(actorSystem) - def extSimAdapter = new TestProbe(actorSystem) + def dataService = testKit.createTestProbe(PrimaryDataMessageFromExt) + def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extPrimaryDataConnection = new ExtPrimaryDataConnection(extPrimaryDataMapping) extPrimaryDataConnection.setActorRefs( dataService.ref(), @@ -69,14 +68,14 @@ class ExtPrimaryDataConnectionTest extends Specification implements DataServiceT extPrimaryDataConnection.convertAndSend(0L, inputDataMap, Optional.of(900L), log) then: - dataService.expectMsg(new ProvidePrimaryData(0L, Map.of(inputUuid, pValue), Optional.of(900L))) - extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataService.ref())) + dataService.expectMessage(new ProvidePrimaryData(0L, Map.of(inputUuid, pValue), Optional.of(900L))) + extSimAdapter.expectMessage(new ScheduleDataServiceMessage(dataService.ref())) } def "ExtPrimaryDataConnection should send no message, if input data for a not requested asset was provided"() { given: - def dataService = new TestProbe(actorSystem) - def extSimAdapter = new TestProbe(actorSystem) + def dataService = testKit.createTestProbe(PrimaryDataMessageFromExt) + def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extPrimaryDataConnection = new ExtPrimaryDataConnection(extPrimaryDataMapping) extPrimaryDataConnection.setActorRefs( dataService.ref(), diff --git a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataConnectionTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataConnectionTest.groovy index 7dc0dc22..5b768af7 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataConnectionTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataConnectionTest.groovy @@ -5,9 +5,12 @@ import edu.ie3.datamodel.models.result.connector.LineResult import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage import edu.ie3.simona.api.data.results.ontology.ProvideResultEntities import edu.ie3.simona.api.data.results.ontology.RequestResultEntities +import edu.ie3.simona.api.data.results.ontology.ResultDataMessageFromExt import edu.ie3.simona.api.data.results.ontology.ResultDataResponseMessageToExt +import edu.ie3.simona.api.simulation.ExtSimulation import edu.ie3.simona.api.test.common.DataServiceTestData import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.actor.testkit.typed.javadsl.ActorTestKit import org.apache.pekko.testkit.TestProbe import org.apache.pekko.testkit.javadsl.TestKit import spock.lang.Shared @@ -22,7 +25,7 @@ import java.time.ZonedDateTime class ExtResultDataConnectionTest extends Specification implements DataServiceTestData { @Shared - ActorSystem actorSystem + ActorTestKit testKit @Shared Map participantResultAssetMapping = Map.of(inputUuid, "Load") @@ -33,19 +36,19 @@ class ExtResultDataConnectionTest extends Specification implements DataServiceTe class WrongResultDataResponseMessageToExt implements ResultDataResponseMessageToExt {} def setupSpec() { - actorSystem = ActorSystem.create() + testKit = ActorTestKit.create() } def cleanupSpec() { - TestKit.shutdownActorSystem(actorSystem) - actorSystem = null + testKit.shutdownTestKit() + testKit = null } def "ExtResultsData should request and receive results correctly as ModelResultEntity"() { given: - def dataService = new TestProbe(actorSystem) - def dataServiceActivation = new TestProbe(actorSystem) - def extSimAdapter = new TestProbe(actorSystem) + def dataService = testKit.createTestProbe(ResultDataMessageFromExt) + def dataServiceActivation = testKit.createTestProbe(ResultDataMessageFromExt) + def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extResultDataConnection = new ExtResultDataConnection(participantResultAssetMapping, gridResultAssetMapping) extResultDataConnection.setActorRefs( dataService.ref(), @@ -61,16 +64,16 @@ class ExtResultDataConnectionTest extends Specification implements DataServiceTe def receivedResults = extResultDataConnection.requestResults(0L) then: - dataService.expectMsg(new RequestResultEntities(0L)) - extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataServiceActivation.ref())) + dataService.expectMessage(new RequestResultEntities(0L)) + extSimAdapter.expectMessage(new ScheduleDataServiceMessage(dataServiceActivation.ref())) receivedResults.get("Load") == loadResult } def "ExtResultsData should fail if wrong response is sent"() { given: - def dataService = new TestProbe(actorSystem) - def dataServiceActivation = new TestProbe(actorSystem) - def extSimAdapter = new TestProbe(actorSystem) + def dataService = testKit.createTestProbe(ResultDataMessageFromExt) + def dataServiceActivation = testKit.createTestProbe(ResultDataMessageFromExt) + def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extResultDataConnection = new ExtResultDataConnection(participantResultAssetMapping, gridResultAssetMapping) extResultDataConnection.setActorRefs( dataService.ref(), @@ -86,8 +89,8 @@ class ExtResultDataConnectionTest extends Specification implements DataServiceTe extResultDataConnection.requestResults(0L) then: - dataService.expectMsg(new RequestResultEntities(0L)) - extSimAdapter.expectMsg(new ScheduleDataServiceMessage(dataServiceActivation.ref())) + dataService.expectMessage(new RequestResultEntities(0L)) + extSimAdapter.expectMessage(new ScheduleDataServiceMessage(dataServiceActivation.ref())) thrown RuntimeException } diff --git a/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy b/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy index 029056ff..7b24d955 100644 --- a/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy +++ b/src/test/groovy/edu/ie3/simona/api/simulation/ExtSimulationSpec.groovy @@ -1,14 +1,8 @@ package edu.ie3.simona.api.simulation -import org.apache.pekko.actor.ActorSystem -import org.apache.pekko.testkit.TestProbe -import org.apache.pekko.testkit.javadsl.TestKit import edu.ie3.simona.api.data.ExtDataConnection -import edu.ie3.simona.api.simulation.ontology.ActivationMessage -import edu.ie3.simona.api.simulation.ontology.CompletionMessage -import edu.ie3.simona.api.simulation.ontology.ControlMessageToExt -import edu.ie3.simona.api.simulation.ontology.TerminationMessage -import edu.ie3.simona.api.simulation.ontology.TerminationCompleted +import edu.ie3.simona.api.simulation.ontology.* +import org.apache.pekko.actor.testkit.typed.javadsl.ActorTestKit import spock.lang.Shared import spock.lang.Specification @@ -17,7 +11,7 @@ import java.lang.reflect.Method class ExtSimulationSpec extends Specification { @Shared - ActorSystem actorSystem + ActorTestKit testKit @Shared Method handleMessage @@ -54,7 +48,7 @@ class ExtSimulationSpec extends Specification { } def setupSpec() { - actorSystem = ActorSystem.create() + testKit = ActorTestKit.create() // setup private method handleMessage = ExtSimulation.getDeclaredMethod("takeAndHandleMessage", null) @@ -62,15 +56,15 @@ class ExtSimulationSpec extends Specification { } def cleanupSpec() { - TestKit.shutdownActorSystem(actorSystem) - actorSystem = null + testKit.shutdownTestKit() + testKit = null } def "An ExtSimulation should handle initialization"() { given: def tick = -1L def newTick = 0L - def extSimAdapter = new TestProbe(actorSystem) + def extSimAdapter = testKit.createTestProbe(ControlResponseMessageFromExt) def extSimData = new ExtSimAdapterData(extSimAdapter.ref(), new String[0]) def extSim = new TestSimulation(newTick, Optional.of(-2L)) extSim.setAdapterData(extSimData) @@ -81,12 +75,12 @@ class ExtSimulationSpec extends Specification { then: finishedActual == false - extSimAdapter.expectMsg(new CompletionMessage(Optional.of(newTick))) + extSimAdapter.expectMessage(new CompletionMessage(Optional.of(newTick))) } def "An ExtSimulation should handle activation and return given new triggers"() { given: - def extSimAdapter = new TestProbe(actorSystem) + def extSimAdapter = testKit.createTestProbe(ControlResponseMessageFromExt) def extSimData = new ExtSimAdapterData(extSimAdapter.ref(), new String[0]) def newTickOpt = newTick.isEmpty() ? Optional.empty() : Optional.of(newTick.first()) @@ -99,7 +93,7 @@ class ExtSimulationSpec extends Specification { then: finishedActual == finished - extSimAdapter.expectMsg(new CompletionMessage(newTickOpt)) + extSimAdapter.expectMessage(new CompletionMessage(newTickOpt)) where: tick | newTick || finished @@ -111,7 +105,7 @@ class ExtSimulationSpec extends Specification { def "An ExtSimulation should handle termination properly"() { given: - def extSimAdapter = new TestProbe(actorSystem) + def extSimAdapter = testKit.createTestProbe(ControlResponseMessageFromExt) def extSimData = new ExtSimAdapterData(extSimAdapter.ref(), new String[0]) def extSim = new TestSimulation(-1L, Optional.empty()) extSim.setAdapterData(extSimData) @@ -122,7 +116,7 @@ class ExtSimulationSpec extends Specification { then: finishedActual == finished - extSimAdapter.expectMsg(new TerminationCompleted()) + extSimAdapter.expectMessage(new TerminationCompleted()) where: simlulationSuccessful || finished @@ -134,7 +128,7 @@ class ExtSimulationSpec extends Specification { def "An ExtSimulation should handle unknown messages by throwing an exception"() { given: - def extSimAdapter = new TestProbe(actorSystem) + def extSimAdapter = testKit.createTestProbe(ControlResponseMessageFromExt) def extSimData = new ExtSimAdapterData(extSimAdapter.ref(), new String[0]) def extSim = new TestSimulation(-1L, Optional.empty()) extSim.setAdapterData(extSimData) From bc7f4dffb72b5652dc90567aa6a38c8a6c6cd10b Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Wed, 8 Jan 2025 14:16:31 +0100 Subject: [PATCH 2/3] Small improvements. --- .../api/data/ExtInputDataConnection.java | 4 +-- .../api/data/ExtOutputDataConnection.java | 4 +-- .../api/data/em/ExtEmDataConnection.java | 5 ++-- .../api/data/ev/ExtEvDataConnection.java | 5 ++-- .../ontology/ScheduleDataServiceMessage.java | 28 ++----------------- .../primarydata/ExtPrimaryDataConnection.java | 5 ++-- .../data/results/ExtResultDataConnection.java | 5 ++-- 7 files changed, 19 insertions(+), 37 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataConnection.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataConnection.java index e01ea258..1290c6d3 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtInputDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataConnection.java @@ -7,7 +7,7 @@ package edu.ie3.simona.api.data; import edu.ie3.simona.api.data.ontology.DataMessageFromExt; -import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; +import edu.ie3.simona.api.simulation.ontology.ControlResponseMessageFromExt; import org.apache.pekko.actor.typed.ActorRef; public interface ExtInputDataConnection extends ExtDataConnection { @@ -19,5 +19,5 @@ public interface ExtInputDataConnection extends Ex * messages * @param extSimAdapter actor ref to the extSimAdapter */ - void setActorRefs(ActorRef dataService, ActorRef> extSimAdapter); + void setActorRefs(ActorRef dataService, ActorRef extSimAdapter); } diff --git a/src/main/java/edu/ie3/simona/api/data/ExtOutputDataConnection.java b/src/main/java/edu/ie3/simona/api/data/ExtOutputDataConnection.java index 01e05ad3..2fd5b013 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtOutputDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtOutputDataConnection.java @@ -6,8 +6,8 @@ package edu.ie3.simona.api.data; -import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; import edu.ie3.simona.api.data.results.ontology.ResultDataMessageFromExt; +import edu.ie3.simona.api.simulation.ontology.ControlResponseMessageFromExt; import org.apache.pekko.actor.typed.ActorRef; /** @@ -28,5 +28,5 @@ public interface ExtOutputDataConnection void setActorRefs( ActorRef extResultDataService, ActorRef dataServiceActivation, - ActorRef> extSimAdapter); + ActorRef extSimAdapter); } diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataConnection.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataConnection.java index 7538e5f6..dcb9b236 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataConnection.java @@ -12,6 +12,7 @@ import edu.ie3.simona.api.data.em.ontology.EmDataMessageFromExt; import edu.ie3.simona.api.data.em.ontology.ProvideEmSetPointData; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; +import edu.ie3.simona.api.simulation.ontology.ControlResponseMessageFromExt; import java.util.List; import java.util.Map; import java.util.Optional; @@ -27,7 +28,7 @@ public class ExtEmDataConnection implements ExtInputDataConnection emDataService; /** Actor reference to adapter that handles scheduler control flow in SIMONA */ - private ActorRef> extSimAdapter; + private ActorRef extSimAdapter; /** Assets that provide primary data to SIMONA */ private final Map extEmMapping; @@ -39,7 +40,7 @@ public ExtEmDataConnection(Map extEmMapping) { @Override public void setActorRefs( ActorRef emDataService, - ActorRef> extSimAdapter) { + ActorRef extSimAdapter) { this.emDataService = emDataService; this.extSimAdapter = extSimAdapter; } diff --git a/src/main/java/edu/ie3/simona/api/data/ev/ExtEvDataConnection.java b/src/main/java/edu/ie3/simona/api/data/ev/ExtEvDataConnection.java index 42ff6ca6..548395d0 100644 --- a/src/main/java/edu/ie3/simona/api/data/ev/ExtEvDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/ev/ExtEvDataConnection.java @@ -10,6 +10,7 @@ import edu.ie3.simona.api.data.ev.model.EvModel; import edu.ie3.simona.api.data.ev.ontology.*; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; +import edu.ie3.simona.api.simulation.ontology.ControlResponseMessageFromExt; import java.util.List; import java.util.Map; import java.util.Optional; @@ -26,12 +27,12 @@ public class ExtEvDataConnection implements ExtInputDataConnection dataService; /** Actor reference to adapter that handles scheduler control flow in SIMONA */ - private ActorRef> extSimAdapter; + private ActorRef extSimAdapter; @Override public void setActorRefs( ActorRef dataService, - ActorRef> extSimAdapter) { + ActorRef extSimAdapter) { this.dataService = dataService; this.extSimAdapter = extSimAdapter; } diff --git a/src/main/java/edu/ie3/simona/api/data/ontology/ScheduleDataServiceMessage.java b/src/main/java/edu/ie3/simona/api/data/ontology/ScheduleDataServiceMessage.java index 4e365f0a..11e394aa 100644 --- a/src/main/java/edu/ie3/simona/api/data/ontology/ScheduleDataServiceMessage.java +++ b/src/main/java/edu/ie3/simona/api/data/ontology/ScheduleDataServiceMessage.java @@ -6,30 +6,8 @@ package edu.ie3.simona.api.data.ontology; -import java.util.Objects; +import edu.ie3.simona.api.simulation.ontology.ControlResponseMessageFromExt; import org.apache.pekko.actor.typed.ActorRef; -public class ScheduleDataServiceMessage { - private final ActorRef dataService; - - public ScheduleDataServiceMessage(ActorRef dataService) { - this.dataService = dataService; - } - - public ActorRef getDataService() { - return dataService; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - ScheduleDataServiceMessage that = (ScheduleDataServiceMessage) o; - return dataService.equals(that.dataService); - } - - @Override - public int hashCode() { - return Objects.hash(dataService); - } -} +public record ScheduleDataServiceMessage(ActorRef dataService) + implements ControlResponseMessageFromExt {} diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnection.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnection.java index 96f61ddd..4ec634e7 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnection.java @@ -11,6 +11,7 @@ import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; import edu.ie3.simona.api.data.primarydata.ontology.PrimaryDataMessageFromExt; import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData; +import edu.ie3.simona.api.simulation.ontology.ControlResponseMessageFromExt; import java.util.*; import java.util.stream.Collectors; import org.apache.pekko.actor.typed.ActorRef; @@ -23,7 +24,7 @@ public class ExtPrimaryDataConnection implements ExtInputDataConnection dataService; /** Actor reference to adapter that handles scheduler control flow in SIMONA */ - private ActorRef> extSimAdapter; + private ActorRef extSimAdapter; /** Assets that provide primary data to SIMONA */ private final Map extPrimaryDataMapping; @@ -35,7 +36,7 @@ public ExtPrimaryDataConnection(Map extPrimaryDataMapping) { @Override public void setActorRefs( ActorRef dataService, - ActorRef> extSimAdapter) { + ActorRef extSimAdapter) { this.dataService = dataService; this.extSimAdapter = extSimAdapter; } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataConnection.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataConnection.java index 36a783f5..d60c5a2a 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataConnection.java @@ -15,6 +15,7 @@ import edu.ie3.simona.api.data.results.ontology.RequestResultEntities; import edu.ie3.simona.api.data.results.ontology.ResultDataMessageFromExt; import edu.ie3.simona.api.data.results.ontology.ResultDataResponseMessageToExt; +import edu.ie3.simona.api.simulation.ontology.ControlResponseMessageFromExt; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -36,7 +37,7 @@ public class ExtResultDataConnection implements ExtOutputDataConnection dataServiceActivation; /** Actor reference to adapter that handles scheduler control flow in SIMONA */ - private ActorRef> extSimAdapter; + private ActorRef extSimAdapter; /** Map uuid to external id of grid related entities */ private final Map gridResultAssetMapping; @@ -61,7 +62,7 @@ public ExtResultDataConnection( public void setActorRefs( ActorRef extResultDataService, ActorRef dataServiceActivation, - ActorRef> extSimAdapter) { + ActorRef extSimAdapter) { this.extResultDataService = extResultDataService; this.dataServiceActivation = dataServiceActivation; this.extSimAdapter = extSimAdapter; From ac7f39b62c8ac37add6032d1c377efd3a5b7ec5f Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Wed, 26 Mar 2025 14:34:33 +0100 Subject: [PATCH 3/3] Adapting to reviewer's comments. --- .../simona/api/data/ExtInputDataConnection.java | 10 ++++++++-- .../simona/api/data/ExtOutputDataConnection.java | 11 +++++------ .../simona/api/data/em/ExtEmDataConnection.java | 9 +++++---- .../simona/api/data/ev/ExtEvDataConnection.java | 9 +++++---- .../data/ontology/ScheduleDataServiceMessage.java | 2 +- .../data/primarydata/ExtPrimaryDataConnection.java | 14 +++++++++----- .../api/data/results/ExtResultDataConnection.java | 13 +++++++------ .../api/data/em/ExtEmDataConnectionTest.groovy | 9 ++++----- .../api/data/ev/ExtEvDataConnectionTest.groovy | 11 ++++++----- .../ExtPrimaryDataConnectionTest.groovy | 8 ++++---- .../results/ExtResultDataConnectionTest.groovy | 10 +++++----- 11 files changed, 59 insertions(+), 47 deletions(-) diff --git a/src/main/java/edu/ie3/simona/api/data/ExtInputDataConnection.java b/src/main/java/edu/ie3/simona/api/data/ExtInputDataConnection.java index 1290c6d3..0a1430b6 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtInputDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtInputDataConnection.java @@ -10,7 +10,11 @@ import edu.ie3.simona.api.simulation.ontology.ControlResponseMessageFromExt; import org.apache.pekko.actor.typed.ActorRef; -public interface ExtInputDataConnection extends ExtDataConnection { +/** + * Interface for a connection between SIMONA and an external simulation with data flow from external + * to SIMONA. + */ +public interface ExtInputDataConnection extends ExtDataConnection { /** * Sets the actor refs for data and control flow. @@ -19,5 +23,7 @@ public interface ExtInputDataConnection extends Ex * messages * @param extSimAdapter actor ref to the extSimAdapter */ - void setActorRefs(ActorRef dataService, ActorRef extSimAdapter); + void setActorRefs( + ActorRef dataService, + ActorRef extSimAdapter); } diff --git a/src/main/java/edu/ie3/simona/api/data/ExtOutputDataConnection.java b/src/main/java/edu/ie3/simona/api/data/ExtOutputDataConnection.java index 2fd5b013..4d9ea51a 100644 --- a/src/main/java/edu/ie3/simona/api/data/ExtOutputDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/ExtOutputDataConnection.java @@ -6,16 +6,15 @@ package edu.ie3.simona.api.data; -import edu.ie3.simona.api.data.results.ontology.ResultDataMessageFromExt; +import edu.ie3.simona.api.data.ontology.DataMessageFromExt; import edu.ie3.simona.api.simulation.ontology.ControlResponseMessageFromExt; import org.apache.pekko.actor.typed.ActorRef; /** * Interface for a connection between SIMONA and an external simulation with data flow from SIMONA - * to external + * to external. */ -public interface ExtOutputDataConnection - extends ExtDataConnection { +public interface ExtOutputDataConnection extends ExtDataConnection { /** * Sets the actor refs for data and control flow @@ -26,7 +25,7 @@ public interface ExtOutputDataConnection * @param extSimAdapter actor ref to the extSimAdapter */ void setActorRefs( - ActorRef extResultDataService, - ActorRef dataServiceActivation, + ActorRef extResultDataService, + ActorRef dataServiceActivation, ActorRef extSimAdapter); } diff --git a/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataConnection.java b/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataConnection.java index dcb9b236..6079a2eb 100644 --- a/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/em/ExtEmDataConnection.java @@ -11,6 +11,7 @@ import edu.ie3.simona.api.data.ExtInputDataConnection; import edu.ie3.simona.api.data.em.ontology.EmDataMessageFromExt; import edu.ie3.simona.api.data.em.ontology.ProvideEmSetPointData; +import edu.ie3.simona.api.data.ontology.DataMessageFromExt; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; import edu.ie3.simona.api.simulation.ontology.ControlResponseMessageFromExt; import java.util.List; @@ -22,10 +23,10 @@ import org.slf4j.Logger; /** Enables data connection of em data between SIMONA and SimonaAPI */ -public class ExtEmDataConnection implements ExtInputDataConnection { +public class ExtEmDataConnection implements ExtInputDataConnection { /** Actor reference to service that handles ev data within SIMONA */ - private ActorRef emDataService; + private ActorRef emDataService; /** Actor reference to adapter that handles scheduler control flow in SIMONA */ private ActorRef extSimAdapter; @@ -39,7 +40,7 @@ public ExtEmDataConnection(Map extEmMapping) { @Override public void setActorRefs( - ActorRef emDataService, + ActorRef emDataService, ActorRef extSimAdapter) { this.emDataService = emDataService; this.extSimAdapter = extSimAdapter; @@ -82,6 +83,6 @@ public void provideEmData(Long tick, Map emData, Optional ma public void sendExtMsg(EmDataMessageFromExt msg) { emDataService.tell(msg); // we need to schedule data receiver activation with scheduler - extSimAdapter.tell(new ScheduleDataServiceMessage<>(emDataService)); + extSimAdapter.tell(new ScheduleDataServiceMessage(emDataService)); } } diff --git a/src/main/java/edu/ie3/simona/api/data/ev/ExtEvDataConnection.java b/src/main/java/edu/ie3/simona/api/data/ev/ExtEvDataConnection.java index 548395d0..564a87ad 100644 --- a/src/main/java/edu/ie3/simona/api/data/ev/ExtEvDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/ev/ExtEvDataConnection.java @@ -9,6 +9,7 @@ import edu.ie3.simona.api.data.ExtInputDataConnection; import edu.ie3.simona.api.data.ev.model.EvModel; import edu.ie3.simona.api.data.ev.ontology.*; +import edu.ie3.simona.api.data.ontology.DataMessageFromExt; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; import edu.ie3.simona.api.simulation.ontology.ControlResponseMessageFromExt; import java.util.List; @@ -18,20 +19,20 @@ import java.util.concurrent.LinkedBlockingQueue; import org.apache.pekko.actor.typed.ActorRef; -public class ExtEvDataConnection implements ExtInputDataConnection { +public class ExtEvDataConnection implements ExtInputDataConnection { /** Data message queue containing messages from SIMONA */ public final LinkedBlockingQueue receiveTriggerQueue = new LinkedBlockingQueue<>(); /** Actor reference to service that handles ev data within SIMONA */ - private ActorRef dataService; + private ActorRef dataService; /** Actor reference to adapter that handles scheduler control flow in SIMONA */ private ActorRef extSimAdapter; @Override public void setActorRefs( - ActorRef dataService, + ActorRef dataService, ActorRef extSimAdapter) { this.dataService = dataService; this.extSimAdapter = extSimAdapter; @@ -104,7 +105,7 @@ public void provideArrivingEvs(Map> arrivals, Optional public void sendExtMsg(EvDataMessageFromExt msg) { dataService.tell(msg); // we need to schedule data receiver activation with scheduler - extSimAdapter.tell(new ScheduleDataServiceMessage<>(dataService)); + extSimAdapter.tell(new ScheduleDataServiceMessage(dataService)); } /** diff --git a/src/main/java/edu/ie3/simona/api/data/ontology/ScheduleDataServiceMessage.java b/src/main/java/edu/ie3/simona/api/data/ontology/ScheduleDataServiceMessage.java index 11e394aa..029b840d 100644 --- a/src/main/java/edu/ie3/simona/api/data/ontology/ScheduleDataServiceMessage.java +++ b/src/main/java/edu/ie3/simona/api/data/ontology/ScheduleDataServiceMessage.java @@ -9,5 +9,5 @@ import edu.ie3.simona.api.simulation.ontology.ControlResponseMessageFromExt; import org.apache.pekko.actor.typed.ActorRef; -public record ScheduleDataServiceMessage(ActorRef dataService) +public record ScheduleDataServiceMessage(ActorRef dataService) implements ControlResponseMessageFromExt {} diff --git a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnection.java b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnection.java index 4ec634e7..ce03e274 100644 --- a/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnection.java @@ -8,20 +8,24 @@ import edu.ie3.datamodel.models.value.Value; import edu.ie3.simona.api.data.ExtInputDataConnection; +import edu.ie3.simona.api.data.ontology.DataMessageFromExt; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; import edu.ie3.simona.api.data.primarydata.ontology.PrimaryDataMessageFromExt; import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData; import edu.ie3.simona.api.simulation.ontology.ControlResponseMessageFromExt; -import java.util.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; import java.util.stream.Collectors; import org.apache.pekko.actor.typed.ActorRef; import org.slf4j.Logger; /** Enables data connection of primary data between SIMONA and SimonaAPI */ -public class ExtPrimaryDataConnection implements ExtInputDataConnection { +public class ExtPrimaryDataConnection implements ExtInputDataConnection { /** Actor reference to service that handles primary data within SIMONA */ - private ActorRef dataService; + private ActorRef dataService; /** Actor reference to adapter that handles scheduler control flow in SIMONA */ private ActorRef extSimAdapter; @@ -35,7 +39,7 @@ public ExtPrimaryDataConnection(Map extPrimaryDataMapping) { @Override public void setActorRefs( - ActorRef dataService, + ActorRef dataService, ActorRef extSimAdapter) { this.dataService = dataService; this.extSimAdapter = extSimAdapter; @@ -79,6 +83,6 @@ public void providePrimaryData( public void sendExtMsg(PrimaryDataMessageFromExt msg) { dataService.tell(msg); // we need to schedule data receiver activation with scheduler - extSimAdapter.tell(new ScheduleDataServiceMessage<>(dataService)); + extSimAdapter.tell(new ScheduleDataServiceMessage(dataService)); } } diff --git a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataConnection.java b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataConnection.java index fcdb084d..3a93a7f2 100644 --- a/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataConnection.java +++ b/src/main/java/edu/ie3/simona/api/data/results/ExtResultDataConnection.java @@ -10,6 +10,7 @@ import edu.ie3.datamodel.models.result.ResultEntity; import edu.ie3.datamodel.models.result.system.SystemParticipantResult; import edu.ie3.simona.api.data.ExtOutputDataConnection; +import edu.ie3.simona.api.data.ontology.DataMessageFromExt; import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage; import edu.ie3.simona.api.data.results.ontology.ProvideResultEntities; import edu.ie3.simona.api.data.results.ontology.RequestResultEntities; @@ -24,17 +25,17 @@ import org.apache.pekko.actor.typed.ActorRef; /** Enables data connection of results between SIMONA and SimonaAPI */ -public class ExtResultDataConnection implements ExtOutputDataConnection { +public class ExtResultDataConnection implements ExtOutputDataConnection { /** Data message queue containing messages from SIMONA */ public final LinkedBlockingQueue receiveTriggerQueue = new LinkedBlockingQueue<>(); /** Actor reference to service that handles result data within SIMONA */ - private ActorRef extResultDataService; + private ActorRef extResultDataService; /** Actor reference to the dataServiceAdapter */ - private ActorRef dataServiceActivation; + private ActorRef dataServiceActivation; /** Actor reference to adapter that handles scheduler control flow in SIMONA */ private ActorRef extSimAdapter; @@ -60,8 +61,8 @@ public ExtResultDataConnection( * @param extSimAdapter actor ref to the extSimAdapter */ public void setActorRefs( - ActorRef extResultDataService, - ActorRef dataServiceActivation, + ActorRef extResultDataService, + ActorRef dataServiceActivation, ActorRef extSimAdapter) { this.extResultDataService = extResultDataService; this.dataServiceActivation = dataServiceActivation; @@ -117,7 +118,7 @@ protected Map createResultMap(List results) public void sendExtMsg(ResultDataMessageFromExt msg) { extResultDataService.tell(msg); // we need to schedule data receiver activation with scheduler - extSimAdapter.tell(new ScheduleDataServiceMessage<>(dataServiceActivation)); + extSimAdapter.tell(new ScheduleDataServiceMessage(dataServiceActivation)); } /** Queues message from SIMONA that should be handled by the external simulation. */ diff --git a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataConnectionTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataConnectionTest.groovy index 0fa5cf6b..7b0f4ecb 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataConnectionTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/em/ExtEmDataConnectionTest.groovy @@ -2,9 +2,8 @@ package edu.ie3.simona.api.data.em import edu.ie3.datamodel.models.value.PValue import edu.ie3.datamodel.models.value.Value -import edu.ie3.simona.api.data.em.ontology.EmDataMessageFromExt import edu.ie3.simona.api.data.em.ontology.ProvideEmSetPointData -import edu.ie3.simona.api.data.ev.ontology.EvDataMessageFromExt +import edu.ie3.simona.api.data.ontology.DataMessageFromExt import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage import edu.ie3.simona.api.test.common.DataServiceTestData import org.apache.pekko.actor.testkit.typed.javadsl.ActorTestKit @@ -33,7 +32,7 @@ class ExtEmDataConnectionTest extends Specification implements DataServiceTestDa def "ExtEmDataConnection should provide em data correctly"() { given: - def dataService = testKit.createTestProbe(EmDataMessageFromExt) + def dataService = testKit.createTestProbe(DataMessageFromExt) def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extEmDataConnection = new ExtEmDataConnection(extEmDataMapping) extEmDataConnection.setActorRefs( @@ -57,7 +56,7 @@ class ExtEmDataConnectionTest extends Specification implements DataServiceTestDa def "ExtEmDataConnection should convert input data correctly"() { given: - def dataService = testKit.createTestProbe(EmDataMessageFromExt) + def dataService = testKit.createTestProbe(DataMessageFromExt) def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extEmDataConnection = new ExtEmDataConnection(extEmDataMapping) extEmDataConnection.setActorRefs( @@ -76,7 +75,7 @@ class ExtEmDataConnectionTest extends Specification implements DataServiceTestDa def "ExtEmDataConnection should send no message, if input data for a not requested asset was provided"() { given: - def dataService = testKit.createTestProbe(EmDataMessageFromExt) + def dataService = testKit.createTestProbe(DataMessageFromExt) def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extEmDataConnection = new ExtEmDataConnection(extEmDataMapping) extEmDataConnection.setActorRefs( diff --git a/src/test/groovy/edu/ie3/simona/api/data/ev/ExtEvDataConnectionTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/ev/ExtEvDataConnectionTest.groovy index a75aab6c..ea925b95 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/ev/ExtEvDataConnectionTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/ev/ExtEvDataConnectionTest.groovy @@ -2,6 +2,7 @@ package edu.ie3.simona.api.data.ev import edu.ie3.simona.api.data.ev.model.EvModel import edu.ie3.simona.api.data.ev.ontology.* +import edu.ie3.simona.api.data.ontology.DataMessageFromExt import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage import org.apache.pekko.actor.testkit.typed.javadsl.ActorTestKit import spock.lang.Shared @@ -23,7 +24,7 @@ class ExtEvDataConnectionTest extends Specification { def "ExtEvDataConnection should request and receive free evcs lots correctly"() { given: - def dataService = testKit.createTestProbe(EvDataMessageFromExt) + def dataService = testKit.createTestProbe(DataMessageFromExt) def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extEvDataConnection = new ExtEvDataConnection() extEvDataConnection.setActorRefs(dataService.ref(), extSimAdapter.ref()) @@ -43,7 +44,7 @@ class ExtEvDataConnectionTest extends Specification { def "ExtEvDataConnection should request and receive current charging prices correctly"() { given: - def dataService = testKit.createTestProbe(EvDataMessageFromExt) + def dataService = testKit.createTestProbe(DataMessageFromExt) def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extEvDataConnection = new ExtEvDataConnection() extEvDataConnection.setActorRefs(dataService.ref(), extSimAdapter.ref()) @@ -63,7 +64,7 @@ class ExtEvDataConnectionTest extends Specification { def "ExtEvDataConnection should request and receive departing EVs correctly"() { given: - def dataService = testKit.createTestProbe(EvDataMessageFromExt) + def dataService = testKit.createTestProbe(DataMessageFromExt) def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extEvDataConnection = new ExtEvDataConnection() extEvDataConnection.setActorRefs(dataService.ref(), extSimAdapter.ref()) @@ -85,7 +86,7 @@ class ExtEvDataConnectionTest extends Specification { def "ExtEvDataConnection should provide arriving EVs correctly"() { given: - def dataService = testKit.createTestProbe(EvDataMessageFromExt) + def dataService = testKit.createTestProbe(DataMessageFromExt) def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extEvDataConnection = new ExtEvDataConnection() extEvDataConnection.setActorRefs(dataService.ref(), extSimAdapter.ref()) @@ -103,7 +104,7 @@ class ExtEvDataConnectionTest extends Specification { def "ExtEvDataConnection should fail if wrong response is sent"() { given: - def dataService = testKit.createTestProbe(EvDataMessageFromExt) + def dataService = testKit.createTestProbe(DataMessageFromExt) def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extEvDataConnection = new ExtEvDataConnection() extEvDataConnection.setActorRefs(dataService.ref(), extSimAdapter.ref()) diff --git a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnectionTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnectionTest.groovy index fb07ef52..8cc119a1 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnectionTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/primarydata/ExtPrimaryDataConnectionTest.groovy @@ -1,8 +1,8 @@ package edu.ie3.simona.api.data.primarydata import edu.ie3.datamodel.models.value.Value +import edu.ie3.simona.api.data.ontology.DataMessageFromExt import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage -import edu.ie3.simona.api.data.primarydata.ontology.PrimaryDataMessageFromExt import edu.ie3.simona.api.data.primarydata.ontology.ProvidePrimaryData import edu.ie3.simona.api.test.common.DataServiceTestData import org.apache.pekko.actor.testkit.typed.javadsl.ActorTestKit @@ -31,7 +31,7 @@ class ExtPrimaryDataConnectionTest extends Specification implements DataServiceT def "ExtPrimaryDataConnection should provide primary data correctly"() { given: - def dataService = testKit.createTestProbe(PrimaryDataMessageFromExt) + def dataService = testKit.createTestProbe(DataMessageFromExt) def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extPrimaryDataConnection = new ExtPrimaryDataConnection(extPrimaryDataMapping) extPrimaryDataConnection.setActorRefs( @@ -55,7 +55,7 @@ class ExtPrimaryDataConnectionTest extends Specification implements DataServiceT def "ExtPrimaryDataConnection should convert input data correctly"() { given: - def dataService = testKit.createTestProbe(PrimaryDataMessageFromExt) + def dataService = testKit.createTestProbe(DataMessageFromExt) def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extPrimaryDataConnection = new ExtPrimaryDataConnection(extPrimaryDataMapping) extPrimaryDataConnection.setActorRefs( @@ -74,7 +74,7 @@ class ExtPrimaryDataConnectionTest extends Specification implements DataServiceT def "ExtPrimaryDataConnection should send no message, if input data for a not requested asset was provided"() { given: - def dataService = testKit.createTestProbe(PrimaryDataMessageFromExt) + def dataService = testKit.createTestProbe(DataMessageFromExt) def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extPrimaryDataConnection = new ExtPrimaryDataConnection(extPrimaryDataMapping) extPrimaryDataConnection.setActorRefs( diff --git a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataConnectionTest.groovy b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataConnectionTest.groovy index 5b768af7..3bf9a64f 100644 --- a/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataConnectionTest.groovy +++ b/src/test/groovy/edu/ie3/simona/api/data/results/ExtResultDataConnectionTest.groovy @@ -2,10 +2,10 @@ package edu.ie3.simona.api.data.results import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.result.connector.LineResult +import edu.ie3.simona.api.data.ontology.DataMessageFromExt import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage import edu.ie3.simona.api.data.results.ontology.ProvideResultEntities import edu.ie3.simona.api.data.results.ontology.RequestResultEntities -import edu.ie3.simona.api.data.results.ontology.ResultDataMessageFromExt import edu.ie3.simona.api.data.results.ontology.ResultDataResponseMessageToExt import edu.ie3.simona.api.simulation.ExtSimulation import edu.ie3.simona.api.test.common.DataServiceTestData @@ -46,8 +46,8 @@ class ExtResultDataConnectionTest extends Specification implements DataServiceTe def "ExtResultsData should request and receive results correctly as ModelResultEntity"() { given: - def dataService = testKit.createTestProbe(ResultDataMessageFromExt) - def dataServiceActivation = testKit.createTestProbe(ResultDataMessageFromExt) + def dataService = testKit.createTestProbe(DataMessageFromExt) + def dataServiceActivation = testKit.createTestProbe(DataMessageFromExt) def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extResultDataConnection = new ExtResultDataConnection(participantResultAssetMapping, gridResultAssetMapping) extResultDataConnection.setActorRefs( @@ -71,8 +71,8 @@ class ExtResultDataConnectionTest extends Specification implements DataServiceTe def "ExtResultsData should fail if wrong response is sent"() { given: - def dataService = testKit.createTestProbe(ResultDataMessageFromExt) - def dataServiceActivation = testKit.createTestProbe(ResultDataMessageFromExt) + def dataService = testKit.createTestProbe(DataMessageFromExt) + def dataServiceActivation = testKit.createTestProbe(DataMessageFromExt) def extSimAdapter = testKit.createTestProbe(ScheduleDataServiceMessage) def extResultDataConnection = new ExtResultDataConnection(participantResultAssetMapping, gridResultAssetMapping) extResultDataConnection.setActorRefs(