100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Continuation of writing tests for ForecastSolarService
Michael Rademaker3703b4efdd66
diff --git a/manager/src/main/java/org/openremote/manager/energy/ForecastSolarService.java b/manager/src/main/java/org/openremote/manager/energy/ForecastSolarService.javaindex a80128456..d9c2106ca 100644--- a/manager/src/main/java/org/openremote/manager/energy/ForecastSolarService.java+++ b/manager/src/main/java/org/openremote/manager/energy/ForecastSolarService.java@@ -2,6 +2,7 @@ package org.openremote.manager.energy;import com.fasterxml.jackson.annotation.JsonProperty;import org.apache.camel.builder.RouteBuilder;+import org.jboss.resteasy.client.jaxrs.ResteasyClient;import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;import org.openremote.container.message.MessageBrokerService;import org.openremote.container.persistence.PersistenceEvent;@@ -82,7 +83,8 @@ public class ForecastSolarService extends RouteBuilder implements ContainerServiprotected static final Logger LOG = Logger.getLogger(ForecastSolarService.class.getName());- protected ResteasyWebTarget forecastSolarClient;+ protected ResteasyClient resteasyClient;+ protected ResteasyWebTarget forecastSolarTarget;private String forecastSolarApiKey;private final Map<String, ScheduledFuture<?>> calculationFutures = new HashMap<>();@@ -108,6 +110,7 @@ public class ForecastSolarService extends RouteBuilder implements ContainerServirulesService = container.getService(RulesService.class);timerService = container.getService(TimerService.class);+ resteasyClient = WebTargetBuilder.createClient(executorService);forecastSolarApiKey = getString(container.getConfig(), FORECAST_SOLAR_API_KEY, null);}@@ -118,7 +121,7 @@ public class ForecastSolarService extends RouteBuilder implements ContainerServireturn;}- forecastSolarClient = WebTargetBuilder.createClient(executorService)+ forecastSolarTarget = resteasyClient.target("https://api.forecast.solar/" + forecastSolarApiKey + "/estimate");container.getService(MessageBrokerService.class).getContext().addRoutes(this);@@ -221,7 +224,7 @@ public class ForecastSolarService extends RouteBuilder implements ContainerServiOptional<Integer> azimuth = electricityProducerSolarAsset.getPanelAzimuth();Optional<Double> kwp = electricityProducerSolarAsset.getPowerExportMax();if (lat.isPresent() && lon.isPresent() && pitch.isPresent() && azimuth.isPresent() && kwp.isPresent()) {- try (Response response = forecastSolarClient+ try (Response response = forecastSolarTarget.path(String.format("%f/%f/%d/%d/%f", lat.get(), lon.get(), pitch.get(), azimuth.get(), kwp.get())).request().build("GET")diff --git a/test/src/test/groovy/org/openremote/test/energy/ForecastSolarServiceTest.groovy b/test/src/test/groovy/org/openremote/test/energy/ForecastSolarServiceTest.groovyindex 42bc7c173..45f3b3c6b 100644--- a/test/src/test/groovy/org/openremote/test/energy/ForecastSolarServiceTest.groovy+++ b/test/src/test/groovy/org/openremote/test/energy/ForecastSolarServiceTest.groovy@@ -1,19 +1,14 @@package org.openremote.test.energyimport com.fasterxml.jackson.databind.ObjectMapper-import org.jboss.resteasy.spi.ResteasyUriInfo-import org.jboss.resteasy.util.BasicAuthHelperimport org.junit.Ignore-import org.openremote.container.web.OAuthServerResponse+import org.openremote.agent.protocol.websocket.WebsocketAgentProtocolimport org.openremote.manager.asset.AssetProcessingServiceimport org.openremote.manager.asset.AssetStorageServiceimport org.openremote.manager.energy.ForecastSolarServiceimport org.openremote.manager.setup.SetupServiceimport org.openremote.model.asset.impl.ElectricityProducerSolarAssetimport org.openremote.model.attribute.AttributeEvent-import org.openremote.model.auth.OAuthGrant-import org.openremote.model.auth.OAuthPasswordGrant-import org.openremote.model.auth.OAuthRefreshTokenGrantimport org.openremote.model.geo.GeoJSONPointimport org.openremote.test.ManagerContainerTraitimport org.openremote.test.setup.ManagerTestSetup@@ -23,11 +18,8 @@ import spock.util.concurrent.PollingConditionsimport javax.ws.rs.client.ClientRequestContextimport javax.ws.rs.client.ClientRequestFilter-import javax.ws.rs.core.Form-import javax.ws.rs.core.HttpHeadersimport javax.ws.rs.core.MediaTypeimport javax.ws.rs.core.Response-import javax.ws.rs.core.UriInfoimport java.time.LocalDateTimeimport java.time.temporal.ChronoUnit@@ -39,73 +31,69 @@ class ForecastSolarServiceTest extends Specification implements ManagerContainer@Shareddef mockServer = new ClientRequestFilter() {-@Overridevoid filter(ClientRequestContext requestContext) throws IOException {def requestUri = requestContext.uri- switch (requestUri.host)- {+ switch (requestUri.host) {case "api.forecast.solar":def now = LocalDateTime.now().truncatedTo(ChronoUnit.HOURS)def content = "\"{\\n\" +\n" +" \" \\\"result\\\": {\\n\" +\n" +" \" \\\"watts\\\": {\\n\" +\n" +" \" \\\"${now.toLocalDate().toString()} ${now.toLocalTime().toString()}\\\": 0,\\n\" +\n" +- " \" \\\"2021-09-01 10:34:00\\\": 780000,\\n\" +\n" +- " \" \\\"2021-09-01 15:00:00\\\": 3904036,\\n\" +\n" +- " \" \\\"2021-09-01 15:15:00\\\": 3854598,\\n\" +\n" +- " \" \\\"2021-09-01 15:30:00\\\": 3746874,\\n\" +\n" +- " \" \\\"2021-09-01 15:45:00\\\": 3675780,\\n\" +\n" +- " \" \\\"2021-09-01 16:00:00\\\": 3553500,\\n\" +\n" +- " \" \\\"2021-09-01 16:15:00\\\": 3439679,\\n\" +\n" +- " \" \\\"2021-09-01 16:30:00\\\": 3278604,\\n\" +\n" +- " \" \\\"2021-09-01 16:45:00\\\": 3137450,\\n\" +\n" +- " \" \\\"2021-09-01 17:00:00\\\": 2954064,\\n\" +\n" +- " \" \\\"2021-09-01 17:15:00\\\": 2739056,\\n\" +\n" +- " \" \\\"2021-09-01 17:30:00\\\": 2493609,\\n\" +\n" +- " \" \\\"2021-09-01 17:45:00\\\": 2254420,\\n\" +\n" +- " \" \\\"2021-09-01 18:00:00\\\": 1949976,\\n\" +\n" +- " \" \\\"2021-09-01 18:15:00\\\": 1697104,\\n\" +\n" +- " \" \\\"2021-09-01 18:30:00\\\": 1452142,\\n\" +\n" +- " \" \\\"2021-09-01 18:45:00\\\": 1194060,\\n\" +\n" +- " \" \\\"2021-09-01 19:00:00\\\": 925642,\\n\" +\n" +- " \" \\\"2021-09-01 19:15:00\\\": 761949,\\n\" +\n" +- " \" \\\"2021-09-01 19:30:00\\\": 594217,\\n\" +\n" +- " \" \\\"2021-09-01 19:45:00\\\": 423624,\\n\" +\n" +- " \" \\\"2021-09-01 19:50:00\\\": 80000,\\n\" +\n" +- " \" \\\"2021-09-01 19:54:00\\\": 0,\\n\" +\n" +- " \" \\\"2021-09-02 06:09:00\\\": 0\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(15).toLocalTime().toString()}\\\": 780000,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(30).toLocalTime().toString()}\\\": 3904036,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(45).toLocalTime().toString()}\\\": 3854598,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(60).toLocalTime().toString()}\\\": 3746874,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(75).toLocalTime().toString()}\\\": 3675780,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(90).toLocalTime().toString()}\\\": 3553500,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(105).toLocalTime().toString()}\\\": 3439679,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(120).toLocalTime().toString()}\\\": 3278604,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(135).toLocalTime().toString()}\\\": 3137450,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(150).toLocalTime().toString()}\\\": 2954064,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(165).toLocalTime().toString()}\\\": 2739056,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(180).toLocalTime().toString()}\\\": 2493609,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(195).toLocalTime().toString()}\\\": 2254420,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(210).toLocalTime().toString()}\\\": 1949976,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(225).toLocalTime().toString()}\\\": 1697104,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(240).toLocalTime().toString()}\\\": 1452142,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(255).toLocalTime().toString()}\\\": 1194060,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(270).toLocalTime().toString()}\\\": 925642,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(285).toLocalTime().toString()}\\\": 761949,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(300).toLocalTime().toString()}\\\": 594217,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(315).toLocalTime().toString()}\\\": 423624,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(330).toLocalTime().toString()}\\\": 80000,\\n\" +\n" ++ " \" \\\"${now.plusDays(1).toLocalDate().toString()} ${now.toLocalTime().toString()}\\\": 0\\n\" +\n" +" \" },\\n\" +\n" +" \" \\\"watt_hours\\\": {\\n\" +\n" +- " \" \\\"2021-09-01 06:07:00\\\": 0,\\n\" +\n" +- " \" \\\"2021-09-01 10:34:00\\\": 3471000,\\n\" +\n" +- " \" \\\"2021-09-01 15:00:00\\\": 20778893,\\n\" +\n" +- " \" \\\"2021-09-01 15:15:00\\\": 21742542,\\n\" +\n" +- " \" \\\"2021-09-01 15:30:00\\\": 22679261,\\n\" +\n" +- " \" \\\"2021-09-01 15:45:00\\\": 23598206,\\n\" +\n" +- " \" \\\"2021-09-01 16:00:00\\\": 24486581,\\n\" +\n" +- " \" \\\"2021-09-01 16:15:00\\\": 25346501,\\n\" +\n" +- " \" \\\"2021-09-01 16:30:00\\\": 26166152,\\n\" +\n" +- " \" \\\"2021-09-01 16:45:00\\\": 26950514,\\n\" +\n" +- " \" \\\"2021-09-01 17:00:00\\\": 27689030,\\n\" +\n" +- " \" \\\"2021-09-01 17:15:00\\\": 28373794,\\n\" +\n" +- " \" \\\"2021-09-01 17:30:00\\\": 28997196,\\n\" +\n" +- " \" \\\"2021-09-01 17:45:00\\\": 29560801,\\n\" +\n" +- " \" \\\"2021-09-01 18:00:00\\\": 30048295,\\n\" +\n" +- " \" \\\"2021-09-01 18:15:00\\\": 30472571,\\n\" +\n" +- " \" \\\"2021-09-01 18:30:00\\\": 30835607,\\n\" +\n" +- " \" \\\"2021-09-01 18:45:00\\\": 31134122,\\n\" +\n" +- " \" \\\"2021-09-01 19:00:00\\\": 31365532,\\n\" +\n" +- " \" \\\"2021-09-01 19:15:00\\\": 31556020,\\n\" +\n" +- " \" \\\"2021-09-01 19:30:00\\\": 31704574,\\n\" +\n" +- " \" \\\"2021-09-01 19:45:00\\\": 31810480,\\n\" +\n" +- " \" \\\"2021-09-01 19:50:00\\\": 31817147,\\n\" +\n" +- " \" \\\"2021-09-01 19:54:00\\\": 31817147,\\n\" +\n" +- " \" \\\"2021-09-02 06:09:00\\\": 0\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.toLocalTime().toString()}\\\": 0,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(15).toLocalTime().toString()}\\\": 3471000,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(30).toLocalTime().toString()}\\\": 20778893,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(45).toLocalTime().toString()}\\\": 21742542,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(60).toLocalTime().toString()}\\\": 22679261,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(75).toLocalTime().toString()}\\\": 23598206,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(90).toLocalTime().toString()}\\\": 24486581,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(105).toLocalTime().toString()}\\\": 25346501,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(120).toLocalTime().toString()}\\\": 26166152,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(135).toLocalTime().toString()}\\\": 26950514,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(150).toLocalTime().toString()}\\\": 27689030,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(165).toLocalTime().toString()}\\\": 28373794,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(180).toLocalTime().toString()}\\\": 28997196,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(195).toLocalTime().toString()}\\\": 29560801,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(210).toLocalTime().toString()}\\\": 30048295,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(225).toLocalTime().toString()}\\\": 30472571,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(240).toLocalTime().toString()}\\\": 30835607,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(255).toLocalTime().toString()}\\\": 31134122,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(270).toLocalTime().toString()}\\\": 31365532,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(285).toLocalTime().toString()}\\\": 31556020,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(300).toLocalTime().toString()}\\\": 31704574,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(315).toLocalTime().toString()}\\\": 31810480,\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()} ${now.plusMinutes(330).toLocalTime().toString()}\\\": 31817147,\\n\" +\n" ++ " \" \\\"${now.plusDays(1).toLocalDate().toString()} ${now.toLocalTime().toString()}\\\": 0\\n\" +\n" +" \" },\\n\" +\n" +" \" \\\"watt_hours_day\\\": {\\n\" +\n" +- " \" \\\"2021-09-01\\\": 31817147\\n\" +\n" ++ " \" \\\"${now.toLocalDate().toString()}\\\": 31817147\\n\" +\n" +" \" }\\n\" +\n" +" \" },\\n\" +\n" +" \" \\\"message\\\": {\\n\" +\n" +@@ -125,65 +113,10 @@ class ForecastSolarServiceTest extends Specification implements ManagerContainer" \" }\\n\" +\n" +" \" }\\n\" +\n" +" \"}\""-// def response = new ObjectMapper().readValue(, ForecastSolarService.EstimateResponse.class)-- // OAuth token request extract the grant info- def grant = ((Form)requestContext.getEntity()).asMap()- if (grant.getFirst(OAuthGrant.VALUE_KEY_GRANT_TYPE) == "password"- && grant.getFirst(OAuthGrant.VALUE_KEY_CLIENT_ID ) == "client1"- && grant.getFirst(OAuthGrant.VALUE_KEY_CLIENT_SECRET ) == "secret1"- && grant.getFirst(OAuthGrant.VALUE_KEY_SCOPE ) == "scope1 scope2"- && grant.getFirst(OAuthPasswordGrant.VALUE_KEY_USERNAME) == "testuser"- && grant.getFirst(OAuthPasswordGrant.VALUE_KEY_PASSWORD) == "password1") {- accessToken = "accesstoken" + accessTokenCount++- def response = new OAuthServerResponse()- response.accessToken = accessToken- response.expiresIn = requestPath == "https://oauthserver/token" ? 5 : 100- response.tokenType = "Bearer"-- // Include refresh token if configured to support it- if (supportsRefresh) {- refreshToken = "refreshtoken" + accessTokenCount- response.refreshToken = refreshToken- }-- requestContext.abortWith(- Response.ok(response, MediaType.APPLICATION_JSON_TYPE).build()- )- return- } else if (grant.getFirst(OAuthGrant.VALUE_KEY_GRANT_TYPE) == "client_credentials"- && grant.getFirst(OAuthGrant.VALUE_KEY_CLIENT_ID ) == "client1"- && grant.getFirst(OAuthGrant.VALUE_KEY_CLIENT_SECRET ) == "secret1"- && grant.getFirst(OAuthGrant.VALUE_KEY_SCOPE ) == "scope1 scope2") {- accessToken = "accesstoken" + accessTokenCount++- def response = new OAuthServerResponse()- response.accessToken = accessToken- response.expiresIn = requestPath == "https://oauthserver/token" ? 1 : 100- response.tokenType = "Bearer"-- requestContext.abortWith(- Response.ok(response, MediaType.APPLICATION_JSON_TYPE).build()- )- return- } else if (supportsRefresh && grant.getFirst(OAuthGrant.VALUE_KEY_GRANT_TYPE) == "refresh_token"- && grant.getFirst(OAuthGrant.VALUE_KEY_CLIENT_ID ) == "client1"- && grant.getFirst(OAuthGrant.VALUE_KEY_CLIENT_SECRET ) == "secret1"- && grant.getFirst(OAuthGrant.VALUE_KEY_SCOPE ) == "scope1 scope2"- && grant.getFirst(OAuthRefreshTokenGrant.REFRESH_TOKEN_GRANT_TYPE) == refreshToken) {- refreshTokenCount++- accessToken = "accesstoken" + accessTokenCount++- refreshToken = "refreshtoken" + accessTokenCount- def response = new OAuthServerResponse()- response.accessToken = accessToken- response.refreshToken = refreshToken- response.expiresIn = requestPath == "https://oauthserver/token" ? 1 : 100- response.tokenType = "Bearer"-- requestContext.abortWith(- Response.ok(response, MediaType.APPLICATION_JSON_TYPE).build()- )- return- }+ def responseBody = new ObjectMapper().readValue(content, ForecastSolarService.EstimateResponse.class)+ requestContext.abortWith(+ Response.ok(responseBody, MediaType.APPLICATION_JSON_TYPE).build()+ )break}@@ -195,20 +128,25 @@ class ForecastSolarServiceTest extends Specification implements ManagerContainergiven: "the container environment is started"def conditions = new PollingConditions(timeout: 10, delay: 0.2)def config = defaultConfig()- config << [(FORECAST_SOLAR_API_KEY) : System.getenv(FORECAST_SOLAR_API_KEY)]+ config << [(FORECAST_SOLAR_API_KEY): System.getenv(FORECAST_SOLAR_API_KEY)]def container = startContainer(config, defaultServices())def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)def assetStorageService = container.getService(AssetStorageService.class)def assetProcessingService = container.getService(AssetProcessingService.class)def forecastSolarService = container.getService(ForecastSolarService.class)+ and: "the web client is configured to use the mock HTTP server"+ if (!forecastSolarService.resteasyClient.configuration.isRegistered(mockServer)) {+ forecastSolarService.resteasyClient.register(mockServer, Integer.MAX_VALUE)+ }+expect: "a Future for calculation should exist and the asset should have filled in value for power and powerForecast"conditions.eventually {assert !forecastSolarService.calculationFutures.isEmpty()assert forecastSolarService.calculationFutures.get(managerTestSetup.electricitySolarAssetId) != nulldef solarAsset = assetStorageService.find(managerTestSetup.electricitySolarAssetId)- assert solarAsset.getAttribute(ElectricityProducerSolarAsset.POWER).flatMap{it.value}.orElse(0d) != 0d- assert solarAsset.getAttribute(ElectricityProducerSolarAsset.POWER_FORECAST).flatMap{it.value}.orElse(0d) != 0d+ assert solarAsset.getAttribute(ElectricityProducerSolarAsset.POWER).flatMap { it.value }.orElse(0d) != 0d+ assert solarAsset.getAttribute(ElectricityProducerSolarAsset.POWER_FORECAST).flatMap { it.value }.orElse(0d) != 0d}when: "an asset is added with includeForecastSolarService set to true"@@ -228,8 +166,8 @@ class ForecastSolarServiceTest extends Specification implements ManagerContainerconditions.eventually {assert forecastSolarService.calculationFutures.get(newSolarAsset.getId()) != nullnewSolarAsset = assetStorageService.find(newSolarAsset.getId())- assert newSolarAsset.getAttribute(ElectricityProducerSolarAsset.POWER).flatMap{it.value}.orElse(0d) != 0d- assert newSolarAsset.getAttribute(ElectricityProducerSolarAsset.POWER_FORECAST).flatMap{it.value}.orElse(0d) != 0d+ assert newSolarAsset.getAttribute(ElectricityProducerSolarAsset.POWER).flatMap { it.value }.orElse(0d) != 0d+ assert newSolarAsset.getAttribute(ElectricityProducerSolarAsset.POWER_FORECAST).flatMap { it.value }.orElse(0d) != 0d}when: "an asset is added with includeForecastSolarService set to false"@@ -256,8 +194,8 @@ class ForecastSolarServiceTest extends Specification implements ManagerContainerthen: "it should be present present in the calculationFutures"conditions.eventually {assert forecastSolarService.calculationFutures.get(newSolarAsset2.getId()) != null- assert newSolarAsset2.getAttribute(ElectricityProducerSolarAsset.POWER).flatMap{it.value}.orElse(0d) == 0d- assert newSolarAsset2.getAttribute(ElectricityProducerSolarAsset.POWER_FORECAST).flatMap{it.value}.orElse(0d) != 0d+ assert newSolarAsset2.getAttribute(ElectricityProducerSolarAsset.POWER).flatMap { it.value }.orElse(0d) == 0d+ assert newSolarAsset2.getAttribute(ElectricityProducerSolarAsset.POWER_FORECAST).flatMap { it.value }.orElse(0d) != 0d}}}