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
More test improvements
Rich Turner95c1731cd56f
diff --git a/test/src/test/groovy/org/openremote/test/failure/RulesExecutionFailureTest.groovy b/test/src/test/groovy/org/openremote/test/failure/RulesExecutionFailureTest.groovyindex 414cebb7e..534ebdf63 100644--- a/test/src/test/groovy/org/openremote/test/failure/RulesExecutionFailureTest.groovy+++ b/test/src/test/groovy/org/openremote/test/failure/RulesExecutionFailureTest.groovy@@ -11,6 +11,7 @@ import org.openremote.manager.setup.builtin.ManagerDemoSetupimport org.openremote.model.rules.AssetRulesetimport org.openremote.model.rules.Rulesetimport org.openremote.model.rules.RulesetStatus+import org.openremote.model.rules.TemporaryFactimport org.openremote.model.value.Valuesimport org.openremote.test.ManagerContainerTraitimport spock.lang.Specification@@ -21,6 +22,8 @@ class RulesExecutionFailureTest extends Specification implements ManagerContainedef "Rule condition invalid return"() {given: "the container environment is started"+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def conditions = new PollingConditions(timeout: 20, delay: 0.2)def container = startContainer(defaultConfig(), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)@@ -47,11 +50,16 @@ class RulesExecutionFailureTest extends Specification implements ManagerContaineassert apartment2Engine.deployments[ruleset.id].error instanceof IllegalArgumentExceptionassert apartment2Engine.deployments[ruleset.id].error.message == "Error evaluating condition of rule 'The when condition is illegal, it's returning an Optional instead of a boolean': result is not boolean but Optional.empty"}++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}def "Rule condition throws exception"() {given: "the container environment is started"+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def conditions = new PollingConditions(timeout: 20, delay: 0.2)def container = startContainer(defaultConfig(), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)@@ -78,11 +86,16 @@ class RulesExecutionFailureTest extends Specification implements ManagerContaineassert apartment2Engine.getError() instanceof RuntimeExceptionassert apartment2Engine.getError().message.startsWith("Ruleset deployments have errors, failed compilation: 0, failed execution: 1")}++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}def "Rule action throws exception"() {given: "the container environment is started"+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def conditions = new PollingConditions(timeout: 20, delay: 0.2)def container = startContainer(defaultConfig(), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)@@ -109,11 +122,16 @@ class RulesExecutionFailureTest extends Specification implements ManagerContaineassert apartment2Engine.getError() instanceof RuntimeExceptionassert apartment2Engine.getError().message.startsWith("Ruleset deployments have errors, failed compilation: 0, failed execution: 1")}++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}def "Rule condition loops"() {given: "the container environment is started"+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def conditions = new PollingConditions(timeout: 20, delay: 0.2)def container = startContainer(defaultConfig(), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)@@ -142,5 +160,8 @@ class RulesExecutionFailureTest extends Specification implements ManagerContaineassert apartment2Engine.getError().message.startsWith("Ruleset deployments have errors, failed compilation: 0, failed execution: 1")assert apartment2Engine.facts.triggerCount == 0 // Ensure trigger count is reset after execution}++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}}diff --git a/test/src/test/groovy/org/openremote/test/protocol/TcpClientTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/TcpClientTest.groovyindex 2b03032e8..0fdeb2502 100644--- a/test/src/test/groovy/org/openremote/test/protocol/TcpClientTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/TcpClientTest.groovy@@ -49,14 +49,14 @@ class TcpClientTest extends Specification implements ManagerContainerTrait {and: "a simple TCP echo server"def echoServerPort = findEphemeralPort()- def echoServer = new TcpStringServer(protocolExecutorService, new InetSocketAddress(echoServerPort), ";", Integer.MAX_VALUE, true)+ def echoServer = new TcpStringServer(protocolExecutorService, new InetSocketAddress("127.0.0.1", echoServerPort), ";", Integer.MAX_VALUE, true)echoServer.addMessageConsumer({message, channel, sender -> echoServer.sendMessage(message)})and: "a simple TCP client"TcpIoClient<String> client = new TcpIoClient<String>(- "localhost",+ "127.0.0.1",echoServerPort,protocolExecutorService)client.setEncoderDecoderProvider({diff --git a/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy b/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovyindex 31e1e526c..f0c143af4 100644--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy@@ -1,6 +1,6 @@package org.openremote.test.rules-import org.openremote.container.timer.TimerService+import org.openremote.manager.asset.AssetProcessingServiceimport org.openremote.manager.asset.AssetStorageServiceimport org.openremote.manager.rules.RulesEngine@@ -11,14 +11,11 @@ import org.openremote.manager.setup.builtin.KeycloakDemoSetupimport org.openremote.manager.setup.builtin.ManagerDemoSetupimport org.openremote.model.asset.Assetimport org.openremote.model.asset.AssetAttribute-import org.openremote.model.attribute.MetaItemTypeimport org.openremote.model.asset.AssetType-import org.openremote.model.attribute.AttributeEvent-import org.openremote.model.attribute.AttributeValueType-import org.openremote.model.attribute.Meta-import org.openremote.model.attribute.MetaItem+import org.openremote.model.attribute.*import org.openremote.model.rules.AssetRulesetimport org.openremote.model.rules.Ruleset+import org.openremote.model.rules.TemporaryFactimport org.openremote.model.rules.TenantRulesetimport org.openremote.model.value.Valuesimport org.openremote.test.ManagerContainerTrait@@ -27,8 +24,8 @@ import spock.util.concurrent.PollingConditionsimport java.util.concurrent.TimeUnit-import static org.openremote.model.rules.RulesetStatus.*import static org.openremote.manager.setup.builtin.ManagerDemoSetup.*+import static org.openremote.model.rules.RulesetStatus.*import static org.openremote.test.rules.BasicRulesImport.assertRulesFiredclass BasicRulesProcessingTest extends Specification implements ManagerContainerTrait {@@ -38,6 +35,8 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerdef conditions = new PollingConditions(timeout: 10, delay: 0.2)and: "the container is started"+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def container = startContainer(defaultConfig(), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)@@ -116,6 +115,9 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerassertRulesFired(smartHomeEngine, 8)assertRulesFired(smartHomeEngine, ["Living Room All", "Kitchen All", "Kitchen Number Attributes", "Parent Type Residence", "Asset Type Room", "Boolean Attributes", "String attributes", "Number value types"])}++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}def "Handle attribute event with no meta, asset create, update, delete"() {@@ -123,6 +125,8 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerdef conditions = new PollingConditions(timeout: 15, delay: 0.2)and: "the container is started"+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def container = startContainer(defaultConfig(), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)@@ -335,6 +339,9 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerassertRulesFired(rulesImport.apartment2Engine, ["All"])assertRulesFired(rulesImport.apartment3Engine, 0)}++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}def "Stop processing when engine in error state"() {@@ -342,13 +349,14 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerdef conditions = new PollingConditions(timeout: 10, delay: 0.2)and: "the container is started"+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def container = startContainer(defaultConfig(), 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)def rulesetStorageService = container.getService(RulesetStorageService.class)def assetProcessingService = container.getService(AssetProcessingService.class)- def assetStorageService = container.getService(AssetStorageService.class)and: "some test rulesets have been imported"def rulesImport = new BasicRulesImport(rulesetStorageService, keycloakDemoSetup, managerDemoSetup)@@ -397,5 +405,8 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerassert rulesImport.apartment2Engine.lastFireTimestamp > apartment2LastFireTimestampassert rulesImport.apartment3Engine.lastFireTimestamp > apartment3LastFireTimestamp}++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}}diff --git a/test/src/test/groovy/org/openremote/test/rules/BasicRulesTimedExecutionTest.groovy b/test/src/test/groovy/org/openremote/test/rules/BasicRulesTimedExecutionTest.groovyindex e74405a74..df905ca2c 100644--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesTimedExecutionTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesTimedExecutionTest.groovy@@ -5,6 +5,7 @@ import org.openremote.manager.rules.RulesServiceimport org.openremote.manager.rules.RulesetStorageServiceimport org.openremote.model.rules.GlobalRulesetimport org.openremote.model.rules.Ruleset+import org.openremote.model.rules.TemporaryFactimport org.openremote.test.ManagerContainerTraitimport spock.lang.Ignoreimport spock.lang.Specification@@ -29,6 +30,8 @@ class BasicRulesTimedExecutionTest extends Specification implements ManagerContadef conditions = new PollingConditions(timeout: 30, delay: 0.2)and: "the container is started"+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def container = startContainer(defaultConfig(), defaultServices())def rulesService = container.getService(RulesService.class)def rulesetStorageService = container.getService(RulesetStorageService.class)@@ -61,11 +64,16 @@ class BasicRulesTimedExecutionTest extends Specification implements ManagerContaassert globalEngineFiredRules.size() > 10assert globalEngineFiredRules.containsAll(expectedFiredRules)}++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}def "Check firing of timer rules with pseudo clock"() {given: "the container environment is started"+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def conditions = new PollingConditions(timeout: 30, delay: 0.2)def container = startContainer(defaultConfig(), defaultServices())def rulesService = container.getService(RulesService.class)@@ -110,5 +118,8 @@ class BasicRulesTimedExecutionTest extends Specification implements ManagerContaassert globalEngineFiredRules.size() > 1assert globalEngineFiredRules.containsAll(expectedFiredRules)}++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}}diff --git a/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy b/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovyindex cc99f918c..daee5e1a2 100644--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy@@ -8,6 +8,7 @@ import org.openremote.manager.setup.builtin.ManagerDemoSetupimport org.openremote.model.rules.AssetRulesetimport org.openremote.model.rules.GlobalRulesetimport org.openremote.model.rules.RulesResource+import org.openremote.model.rules.TemporaryFactimport org.openremote.model.rules.TenantRulesetimport org.openremote.model.value.Valuesimport org.openremote.test.ManagerContainerTrait@@ -27,6 +28,8 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerdef "Access rules as superuser"() {given: "the server container is started"def container = startContainer(defaultConfig(), defaultServices())+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def rulesetStorageService = container.getService(RulesetStorageService.class)def rulesService = container.getService(RulesService.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)@@ -292,11 +295,16 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerassetRuleset.name == "Test asset definition"assetRuleset.rules == "SomeRulesCode"assetRuleset.assetId == managerDemoSetup.apartment2Id++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}def "Access rules as testuser1"() {given: "the server container is started"+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def container = startContainer(defaultConfig(), defaultServices())def rulesetStorageService = container.getService(RulesetStorageService.class)def rulesService = container.getService(RulesService.class)@@ -518,12 +526,17 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerthen: "access should be forbidden"ex = thrown()ex.response.status == 403++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}def "Access rules as testuser2"() {given: "the server container is started"def container = startContainer(defaultConfig(), defaultServices())+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def rulesetStorageService = container.getService(RulesetStorageService.class)def rulesService = container.getService(RulesService.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)@@ -660,12 +673,17 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerthen: "access should be forbidden"ex = thrown()ex.response.status == 403++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}def "Access rules as testuser3"() {given: "the server container is started"def container = startContainer(defaultConfig(), defaultServices())+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def rulesetStorageService = container.getService(RulesetStorageService.class)def rulesService = container.getService(RulesService.class)def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)@@ -872,5 +890,8 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainerthen: "access should be forbidden"ex = thrown()ex.response.status == 403++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}}diff --git a/test/src/test/groovy/org/openremote/test/rules/residence/FlowRulesTest.groovy b/test/src/test/groovy/org/openremote/test/rules/residence/FlowRulesTest.groovyindex c9e09055f..50e7386ce 100644--- a/test/src/test/groovy/org/openremote/test/rules/residence/FlowRulesTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/residence/FlowRulesTest.groovy@@ -1,13 +1,11 @@package org.openremote.test.rules.residence-import org.openremote.container.timer.TimerService+import org.openremote.manager.asset.AssetProcessingServiceimport org.openremote.manager.asset.AssetStorageServiceimport org.openremote.manager.rules.FlowRulesBuilder-import org.openremote.manager.rules.RulesEngineimport org.openremote.manager.rules.RulesServiceimport org.openremote.manager.rules.RulesetStorageService-import org.openremote.manager.rules.geofence.ORConsoleGeofenceAssetAdapterimport org.openremote.manager.setup.SetupServiceimport org.openremote.manager.setup.builtin.ManagerDemoSetupimport org.openremote.model.attribute.AttributeEvent@@ -20,18 +18,17 @@ import org.openremote.test.ManagerContainerTraitimport spock.lang.Specificationimport spock.util.concurrent.PollingConditions-import java.util.concurrent.TimeUnit-import static org.openremote.model.rules.RulesetStatus.DEPLOYEDclass FlowRulesTest extends Specification implements ManagerContainerTrait {- private FlowRulesBuilder builderdef "Execute flow rules"() {given: "expected conditions"def conditions = new PollingConditions(timeout: 10, delay: 0.2)and: "the container is started"+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def container = startContainer(defaultConfig(), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def rulesService = container.getService(RulesService.class)@@ -79,5 +76,8 @@ class FlowRulesTest extends Specification implements ManagerContainerTrait {getAttribute("targetTemperature").get().getValueAsNumber().get()assert bedroomTargetTemp.intValue() == (startTemperature.intValue() + 10) : ("it was actually " + bedroomTargetTemp.intValue())//convert to int considering floating point inaccuracy}++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}}diff --git a/test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovy b/test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovyindex e917305fc..5cf04564b 100644--- a/test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovy@@ -63,8 +63,8 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {ORConsoleGeofenceAssetAdapter.NOTIFY_ASSETS_DEBOUNCE_MILLIS = 100and: "the rule firing delay time is set to a small value for testing"- def originalExpirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS- TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 100+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500and: "the container environment is started with the mock handler"def conditions = new PollingConditions(timeout: 15, delay: 0.2)@@ -466,7 +466,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {RulesEngine.PAUSE_SCHEDULER = originalPauseRulesEngine.UNPAUSE_SCHEDULER = originalUnpauseORConsoleGeofenceAssetAdapter.NOTIFY_ASSETS_DEBOUNCE_MILLIS = originalDebounceMillis- TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = originalExpirationMillis+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillisnotificationService.notificationHandlerMap.put(emailNotificationHandler.getTypeName(), emailNotificationHandler)notificationService.notificationHandlerMap.put(pushNotificationHandler.getTypeName(), pushNotificationHandler)}diff --git a/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceAllLightsOffTest.groovy b/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceAllLightsOffTest.groovyindex 81147649c..5394592fb 100644--- a/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceAllLightsOffTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceAllLightsOffTest.groovy@@ -10,6 +10,7 @@ import org.openremote.manager.setup.builtin.ManagerDemoSetupimport org.openremote.model.attribute.AttributeEventimport org.openremote.model.rules.AssetRulesetimport org.openremote.model.rules.Ruleset+import org.openremote.model.rules.TemporaryFactimport org.openremote.model.value.Valuesimport org.openremote.test.ManagerContainerTraitimport spock.lang.Specification@@ -23,6 +24,8 @@ class ResidenceAllLightsOffTest extends Specification implements ManagerContainedef "Turn all lights off"() {given: "the container environment is started"+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def conditions = new PollingConditions(timeout: 10, delay: 0.2)def container = startContainer(defaultConfig(), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)@@ -91,5 +94,8 @@ class ResidenceAllLightsOffTest extends Specification implements ManagerContainedef livingroomAsset = assetStorageService.find(managerDemoSetup.apartment2LivingroomId, true)assert livingroomAsset.getAttribute("lightSwitch").get().valueAsBoolean.get()}++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}}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 fd9792e86..10130a6e0 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@@ -11,6 +11,7 @@ import org.openremote.manager.setup.builtin.ManagerDemoSetupimport org.openremote.model.attribute.AttributeEventimport org.openremote.model.rules.AssetRulesetimport org.openremote.model.rules.Ruleset+import org.openremote.model.rules.TemporaryFactimport org.openremote.model.value.Valuesimport org.openremote.test.ManagerContainerTraitimport spock.lang.Specification@@ -26,6 +27,8 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerContadef "Auto ventilation with CO2 detection"() {given: "the container environment is started"+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def conditions = new PollingConditions(timeout: 20, delay: 0.2)def container = startContainer(defaultConfig(), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)@@ -185,6 +188,9 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerContadef apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)assert apartment.getAttribute("ventilationLevel").get().getValueAsNumber().get() == 64d}++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}}diff --git a/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceNotifyAlarmTriggerTest.groovy b/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceNotifyAlarmTriggerTest.groovyindex ada7901f9..d532de026 100644--- a/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceNotifyAlarmTriggerTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceNotifyAlarmTriggerTest.groovy@@ -23,6 +23,7 @@ import org.openremote.model.notification.NotificationSendResultimport org.openremote.model.notification.PushNotificationMessageimport org.openremote.model.rules.AssetRulesetimport org.openremote.model.rules.Ruleset+import org.openremote.model.rules.TemporaryFactimport org.openremote.model.value.ObjectValueimport org.openremote.model.value.Valuesimport org.openremote.test.ManagerContainerTrait@@ -47,6 +48,8 @@ class ResidenceNotifyAlarmTriggerTest extends Specification implements ManagerCodef messages = []given: "the container environment is started with the mock handler"+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def conditions = new PollingConditions(timeout: 20, delay: 0.2)def container = startContainer(defaultConfig(), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)@@ -232,5 +235,6 @@ class ResidenceNotifyAlarmTriggerTest extends Specification implements ManagerCocleanup: "the mock is removed"notificationService.notificationHandlerMap.put(pushNotificationHandler.getTypeName(), pushNotificationHandler)+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}}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 46b9b83bc..268232938 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@@ -11,6 +11,7 @@ import org.openremote.manager.setup.builtin.ManagerDemoSetupimport org.openremote.model.attribute.AttributeEventimport org.openremote.model.rules.AssetRulesetimport org.openremote.model.rules.Ruleset+import org.openremote.model.rules.TemporaryFactimport org.openremote.model.value.Valuesimport org.openremote.test.ManagerContainerTraitimport spock.lang.Specification@@ -25,6 +26,8 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCondef "Presence detection with motion sensor"() {given: "the container environment is started"+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def conditions = new PollingConditions(timeout: 30, delay: 0.2)def container = startContainer(defaultConfig(), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)@@ -148,11 +151,16 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerConassert !hallway.getAttribute("presenceDetected").get().getValueAsBoolean().get()assert hallway.getAttribute("lastPresenceDetected").get().getValueAsNumber().get() == expectedLastPresenceDetected}++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}def "Presence detection with motion sensor and confirmation with CO2 level"() {given: "the container environment is started"+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def conditions = new PollingConditions(timeout: 20, delay: 0.2)def container = startContainer(defaultConfig(), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)@@ -274,6 +282,9 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerConassert !roomAsset.getAttribute("presenceDetected").get().getValueAsBoolean().get()assert roomAsset.getAttribute("lastPresenceDetected").get().getValueAsNumber().get() == expectedLastPresenceDetected}++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}/* TODO Migrate to JS, didn't compile even with Droolsdiff --git a/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceSmartSwitchTest.groovy b/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceSmartSwitchTest.groovyindex 5ca9a5582..adef3f28f 100644--- a/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceSmartSwitchTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceSmartSwitchTest.groovy@@ -10,6 +10,7 @@ import org.openremote.manager.setup.builtin.ManagerDemoSetupimport org.openremote.model.attribute.AttributeEventimport org.openremote.model.rules.AssetRulesetimport org.openremote.model.rules.Ruleset+import org.openremote.model.rules.TemporaryFactimport org.openremote.model.value.Valuesimport org.openremote.test.ManagerContainerTraitimport spock.lang.Specification@@ -26,6 +27,8 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainergiven: "the container environment is started"def conditions = new PollingConditions(timeout: 10, delay: 0.2)+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def container = startContainer(defaultConfig(), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def rulesService = container.getService(RulesService.class)@@ -145,12 +148,17 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainerassert !kitchen.getAttribute("smartSwitchStopTimeC").get().getValue().isPresent()assert !kitchen.getAttribute("smartSwitchEnabledC").get().getValue().isPresent()}++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}def "Set mode ON_AT and begin/end cycle time in past"() {given: "the container environment is started"def conditions = new PollingConditions(timeout: 10, delay: 0.2)+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def container = startContainer(defaultConfig(), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def rulesService = container.getService(RulesService.class)@@ -238,12 +246,17 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainerassert !kitchen.getAttribute("smartSwitchStopTimeC").get().getValue().isPresent()assert !kitchen.getAttribute("smartSwitchEnabledC").get().getValue().isPresent()}++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}def "Set mode READY_AT and begin/end cycle time in future"() {given: "the container environment is started"def conditions = new PollingConditions(timeout: 10, delay: 0.2)+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def container = startContainer(defaultConfig(), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def rulesService = container.getService(RulesService.class)@@ -355,12 +368,17 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainerassert !kitchen.getAttribute("smartSwitchStopTimeC").get().getValue().isPresent()assert !kitchen.getAttribute("smartSwitchEnabledC").get().getValue().isPresent()}++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}def "Set mode READY_AT and begin/end cycle time in past"() {given: "the container environment is started"def conditions = new PollingConditions(timeout: 10, delay: 0.2)+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def container = startContainer(defaultConfig(), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def rulesService = container.getService(RulesService.class)@@ -449,12 +467,17 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainerassert !kitchen.getAttribute("smartSwitchStopTimeC").get().getValue().isPresent()assert !kitchen.getAttribute("smartSwitchEnabledC").get().getValue().isPresent()}++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}def "Set mode READY_AT and insufficient begin/end cycle time"() {given: "the container environment is started"def conditions = new PollingConditions(timeout: 10, delay: 0.2)+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def container = startContainer(defaultConfig(), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def rulesService = container.getService(RulesService.class)@@ -543,6 +566,9 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainerassert !kitchen.getAttribute("smartSwitchStopTimeC").get().getValue().isPresent()assert !kitchen.getAttribute("smartSwitchEnabledC").get().getValue().isPresent()}++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}}diff --git a/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceVacationModeTest.groovy b/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceVacationModeTest.groovyindex 30aa7c777..be02ccf71 100644--- a/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceVacationModeTest.groovy+++ b/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceVacationModeTest.groovy@@ -11,6 +11,7 @@ import org.openremote.model.attribute.AttributeEventimport org.openremote.model.attribute.AttributeExecuteStatusimport org.openremote.model.rules.AssetRulesetimport org.openremote.model.rules.Ruleset+import org.openremote.model.rules.TemporaryFactimport org.openremote.model.value.Valuesimport org.openremote.test.ManagerContainerTraitimport spock.lang.Specification@@ -28,6 +29,8 @@ class ResidenceVacationModeTest extends Specification implements ManagerContainegiven: "the container environment is started"def conditions = new PollingConditions(timeout: 20, delay: 0.2)+ def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500def container = startContainer(defaultConfig(), defaultServices())def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)def rulesService = container.getService(RulesService.class)@@ -123,5 +126,8 @@ class ResidenceVacationModeTest extends Specification implements ManagerContaineassert asset.getAttribute("nightSceneEnabled" + it.name()).get().getValueAsBoolean().get()}}++ cleanup: "the static rules time variable is reset"+ TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis}}