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
Testing related updates
Rich Turner914ed3e15397
diff --git a/manager/server/src/main/java/org/openremote/manager/server/agent/AgentService.java b/manager/server/src/main/java/org/openremote/manager/server/agent/AgentService.javaindex 0a71967c6..647ce80c9 100644--- a/manager/server/src/main/java/org/openremote/manager/server/agent/AgentService.java+++ b/manager/server/src/main/java/org/openremote/manager/server/agent/AgentService.java@@ -414,6 +414,14 @@ public class AgentService extends RouteBuilder implements ContainerService, Cons}}+ public Protocol.DeploymentStatus getProtocolDeploymentStatus(AttributeRef protocolRef) {+ synchronized (protocolConfigurations) {+ return Optional.ofNullable(protocolConfigurations.get(protocolRef))+ .map(pair -> pair.value)+ .orElse(null);+ }+ }+protected Protocol getProtocol(AssetAttribute protocolConfiguration) {return protocols.get(protocolConfiguration.getValueAsString().orElse(null));}diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/BuiltinSetupTasks.java b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/BuiltinSetupTasks.javaindex 0a5d41665..024068f66 100644--- a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/BuiltinSetupTasks.java+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/BuiltinSetupTasks.java@@ -30,62 +30,58 @@ import static org.openremote.container.util.MapAccess.getBoolean;/*** Builtin setup tasks.* <p>- * When developer mode is enabled, all builtin setup tasks will be executed- * regardless of other configuration options. With developer mode disabled,- * builtin tasks can be selectively enabled (they are disabled by default), see:- * <ul>+ * All setup tasks are configurable.+ * <p>+ * When developer mode is enabled all setup tasks default to enabled.+ * When developer mode is disabled all setup tasks default to false.+ * <p>+ * Some setup tasks require other setup tasks so if a dependent task+ * is requested to be disabled it will be overridden and enabled anyway+ * (see list of config options for details)+ * <p>+ * Setup tasks are configured via the config hash map supplied in the+ * {@link Container} constructor. Available config options are:+ * <ul>* <li>{@link #SETUP_INIT_CLEAN_DATABASE}</li>- * <li>{@link #SETUP_IMPORT_DEMO_DATA}</li>+ * <li>{@link #SETUP_IMPORT_DEMO_ASSETS} depends on {@link #SETUP_IMPORT_DEMO_USERS}</li>+ * <li>{@link #SETUP_IMPORT_DEMO_USERS}</li>+ * <li>{@link #SETUP_IMPORT_DEMO_RULES} depends on {@link #SETUP_IMPORT_DEMO_ASSETS}</li>* </ul>*/public class BuiltinSetupTasks extends AbstractSetupTasks {public static final String SETUP_INIT_CLEAN_DATABASE = "SETUP_INIT_CLEAN_DATABASE";- public static final boolean SETUP_INIT_CLEAN_DATABASE_DEFAULT = false;-- public static final String SETUP_IMPORT_DEMO_DATA = "SETUP_IMPORT_DEMO_DATA";- public static final boolean SETUP_IMPORT_DEMO_DATA_DEFAULT = false;-+ public static final String SETUP_IMPORT_DEMO_USERS = "SETUP_IMPORT_DEMO_USERS";+ public static final String SETUP_IMPORT_DEMO_ASSETS = "SETUP_IMPORT_DEMO_ASSETS";public static final String SETUP_IMPORT_DEMO_RULES = "SETUP_IMPORT_DEMO_RULES";- public static final boolean SETUP_IMPORT_DEMO_RULES_DEFAULT = true;@Overridepublic List<Setup> createTasks(Container container) {- if (container.isDevMode()) {+ boolean cleanDatabase = getBoolean(container.getConfig(), SETUP_INIT_CLEAN_DATABASE, container.isDevMode());+ boolean importDemoRules = getBoolean(container.getConfig(), SETUP_IMPORT_DEMO_RULES, container.isDevMode());+ // If importing demo rules we have to import demo assets+ boolean importDemoAssets = importDemoRules || getBoolean(container.getConfig(), SETUP_IMPORT_DEMO_ASSETS, container.isDevMode());+ // If importing demo assets we have to import demo users+ boolean importDemoUsers = importDemoAssets || getBoolean(container.getConfig(), SETUP_IMPORT_DEMO_USERS, container.isDevMode());++ if (cleanDatabase) {addTask(new ManagerCleanSetup(container));addTask(new KeycloakCleanSetup(container));addTask(new KeycloakInitSetup(container));addTask(new ManagerInitSetup(container));+ }+ if (importDemoUsers) {addTask(new KeycloakDemoSetup(container));- addTask(new ManagerDemoSetup(container));-- } else {-- if (getBoolean(container.getConfig(), SETUP_INIT_CLEAN_DATABASE, SETUP_INIT_CLEAN_DATABASE_DEFAULT)) {- addTask(new ManagerCleanSetup(container));- addTask(new KeycloakCleanSetup(container));- addTask(new KeycloakInitSetup(container));- addTask(new ManagerInitSetup(container));- }-- if (getBoolean(container.getConfig(), SETUP_IMPORT_DEMO_DATA, SETUP_IMPORT_DEMO_DATA_DEFAULT)) {- addTask(new KeycloakDemoSetup(container));- addTask(new ManagerDemoSetup(container));- }+ }+ if (importDemoAssets) {+ addTask(new ManagerDemoSetup(container));}- // We want to import demo rules when either- //- // - dev mode is on and demo rules import is not disabled (some tests need other rules)- // - production mode is on and both demo data import and demo rules import is enabled- //- if (container.isDevMode() && getBoolean(container.getConfig(), SETUP_IMPORT_DEMO_RULES, SETUP_IMPORT_DEMO_RULES_DEFAULT)- || (getBoolean(container.getConfig(), SETUP_INIT_CLEAN_DATABASE, SETUP_INIT_CLEAN_DATABASE_DEFAULT) &&- getBoolean(container.getConfig(), SETUP_IMPORT_DEMO_RULES, SETUP_IMPORT_DEMO_RULES_DEFAULT))) {+ if (importDemoRules) {addTask(new RulesDemoSetup(container));}diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerDemoSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerDemoSetup.javaindex b0175d6a0..1264b250e 100644--- a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerDemoSetup.java+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerDemoSetup.java@@ -20,6 +20,8 @@package org.openremote.manager.server.setup.builtin;import com.vividsolutions.jts.geom.Coordinate;+import org.openremote.agent3.protocol.macro.MacroAction;+import org.openremote.agent3.protocol.macro.MacroProtocol;import org.openremote.agent3.protocol.simulator.SimulatorProtocol;import org.openremote.agent3.protocol.simulator.element.ColorSimulatorElement;import org.openremote.agent3.protocol.simulator.element.DecimalSimulatorElement;@@ -66,12 +68,15 @@ public class ManagerDemoSetup extends AbstractManagerSetup {public String thingId;public String smartHomeId;public String apartment1Id;+ public String apartment1SceneAgentId;public String apartment1LivingroomId;public String apartment1LivingroomThermostatId;public String apartment2Id;public String apartment3Id;public String apartment2LivingroomId;public String apartment3LivingroomId;+ public String masterRealmId;+ public String customerARealmId;public ManagerDemoSetup(Container container) {super(container);@@ -83,6 +88,8 @@ public class ManagerDemoSetup extends AbstractManagerSetup {KeycloakDemoSetup keycloakDemoSetup = setupService.getTaskOfType(KeycloakDemoSetup.class);Tenant masterTenant = keycloakDemoSetup.masterTenant;Tenant customerATenant = keycloakDemoSetup.customerATenant;+ masterRealmId = masterTenant.getId();+ customerARealmId = customerATenant.getId();// ################################ Demo assets for 'master' realm ###################################@@ -529,11 +536,11 @@ public class ManagerDemoSetup extends AbstractManagerSetup {new MetaItem("urn:thirdparty:bar", Values.create("BAR"))),- new AssetAttribute("comfortTemperature", DECIMAL)+ new AssetAttribute("targetTemperature", DECIMAL).setMeta(new MetaItem(AssetMeta.LABEL,- Values.create("Comfort Temperature")),+ Values.create("Target Temperature")),new MetaItem(AssetMeta.RULE_STATE,Values.create(true)),@@ -552,6 +559,77 @@ public class ManagerDemoSetup extends AbstractManagerSetup {apartment1LivingroomThermostat = assetStorageService.merge(apartment1LivingroomThermostat);apartment1LivingroomThermostatId = apartment1LivingroomThermostat.getId();+ // Create scene agent+ ServerAsset apartment1Scenes = new ServerAsset("Scenes", AGENT, apartment1);+ apartment1Scenes.setLocation(geometryFactory.createPoint(new Coordinate(5.470945, 51.438000)));+ apartment1Scenes.setAttributes(+ initProtocolConfiguration(new AssetAttribute("homeScene"), MacroProtocol.PROTOCOL_NAME)+ .setMeta(+ new MacroAction(new AttributeState(new AttributeRef(apartment1Id, "alarmEnabled"), Values.create(false))).toMetaItem(),+ new MacroAction(new AttributeState(new AttributeRef(apartment1Id, "lastExecutedScene"), Values.create("HOME"))).toMetaItem(),+ new MacroAction(new AttributeState(new AttributeRef(apartment1LivingroomThermostatId, "targetTemperature"), Values.create(21d))).toMetaItem()+ ),+ initProtocolConfiguration(new AssetAttribute("awayScene"), MacroProtocol.PROTOCOL_NAME)+ .setMeta(+ new MacroAction(new AttributeState(new AttributeRef(apartment1Id, "alarmEnabled"), Values.create(true))).toMetaItem(),+ new MacroAction(new AttributeState(new AttributeRef(apartment1Id, "lastExecutedScene"), Values.create("AWAY"))).toMetaItem(),+ new MacroAction(new AttributeState(new AttributeRef(apartment1LivingroomThermostatId, "targetTemperature"), Values.create(15d))).toMetaItem()+ ),+ initProtocolConfiguration(new AssetAttribute("eveningScene"), MacroProtocol.PROTOCOL_NAME)+ .setMeta(+ new MacroAction(new AttributeState(new AttributeRef(apartment1Id, "alarmEnabled"), Values.create(false))).toMetaItem(),+ new MacroAction(new AttributeState(new AttributeRef(apartment1Id, "lastExecutedScene"), Values.create("EVENING"))).toMetaItem(),+ new MacroAction(new AttributeState(new AttributeRef(apartment1LivingroomThermostatId, "targetTemperature"), Values.create(22d))).toMetaItem()+ ),+ initProtocolConfiguration(new AssetAttribute("nightScene"), MacroProtocol.PROTOCOL_NAME)+ .setMeta(+ new MacroAction(new AttributeState(new AttributeRef(apartment1Id, "alarmEnabled"), Values.create(true))).toMetaItem(),+ new MacroAction(new AttributeState(new AttributeRef(apartment1Id, "lastExecutedScene"), Values.create("NIGHT"))).toMetaItem(),+ new MacroAction(new AttributeState(new AttributeRef(apartment1LivingroomThermostatId, "targetTemperature"), Values.create(19d))).toMetaItem()+ )+ );+ apartment1Scenes = assetStorageService.merge(apartment1Scenes);+ apartment1SceneAgentId = apartment1Scenes.getId();++ // Update apartment 1 with scenes+ apartment1.addAttribute(+ new AssetAttribute("homeScene", AttributeType.STRING)+ .setMeta(+ new MetaItem(AssetMeta.LABEL, Values.create("Execute Home Scene")),+ new MetaItem(AssetMeta.EXECUTABLE, Values.create(true)),+ new MetaItem(AssetMeta.AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "homeScene").toArrayValue())+ )+ );++ apartment1.addAttribute(+ new AssetAttribute("awayScene", AttributeType.STRING)+ .setMeta(+ new MetaItem(AssetMeta.LABEL, Values.create("Execute Away Scene")),+ new MetaItem(AssetMeta.EXECUTABLE, Values.create(true)),+ new MetaItem(AssetMeta.AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "awayScene").toArrayValue())+ )+ );++ apartment1.addAttribute(+ new AssetAttribute("eveningScene", AttributeType.STRING)+ .setMeta(+ new MetaItem(AssetMeta.LABEL, Values.create("Execute Evening Scene")),+ new MetaItem(AssetMeta.EXECUTABLE, Values.create(true)),+ new MetaItem(AssetMeta.AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "eveningScene").toArrayValue())+ )+ );++ apartment1.addAttribute(+ new AssetAttribute("nightScene", AttributeType.STRING)+ .setMeta(+ new MetaItem(AssetMeta.LABEL, Values.create("Execute Night Scene")),+ new MetaItem(AssetMeta.EXECUTABLE, Values.create(true)),+ new MetaItem(AssetMeta.AGENT_LINK, new AttributeRef(apartment1SceneAgentId, "nightScene").toArrayValue())+ )+ );++ apartment1 = assetStorageService.merge(apartment1);+ServerAsset apartment2 = new ServerAsset("Apartment 2", RESIDENCE, smartHome);apartment2.setLocation(geometryFactory.createPoint(new Coordinate(5.470945, 51.438000)));apartment2.setAttributes(diff --git a/manager/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy b/manager/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovyindex 3b95f9390..28b7c720b 100644--- a/manager/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy+++ b/manager/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy@@ -2,7 +2,6 @@ package org.openremote.testimport com.google.common.collect.Listsimport org.drools.core.time.impl.PseudoClockScheduler-import org.kie.api.runtime.conf.ClockTypeOptionimport org.openremote.agent3.protocol.Protocolimport org.openremote.container.Containerimport org.openremote.container.ContainerService@@ -14,6 +13,7 @@ import org.openremote.manager.server.agent.AgentServiceimport org.openremote.manager.server.apps.ConsoleAppServiceimport org.openremote.manager.server.asset.AssetProcessingServiceimport org.openremote.manager.server.asset.AssetStorageService+import org.openremote.manager.server.concurrent.ManagerExecutorServiceimport org.openremote.manager.server.datapoint.AssetDatapointServiceimport org.openremote.manager.server.event.EventServiceimport org.openremote.manager.server.i18n.I18NService@@ -24,14 +24,13 @@ import org.openremote.manager.server.rules.RulesServiceimport org.openremote.manager.server.rules.RulesetStorageServiceimport org.openremote.manager.server.security.ManagerIdentityServiceimport org.openremote.manager.server.setup.SetupService-import org.openremote.manager.server.concurrent.ManagerExecutorServiceimport org.openremote.manager.server.web.ManagerWebServiceimport java.util.concurrent.TimeUnitimport static org.openremote.container.timer.TimerService.Clock.PSEUDOimport static org.openremote.container.timer.TimerService.TIMER_CLOCK_TYPE-import static org.openremote.manager.server.setup.builtin.BuiltinSetupTasks.SETUP_IMPORT_DEMO_RULES+import static org.openremote.manager.server.setup.builtin.BuiltinSetupTasks.*trait ManagerContainerTrait extends ContainerTrait {@@ -67,12 +66,31 @@ trait ManagerContainerTrait extends ContainerTrait {}/**- * Faster startup if you don't need to test rules.+ * Faster startup - Start a container with no demo rules*/- static Container startContainerWithoutDemoRules(Map<String, String> config, Iterable<ContainerService> services) {+ static Container startContainerNoDemoRules(Map<String, String> config, Iterable<ContainerService> services) {startContainer(config << [(SETUP_IMPORT_DEMO_RULES): "false"], services)}+ /**+ * Faster startup - Start a container with no demo assets or rules+ */+ static Container startContainerNoDemoRulesOrAssets(Map<String, String> config, Iterable<ContainerService> services) {+ config << [(SETUP_IMPORT_DEMO_ASSETS): "false"]+ config << [(SETUP_IMPORT_DEMO_RULES): "false"]+ startContainer(config, services);+ }++ /**+ * Faster startup - Start a container with no demo users, assets or rules+ */+ static Container startContainerMinimal(Map<String, String> config, Iterable<ContainerService> services) {+ config << [(SETUP_IMPORT_DEMO_USERS): "false"]+ config << [(SETUP_IMPORT_DEMO_ASSETS): "false"]+ config << [(SETUP_IMPORT_DEMO_RULES): "false"]+ startContainer(config, services);+ }+/*** Use pseudo clock instead of wall clock.*/diff --git a/manager/test/src/test/groovy/org/openremote/test/admin/AdminTenantsActivityTest.groovy b/manager/test/src/test/groovy/org/openremote/test/admin/AdminTenantsActivityTest.groovyindex 4eb6483c0..d419bbff3 100644--- a/manager/test/src/test/groovy/org/openremote/test/admin/AdminTenantsActivityTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/admin/AdminTenantsActivityTest.groovy@@ -46,7 +46,7 @@ class AdminTenantsActivityTest extends Specification implements ManagerContainergiven: "The server container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRulesOrAssets(defaultConfig(serverPort), defaultServices())def identityService = container.getService(ManagerIdentityService.class)and: "expected results"diff --git a/manager/test/src/test/groovy/org/openremote/test/admin/AdminUsersActivityTest.groovy b/manager/test/src/test/groovy/org/openremote/test/admin/AdminUsersActivityTest.groovyindex abc93bba5..cf3670132 100644--- a/manager/test/src/test/groovy/org/openremote/test/admin/AdminUsersActivityTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/admin/AdminUsersActivityTest.groovy@@ -43,7 +43,7 @@ class AdminUsersActivityTest extends Specification implements ManagerContainerTrgiven: "The server container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRulesOrAssets(defaultConfig(serverPort), defaultServices())def identityService = container.getService(ManagerIdentityService.class)and: "expected results"diff --git a/manager/test/src/test/groovy/org/openremote/test/agent/AgentDeploymentTest.groovy b/manager/test/src/test/groovy/org/openremote/test/agent/AgentDeploymentTest.groovydeleted file mode 100644index 0f1e9e085..000000000--- a/manager/test/src/test/groovy/org/openremote/test/agent/AgentDeploymentTest.groovy+++ /dev/null@@ -1,77 +0,0 @@-package org.openremote.test.agent--import org.openremote.agent3.protocol.simulator.SimulatorProtocol-import org.openremote.manager.server.asset.AssetProcessingService-import org.openremote.manager.server.asset.AssetStorageService-import org.openremote.manager.server.setup.SetupService-import org.openremote.manager.server.setup.builtin.ManagerDemoSetup-import org.openremote.model.attribute.AttributeEvent-import org.openremote.model.attribute.ColorRGB-import org.openremote.model.value.ArrayValue-import org.openremote.model.value.ValueType-import org.openremote.model.value.Values-import org.openremote.test.ManagerContainerTrait-import spock.lang.Specification-import spock.util.concurrent.PollingConditions--class AgentDeploymentTest extends Specification implements ManagerContainerTrait {-- def "Check agent and thing deployment"() {-- given: "expected conditions"- def conditions = new PollingConditions(timeout: 30, initialDelay: 1)-- when: "the demo agent and thing have been deployed"- def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)- def simulatorProtocol = container.getService(SimulatorProtocol.class)- def assetStorageService = container.getService(AssetStorageService.class)- def assetProcessingService = container.getService(AssetProcessingService.class)-- then: "the simulator elements should have the initial state"- conditions.eventually {- assert simulatorProtocol.getState(managerDemoSetup.thingId, "light1Toggle").asBoolean()- assert simulatorProtocol.getState(managerDemoSetup.thingId, "light1Dimmer") == null- // No initial value!- assert new ColorRGB(simulatorProtocol.getState(managerDemoSetup.thingId, "light1Color") as ArrayValue) == new ColorRGB(88, 123, 88)- assert Values.getNumber(simulatorProtocol.getState(managerDemoSetup.thingId, "light1PowerConsumption")).orElse(null) == 12.345d- }-- when: "a client wants to change a thing attributes' value, triggering an actuator"- conditions = new PollingConditions(timeout: 3, initialDelay: 1)- def light1DimmerChange = new AttributeEvent(- managerDemoSetup.thingId, "light1Dimmer", Values.create(66)- )- assetProcessingService.sendAttributeEvent(light1DimmerChange)-- then: "the simulator state and thing attribute value should be updated (simulator reflects actuator write as sensor read)"- conditions.eventually {- assert simulatorProtocol.getState(managerDemoSetup.thingId, "light1Dimmer") != null- assert Values.getNumber(simulatorProtocol.getState(managerDemoSetup.thingId, "light1Dimmer")).orElse(null) == 66d- def thing = assetStorageService.find(managerDemoSetup.thingId, true)- def attribute = thing.getAttribute("light1Dimmer")- assert attribute.get().getValue().isPresent()- assert attribute.get().getValue().get().getType() == ValueType.NUMBER- assert attribute.get().getValueAsInteger().isPresent()- assert attribute.get().getValueAsInteger().get() == 66- }-- when: "a simulated sensor changes its value"- conditions = new PollingConditions(timeout: 3, initialDelay: 1)- simulatorProtocol.putState(managerDemoSetup.thingId, "light1Dimmer", Values.create(77))-- then: "the thing attribute value should be updated"- conditions.eventually {- def thing = assetStorageService.find(managerDemoSetup.thingId, true)- def attribute = thing.getAttribute("light1Dimmer")- assert attribute.get().getValue().isPresent()- assert attribute.get().getValue().get().getType() == ValueType.NUMBER- assert attribute.get().getValueAsInteger().isPresent()- assert attribute.get().getValueAsInteger().get() == 77- }-- cleanup: "the server should be stopped"- stopContainer(container)- }-}diff --git a/manager/test/src/test/groovy/org/openremote/test/assets/AssetBrowserPresenterTest.groovy b/manager/test/src/test/groovy/org/openremote/test/assets/AssetBrowserPresenterTest.groovyindex 72299e283..4c9dc18b9 100644--- a/manager/test/src/test/groovy/org/openremote/test/assets/AssetBrowserPresenterTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/assets/AssetBrowserPresenterTest.groovy@@ -43,7 +43,7 @@ class AssetBrowserPresenterTest extends Specification implements ManagerContainegiven: "The server container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def identityService = container.getService(ManagerIdentityService.class)def assetStorageService = container.getService(AssetStorageService.class)def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)@@ -212,7 +212,7 @@ class AssetBrowserPresenterTest extends Specification implements ManagerContainegiven: "The server container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def identityService = container.getService(ManagerIdentityService.class)def assetStorageService = container.getService(AssetStorageService.class)def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)@@ -390,7 +390,7 @@ class AssetBrowserPresenterTest extends Specification implements ManagerContainegiven: "The server container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def identityService = container.getService(ManagerIdentityService.class)def assetStorageService = container.getService(AssetStorageService.class)def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)diff --git a/manager/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovy b/manager/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovyindex cf2533d9a..ff4be902e 100644--- a/manager/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovy@@ -20,7 +20,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTraitwhen: "the demo agent and thing have been deployed"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def simulatorProtocol = container.getService(SimulatorProtocol.class)def assetStorageService = container.getService(AssetStorageService.class)diff --git a/manager/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovy b/manager/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovyindex 2e2f09816..d6afbaf97 100644--- a/manager/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovy@@ -26,7 +26,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTraitdef "Test asset changes as superuser"() {given: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)diff --git a/manager/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy b/manager/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovyindex a96f03578..054afb9d6 100644--- a/manager/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy@@ -28,7 +28,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTraidef "Access assets as superuser"() {given: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)def conditions = new PollingConditions(delay: 1, timeout: 5)@@ -203,7 +203,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTraigiven: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)def conditions = new PollingConditions(delay: 1, timeout: 10)@@ -358,7 +358,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTraidef "Access assets as testuser2"() {given: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)@@ -489,7 +489,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTraidef "Access assets as testuser3"() {given: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)def conditions = new PollingConditions(delay: 1, timeout: 5)@@ -662,13 +662,13 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTraiex.response.status == 403when: "a protected asset attribute is written on a user asset"- assetResource.writeAttributeValue(null, managerDemoSetup.apartment1LivingroomThermostatId, "comfortTemperature", Values.create(22.123).toJson())+ assetResource.writeAttributeValue(null, managerDemoSetup.apartment1LivingroomThermostatId, "targetTemperature", Values.create(22.123).toJson())then: "result should match"conditions.eventually {def asset = assetResource.get(null, managerDemoSetup.apartment1LivingroomThermostatId)- assert asset.getAttribute("comfortTemperature").get().getValue().isPresent()- assert asset.getAttribute("comfortTemperature").get().getValue().get().toJson() == Values.create(22.123).toJson()+ assert asset.getAttribute("targetTemperature").get().getValue().isPresent()+ assert asset.getAttribute("targetTemperature").get().getValue().get().toJson() == Values.create(22.123).toJson()}when: "an attribute is written on a non-existent user asset"diff --git a/manager/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy b/manager/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovyindex 9f6fceb78..950c6a117 100644--- a/manager/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy@@ -1,6 +1,5 @@package org.openremote.test.assets-import org.openremote.model.value.Valuesimport org.openremote.agent3.protocol.AbstractProtocolimport org.openremote.manager.server.asset.AssetProcessingServiceimport org.openremote.manager.server.asset.AssetStorageService@@ -9,17 +8,14 @@ import org.openremote.manager.server.rules.RulesServiceimport org.openremote.manager.server.setup.SetupServiceimport org.openremote.manager.server.setup.builtin.KeycloakDemoSetupimport org.openremote.manager.server.setup.builtin.ManagerDemoSetup-import org.openremote.model.*+import org.openremote.model.Constantsimport org.openremote.model.asset.AssetAttributeimport org.openremote.model.asset.AssetMetaimport org.openremote.model.asset.AssetStateimport org.openremote.model.asset.AssetTypeimport org.openremote.model.asset.agent.ProtocolConfiguration-import org.openremote.model.attribute.AttributeEvent-import org.openremote.model.attribute.AttributeRef-import org.openremote.model.attribute.AttributeState-import org.openremote.model.attribute.AttributeType-import org.openremote.model.attribute.MetaItem+import org.openremote.model.attribute.*+import org.openremote.model.value.Valuesimport org.openremote.test.ManagerContainerTraitimport spock.lang.Specificationimport spock.util.concurrent.PollingConditions@@ -28,14 +24,13 @@ import java.util.function.Consumerimport java.util.logging.Loggerclass AssetProcessingTest extends Specification implements ManagerContainerTrait {- Logger LOG = Logger.getLogger(AssetStorageService.class.getName())+ Logger LOG = Logger.getLogger(AssetProcessingTest.class.getName())- def "Check processing of asset updates"() {+ def "Check processing of asset updates through the processing chain"() {given: "expected conditions"def conditions = new PollingConditions(timeout: 10, delay: 1)- // TODO: Update this to use Simulator Protocoland: "a mock protocol"def mockProtocolName = Constants.PROTOCOL_NAMESPACE + ":mockProtocol"def protocolDeployed = false@@ -81,30 +76,57 @@ class AssetProcessingTest extends Specification implements ManagerContainerTrait}}- and: "a mock attribute event consumer"+ and: "mock attribute state consumers"List<AssetState> updatesPassedStartOfProcessingChain = []- List<AssetState> updatesReachedEndOfProcessingChain = []-- Consumer<AssetState> mockEndConsumer = { assetUpdate ->- updatesReachedEndOfProcessingChain.add(assetUpdate)- }+ List<AssetState> updatesPassedRulesService = []+ List<AssetState> updatesPassedAgentService = []+ List<AssetState> updatesPassedAssetStorageService = []+ List<AssetState> updatesPassedDatapointService = []Consumer<AssetState> mockStartConsumer = { assetUpdate ->updatesPassedStartOfProcessingChain.add(assetUpdate)}- and: "the container is started with the mock consumers and mock protocol"+ Consumer<AssetState> mockRulesServiceConsumer = { assetState ->+ updatesPassedRulesService.add(assetState)+ }++ Consumer<AssetState> mockAgentServiceConsumer = { assetState ->+ updatesPassedAgentService.add(assetState)+ }++ Consumer<AssetState> mockAssetStorageConsumer = { assetState ->+ updatesPassedAssetStorageService.add(assetState)+ }++ Consumer<AssetState> mockDatapointServiceConsumer = { assetState ->+ updatesPassedDatapointService.add(assetState)+ }++ when: "the container is started with the mock protocol and consumers"def serverPort = findEphemeralPort()- def container = startContainer(defaultConfig(serverPort), defaultServices(mockProtocol))+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices(mockProtocol))def assetStorageService = container.getService(AssetStorageService.class)def assetProcessingService = container.getService(AssetProcessingService.class)def rulesService = container.getService(RulesService.class)def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)- assetProcessingService.processors.add(0, mockStartConsumer)- assetProcessingService.processors.add(mockEndConsumer)++ then: "the container should be running and initialised"+ conditions.eventually {+ assert isContainerRunning()++ // Below is here to check the macro executable attributes have been initialised+ def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)+ assert apartment1.getAttribute("nightScene").get().getValueAsString().orElse("") == "READY"+ }when: "a mock agent that uses the mock protocol is created"+ assetProcessingService.processors.add(mockDatapointServiceConsumer)+ assetProcessingService.processors.add(3, mockAssetStorageConsumer)+ assetProcessingService.processors.add(2, mockAgentServiceConsumer)+ assetProcessingService.processors.add(1, mockRulesServiceConsumer)+ assetProcessingService.processors.add(0, mockStartConsumer)def mockAgent = new ServerAsset()mockAgent.setName("Mock Agent")mockAgent.setType(AssetType.AGENT)@@ -118,34 +140,34 @@ class AssetProcessingTest extends Specification implements ManagerContainerTraitdef mockThing = new ServerAsset("Mock Thing Asset", AssetType.THING, mockAgent)mockThing.setAttributes(new AssetAttribute("light1Toggle", AttributeType.BOOLEAN, Values.create(false))- .setMeta(+ .setMeta(new MetaItem(- AssetMeta.DESCRIPTION,- Values.create("The switch for the light 1 in the living room")+ AssetMeta.DESCRIPTION,+ Values.create("The switch for the light 1 in the living room")),new MetaItem(- AssetMeta.AGENT_LINK,- new AttributeRef(mockAgent.getId(), "mock123").toArrayValue()+ AssetMeta.AGENT_LINK,+ new AttributeRef(mockAgent.getId(), "mock123").toArrayValue())- ),+ ),new AssetAttribute("light2Toggle", AttributeType.BOOLEAN, Values.create(false))- .setMeta(+ .setMeta(new MetaItem(- AssetMeta.DESCRIPTION,- Values.create("The switch for the light 2 in the living room")+ AssetMeta.DESCRIPTION,+ Values.create("The switch for the light 2 in the living room")),new MetaItem(- AssetMeta.AGENT_LINK,- new AttributeRef("INVALID AGENT ID", managerDemoSetup.agentProtocolConfigName).toArrayValue()+ AssetMeta.AGENT_LINK,+ new AttributeRef("INVALID AGENT ID", managerDemoSetup.agentProtocolConfigName).toArrayValue())- ),+ ),new AssetAttribute("plainAttribute", AttributeType.STRING, Values.create("demo"))- .setMeta(+ .setMeta(new MetaItem(- AssetMeta.DESCRIPTION,- Values.create("A plain string attribute for storing information")+ AssetMeta.DESCRIPTION,+ Values.create("A plain string attribute for storing information"))- )+ ))mockThing = assetStorageService.merge(mockThing)@@ -153,44 +175,48 @@ class AssetProcessingTest extends Specification implements ManagerContainerTraitconditions.eventually {assert protocolDeployed}-- when: "an attribute event occurs for the valid protocol attribute"+ when: "an attribute event occurs for a valid protocol linked attribute on the test asset"def light1toggleOn = new AttributeEvent(- new AttributeState(new AttributeRef(mockThing.getId(), "light1Toggle"), Values.create(true))+ new AttributeState(new AttributeRef(mockThing.getId(), "light1Toggle"), Values.create(false)))assetProcessingService.sendAttributeEvent(light1toggleOn)- then: "the attribute event should pass the start of the processing chain, reach the mock protocol and but not reach the end of the processing chain"+ then: "the attribute event should reach the protocol and stop at the agent service with a status of COMPLETED"conditions.eventually {assert updatesPassedStartOfProcessingChain.size() == 1- assert updatesReachedEndOfProcessingChain.size() == 0- assert sendToActuatorEvents.size() == 1- assert sendToActuatorEvents[0].entityId == mockThing.id- assert sendToActuatorEvents[0].attributeName == "light1Toggle"- assert Values.getBoolean(sendToActuatorEvents[0].attributeState.currentValue.orElse(null)).orElse(null)+ assert updatesPassedRulesService.size() == 1+ assert updatesPassedAgentService.size() == 0+ assert updatesPassedAssetStorageService.size() == 0+ assert updatesPassedDatapointService.size() == 0+ assert updatesPassedStartOfProcessingChain[0].attribute.getAssetId().orElse("") == mockThing.getId()+ assert updatesPassedStartOfProcessingChain[0].attribute.getName().orElse("") == "light1Toggle"+ assert !updatesPassedStartOfProcessingChain[0].getValueAsBoolean()+ assert updatesPassedStartOfProcessingChain[0].error == nullassert updatesPassedStartOfProcessingChain[0].processingStatus == AssetState.ProcessingStatus.COMPLETED+ assert sendToActuatorEvents.size() == 1}- when: "the protocol gets a response from the server"+ when: "the protocol updates the attributes value with the value it just received"mockProtocol.responseReceived()- //region then: "the protocol should have sent a new attribute event for the sensor change which should pass the start of the processing chain skip the protocol but still reach the end of the processing chain- then: "the protocol should have sent a new attribute event for the sensor change which should pass the start of the processing chain skip the protocol but still reach the end of the processing chain"+ then: "a new attribute event should occur and reach the end of the processing chain"conditions.eventually {assert updatesPassedStartOfProcessingChain.size() == 2- assert sendToActuatorEvents.size() == 1- assert updatesReachedEndOfProcessingChain.size() == 1- assert updatesReachedEndOfProcessingChain[0].name == "Mock Thing Asset"- assert updatesReachedEndOfProcessingChain[0].attributeName == "light1Toggle"- assert !Values.getBoolean(updatesReachedEndOfProcessingChain[0].oldValue).orElse(null)- assert Values.getBoolean(updatesReachedEndOfProcessingChain[0].value).orElse(null)- assert updatesReachedEndOfProcessingChain[0].processingStatus == AssetState.ProcessingStatus.COMPLETED+ assert updatesPassedRulesService.size() == 2+ assert updatesPassedAgentService.size() == 1+ assert updatesPassedAssetStorageService.size() == 1+ assert updatesPassedDatapointService.size() == 1+ assert updatesPassedStartOfProcessingChain[1].attribute.getAssetId().orElse("") == mockThing.getId()+ assert updatesPassedStartOfProcessingChain[1].attribute.getName().orElse("") == "light1Toggle"+ assert !Values.getBoolean(updatesPassedStartOfProcessingChain[1].getOldValue()).orElse(true)+ assert !updatesPassedStartOfProcessingChain[1].getValueAsBoolean()+ assert updatesPassedStartOfProcessingChain[1].error == null+ assert updatesPassedStartOfProcessingChain[1].processingStatus == AssetState.ProcessingStatus.COMPLETED}- //endregionwhen: "an attribute event occurs for the invalid protocol attribute"updatesPassedStartOfProcessingChain.clear()- updatesReachedEndOfProcessingChain.clear()+ updatesPassedDatapointService.clear()sendToActuatorEvents.clear()def light2toggleOn = new AttributeEvent(new AttributeState(new AttributeRef(mockThing.getId(), "light2Toggle"), Values.create(true))@@ -200,7 +226,7 @@ class AssetProcessingTest extends Specification implements ManagerContainerTraitthen: "the attribute event should pass the start of the processing chain, but not reach the mock protocol or the end of the processing chain and error should be populated"conditions.eventually {assert updatesPassedStartOfProcessingChain.size() == 1- assert updatesReachedEndOfProcessingChain.size() == 0+ assert updatesPassedDatapointService.size() == 0assert sendToActuatorEvents.size() == 0assert updatesPassedStartOfProcessingChain[0].id == mockThing.idassert updatesPassedStartOfProcessingChain[0].attributeName == "light2Toggle"@@ -211,7 +237,7 @@ class AssetProcessingTest extends Specification implements ManagerContainerTraitwhen: "an attribute event occurs for the plain attribute"updatesPassedStartOfProcessingChain.clear()- updatesReachedEndOfProcessingChain.clear()+ updatesPassedDatapointService.clear()sendToActuatorEvents.clear()def plainAttributeTest = new AttributeEvent(new AttributeState(new AttributeRef(mockThing.getId(), "plainAttribute"), Values.create("test"))@@ -222,13 +248,13 @@ class AssetProcessingTest extends Specification implements ManagerContainerTraitconditions.eventually {assert updatesPassedStartOfProcessingChain.size() == 1assert sendToActuatorEvents.size() == 0- assert updatesReachedEndOfProcessingChain.size() == 1- assert updatesReachedEndOfProcessingChain[0].name == "Mock Thing Asset"- assert updatesReachedEndOfProcessingChain[0].attributeName == "plainAttribute"- assert Values.getString(updatesReachedEndOfProcessingChain[0].oldValue).orElse(null) == "demo"- assert Values.getString(updatesReachedEndOfProcessingChain[0].value).orElse(null) == "test"- assert updatesReachedEndOfProcessingChain[0].error == null- assert updatesReachedEndOfProcessingChain[0].processingStatus == AssetState.ProcessingStatus.COMPLETED+ assert updatesPassedDatapointService.size() == 1+ assert updatesPassedDatapointService[0].name == "Mock Thing Asset"+ assert updatesPassedDatapointService[0].attributeName == "plainAttribute"+ assert Values.getString(updatesPassedDatapointService[0].oldValue).orElse(null) == "demo"+ assert Values.getString(updatesPassedDatapointService[0].value).orElse(null) == "test"+ assert updatesPassedDatapointService[0].error == null+ assert updatesPassedDatapointService[0].processingStatus == AssetState.ProcessingStatus.COMPLETED}}}diff --git a/manager/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy b/manager/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovyindex dc8b4711c..7cfc43791 100644--- a/manager/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy@@ -24,7 +24,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {def "Query assets"() {given: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)def assetStorageService = container.getService(AssetStorageService.class)@@ -40,7 +40,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {then: "result should match (and some values should be empty because we need an AssetQuery to get them)"asset.id == managerDemoSetup.apartment1Id- asset.version == 0+ asset.version == 1asset.createdOn.time < System.currentTimeMillis()asset.name == "Apartment 1"asset.wellKnownType == AssetType.RESIDENCE@@ -161,7 +161,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {then: "result should match"assets.size() == 3assets.get(0).id == managerDemoSetup.apartment1Id- assets.get(0).version == 0+ assets.get(0).version == 1assets.get(0).createdOn.time < System.currentTimeMillis()assets.get(0).name == "Apartment 1"assets.get(0).wellKnownType == AssetType.RESIDENCE@@ -221,10 +221,11 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {)then: "result should match"- assets.size() == 3+ assets.size() == 4assets.get(0).id == managerDemoSetup.apartment1Idassets.get(1).id == managerDemoSetup.apartment1LivingroomIdassets.get(2).id == managerDemoSetup.apartment1LivingroomThermostatId+ assets.get(3).id == managerDemoSetup.apartment1SceneAgentIdwhen: "a query is executed"assets = assetStorageService.findAll(@@ -250,8 +251,8 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {assets.get(2).getAttributesList().size() == 2!assets.get(2).getAttribute("currentTemperature").get().getValue().isPresent()assets.get(2).getAttribute("currentTemperature").get().meta.size() == 3- !assets.get(2).getAttribute("comfortTemperature").get().getValue().isPresent()- assets.get(2).getAttribute("comfortTemperature").get().meta.size() == 2+ !assets.get(2).getAttribute("targetTemperature").get().getValue().isPresent()+ assets.get(2).getAttribute("targetTemperature").get().meta.size() == 2assets.get(3).id == managerDemoSetup.apartment2Idwhen: "a query is executed"@@ -276,8 +277,9 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {)then: "result should match"- assets.size() == 1+ assets.size() == 2assets.get(0).id == managerDemoSetup.agentId+ assets.get(1).id == managerDemoSetup.apartment1SceneAgentIdwhen: "a query is executed"assets = assetStorageService.findAll(new AssetQuery()diff --git a/manager/test/src/test/groovy/org/openremote/test/map/MapResourceTest.groovy b/manager/test/src/test/groovy/org/openremote/test/map/MapResourceTest.groovyindex 972db7f9f..df490b4a3 100644--- a/manager/test/src/test/groovy/org/openremote/test/map/MapResourceTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/map/MapResourceTest.groovy@@ -14,7 +14,7 @@ class MapResourceTest extends Specification implements ManagerContainerTrait {def "Retrieve map settings"() {given: "the server container is started"def serverPort = findEphemeralPort();- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerMinimal(defaultConfig(serverPort), defaultServices())and: "an authenticated user"def realm = MASTER_REALM;diff --git a/manager/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy b/manager/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovynew file mode 100644index 000000000..dc8fcbfb3--- /dev/null+++ b/manager/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy@@ -0,0 +1,320 @@+/*+ * Copyright 2017, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.test.protocol++import org.openremote.agent3.protocol.AbstractProtocol+import org.openremote.agent3.protocol.Protocol+import org.openremote.manager.server.agent.AgentService+import org.openremote.manager.server.asset.AssetStorageService+import org.openremote.manager.server.asset.ServerAsset+import org.openremote.model.Constants+import org.openremote.model.asset.AssetAttribute+import org.openremote.model.asset.AssetMeta+import org.openremote.model.asset.AssetType+import org.openremote.model.asset.agent.ProtocolConfiguration+import org.openremote.model.attribute.AttributeEvent+import org.openremote.model.attribute.AttributeRef+import org.openremote.model.attribute.AttributeType+import org.openremote.model.attribute.MetaItem+import org.openremote.model.value.Values+import org.openremote.test.ManagerContainerTrait+import spock.lang.Specification+import spock.util.concurrent.PollingConditions++import java.util.logging.Logger+/**+ * This tests the basic protocol interface and abstract protocol implementation.+ */+class BasicProtocolTest extends Specification implements ManagerContainerTrait {+ Logger LOG = Logger.getLogger(BasicProtocolTest.class.getName())++ def "Check processing of asset updates"() {++ given: "expected conditions"+ def conditions = new PollingConditions(timeout: 10, delay: 1)++ and: "a mock protocol"+ def mockProtocolName = Constants.PROTOCOL_NAMESPACE + ":mockProtocol"+ Map<String, Integer> protocolExpectedLinkedAttributeCount = [:]+ protocolExpectedLinkedAttributeCount['mockConfig1'] = 2+ protocolExpectedLinkedAttributeCount['mockConfig2'] = 2+ protocolExpectedLinkedAttributeCount['mockConfig3'] = 2+ protocolExpectedLinkedAttributeCount['mockConfig4'] = 2+ List<AssetAttribute> protocolLinkedConfigurations = []+ Map<String, List<AssetAttribute>> protocolLinkedAttributes = [:]+ protocolLinkedAttributes['mockConfig1'] = []+ protocolLinkedAttributes['mockConfig2'] = []+ protocolLinkedAttributes['mockConfig3'] = []+ protocolLinkedAttributes['mockConfig4'] = []+ List<AttributeEvent> protocolWriteAttributes = []+ List<String> protocolMethodCalls = []+ def mockProtocol = new AbstractProtocol() {+ protected void responseReceived() {+ // Assume we've pushed the update to the actual device and it responded with OK+ // so now we want to cause a sensor update that will go through the processing+ // chain.+ updateLinkedAttribute(protocolWriteAttributes.last().getAttributeState())+ }++ @Override+ protected void doLinkProtocolConfiguration(AssetAttribute protocolConfiguration) {+ protocolMethodCalls.add("LINK_PROTOCOL")+ protocolLinkedConfigurations.add(protocolConfiguration)+ if (!protocolConfiguration.getMetaItem("MOCK_REQUIRED_META").isPresent()) {+ updateDeploymentStatus(protocolConfiguration.getReferenceOrThrow(), Protocol.DeploymentStatus.ERROR)+ } else if(protocolConfiguration.getMetaItem("MOCK_THROW_EXCEPTION").isPresent()) {+ throw new IllegalStateException("Exception occurred whilst linking the protocol configuration")+ } else if (protocolConfiguration.isEnabled()) {+ updateDeploymentStatus(protocolConfiguration.getReferenceOrThrow(), Protocol.DeploymentStatus.LINKED_ENABLED)+ } else {+ updateDeploymentStatus(protocolConfiguration.getReferenceOrThrow(), Protocol.DeploymentStatus.LINKED_DISABLED)+ }+ }++ @Override+ protected void doUnlinkProtocolConfiguration(AssetAttribute protocolConfiguration) {+ protocolMethodCalls.add("UNLINK_PROTOCOL")+ protocolLinkedConfigurations.removeAll { it.getReferenceOrThrow().equals(protocolConfiguration.getReferenceOrThrow()) }+ }++ @Override+ protected void doLinkAttribute(AssetAttribute attribute, AssetAttribute protocolConfiguration) {+ protocolMethodCalls.add("LINK_ATTRIBUTE")++ if (!attribute.getMetaItem("MOCK_ATTRIBUTE_REQUIRED_META").isPresent()) {+ // This tests exception handling during linking of attributes+ throw new IllegalStateException("Attribute is not valid");+ }+ protocolLinkedAttributes[protocolConfiguration.getName().orElse("")] << attribute+ }++ @Override+ protected void doUnlinkAttribute(AssetAttribute attribute, AssetAttribute protocolConfiguration) {+ protocolMethodCalls.add("UNLINK_ATTRIBUTE")+ (protocolLinkedAttributes[protocolConfiguration.getName().orElse("")])+ .removeAll { it.getReferenceOrThrow().equals(attribute.getReferenceOrThrow()) }+ }++ @Override+ protected void processLinkedAttributeWrite(AttributeEvent event, AssetAttribute protocolConfiguration) {+ protocolMethodCalls.add("ATTRIBUTE_WRITE")+ if (!(protocolLinkedAttributes[protocolConfiguration.getName().orElse("")])+ .any {it.getReferenceOrThrow().equals(event.attributeRef)}) {+ throw new IllegalStateException("Attribute is not linked")+ }+ protocolWriteAttributes.add(event)+ }++ @Override+ String getProtocolName() {+ return mockProtocolName+ }+ }++ and: "the container is started with the mock protocol"+ def serverPort = findEphemeralPort()+ def container = startContainerMinimal(defaultConfig(serverPort), defaultServices(mockProtocol))+ def assetStorageService = container.getService(AssetStorageService.class)+ def agentService = container.getService(AgentService.class)++ when: "a mock agent that uses the mock protocol is created with a valid protocol configuration"+ def mockAgent = new ServerAsset()+ mockAgent.setName("Mock Agent")+ mockAgent.setType(AssetType.AGENT)+ mockAgent.setAttributes(+ ProtocolConfiguration.initProtocolConfiguration(new AssetAttribute("mockConfig1"), mockProtocolName)+ .setMeta(+ new MetaItem("MOCK_REQUIRED_META", Values.create(true))+ ),+ ProtocolConfiguration.initProtocolConfiguration(new AssetAttribute("mockConfig2"), mockProtocolName),+ ProtocolConfiguration.initProtocolConfiguration(new AssetAttribute("mockConfig3"), mockProtocolName)+ .setMeta(+ new MetaItem("MOCK_THROW_EXCEPTION", Values.create(""))+ ),+ ProtocolConfiguration.initProtocolConfiguration(new AssetAttribute("mockConfig4"), mockProtocolName)+ .setMeta(+ new MetaItem("MOCK_REQUIRED_META", Values.create(true)),+ new MetaItem(AssetMeta.ENABLED, Values.create(false))+ )+ )+ mockAgent.setRealmId(Constants.MASTER_REALM)+ mockAgent = assetStorageService.merge(mockAgent)++ then: "the protocol configurations should be linked and their deployment status should be available in the agent service"+ conditions.eventually {+ assert protocolLinkedConfigurations.size() == 4+ def config1 = protocolLinkedConfigurations.find { it.getName().orElse("").equals("mockConfig1") }+ def config2 = protocolLinkedConfigurations.find { it.getName().orElse("").equals("mockConfig2") }+ def config3 = protocolLinkedConfigurations.find { it.getName().orElse("").equals("mockConfig3") }+ def config4 = protocolLinkedConfigurations.find { it.getName().orElse("").equals("mockConfig4") }+ assert config1 != null+ assert config2 != null+ assert config3 != null+ assert config4 != null+ assert agentService.getProtocolDeploymentStatus(config1.getReferenceOrThrow()) == Protocol.DeploymentStatus.LINKED_ENABLED+ assert agentService.getProtocolDeploymentStatus(config2.getReferenceOrThrow()) == Protocol.DeploymentStatus.ERROR+ assert agentService.getProtocolDeploymentStatus(config3.getReferenceOrThrow()) == Protocol.DeploymentStatus.ERROR+ assert agentService.getProtocolDeploymentStatus(config4.getReferenceOrThrow()) == Protocol.DeploymentStatus.LINKED_DISABLED+ }++ when: "a mock thing asset is created that links to the mock protocol configurations"+ def mockThing = new ServerAsset("Mock Thing Asset", AssetType.THING, mockAgent)+ mockThing.setAttributes(+ new AssetAttribute("light1Toggle", AttributeType.BOOLEAN, Values.create(false))+ .setMeta(+ new MetaItem("MOCK_ATTRIBUTE_REQUIRED_META"),+ new MetaItem(+ AssetMeta.AGENT_LINK,+ new AttributeRef(mockAgent.getId(), "mockConfig1").toArrayValue()+ )+ ),+ new AssetAttribute("temp1Target", AttributeType.BOOLEAN)+ .setMeta(+ new MetaItem("MOCK_ATTRIBUTE_REQUIRED_META"),+ new MetaItem(+ AssetMeta.AGENT_LINK,+ new AttributeRef(mockAgent.getId(), "mockConfig1").toArrayValue()+ )+ ),+ new AssetAttribute("invalid1Toggle", AttributeType.BOOLEAN, Values.create(false))+ .setMeta(+ new MetaItem(+ AssetMeta.AGENT_LINK,+ new AttributeRef(mockAgent.getId(), "mockConfig1").toArrayValue()+ )+ ),+ new AssetAttribute("light2Toggle", AttributeType.BOOLEAN, Values.create(false))+ .setMeta(+ new MetaItem("MOCK_ATTRIBUTE_REQUIRED_META"),+ new MetaItem(+ AssetMeta.AGENT_LINK,+ new AttributeRef(mockAgent.getId(), "mockConfig2").toArrayValue()+ )+ ),+ new AssetAttribute("temp2Target", AttributeType.BOOLEAN)+ .setMeta(+ new MetaItem("MOCK_ATTRIBUTE_REQUIRED_META"),+ new MetaItem(+ AssetMeta.AGENT_LINK,+ new AttributeRef(mockAgent.getId(), "mockConfig2").toArrayValue()+ )+ ),+ new AssetAttribute("light3Toggle", AttributeType.BOOLEAN, Values.create(false))+ .setMeta(+ new MetaItem("MOCK_ATTRIBUTE_REQUIRED_META"),+ new MetaItem(+ AssetMeta.AGENT_LINK,+ new AttributeRef(mockAgent.getId(), "mockConfig3").toArrayValue()+ )+ ),+ new AssetAttribute("temp3Target", AttributeType.BOOLEAN)+ .setMeta(+ new MetaItem("MOCK_ATTRIBUTE_REQUIRED_META"),+ new MetaItem(+ AssetMeta.AGENT_LINK,+ new AttributeRef(mockAgent.getId(), "mockConfig3").toArrayValue()+ )+ ),+ new AssetAttribute("light4Toggle", AttributeType.BOOLEAN, Values.create(false))+ .setMeta(+ new MetaItem("MOCK_ATTRIBUTE_REQUIRED_META"),+ new MetaItem(+ AssetMeta.AGENT_LINK,+ new AttributeRef(mockAgent.getId(), "mockConfig4").toArrayValue()+ )+ ),+ new AssetAttribute("temp4Target", AttributeType.BOOLEAN)+ .setMeta(+ new MetaItem("MOCK_ATTRIBUTE_REQUIRED_META"),+ new MetaItem(+ AssetMeta.AGENT_LINK,+ new AttributeRef(mockAgent.getId(), "mockConfig4").toArrayValue()+ )+ ),+ new AssetAttribute("invalid5Toggle", AttributeType.BOOLEAN, Values.create(false))+ .setMeta(+ new MetaItem(+ AssetMeta.AGENT_LINK,+ new AttributeRef(mockAgent.getId(), "INVALID CONFIG").toArrayValue()+ )+ ),+ new AssetAttribute("plainAttribute", AttributeType.STRING, Values.create("demo"))+ .setMeta(+ new MetaItem(+ AssetMeta.DESCRIPTION,+ Values.create("A plain string attribute for storing information")+ )+ )+ )+ mockThing = assetStorageService.merge(mockThing)++ then: "the mock thing to be fully deployed"+ conditions.eventually {+ assert protocolLinkedAttributes['mockConfig1'].size() == protocolExpectedLinkedAttributeCount['mockConfig1']+ assert protocolLinkedAttributes['mockConfig2'].size() == protocolExpectedLinkedAttributeCount['mockConfig2']+ assert protocolLinkedAttributes['mockConfig3'].size() == protocolExpectedLinkedAttributeCount['mockConfig3']+ assert protocolLinkedAttributes['mockConfig4'].size() == protocolExpectedLinkedAttributeCount['mockConfig4']+ }++ and: "the deployment should have occurred in the correct order"+ assert protocolMethodCalls.size() == 13+ assert protocolMethodCalls[0] == "LINK_PROTOCOL"+ assert protocolMethodCalls[1] == "LINK_PROTOCOL"+ assert protocolMethodCalls[2] == "LINK_PROTOCOL"+ assert protocolMethodCalls[3] == "LINK_PROTOCOL"+ assert protocolMethodCalls[4] == "LINK_ATTRIBUTE"+ assert protocolMethodCalls[5] == "LINK_ATTRIBUTE"+ assert protocolMethodCalls[6] == "LINK_ATTRIBUTE"+ assert protocolMethodCalls[7] == "LINK_ATTRIBUTE"+ assert protocolMethodCalls[8] == "LINK_ATTRIBUTE"+ assert protocolMethodCalls[9] == "LINK_ATTRIBUTE"+ assert protocolMethodCalls[10] == "LINK_ATTRIBUTE"+ assert protocolMethodCalls[11] == "LINK_ATTRIBUTE"+ assert protocolMethodCalls[12] == "LINK_ATTRIBUTE"++ when: "a linked attribute is removed"+ protocolMethodCalls.clear()+ mockThing.removeAttribute("temp3Target")+ mockThing = assetStorageService.merge(mockThing)++ then: "the protocol should not be unlinked"+ conditions.eventually {+ assert protocolLinkedAttributes['mockConfig3'].size() == 1+ assert protocolMethodCalls.size() == 1+ assert protocolMethodCalls[0] == "UNLINK_ATTRIBUTE"+ }++ when: "a protocol configuration is removed"+ protocolMethodCalls.clear()+ mockAgent.removeAttribute("mockConfig4")+ mockAgent = assetStorageService.merge(mockAgent)++ then: "the attributes should be unlinked then the protocol configuration"+ conditions.eventually {+ assert protocolLinkedAttributes["mockConfig4"].size() == 0+ assert protocolMethodCalls.size() == 3+ assert protocolMethodCalls[0] == "UNLINK_ATTRIBUTE"+ assert protocolMethodCalls[1] == "UNLINK_ATTRIBUTE"+ assert protocolMethodCalls[2] == "UNLINK_PROTOCOL"+ }++ // TODO: Extend this test+ }+}\ No newline at end of filediff --git a/manager/test/src/test/groovy/org/openremote/test/protocol/MacroProtocolTest.groovy b/manager/test/src/test/groovy/org/openremote/test/protocol/MacroProtocolTest.groovynew file mode 100644index 000000000..adc7088f7--- /dev/null+++ b/manager/test/src/test/groovy/org/openremote/test/protocol/MacroProtocolTest.groovy@@ -0,0 +1,72 @@+package org.openremote.test.protocol++import org.openremote.manager.server.asset.AssetProcessingService+import org.openremote.manager.server.asset.AssetStorageService+import org.openremote.manager.server.setup.SetupService+import org.openremote.manager.server.setup.builtin.ManagerDemoSetup+import org.openremote.model.attribute.AttributeEvent+import org.openremote.model.attribute.AttributeExecuteStatus+import org.openremote.test.ManagerContainerTrait+import spock.lang.Specification+import spock.util.concurrent.PollingConditions++class MacroProtocolTest extends Specification implements ManagerContainerTrait {+ def "Check macro agent and device asset deployment"() {++ given: "expected conditions"+ def conditions = new PollingConditions(timeout: 10, initialDelay: 0)++ when: "the container starts"+ def serverPort = findEphemeralPort()+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())+ def assetStorageService = container.getService(AssetStorageService.class)+ def assetProcessingService = container.getService(AssetProcessingService.class)+ def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)++ then: "the container should be running"+ conditions.eventually {+ assert isContainerRunning()+ }++ when: "Apartment 1 home scene is executed"+ def macroExecute = new AttributeEvent(managerDemoSetup.apartment1Id, "homeScene", AttributeExecuteStatus.REQUEST_START.asValue())+ assetProcessingService.sendAttributeEvent(macroExecute)++ then: "Apartment 1 alarm enabled, last scene and living room target temp attribute values should be update to match the scene"+ conditions.eventually {+ def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)+ def thermostat1 = assetStorageService.find(managerDemoSetup.apartment1LivingroomThermostatId, true)+ assert !apartment1.getAttribute("alarmEnabled").get().getValueAsBoolean().orElse(true)+ assert apartment1.getAttribute("lastExecutedScene").get().getValueAsString().orElse("") == "HOME"+ assert thermostat1.getAttribute("targetTemperature").get().getValueAsNumber().orElse(0d) == 21d+ }++ then: "Apartment 1 home scene attribute status should show as COMPLETED"+ conditions.eventually {+ def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)+ assert apartment1.getAttribute("homeScene").get().getValueAsString().orElse("") == AttributeExecuteStatus.COMPLETED.toString()+ }++ when: "Apartment 1 away scene is executed"+ macroExecute = new AttributeEvent(managerDemoSetup.apartment1Id, "awayScene", AttributeExecuteStatus.REQUEST_START.asValue())+ assetProcessingService.sendAttributeEvent(macroExecute)++ then: "Apartment 1 alarm enabled, last scene and living room target temp attribute values should be update to match the scene"+ conditions.eventually {+ def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)+ def thermostat1 = assetStorageService.find(managerDemoSetup.apartment1LivingroomThermostatId, true)+ assert apartment1.getAttribute("alarmEnabled").get().getValueAsBoolean().orElse(false)+ assert apartment1.getAttribute("lastExecutedScene").get().getValueAsString().orElse("") == "AWAY"+ assert thermostat1.getAttribute("targetTemperature").get().getValueAsNumber().orElse(0d) == 15d+ }++ then: "Apartment 1 away scene attribute status should show as COMPLETED"+ conditions.eventually {+ def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)+ assert apartment1.getAttribute("awayScene").get().getValueAsString().orElse("") == AttributeExecuteStatus.COMPLETED.toString()+ }++ cleanup: "the server should be stopped"+ stopContainer(container)+ }+}\ No newline at end of filediff --git a/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovy b/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovyindex 5a410d007..fd7f407bf 100644--- a/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovy@@ -28,7 +28,7 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainerand: "the container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)def rulesService = container.getService(RulesService.class)diff --git a/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy b/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovyindex 38e119967..5023fbd4d 100644--- a/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy@@ -79,7 +79,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerand: "the container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)def rulesService = container.getService(RulesService.class)@@ -187,7 +187,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerand: "the container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)def rulesService = container.getService(RulesService.class)@@ -274,7 +274,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerand: "the container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)def rulesService = container.getService(RulesService.class)@@ -446,7 +446,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerand: "the container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)def rulesService = container.getService(RulesService.class)diff --git a/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesTimedExecutionTest.groovy b/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesTimedExecutionTest.groovyindex 08eeb1e4b..5b754e795 100644--- a/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesTimedExecutionTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesTimedExecutionTest.groovy@@ -31,7 +31,7 @@ class BasicRulesTimedExecutionTest extends Specification implements ManagerContaand: "the container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def rulesService = container.getService(RulesService.class)def rulesetStorageService = container.getService(RulesetStorageService.class)@@ -73,7 +73,7 @@ class BasicRulesTimedExecutionTest extends Specification implements ManagerContagiven: "the container environment is started"def conditions = new PollingConditions(timeout: 10, delay: 1)def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort) << [(TIMER_CLOCK_TYPE): PSEUDO.name()], defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort) << [(TIMER_CLOCK_TYPE): PSEUDO.name()], defaultServices())def rulesService = container.getService(RulesService.class)def rulesetStorageService = container.getService(RulesetStorageService.class)diff --git a/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy b/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovyindex 593174a4b..a489688d7 100644--- a/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy@@ -25,7 +25,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerdef "Access rules as superuser"() {given: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def rulesetStorageService = container.getService(RulesetStorageService.class)def rulesService = container.getService(RulesService.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)@@ -295,7 +295,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainergiven: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def rulesetStorageService = container.getService(RulesetStorageService.class)def rulesService = container.getService(RulesService.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)@@ -525,7 +525,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainergiven: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def rulesetStorageService = container.getService(RulesetStorageService.class)def rulesService = container.getService(RulesService.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)@@ -673,7 +673,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainergiven: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def rulesetStorageService = container.getService(RulesetStorageService.class)def rulesService = container.getService(RulesService.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)diff --git a/manager/test/src/test/groovy/org/openremote/test/user/NotificationServiceTest.groovy b/manager/test/src/test/groovy/org/openremote/test/user/NotificationServiceTest.groovyindex 67b3872f7..0f64d7fd9 100644--- a/manager/test/src/test/groovy/org/openremote/test/user/NotificationServiceTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/user/NotificationServiceTest.groovy@@ -19,7 +19,7 @@ class NotificationServiceTest extends Specification implements ManagerContainerTgiven: "the server container is started"def serverPort = findEphemeralPort()- def container = startContainerWithoutDemoRules(defaultConfig(serverPort), defaultServices())+ def container = startContainerNoDemoRules(defaultConfig(serverPort), defaultServices())def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)def notificationService = container.getService(NotificationService.class)diff --git a/manager/test/src/test/resources/org/openremote/test/rules/BasicSmartHomeMatchAllAssetStates.drl b/manager/test/src/test/resources/org/openremote/test/rules/BasicSmartHomeMatchAllAssetStates.drlindex ba5d42c70..973970013 100644--- a/manager/test/src/test/resources/org/openremote/test/rules/BasicSmartHomeMatchAllAssetStates.drl+++ b/manager/test/src/test/resources/org/openremote/test/rules/BasicSmartHomeMatchAllAssetStates.drl@@ -36,7 +36,7 @@ endrule "Living Room Comfort Temperature"when- $e: AssetState(name == "Living Room Thermostat", attributeName == "comfortTemperature")+ $e: AssetState(name == "Living Room Thermostat", attributeName == "targetTemperature")thenreturn;end