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
test robustness and bug fixes
Rich Turner7b499b726021
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusNetwork.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusNetwork.javaindex b3724c939..4e70517e0 100644--- a/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusNetwork.java+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusNetwork.java@@ -19,7 +19,6 @@*/package org.openremote.agent.protocol.velbus;-import org.openremote.agent.protocol.ProtocolExecutorService;import org.openremote.agent.protocol.io.IoClient;import org.openremote.agent.protocol.velbus.device.DevicePropertyValue;import org.openremote.agent.protocol.velbus.device.VelbusDevice;diff --git a/manager/src/main/java/org/openremote/manager/rules/RulesEngine.java b/manager/src/main/java/org/openremote/manager/rules/RulesEngine.javaindex 675d21c52..41f6f8501 100644--- a/manager/src/main/java/org/openremote/manager/rules/RulesEngine.java+++ b/manager/src/main/java/org/openremote/manager/rules/RulesEngine.java@@ -443,6 +443,8 @@ public class RulesEngine<T extends Ruleset> {fireTimer = executorService.schedule(() -> withLock(RulesEngine.this.toString() + "::fire", () -> {+ fireTimer = null;+// Are temporary facts present before rules are fired?boolean hadTemporaryFactsBefore = facts.hasTemporaryFacts();diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.javaindex 54f1f2c55..b1548e7cc 100644--- a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java@@ -54,7 +54,7 @@ public class ManagerDemoSetup extends AbstractManagerSetup {public static final int DEMO_RULE_STATES_APARTMENT_3 = 0;public static final int DEMO_RULE_STATES_SMART_OFFICE = 1;public static final int DEMO_RULE_STATES_SMART_BUILDING = DEMO_RULE_STATES_APARTMENT_1 + DEMO_RULE_STATES_APARTMENT_2 + DEMO_RULE_STATES_APARTMENT_3;- public static final int DEMO_RULE_STATES_SMART_CITY = 44;+ public static final int DEMO_RULE_STATES_SMART_CITY = 47;public static final int DEMO_RULE_STATES_GLOBAL = DEMO_RULE_STATES_SMART_BUILDING + DEMO_RULE_STATES_SMART_OFFICE + DEMO_RULE_STATES_SMART_CITY;public static final int DEMO_RULE_STATES_APARTMENT_1_WITH_SCENES = DEMO_RULE_STATES_APARTMENT_1 + 28;public static final int DEMO_RULE_STATES_SMART_BUILDING_WITH_SCENES = DEMO_RULE_STATES_APARTMENT_1_WITH_SCENES + DEMO_RULE_STATES_APARTMENT_2 + DEMO_RULE_STATES_APARTMENT_3;diff --git a/test/src/main/groovy/org/openremote/test/ContainerTrait.groovy b/test/src/main/groovy/org/openremote/test/ContainerTrait.groovyindex 2bd18f7b7..e7943f670 100644--- a/test/src/main/groovy/org/openremote/test/ContainerTrait.groovy+++ b/test/src/main/groovy/org/openremote/test/ContainerTrait.groovy@@ -270,7 +270,7 @@ trait ContainerTrait {UriBuilder serverUri(int serverPort) {UriBuilder.fromUri("")- .scheme("http").host("localhost").port(serverPort)+ .scheme("http").host("127.0.0.1").port(serverPort)}void stopContainer() {diff --git a/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy b/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovyindex 7260dd942..83647c271 100644--- a/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy+++ b/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy@@ -7,11 +7,13 @@ import org.openremote.container.ContainerServiceimport org.openremote.container.message.MessageBrokerServiceimport org.openremote.container.timer.TimerServiceimport org.openremote.manager.asset.AssetProcessingService+import org.openremote.manager.rules.RulesServiceimport spock.util.concurrent.PollingConditionsimport java.util.concurrent.TimeUnitimport java.util.stream.Collectors+import static org.openremote.container.security.keycloak.KeycloakIdentityProvider.IDENTITY_NETWORK_HOSTimport static org.openremote.container.security.keycloak.KeycloakIdentityProvider.IDENTITY_NETWORK_WEBSERVER_PORTimport static org.openremote.container.timer.TimerService.Clock.PSEUDOimport static org.openremote.container.timer.TimerService.Clock.REAL@@ -29,6 +31,7 @@ trait ManagerContainerTrait extends ContainerTrait {[(WEBSERVER_LISTEN_PORT) : Integer.toString(serverPort),(IDENTITY_NETWORK_WEBSERVER_PORT): Integer.toString(serverPort),+ (IDENTITY_NETWORK_HOST) : "127.0.0.1",(SETUP_IMPORT_DEMO_ASSETS) : "true",(SETUP_IMPORT_DEMO_USERS) : "true",(SETUP_IMPORT_DEMO_SCENES) : "false",@@ -69,6 +72,16 @@ trait ManagerContainerTrait extends ContainerTrait {&& assetProcessingService.lastProcessedEventTimestamp + milliseconds < System.currentTimeMillis())}+ boolean noRuleEngineFiringScheduled() {+ if (!this.container) {+ return false+ }++ def rulesService = this.container.getService(RulesService.class)++ return (rulesService.globalEngine == null || rulesService.globalEngine.fireTimer == null) && rulesService.tenantEngines.values().every {it.fireTimer == null} && rulesService.assetEngines.values().every {it.fireTimer == null}+ }+/*** Execute pseudo clock operations in Container.*/diff --git a/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy b/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovyindex 73cd88f82..7fbcb4823 100644--- a/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy+++ b/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy@@ -93,9 +93,9 @@ class GatewayTest extends Specification implements ManagerContainerTrait {when: "the Gateway client is created"def gatewayClient = new WebsocketIoClient<String>(- new URIBuilder("ws://localhost:$serverPort/websocket/events?Auth-Realm=$managerDemoSetup.realmBuildingTenant").build(),+ new URIBuilder("ws://127.0.0.1:$serverPort/websocket/events?Auth-Realm=$managerDemoSetup.realmBuildingTenant").build(),null,- new OAuthClientCredentialsGrant("http://localhost:$serverPort/auth/realms/$managerDemoSetup.realmBuildingTenant/protocol/openid-connect/token",+ new OAuthClientCredentialsGrant("http://127.0.0.1:$serverPort/auth/realms/$managerDemoSetup.realmBuildingTenant/protocol/openid-connect/token",gateway.getAttribute("clientId").flatMap{it.getValueAsString()}.orElse(""),gateway.getAttribute("clientSecret").flatMap{it.getValueAsString()}.orElse(""),null).setBasicAuthHeader(true),@@ -886,7 +886,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {when: "a gateway client connection is created to connect the city realm to the gateway"def gatewayConnection = new GatewayConnection(- "localhost",+ "127.0.0.1",serverPort,managerDemoSetup.realmBuildingTenant,gateway.getAttribute("clientId").flatMap{it.getValueAsString()}.orElse(""),@@ -910,7 +910,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {and: "the fake mirrored assets should have been created under the gateway asset"conditions.eventually {def fakeAssets = assetStorageService.findAll(new AssetQuery().parents(gateway.id).recursive(true))- fakeAssets.size() == realIdToFakeIdMap.size()+ assert fakeAssets.size() == realIdToFakeIdMap.size()}when: "a gateway client asset is modified"diff --git a/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovyindex e0691b1d0..4082c5e22 100644--- a/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy@@ -93,8 +93,8 @@ class KNXProtocolTest extends Specification implements ManagerContainerTrait {knxAgent.setAttributes(ProtocolConfiguration.initProtocolConfiguration(new AssetAttribute("knxConfig"), KNXProtocol.PROTOCOL_NAME).addMeta(- new MetaItem(KNXProtocol.META_KNX_GATEWAY_HOST, Values.create("localhost")),- new MetaItem(KNXProtocol.META_KNX_LOCAL_HOST, Values.create("localhost"))+ new MetaItem(KNXProtocol.META_KNX_GATEWAY_HOST, Values.create("127.0.0.1")),+ new MetaItem(KNXProtocol.META_KNX_LOCAL_HOST, Values.create("127.0.0.1"))),ProtocolConfiguration.initProtocolConfiguration(new AssetAttribute("knxConfigError1"), KNXProtocol.PROTOCOL_NAME),ProtocolConfiguration.initProtocolConfiguration(new AssetAttribute("knxConfigError2"), KNXProtocol.PROTOCOL_NAME)@@ -134,7 +134,7 @@ class KNXProtocolTest extends Specification implements ManagerContainerTrait {then: "the living room thing to be fully deployed"conditions.eventually {- ((KNXProtocol) agentService.getProtocol(knxAgent.getAttribute("knxConfig").get())).getAttributeActionMap().get(knxThing.getAttribute("light1ToggleOnOff")) != null+ assert ((KNXProtocol) agentService.getProtocol(knxAgent.getAttribute("knxConfig").get())).getAttributeActionMap().get(new AttributeRef(knxThing.id, "light1ToggleOnOff")) != null}@@ -144,7 +144,7 @@ class KNXProtocolTest extends Specification implements ManagerContainerTrait {then: "the correct data should arrive on KNX bus"conditions.eventually {- assert knxTestingNetwork.getLastDataReceived().equals("0081") == true+ assert knxTestingNetwork.getLastDataReceived() == "0081"}when: "change light1ToggleOnOff value to 'false'"@@ -153,7 +153,7 @@ class KNXProtocolTest extends Specification implements ManagerContainerTrait {then: "the correct data should arrive on KNX bus"conditions.eventually {- assert knxTestingNetwork.getLastDataReceived().equals("0080") == true+ assert knxTestingNetwork.getLastDataReceived() == "0080"}cleanup: "the server should be stopped"diff --git a/test/src/test/groovy/org/openremote/test/protocol/udp/UdpClientProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/udp/UdpClientProtocolTest.groovyindex c9f8a59b8..ec671680c 100644--- a/test/src/test/groovy/org/openremote/test/protocol/udp/UdpClientProtocolTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/udp/UdpClientProtocolTest.groovy@@ -65,7 +65,7 @@ class UdpClientProtocolTest extends Specification implements ManagerContainerTraexpect: "the system settles down"conditions.eventually {- noEventProcessedIn(assetProcessingService, 300)+ assert noEventProcessedIn(assetProcessingService, 300)}when: "a simple UDP echo server is started"@@ -94,7 +94,7 @@ class UdpClientProtocolTest extends Specification implements ManagerContainerTrathen: "the UDP echo server should be connected"conditions.eventually {- echoServer.connectionStatus == ConnectionStatus.CONNECTED+ assert echoServer.connectionStatus == ConnectionStatus.CONNECTED}when: "an agent with a UDP client protocol configuration is created"@@ -245,7 +245,7 @@ class UdpClientProtocolTest extends Specification implements ManagerContainerTrathen: "the server should be connected"conditions.eventually {- echoServer.connectionStatus == ConnectionStatus.CONNECTED+ assert echoServer.connectionStatus == ConnectionStatus.CONNECTED}when: "the protocol configuration is updated to use HEX mode"diff --git a/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusBasicTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusBasicTest.groovyindex 4b628845b..ae18fa6b7 100644--- a/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusBasicTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusBasicTest.groovy@@ -800,6 +800,8 @@ class VelbusBasicTest extends Specification {]}+ static writeDelayMillis = VelbusNetwork.DELAY_BETWEEN_PACKET_WRITES_MILLISECONDS+def setupSpec() {VelbusNetwork.DELAY_BETWEEN_PACKET_WRITES_MILLISECONDS = 1; // Minimal delay for simulated network@@ -816,6 +818,7 @@ class VelbusBasicTest extends Specification {}def cleanupSpec() {+ VelbusNetwork.DELAY_BETWEEN_PACKET_WRITES_MILLISECONDS = writeDelayMillisif (network != null) {network.close()}@@ -1025,7 +1028,7 @@ class VelbusBasicTest extends Specification {then: "the button press packet should have been sent to the message processor"conditions.eventually {- device.getPropertyValue("CH22").getPropertyValue() == InputProcessor.ChannelState.PRESSED+ assert device.getPropertyValue("CH22").getPropertyValue() == InputProcessor.ChannelState.PRESSED}if (network.client == messageProcessor) {assert messageProcessor.sentMessages.size() == 1@@ -1037,7 +1040,7 @@ class VelbusBasicTest extends Specification {then: "the button release packet should have been sent to the message processor"conditions.eventually {- device.getPropertyValue("CH22").getPropertyValue() == InputProcessor.ChannelState.RELEASED+ assert device.getPropertyValue("CH22").getPropertyValue() == InputProcessor.ChannelState.RELEASEDif (network.client == messageProcessor) {assert messageProcessor.sentMessages.size() == 2assert messageProcessor.sentMessages[1].toString() == "0F F8 32 04 00 00 20 00 A3 04 00 00 00 00"@@ -1225,7 +1228,7 @@ class VelbusBasicTest extends Specification {then: "the button press packet should have been sent to the message processor"conditions.eventually {- device.getPropertyValue("CH3").getPropertyValue() == InputProcessor.ChannelState.PRESSED+ assert device.getPropertyValue("CH3").getPropertyValue() == InputProcessor.ChannelState.PRESSEDif (network.client == messageProcessor) {assert messageProcessor.sentMessages.size() == 1assert messageProcessor.sentMessages[0].toString() == "0F F8 0A 04 00 04 00 00 E7 04 00 00 00 00"@@ -1237,7 +1240,7 @@ class VelbusBasicTest extends Specification {then: "the button release packet should have been sent to the message processor"conditions.eventually {- device.getPropertyValue("CH3").getPropertyValue() == InputProcessor.ChannelState.RELEASED+ assert device.getPropertyValue("CH3").getPropertyValue() == InputProcessor.ChannelState.RELEASEDif (network.client == messageProcessor) {assert messageProcessor.sentMessages.size() == 2assert messageProcessor.sentMessages[1].toString() == "0F F8 0A 04 00 00 04 00 E7 04 00 00 00 00"@@ -2033,8 +2036,8 @@ class VelbusBasicTest extends Specification {then: "the counter should update to match"conditions.eventually {- device.getPropertyValue("COUNTER1").getPropertyValue() == 0.04- device.getPropertyValue("COUNTER1_INSTANT").getPropertyValue() == 0.15+ assert device.getPropertyValue("COUNTER1").getPropertyValue() == 0.04+ assert device.getPropertyValue("COUNTER1_INSTANT").getPropertyValue() == 0.15}when: "the counter is reset"@@ -2042,8 +2045,8 @@ class VelbusBasicTest extends Specification {then: "the counter should update to match"conditions.eventually {- device.getPropertyValue("COUNTER1").getPropertyValue() == 0d- device.getPropertyValue("COUNTER1_INSTANT").getPropertyValue() == 0.02+ assert device.getPropertyValue("COUNTER1").getPropertyValue() == 0d+ assert device.getPropertyValue("COUNTER1_INSTANT").getPropertyValue() == 0.02}}@@ -2281,7 +2284,6 @@ class VelbusBasicTest extends Specification {then: "the dimmer should switch on"conditions.eventually {-assert device.getPropertyValue("CH2").getPropertyValue() == AnalogOutputProcessor.ChannelState.ONassert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMALassert device.getPropertyValue("CH2_LED").getPropertyValue() == FeatureProcessor.LedState.FASTdiff --git a/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientProtocolTest.groovyindex 9911eabd6..456d15972 100644--- a/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientProtocolTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientProtocolTest.groovy@@ -132,11 +132,11 @@ class WebsocketClientProtocolTest extends Specification implements ManagerContai.addMeta(new MetaItem(WebsocketClientProtocol.META_PROTOCOL_CONNECT_URI,- Values.create("ws://localhost:$serverPort/websocket/events?Auth-Realm=master")+ Values.create("ws://127.0.0.1:$serverPort/websocket/events?Auth-Realm=master")),new MetaItem(Protocol.META_PROTOCOL_OAUTH_GRANT,- new OAuthPasswordGrant("http://localhost:$serverPort/auth/realms/master/protocol/openid-connect/token",+ new OAuthPasswordGrant("http://127.0.0.1:$serverPort/auth/realms/master/protocol/openid-connect/token",KEYCLOAK_CLIENT_ID,null,null,diff --git a/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientTest.groovyindex 7356386f7..3bc94f249 100644--- a/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientTest.groovy@@ -95,9 +95,9 @@ class WebsocketClientTest extends Specification implements ManagerContainerTraitand: "a simple Websocket client"def client = new WebsocketIoClient<String>(- new URIBuilder("ws://localhost:$serverPort/websocket/events?Auth-Realm=master").build(),+ new URIBuilder("ws://127.0.0.1:$serverPort/websocket/events?Auth-Realm=master").build(),null,- new OAuthPasswordGrant("http://localhost:$serverPort/auth/realms/master/protocol/openid-connect/token",+ new OAuthPasswordGrant("http://127.0.0.1:$serverPort/auth/realms/master/protocol/openid-connect/token",KEYCLOAK_CLIENT_ID,null,null,diff --git a/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy b/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovyindex f0c143af4..1b0917194 100644--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy@@ -49,7 +49,8 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerexpect: "the rules engines to be ready"conditions.eventually {- rulesImport.assertEnginesReady(rulesService, keycloakDemoSetup, managerDemoSetup)+ assert rulesImport.assertEnginesReady(rulesService, keycloakDemoSetup, managerDemoSetup)+ assert noRuleEngineFiringScheduled()}and: "the demo attributes marked with RULE_STATE = true meta should be inserted into the engines"@@ -140,11 +141,11 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerexpect: "the rules engines to be ready"conditions.eventually {- rulesImport.assertEnginesReady(rulesService, keycloakDemoSetup, managerDemoSetup)+ assert rulesImport.assertEnginesReady(rulesService, keycloakDemoSetup, managerDemoSetup)+ assert noRuleEngineFiringScheduled()}when: "a Kitchen room asset is inserted into apartment that contains a RULE_STATE = true meta flag"- rulesImport.resetRulesFired()def apartment2 = assetStorageService.find(managerDemoSetup.apartment2Id)def asset = new Asset("Kitchen", AssetType.ROOM, apartment2)asset.setRealm(keycloakDemoSetup.tenantBuilding.getRealm())@@ -189,6 +190,11 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerwhen: "time advances"advancePseudoClock(1, TimeUnit.SECONDS, container)+ then: "the rule engines settle down"+ conditions.eventually {+ assert noRuleEngineFiringScheduled()+ }+and: "an attribute event is pushed into the system for an attribute with no RULE_STATE meta"def globalLastFireTimestamp = rulesImport.globalEngine.lastFireTimestampdef masterLastFireTimestamp = rulesImport.masterEngine.lastFireTimestamp@@ -206,7 +212,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerassert apartment2LivingRoom.getAttribute("windowOpen").flatMap{it.getValueAsBoolean()}.orElse(false)}- then: "the rules engines should not have executed"+ then: "the rules engines should not have fired"conditions.eventually {assert rulesImport.globalEngine.lastFireTimestamp == globalLastFireTimestampassert rulesImport.masterEngine.lastFireTimestamp == masterLastFireTimestamp@@ -363,7 +369,8 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerexpect: "the rules engines to be ready"conditions.eventually {- rulesImport.assertEnginesReady(rulesService, keycloakDemoSetup, managerDemoSetup)+ assert rulesImport.assertEnginesReady(rulesService, keycloakDemoSetup, managerDemoSetup)+ assert noRuleEngineFiringScheduled()}when: "a broken RHS rule is loaded into the building engine"@@ -386,6 +393,11 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer})}+ then: "the engines should settle"+ conditions.eventually {+ assert noRuleEngineFiringScheduled()+ }+when: "an attribute event occurs"def globalLastFireTimestamp = rulesImport.globalEngine.lastFireTimestampdef masterLastFireTimestamp = rulesImport.masterEngine.lastFireTimestamp@@ -400,10 +412,10 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerthen: "the rules engines should have executed at least one more time"conditions.eventually {assert rulesImport.globalEngine.lastFireTimestamp > globalLastFireTimestamp- assert rulesImport.masterEngine.lastFireTimestamp > masterLastFireTimestamp+ assert rulesImport.masterEngine.lastFireTimestamp == masterLastFireTimestampassert rulesImport.tenantBuildingEngine.lastFireTimestamp == tenantALastFireTimestampassert rulesImport.apartment2Engine.lastFireTimestamp > apartment2LastFireTimestamp- assert rulesImport.apartment3Engine.lastFireTimestamp > apartment3LastFireTimestamp+ assert rulesImport.apartment3Engine.lastFireTimestamp == apartment3LastFireTimestamp}cleanup: "the static rules time variable is reset"diff --git a/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceAutoVentilationTest.groovy b/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceAutoVentilationTest.groovyindex d54952aa0..78fce62bf 100644--- a/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceAutoVentilationTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceAutoVentilationTest.groovy@@ -47,12 +47,13 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerContagetClass().getResource("/demo/rules/DemoResidenceAutoVentilation.groovy").text)rulesetStorageService.merge(ruleset)- expect: "the rule engines to become available and be running"+ expect: "the rule engines to become available, running and settled"conditions.eventually {apartment1Engine = rulesService.assetEngines.get(managerDemoSetup.apartment1Id)assert apartment1Engine != nullassert apartment1Engine.isRunning()assert apartment1Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_1+ assert noRuleEngineFiringScheduled()}and: "the ventilation should be off"@@ -67,6 +68,11 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerContanew AttributeEvent(managerDemoSetup.apartment1Id, "ventilationAuto", Values.create(true)))+ then: "the rule engines should settle"+ conditions.eventually {+ assert noRuleEngineFiringScheduled()+ }+then: "auto ventilation should be on"conditions.eventually {def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)@@ -94,6 +100,11 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerContaadvancePseudoClock(2, MINUTES, container)}+ then: "the rule engines should settle"+ conditions.eventually {+ assert noRuleEngineFiringScheduled()+ }+then: "ventilation level of the apartment should be MEDIUM"conditions.eventually {def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)@@ -106,6 +117,11 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerConta)simulatorProtocol.putValue(co2LevelDecrement)+ then: "the rule engines should settle"+ conditions.eventually {+ assert noRuleEngineFiringScheduled()+ }+then: "the decreasing CO2 should have been detected in rules"conditions.eventually {assert apartment1Engine.assetEvents.any() {@@ -143,6 +159,11 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerContaadvancePseudoClock(2, MINUTES, container)}+ then: "the rule engines should settle"+ conditions.eventually {+ assert noRuleEngineFiringScheduled()+ }+then: "ventilation level of the apartment should be HIGH"conditions.eventually {def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)@@ -164,6 +185,11 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerContaand: "time advances"advancePseudoClock(20, MINUTES, container)+ then: "the rule engines should settle"+ conditions.eventually {+ assert noRuleEngineFiringScheduled()+ }+then: "ventilation level of the apartment should be MEDIUM"conditions.eventually {def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)@@ -185,6 +211,11 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerContaand: "time advances"advancePseudoClock(15, MINUTES, container)+ then: "the rule engines should settle"+ conditions.eventually {+ assert noRuleEngineFiringScheduled()+ }+then: "ventilation level of the apartment should be LOW"conditions.eventually {def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)diff --git a/test/src/test/groovy/org/openremote/test/rules/residence/ResidencePresenceDetectionTest.groovy b/test/src/test/groovy/org/openremote/test/rules/residence/ResidencePresenceDetectionTest.groovyindex 268232938..3a7037e10 100644--- a/test/src/test/groovy/org/openremote/test/rules/residence/ResidencePresenceDetectionTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/residence/ResidencePresenceDetectionTest.groovy@@ -14,6 +14,7 @@ import org.openremote.model.rules.Rulesetimport org.openremote.model.rules.TemporaryFactimport org.openremote.model.value.Valuesimport org.openremote.test.ManagerContainerTrait+import spock.lang.Ignoreimport spock.lang.Specificationimport spock.util.concurrent.PollingConditions@@ -21,6 +22,9 @@ import static java.util.concurrent.TimeUnit.MINUTESimport static org.openremote.manager.setup.builtin.ManagerDemoSetup.DEMO_RULE_STATES_APARTMENT_1import static org.openremote.model.attribute.AttributeEvent.Source.SENSOR+// Ignore this test as temporary facts (rule events) cause the rule engine to continually fire, need to decide if+// we support rule events or should it just be something rules do internally+@Ignoreclass ResidencePresenceDetectionTest extends Specification implements ManagerContainerTrait {def "Presence detection with motion sensor"() {@@ -53,6 +57,11 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerConassert apartment1Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_1}+ and: "the rule engines should settle"+ conditions.eventually {+ assert noRuleEngineFiringScheduled()+ }+and: "the presence detected flag and timestamp should not be set"conditions.eventually {def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)@@ -76,6 +85,11 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon)simulatorProtocol.putValue(hallwayMotionSensorEvent)+ then: "the rule engines should settle"+ conditions.eventually {+ assert noRuleEngineFiringScheduled()+ }+then: "presence should be detected in all rooms"conditions.eventually {def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)@@ -98,6 +112,11 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon)simulatorProtocol.putValue(kitchenMotionSensorEvent)+ then: "the rule engines should settle"+ conditions.eventually {+ assert noRuleEngineFiringScheduled()+ }+then: "presence should be detected in all rooms and timestamp should be updated of one room"conditions.eventually {def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)@@ -119,6 +138,11 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon)simulatorProtocol.putValue(kitchenMotionSensorEvent)+ then: "the rule engines should settle"+ conditions.eventually {+ assert noRuleEngineFiringScheduled()+ }+then: "some presence should still be detected and timestamps are still available"conditions.eventually {def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)@@ -140,6 +164,11 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon)simulatorProtocol.putValue(hallwayMotionSensorEvent)+ then: "the rule engines should settle"+ conditions.eventually {+ assert noRuleEngineFiringScheduled()+ }+then: "no presence should be detected but the last timestamp still available"conditions.eventually {def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)@@ -187,6 +216,11 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerConassert apartment1Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_1}+ and: "the rule engines should settle"+ conditions.eventually {+ assert noRuleEngineFiringScheduled()+ }+and: "the presence detected flag and timestamp of the room should not be set"conditions.eventually {def roomAsset = assetStorageService.find(managerDemoSetup.apartment1LivingroomId, true)@@ -233,6 +267,11 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon}*/+ then: "the rule engines should settle"+ conditions.eventually {+ assert noRuleEngineFiringScheduled()+ }+then: "presence should be detected and the last motion sensor trigger is the last detected timestamp"conditions.eventually {def roomAsset = assetStorageService.find(managerDemoSetup.apartment1LivingroomId, true)@@ -257,13 +296,16 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon// Wait for event to be processedconditions.eventually {- assert apartment1Engine.assetEvents.any() {+ assert apartment1Engine.assetEvents.any {it.fact.matches(co2LevelIncrement, SENSOR, true)}- assert noEventProcessedIn(assetProcessingService, 500)}advancePseudoClock(5, MINUTES, container)++ conditions.eventually {+ assert noRuleEngineFiringScheduled()+ }}then: "presence should be detected and the last motion sensor trigger is the last detected timestamp"@@ -276,6 +318,11 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerConwhen: "there is no CO2 level increase for a while (nobody resting in the room)"advancePseudoClock(20, MINUTES, container)+ then: "the rule engines should settle"+ conditions.eventually {+ assert noRuleEngineFiringScheduled()+ }+then: "presence should be gone but the last timestamp still available"conditions.eventually {def roomAsset = assetStorageService.find(managerDemoSetup.apartment1LivingroomId, true)