Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Split built in demo and test setup; demo setup updated to only include smart city

Rich Turner453746a3e577
diff --git a/deployment/manager/shared/locales/en/or.json b/deployment/manager/shared/locales/en/or.json
index 7191864ab..b00f7a937 100644
--- a/deployment/manager/shared/locales/en/or.json
+++ b/deployment/manager/shared/locales/en/or.json
@@ -254,8 +254,8 @@
"EUR_PER_MONTH": "€/month",
"GBP_PER_KWH": "£/kWh",
"GBP_PER_MONTH": "£/month",
- "EUR": "€",
- "GBP": "£",
+ "CURRENCY_EUR": "€",
+ "CURRENCY_GBP": "£",
"POWER_KW": "kW",
"POWER_W": "W",
"POWER_KWP": "kWp",
diff --git a/deployment/map/mapsettings.json b/deployment/map/mapsettings.json
index b22625f9d..4a193842e 100644
--- a/deployment/map/mapsettings.json
+++ b/deployment/map/mapsettings.json
@@ -1,9 +1,9 @@
{
"options": {
"default": {
- "center": [ 4.490445, 51.903955 ],
+ "center": [ 4.485222, 51.911712 ],
"bounds": [ 3.911, 51.737, 4.784, 52.109 ],
- "zoom": 13.45,
+ "zoom": 14,
"maxZoom": 19,
"boxZoom": false
},
diff --git a/manager/src/main/java/org/openremote/manager/rules/RulesBuilder.java b/manager/src/main/java/org/openremote/manager/rules/RulesBuilder.java
index dae77ec8c..4505fb84f 100644
--- a/manager/src/main/java/org/openremote/manager/rules/RulesBuilder.java
+++ b/manager/src/main/java/org/openremote/manager/rules/RulesBuilder.java
@@ -121,5 +121,4 @@ public class RulesBuilder {
}
return rules.toArray(new Rule[rules.size()]);
}
-
}
diff --git a/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java b/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java
index f83fe9f75..516c428e3 100644
--- a/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java
+++ b/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java
@@ -743,4 +743,52 @@ public abstract class AbstractManagerSetup implements Setup {
return lightAsset;
}
+
+ protected Asset createDemoElectricityStorageAsset(String name, Asset area, GeoJSON location) {
+ Asset electricityStorageAsset = new Asset(name, ELECTRICITY_STORAGE, area).addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, location.toValue()).addMeta(SHOW_ON_DASHBOARD)
+ );
+
+ return electricityStorageAsset;
+ }
+
+ protected Asset createDemoElectricityProducerAsset(String name, Asset area, GeoJSON location) {
+ Asset electricityProducerAsset = new Asset(name, ELECTRICITY_PRODUCER, area).addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, location.toValue()).addMeta(SHOW_ON_DASHBOARD)
+ );
+
+ return electricityProducerAsset;
+ }
+
+ protected Asset createDemoElectricityConsumerAsset(String name, Asset area, GeoJSON location) {
+ Asset electricityConsumerAsset = new Asset(name, ELECTRICITY_CONSUMER, area).addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, location.toValue()).addMeta(SHOW_ON_DASHBOARD)
+ );
+
+ return electricityConsumerAsset;
+ }
+
+ protected Asset createDemoElectricityChargerAsset(String name, Asset area, GeoJSON location) {
+ Asset electricityConsumerAsset = new Asset(name, ELECTRICITY_CHARGER, area).addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, location.toValue()).addMeta(SHOW_ON_DASHBOARD)
+ );
+
+ return electricityConsumerAsset;
+ }
+
+ protected Asset createDemoGroundwaterAsset(String name, Asset area, GeoJSON location) {
+ Asset groundwaterAsset = new Asset(name, GROUNDWATER, area).addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, location.toValue()).addMeta(SHOW_ON_DASHBOARD)
+ );
+
+ return groundwaterAsset;
+ }
+
+ protected Asset createDemoParkingAsset(String name, Asset area, GeoJSON location) {
+ Asset parkingAsset = new Asset(name, PARKING, area).addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, location.toValue()).addMeta(SHOW_ON_DASHBOARD)
+ );
+
+ return parkingAsset;
+ }
}
diff --git a/manager/src/main/java/org/openremote/manager/setup/SetupTasks.java b/manager/src/main/java/org/openremote/manager/setup/SetupTasks.java
index af17ea21a..f5814c6b3 100644
--- a/manager/src/main/java/org/openremote/manager/setup/SetupTasks.java
+++ b/manager/src/main/java/org/openremote/manager/setup/SetupTasks.java
@@ -70,6 +70,7 @@ public interface SetupTasks {
String SETUP_IMPORT_DEMO_RULES = "SETUP_IMPORT_DEMO_RULES";
String SETUP_IMPORT_DEMO_SCENES = "SETUP_IMPORT_DEMO_SCENES";
String SETUP_IMPORT_DEMO_AGENT = "SETUP_IMPORT_DEMO_AGENT";
+ String SETUP_TESTS = "SETUP_TESTS";
static boolean isImportDemoUsers(Container container) {
return isImportDemoAssets(container)
@@ -96,6 +97,10 @@ public interface SetupTasks {
return getBoolean(container.getConfig(), SETUP_IMPORT_DEMO_AGENT, false);
}
+ static boolean isTestSetup(Container container) {
+ return getBoolean(container.getConfig(), SETUP_TESTS, false);
+ }
+
List<Setup> createTasks(Container container);
<S extends Setup> S getTaskOfType(Class<S> setupType);
diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/BuiltinSetupTasks.java b/manager/src/main/java/org/openremote/manager/setup/builtin/BuiltinSetupTasks.java
index 2fff3b68b..f37e22e1c 100644
--- a/manager/src/main/java/org/openremote/manager/setup/builtin/BuiltinSetupTasks.java
+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/BuiltinSetupTasks.java
@@ -38,22 +38,46 @@ public class BuiltinSetupTasks extends AbstractSetupTasks {
// Basic vs Keycloak identity provider
if (container.getService(ManagerIdentityService.class).isKeycloakEnabled()) {
+
// Keycloak is not managed by persistence service so need separate clean task
addTask(new KeycloakCleanSetup(container));
addTask(new KeycloakInitSetup(container));
- if (isImportDemoUsers(container)) {
- addTask(new KeycloakDemoSetup(container));
- }
- if (isImportDemoAssets(container)) {
- addTask(new ManagerDemoSetup(container, isImportDemoScenes(container)));
+ if (isTestSetup(container)) {
+ if (isImportDemoUsers(container)) {
+ addTask(new KeycloakTestSetup(container));
+ }
+ } else {
+ if (isImportDemoUsers(container)) {
+ addTask(new KeycloakDemoSetup(container));
+ }
}
- if (isImportDemoRules(container)) {
- addTask(new RulesDemoSetup(container));
- }
- if (isImportDemoAgent(container)) {
- addTask(new ManagerDemoAgentSetup(container));
+
+ if (isTestSetup(container)) {
+
+ if (isImportDemoAssets(container)) {
+ addTask(new ManagerTestSetup(container, isImportDemoScenes(container)));
+ }
+ if (isImportDemoRules(container)) {
+ addTask(new RulesTestSetup(container));
+ }
+ if (isImportDemoAgent(container)) {
+ addTask(new ManagerTestAgentSetup(container));
+ }
+
+ } else {
+
+ if (isImportDemoAssets(container)) {
+ addTask(new ManagerDemoSetup(container));
+ }
+ if (isImportDemoRules(container)) {
+ addTask(new RulesDemoSetup(container));
+ }
+ if (isImportDemoAgent(container)) {
+ addTask(new ManagerDemoAgentSetup(container));
+ }
}
+
}
return getTasks();
diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/KeycloakDemoSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/KeycloakDemoSetup.java
index 41329dcac..89b16ef67 100644
--- a/manager/src/main/java/org/openremote/manager/setup/builtin/KeycloakDemoSetup.java
+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/KeycloakDemoSetup.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016, OpenRemote Inc.
+ * Copyright 2020, OpenRemote Inc.
*
* See the CONTRIBUTORS.txt file in the distribution for a
* full listing of individual contributors.
@@ -19,11 +19,7 @@
*/
package org.openremote.manager.setup.builtin;
-import org.cyclopsgroup.jcli.spi.Cli;
-import org.keycloak.representations.idm.ClientRepresentation;
import org.openremote.container.Container;
-import org.openremote.container.util.UniqueIdentifierGenerator;
-import org.openremote.manager.mqtt.MqttBrokerService;
import org.openremote.manager.setup.AbstractKeycloakSetup;
import org.openremote.model.Constants;
import org.openremote.model.security.ClientRole;
@@ -33,18 +29,11 @@ import org.openremote.model.security.User;
import java.util.Arrays;
import java.util.logging.Logger;
-import static org.openremote.model.Constants.KEYCLOAK_CLIENT_ID;
-import static org.openremote.model.Constants.MASTER_REALM;
-
/**
* We have the following demo users:
* <ul>
* <li><code>admin</code> - The superuser in the "master" realm with all access</li>
- * <li><code>testuser1</code> - (Password: testuser1) A user in the "master" realm with read/write access to assets and rules</li>
- * <li><code>testuser2</code> - (Password: testuser2) A user in the "building" realm with only read access to assets</li>
- * <li><code>testuser3</code> - (Password: testuser3) A user in the "building" realm with read/write access to a restricted set of assets and their rules</li>
- * <li><code>building</code> - (Password: building) A user in the "building" realm with read/write access to the building apartment 1 assets and their rules</li>
- * <li><code>testuser4</code> - (Password: testuser4) A user in the "smartcity" realm with read/write access to a restricted set of assets and their rules</li>
+ * <li><code>smartcity</code> - (Password: smartcity) A user in the "smartcity" realm with read access</li>
*
* </ul>
*/
@@ -52,13 +41,8 @@ public class KeycloakDemoSetup extends AbstractKeycloakSetup {
private static final Logger LOG = Logger.getLogger(KeycloakDemoSetup.class.getName());
- public String testuser1Id;
- public String testuser2Id;
- public String testuser3Id;
public String smartCityUserId;
- public String buildingUserId;
public Tenant masterTenant;
- public Tenant tenantBuilding;
public Tenant tenantCity;
public KeycloakDemoSetup(Container container) {
@@ -71,7 +55,6 @@ public class KeycloakDemoSetup extends AbstractKeycloakSetup {
// Tenants
masterTenant = identityService.getIdentityProvider().getTenant(Constants.MASTER_REALM);
- tenantBuilding = createTenant("building", "Building");
tenantCity = createTenant("smartcity", "Smart City");
// Don't allow demo users to write assets
@@ -79,46 +62,9 @@ public class KeycloakDemoSetup extends AbstractKeycloakSetup {
.filter(clientRole -> clientRole != ClientRole.WRITE_ASSETS)
.toArray(ClientRole[]::new);
-
// Users
- User testuser1 = createUser(MASTER_REALM, "testuser1", "testuser1", "DemoMaster", "DemoLast", null, true, container.isDevMode() ? REGULAR_USER_ROLES : demoUserRoles);
- this.testuser1Id = testuser1.getId();
- keycloakProvider.updateRoles(MASTER_REALM, testuser1Id, "account"); // Remove all roles for account client
- User testuser2 = createUser(tenantBuilding.getRealm(), "testuser2", "testuser2", "DemoA2", "DemoLast", "[email protected]", true, new ClientRole[] {
- ClientRole.WRITE_USER,
- ClientRole.READ_MAP,
- ClientRole.READ_ASSETS
- });
- this.testuser2Id = testuser2.getId();
- keycloakProvider.updateRoles(tenantBuilding.getRealm(), testuser2Id, "account"); // Remove all roles for account client
- User testuser3 = createUser(tenantBuilding.getRealm(), "testuser3", "testuser3", "DemoA3", "DemoLast", "[email protected]", true, container.isDevMode() ? REGULAR_USER_ROLES : demoUserRoles);
- this.testuser3Id = testuser3.getId();
- keycloakProvider.updateRoles(tenantBuilding.getRealm(), testuser3Id, "account"); // Remove all roles for account client
- User buildingUser = createUser(tenantBuilding.getRealm(), "building", "building", "Building", "User", "[email protected]", true, demoUserRoles);
- this.buildingUserId = buildingUser.getId();
- keycloakProvider.updateRoles(tenantBuilding.getRealm(), buildingUserId, "account"); // Remove all roles for account client
User smartCityUser = createUser(tenantCity.getRealm(), "smartcity", "smartcity", "Smart", "City", null, true, demoUserRoles);
this.smartCityUserId = smartCityUser.getId();
keycloakProvider.updateRoles(tenantCity.getRealm(), smartCityUserId, "account"); // Remove all roles for account client
-
- if (container.isDevMode()) {
- /*
- * MQTT Client
- */
- ClientRepresentation mqttClient = new ClientRepresentation();
- String buildingMqttClientId = MqttBrokerService.MQTT_CLIENT_ID_PREFIX + UniqueIdentifierGenerator.generateId(tenantBuilding.getRealm());
- mqttClient.setClientId(buildingMqttClientId);
- mqttClient.setName("MQTT");
- mqttClient.setStandardFlowEnabled(false);
- mqttClient.setImplicitFlowEnabled(false);
- mqttClient.setDirectAccessGrantsEnabled(false);
- mqttClient.setServiceAccountsEnabled(true);
- mqttClient.setSecret(UniqueIdentifierGenerator.generateId(tenantBuilding.getRealm()));
- mqttClient = keycloakProvider.createClient(tenantBuilding.getRealm(), mqttClient);
-
- // Add asset RW roles to service user
- User serviceUser = keycloakProvider.getClientServiceUser(tenantBuilding.getRealm(), mqttClient.getClientId());
- keycloakProvider.updateRoles(tenantBuilding.getRealm(), serviceUser.getId(), KEYCLOAK_CLIENT_ID, ClientRole.READ_ASSETS.getValue(), ClientRole.WRITE_ASSETS.getValue(), ClientRole.WRITE_ATTRIBUTES.getValue());
- }
}
}
diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/KeycloakTestSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/KeycloakTestSetup.java
new file mode 100644
index 000000000..25a1a24f6
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/KeycloakTestSetup.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2020, 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.manager.setup.builtin;
+
+import org.keycloak.representations.idm.ClientRepresentation;
+import org.openremote.container.Container;
+import org.openremote.container.util.UniqueIdentifierGenerator;
+import org.openremote.manager.mqtt.MqttBrokerService;
+import org.openremote.manager.setup.AbstractKeycloakSetup;
+import org.openremote.model.Constants;
+import org.openremote.model.security.ClientRole;
+import org.openremote.model.security.Tenant;
+import org.openremote.model.security.User;
+
+import java.util.Arrays;
+import java.util.logging.Logger;
+
+import static org.openremote.model.Constants.KEYCLOAK_CLIENT_ID;
+import static org.openremote.model.Constants.MASTER_REALM;
+
+/**
+ * We have the following demo users:
+ * <ul>
+ * <li><code>admin</code> - The superuser in the "master" realm with all access</li>
+ * <li><code>testuser1</code> - (Password: testuser1) A user in the "master" realm with read/write access to assets and rules</li>
+ * <li><code>testuser2</code> - (Password: testuser2) A user in the "building" realm with only read access to assets</li>
+ * <li><code>testuser3</code> - (Password: testuser3) A user in the "building" realm with read/write access to a restricted set of assets and their rules</li>
+ * <li><code>building</code> - (Password: building) A user in the "building" realm with read/write access to the building apartment 1 assets and their rules</li>
+ * <li><code>testuser4</code> - (Password: testuser4) A user in the "smartcity" realm with read/write access to a restricted set of assets and their rules</li>
+ *
+ * </ul>
+ */
+public class KeycloakTestSetup extends AbstractKeycloakSetup {
+
+ private static final Logger LOG = Logger.getLogger(KeycloakTestSetup.class.getName());
+
+ public String testuser1Id;
+ public String testuser2Id;
+ public String testuser3Id;
+ public String smartCityUserId;
+ public String buildingUserId;
+ public Tenant masterTenant;
+ public Tenant tenantBuilding;
+ public Tenant tenantCity;
+
+ public KeycloakTestSetup(Container container) {
+ super(container);
+ }
+
+ @Override
+ public void onStart() throws Exception {
+ super.onStart();
+
+ // Tenants
+ masterTenant = identityService.getIdentityProvider().getTenant(Constants.MASTER_REALM);
+ tenantBuilding = createTenant("building", "Building");
+ tenantCity = createTenant("smartcity", "Smart City");
+
+ // Don't allow demo users to write assets
+ ClientRole[] demoUserRoles = Arrays.stream(REGULAR_USER_ROLES)
+ .filter(clientRole -> clientRole != ClientRole.WRITE_ASSETS)
+ .toArray(ClientRole[]::new);
+
+
+ // Users
+ User testuser1 = createUser(MASTER_REALM, "testuser1", "testuser1", "DemoMaster", "DemoLast", null, true, container.isDevMode() ? REGULAR_USER_ROLES : demoUserRoles);
+ this.testuser1Id = testuser1.getId();
+ keycloakProvider.updateRoles(MASTER_REALM, testuser1Id, "account"); // Remove all roles for account client
+ User testuser2 = createUser(tenantBuilding.getRealm(), "testuser2", "testuser2", "DemoA2", "DemoLast", "[email protected]", true, new ClientRole[] {
+ ClientRole.WRITE_USER,
+ ClientRole.READ_MAP,
+ ClientRole.READ_ASSETS
+ });
+ this.testuser2Id = testuser2.getId();
+ keycloakProvider.updateRoles(tenantBuilding.getRealm(), testuser2Id, "account"); // Remove all roles for account client
+ User testuser3 = createUser(tenantBuilding.getRealm(), "testuser3", "testuser3", "DemoA3", "DemoLast", "[email protected]", true, container.isDevMode() ? REGULAR_USER_ROLES : demoUserRoles);
+ this.testuser3Id = testuser3.getId();
+ keycloakProvider.updateRoles(tenantBuilding.getRealm(), testuser3Id, "account"); // Remove all roles for account client
+ User buildingUser = createUser(tenantBuilding.getRealm(), "building", "building", "Building", "User", "[email protected]", true, demoUserRoles);
+ this.buildingUserId = buildingUser.getId();
+ keycloakProvider.updateRoles(tenantBuilding.getRealm(), buildingUserId, "account"); // Remove all roles for account client
+ User smartCityUser = createUser(tenantCity.getRealm(), "smartcity", "smartcity", "Smart", "City", null, true, demoUserRoles);
+ this.smartCityUserId = smartCityUser.getId();
+ keycloakProvider.updateRoles(tenantCity.getRealm(), smartCityUserId, "account"); // Remove all roles for account client
+
+ if (container.isDevMode()) {
+ /*
+ * MQTT Client
+ */
+ ClientRepresentation mqttClient = new ClientRepresentation();
+ String buildingMqttClientId = MqttBrokerService.MQTT_CLIENT_ID_PREFIX + UniqueIdentifierGenerator.generateId(tenantBuilding.getRealm());
+ mqttClient.setClientId(buildingMqttClientId);
+ mqttClient.setName("MQTT");
+ mqttClient.setStandardFlowEnabled(false);
+ mqttClient.setImplicitFlowEnabled(false);
+ mqttClient.setDirectAccessGrantsEnabled(false);
+ mqttClient.setServiceAccountsEnabled(true);
+ mqttClient.setSecret(UniqueIdentifierGenerator.generateId(tenantBuilding.getRealm()));
+ mqttClient = keycloakProvider.createClient(tenantBuilding.getRealm(), mqttClient);
+
+ // Add asset RW roles to service user
+ User serviceUser = keycloakProvider.getClientServiceUser(tenantBuilding.getRealm(), mqttClient.getClientId());
+ keycloakProvider.updateRoles(tenantBuilding.getRealm(), serviceUser.getId(), KEYCLOAK_CLIENT_ID, ClientRole.READ_ASSETS.getValue(), ClientRole.WRITE_ASSETS.getValue(), ClientRole.WRITE_ATTRIBUTES.getValue());
+ }
+ }
+}
diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoAgentSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoAgentSetup.java
index 052180167..b0c4667df 100644
--- a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoAgentSetup.java
+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoAgentSetup.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016, OpenRemote Inc.
+ * Copyright 2020, OpenRemote Inc.
*
* See the CONTRIBUTORS.txt file in the distribution for a
* full listing of individual contributors.
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.java
index 44e7b42f8..a9dda3c2e 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
@@ -19,28 +19,35 @@
*/
package org.openremote.manager.setup.builtin;
+import org.openremote.agent.protocol.http.HttpClientProtocol;
import org.openremote.agent.protocol.simulator.SimulatorProtocol;
import org.openremote.container.Container;
import org.openremote.container.util.UniqueIdentifierGenerator;
-import org.openremote.manager.security.UserConfiguration;
import org.openremote.manager.setup.AbstractManagerSetup;
import org.openremote.model.apps.ConsoleAppConfig;
import org.openremote.model.asset.Asset;
import org.openremote.model.asset.AssetAttribute;
-import org.openremote.model.asset.UserAsset;
-import org.openremote.model.attribute.*;
+import org.openremote.model.asset.AssetType;
+import org.openremote.model.asset.ElectricityProducerOrientationType;
+import org.openremote.model.attribute.AttributeLink;
+import org.openremote.model.attribute.AttributeRef;
+import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.MetaItem;
import org.openremote.model.geo.GeoJSONPoint;
import org.openremote.model.security.Tenant;
-import org.openremote.model.simulator.element.ColorSimulatorElement;
import org.openremote.model.simulator.element.NumberSimulatorElement;
-import org.openremote.model.simulator.element.SwitchSimulatorElement;
-import org.openremote.model.value.ObjectValue;
+import org.openremote.model.simulator.element.ReplaySimulatorElement;
+import org.openremote.model.value.JsonPathFilter;
+import org.openremote.model.value.Value;
+import org.openremote.model.value.ValueFilter;
import org.openremote.model.value.Values;
-import java.util.Arrays;
-import java.util.List;
+import java.time.Duration;
+import java.time.LocalTime;
-import static org.openremote.manager.datapoint.AssetDatapointService.DATA_POINTS_MAX_AGE_DAYS_DEFAULT;
+import static java.time.temporal.ChronoField.SECOND_OF_DAY;
+import static org.openremote.agent.protocol.http.HttpClientProtocol.*;
+import static org.openremote.model.Constants.UNITS_POWER_KILOWATT;
import static org.openremote.model.asset.AssetType.*;
import static org.openremote.model.asset.agent.ProtocolConfiguration.initProtocolConfiguration;
import static org.openremote.model.attribute.AttributeValueType.*;
@@ -48,61 +55,18 @@ import static org.openremote.model.attribute.MetaItemType.*;
public class ManagerDemoSetup extends AbstractManagerSetup {
- // Update these numbers whenever you change a RULE_STATE flag in test data
- public static final int DEMO_RULE_STATES_APARTMENT_1 = 44;
- public static final int DEMO_RULE_STATES_APARTMENT_2 = 13;
- 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 = 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;
- public static GeoJSONPoint SMART_OFFICE_LOCATION = new GeoJSONPoint(5.460315214821094, 51.44541688237109);
- public static GeoJSONPoint SMART_BUILDING_LOCATION = new GeoJSONPoint(5.454027, 51.446308);
- public static GeoJSONPoint SMART_CITY_LOCATION = new GeoJSONPoint(5.3814711, 51.4484647);
- public static GeoJSONPoint AREA_1_LOCATION = new GeoJSONPoint(5.478478, 51.439272);
- public static GeoJSONPoint AREA_2_LOCATION = new GeoJSONPoint(5.473829, 51.438744);
- public static GeoJSONPoint AREA_3_LOCATION = new GeoJSONPoint(5.487478, 51.446979);
- public static final String agentProtocolConfigName = "simulator123";
- public static final String thingLightToggleAttributeName = "light1Toggle";
- public static final Scene[] DEMO_APARTMENT_SCENES = new Scene[] {
- new Scene("morningScene", "Morning scene", "MORNING", "0 0 7 ? *", false, 21d),
- new Scene("dayScene", "Day scene", "DAY", "0 30 8 ? *", true, 15d),
- new Scene("eveningScene", "Evening scene", "EVENING", "0 30 17 ? *", false, 22d),
- new Scene("nightScene", "Night scene", "NIGHT", "0 0 22 ? *", true, 19d)
- };
- final protected boolean importDemoScenes;
- public String smartOfficeId;
- public String groundFloorId;
- public String lobbyId;
- public String agentId;
- public String thingId;
- public String smartBuildingId;
- public String apartment1Id;
- public String apartment1SceneAgentId;
- public String apartment1ServiceAgentId;
- public String apartment1LivingroomId = UniqueIdentifierGenerator.generateId("apartment1LivingroomId");
- public String apartment1KitchenId;
- public String apartment1HallwayId;
- public String apartment1Bedroom1Id;
- public String apartment1BathroomId;
- public String apartment2Id;
- public String apartment3Id;
- public String apartment2LivingroomId;
- public String apartment2BathroomId;
- public String apartment3LivingroomId;
+ public static GeoJSONPoint STATIONSPLEIN_LOCATION = new GeoJSONPoint(4.470175, 51.923464);
public String masterRealm;
- public String realmBuildingTenant;
public String realmCityTenant;
- public String smartCityServiceAgentId;
public String area1Id;
- public String microphone1Id;
- public String peopleCounter3AssetId;
+ public String smartcitySimulatorAgentId;
+ public String energyManagementId;
+ public String weatherHttpApiAgentId;
- public ManagerDemoSetup(Container container, boolean importDemoScenes) {
+ private final long halfHourInMillis = Duration.ofMinutes(30).toMillis();
+
+ public ManagerDemoSetup(Container container) {
super(container);
- this.importDemoScenes = importDemoScenes;
}
@Override
@@ -110,657 +74,751 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
KeycloakDemoSetup keycloakDemoSetup = setupService.getTaskOfType(KeycloakDemoSetup.class);
Tenant masterTenant = keycloakDemoSetup.masterTenant;
- Tenant tenantBuilding = keycloakDemoSetup.tenantBuilding;
Tenant tenantCity = keycloakDemoSetup.tenantCity;
masterRealm = masterTenant.getRealm();
- this.realmBuildingTenant = tenantBuilding.getRealm();
this.realmCityTenant = tenantCity.getRealm();
// ################################ Demo assets for 'master' realm ###################################
- ObjectValue locationValue = SMART_OFFICE_LOCATION.toValue();
-
- Asset smartOffice = new Asset();
- smartOffice.setRealm(masterRealm);
- smartOffice.setName("Smart Office");
- smartOffice.setType(BUILDING);
- List<AssetAttribute> smartOfficeAttributes = Arrays.asList(
- new AssetAttribute(AttributeType.LOCATION, locationValue),
- new AssetAttribute(AttributeType.GEO_STREET, Values.create("Torenallee 20")),
- new AssetAttribute(AttributeType.GEO_POSTAL_CODE, Values.create(5617)),
- new AssetAttribute(AttributeType.GEO_CITY, Values.create("Eindhoven")),
- new AssetAttribute(AttributeType.GEO_COUNTRY, Values.create("Netherlands"))
+
+ // ################################ Link demo users and assets ###################################
+
+
+ // ################################ Make users restricted ###################################
+
+
+ // ################################ Realm smartcity ###################################
+
+ Asset smartcitySimulatorAgent = new Asset("Simulator Agent", AssetType.AGENT);
+ smartcitySimulatorAgent.setRealm(this.realmCityTenant);
+ smartcitySimulatorAgent
+ .addAttributes(
+ initProtocolConfiguration(new AssetAttribute("inputSimulator"), SimulatorProtocol.PROTOCOL_NAME)
+ .addMeta(
+ new MetaItem(
+ SimulatorProtocol.CONFIG_MODE,
+ Values.create(SimulatorProtocol.Mode.WRITE_THROUGH_IMMEDIATE.toString())
+ ))
+ )
+ .addAttributes(
+ initProtocolConfiguration(new AssetAttribute("replaySimulator"), SimulatorProtocol.PROTOCOL_NAME)
+ .addMeta(
+ new MetaItem(
+ SimulatorProtocol.CONFIG_MODE,
+ Values.create(SimulatorProtocol.Mode.REPLAY.toString())
+ )
+ )
+ );
+ smartcitySimulatorAgent = assetStorageService.merge(smartcitySimulatorAgent);
+ smartcitySimulatorAgentId = smartcitySimulatorAgent.getId();
+
+ LocalTime midnight = LocalTime.of(0, 0);
+
+ // ################################ Realm smartcity - Energy Management ###################################
+
+ Asset energyManagement = new Asset();
+ energyManagement.setRealm(this.realmCityTenant);
+ energyManagement.setName("Energy Management");
+ energyManagement.setType(THING);
+ energyManagement.addAttributes(
+ new AssetAttribute("totalPowerProducers", POWER).addMeta(
+ LABEL.withInitialValue("Combined power of all producers"),
+ UNIT_TYPE.withInitialValue(UNITS_POWER_KILOWATT),
+ STORE_DATA_POINTS,
+ READ_ONLY,
+ RULE_STATE),
+ new AssetAttribute("totalPowerConsumers", POWER).addMeta(
+ LABEL.withInitialValue("Combined power use of all consumers"),
+ UNIT_TYPE.withInitialValue(UNITS_POWER_KILOWATT),
+ STORE_DATA_POINTS,
+ RULE_STATE,
+ READ_ONLY)
+ );
+ energyManagement = assetStorageService.merge(energyManagement);
+ energyManagementId = energyManagement.getId();
+
+ // ### De Rotterdam ###
+ Asset building1Asset = new Asset("De Rotterdam", BUILDING, energyManagement);
+ building1Asset.setAttributes(
+ new AssetAttribute(AttributeType.GEO_STREET, Values.create("Wilhelminakade 139")),
+ new AssetAttribute(AttributeType.GEO_POSTAL_CODE, Values.create("3072 AP")),
+ new AssetAttribute(AttributeType.GEO_CITY, Values.create("Rotterdam")),
+ new AssetAttribute(AttributeType.GEO_COUNTRY, Values.create("Netherlands")),
+ new AssetAttribute("powerBalance", POWER).addMeta(
+ LABEL.withInitialValue("Balance of power production and use"),
+ UNIT_TYPE.withInitialValue(UNITS_POWER_KILOWATT),
+ STORE_DATA_POINTS,
+ RULE_STATE,
+ READ_ONLY)
);
+ building1Asset = assetStorageService.merge(building1Asset);
- smartOffice.setAttributes(smartOfficeAttributes);
- smartOffice = assetStorageService.merge(smartOffice);
- smartOfficeId = smartOffice.getId();
+ Asset storage1Asset = createDemoElectricityStorageAsset("Battery De Rotterdam", building1Asset, new GeoJSONPoint(4.488324, 51.906577));
+ storage1Asset = assetStorageService.merge(storage1Asset);
- Asset groundFloor = new Asset("Ground Floor", FLOOR, smartOffice)
- .addAttributes(new AssetAttribute(AttributeType.LOCATION, locationValue));
- groundFloor = assetStorageService.merge(groundFloor);
- groundFloorId = groundFloor.getId();
+ Asset consumption1Asset = createDemoElectricityConsumerAsset("Consumption De Rotterdam", building1Asset, new GeoJSONPoint(4.487519, 51.906544));
+ consumption1Asset = assetStorageService.merge(consumption1Asset);
- Asset lobby = new Asset("Lobby", ROOM, groundFloor)
- .addAttributes(new AssetAttribute(AttributeType.LOCATION, locationValue));
- lobby.addAttributes(
- new AssetAttribute("lobbyLocations", AttributeValueType.ARRAY)
+ Asset production1Asset = createDemoElectricityProducerAsset("Solar De Rotterdam", building1Asset, new GeoJSONPoint(4.488592, 51.907047));
+ production1Asset.getAttribute("totalPower").ifPresent(assetAttribute -> {
+ assetAttribute.setValue(Values.create(6.02));
+ assetAttribute.addMeta(STORE_DATA_POINTS);
+ });
+ production1Asset.getAttribute("totalEnergy").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(6.02)));
+ production1Asset.getAttribute("installedCapacity").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(16.52)));
+ production1Asset.getAttribute("systemEfficiency").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(93)));
+ production1Asset.getAttribute("panelOrientation").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(ElectricityProducerOrientationType.EAST_WEST.name())));
+ production1Asset = assetStorageService.merge(production1Asset);
+
+ // ### Stadhuis ###
+
+ Asset building2Asset = new Asset("Stadhuis", BUILDING, energyManagement);
+ building2Asset.setAttributes(
+ new AssetAttribute(AttributeType.GEO_STREET, Values.create("Coolsingel 40")),
+ new AssetAttribute(AttributeType.GEO_POSTAL_CODE, Values.create("3011 AD")),
+ new AssetAttribute(AttributeType.GEO_CITY, Values.create("Rotterdam")),
+ new AssetAttribute(AttributeType.GEO_COUNTRY, Values.create("Netherlands"))
);
+ building2Asset = assetStorageService.merge(building2Asset);
+
+ Asset storage2Asset = createDemoElectricityStorageAsset("Battery Stadhuis", building2Asset, new GeoJSONPoint(4.47985, 51.92274));
+ storage2Asset = assetStorageService.merge(storage2Asset);
- lobby = assetStorageService.merge(lobby);
- lobbyId = lobby.getId();
+ Asset consumption2Asset = createDemoElectricityConsumerAsset("Consumption Stadhuis", building2Asset, new GeoJSONPoint(4.47933, 51.92259));
+ consumption2Asset = assetStorageService.merge(consumption2Asset);
+
+ Asset production2Asset = createDemoElectricityProducerAsset("Solar Stadhuis", building2Asset, new GeoJSONPoint(4.47945, 51.92301));
+ production2Asset.getAttribute("totalPower").ifPresent(assetAttribute -> {
+ assetAttribute.setValue(Values.create(5.13));
+ assetAttribute.addMeta(STORE_DATA_POINTS);
+ });
+ production2Asset.getAttribute("totalEnergy").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(5.13)));
+ production2Asset.getAttribute("installedCapacity").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(15.70)));
+ production2Asset.getAttribute("systemEfficiency").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(79)));
+ production2Asset.getAttribute("panelOrientation").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(ElectricityProducerOrientationType.SOUTH.name())));
+ production2Asset = assetStorageService.merge(production2Asset);
+
+ // ### Markthal ###
+
+ Asset building3Asset = new Asset("Markthal", BUILDING, energyManagement);
+ building3Asset.setAttributes(
+ new AssetAttribute(AttributeType.GEO_STREET, Values.create("Dominee Jan Scharpstraat 298")),
+ new AssetAttribute(AttributeType.GEO_POSTAL_CODE, Values.create("3011 GZ")),
+ new AssetAttribute(AttributeType.GEO_CITY, Values.create("Rotterdam")),
+ new AssetAttribute(AttributeType.GEO_COUNTRY, Values.create("Netherlands")),
+ new AssetAttribute("allChargersInUse", BOOLEAN)
+ .addMeta(
+ LABEL.withInitialValue("All chargers in use"),
+ RULE_STATE,
+ READ_ONLY)
+ );
+ building3Asset = assetStorageService.merge(building3Asset);
- Asset agent = new Asset("Demo Agent", AGENT, lobby);
- agent.addAttributes(
- new AssetAttribute(AttributeType.LOCATION, locationValue),
- initProtocolConfiguration(new AssetAttribute(agentProtocolConfigName), SimulatorProtocol.PROTOCOL_NAME)
- .addMeta(
+ Asset production3Asset = createDemoElectricityProducerAsset("Solar Markthal", building3Asset, new GeoJSONPoint(4.47945, 51.92301));
+ production3Asset.getAttribute("totalPower").ifPresent(assetAttribute -> {
+ assetAttribute.setValue(Values.create(4.28));
+ assetAttribute.addMeta(STORE_DATA_POINTS);
+ });
+ production3Asset.getAttribute("totalEnergy").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(4.28)));
+ production3Asset.getAttribute("installedCapacity").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(18.11)));
+ production3Asset.getAttribute("systemEfficiency").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(91)));
+ production3Asset.getAttribute("panelOrientation").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(ElectricityProducerOrientationType.SOUTH.name())));
+ production3Asset = assetStorageService.merge(production3Asset);
+
+ Asset charger1Asset = createDemoElectricityChargerAsset("Charger 1 Markthal", building3Asset, new GeoJSONPoint(4.486143, 51.920058));
+ charger1Asset.getAttribute("power").ifPresent(assetAttribute -> {
+ assetAttribute.setValue(Values.create(0));
+ assetAttribute.addMeta(
new MetaItem(
- SimulatorProtocol.CONFIG_MODE,
- Values.create(SimulatorProtocol.Mode.WRITE_THROUGH_DELAYED.toString())
+ AGENT_LINK,
+ new AttributeRef(smartcitySimulatorAgentId, "replaySimulator").toArrayValue()
),
new MetaItem(
- SimulatorProtocol.CONFIG_WRITE_DELAY_MILLISECONDS,
- Values.create(500)
- ))
- );
-
- agent = assetStorageService.merge(agent);
- agentId = agent.getId();
+ SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(ReplaySimulatorElement.ELEMENT_NAME)
+ ),
+ new MetaItem(
+ SimulatorProtocol.REPLAY_ATTRIBUTE_LINK_DATA,
+ Values.createArray().addAll(
+ Values.createObject().put("timestamp", midnight.get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(1).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(2).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(3).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(4).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(5).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(6).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(7).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(8).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(9).get(SECOND_OF_DAY)).put("value", 2),
+ Values.createObject().put("timestamp", midnight.plusHours(10).get(SECOND_OF_DAY)).put("value", 5),
+ Values.createObject().put("timestamp", midnight.plusHours(11).get(SECOND_OF_DAY)).put("value", 10),
+ Values.createObject().put("timestamp", midnight.plusHours(12).get(SECOND_OF_DAY)).put("value", 5),
+ Values.createObject().put("timestamp", midnight.plusHours(13).get(SECOND_OF_DAY)).put("value", 3),
+ Values.createObject().put("timestamp", midnight.plusHours(14).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(15).get(SECOND_OF_DAY)).put("value", 15),
+ Values.createObject().put("timestamp", midnight.plusHours(16).get(SECOND_OF_DAY)).put("value", 32),
+ Values.createObject().put("timestamp", midnight.plusHours(17).get(SECOND_OF_DAY)).put("value", 35),
+ Values.createObject().put("timestamp", midnight.plusHours(18).get(SECOND_OF_DAY)).put("value", 17),
+ Values.createObject().put("timestamp", midnight.plusHours(19).get(SECOND_OF_DAY)).put("value", 9),
+ Values.createObject().put("timestamp", midnight.plusHours(20).get(SECOND_OF_DAY)).put("value", 6),
+ Values.createObject().put("timestamp", midnight.plusHours(21).get(SECOND_OF_DAY)).put("value", 3),
+ Values.createObject().put("timestamp", midnight.plusHours(22).get(SECOND_OF_DAY)).put("value", 3),
+ Values.createObject().put("timestamp", midnight.plusHours(23).get(SECOND_OF_DAY)).put("value", 0)
+ )
+ )
+ );
+ });
+ charger1Asset = assetStorageService.merge(charger1Asset);
- Asset thing = new Asset("Demo Thing", THING, agent)
- .addAttributes(new AssetAttribute(AttributeType.LOCATION, locationValue)
- .setMeta(new MetaItem(RULE_STATE, Values.create(true))));
- thing.addAttributes(
- new AssetAttribute(thingLightToggleAttributeName, BOOLEAN, Values.create(true))
- .setMeta(new Meta(
+ Asset charger2Asset = createDemoElectricityChargerAsset("Charger 2 Markthal", building3Asset, new GeoJSONPoint(4.486188, 51.919957));
+ charger2Asset.getAttribute("power").ifPresent(assetAttribute -> {
+ assetAttribute.setValue(Values.create(0));
+ assetAttribute.addMeta(
new MetaItem(
- LABEL,
- Values.create("Light 1 Toggle")),
+ AGENT_LINK,
+ new AttributeRef(smartcitySimulatorAgentId, "replaySimulator").toArrayValue()
+ ),
new MetaItem(
- DESCRIPTION,
- Values.create("Switch for living room light")),
+ SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(ReplaySimulatorElement.ELEMENT_NAME)
+ ),
new MetaItem(
- STORE_DATA_POINTS,
- Values.create(true)),
+ SimulatorProtocol.REPLAY_ATTRIBUTE_LINK_DATA,
+ Values.createArray().addAll(
+ Values.createObject().put("timestamp", midnight.get(SECOND_OF_DAY)).put("value", 5),
+ Values.createObject().put("timestamp", midnight.plusHours(1).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(2).get(SECOND_OF_DAY)).put("value", 11),
+ Values.createObject().put("timestamp", midnight.plusHours(3).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(4).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(5).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(6).get(SECOND_OF_DAY)).put("value", 5),
+ Values.createObject().put("timestamp", midnight.plusHours(7).get(SECOND_OF_DAY)).put("value", 10),
+ Values.createObject().put("timestamp", midnight.plusHours(8).get(SECOND_OF_DAY)).put("value", 6),
+ Values.createObject().put("timestamp", midnight.plusHours(9).get(SECOND_OF_DAY)).put("value", 3),
+ Values.createObject().put("timestamp", midnight.plusHours(10).get(SECOND_OF_DAY)).put("value", 3),
+ Values.createObject().put("timestamp", midnight.plusHours(11).get(SECOND_OF_DAY)).put("value", 17),
+ Values.createObject().put("timestamp", midnight.plusHours(12).get(SECOND_OF_DAY)).put("value", 14),
+ Values.createObject().put("timestamp", midnight.plusHours(13).get(SECOND_OF_DAY)).put("value", 9),
+ Values.createObject().put("timestamp", midnight.plusHours(14).get(SECOND_OF_DAY)).put("value", 4),
+ Values.createObject().put("timestamp", midnight.plusHours(15).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(16).get(SECOND_OF_DAY)).put("value", 28),
+ Values.createObject().put("timestamp", midnight.plusHours(17).get(SECOND_OF_DAY)).put("value", 38),
+ Values.createObject().put("timestamp", midnight.plusHours(18).get(SECOND_OF_DAY)).put("value", 32),
+ Values.createObject().put("timestamp", midnight.plusHours(19).get(SECOND_OF_DAY)).put("value", 26),
+ Values.createObject().put("timestamp", midnight.plusHours(20).get(SECOND_OF_DAY)).put("value", 13),
+ Values.createObject().put("timestamp", midnight.plusHours(21).get(SECOND_OF_DAY)).put("value", 6),
+ Values.createObject().put("timestamp", midnight.plusHours(22).get(SECOND_OF_DAY)).put("value", 3),
+ Values.createObject().put("timestamp", midnight.plusHours(23).get(SECOND_OF_DAY)).put("value", 0)
+ )
+ )
+ );
+ });
+ charger2Asset = assetStorageService.merge(charger2Asset);
+
+ Asset charger3Asset = createDemoElectricityChargerAsset("Charger 3 Markthal", building3Asset, new GeoJSONPoint(4.486232, 51.919856));
+ charger1Asset.getAttribute("power").ifPresent(assetAttribute -> {
+ assetAttribute.setValue(Values.create(0));
+ assetAttribute.addMeta(
new MetaItem(
- DATA_POINTS_MAX_AGE_DAYS,
- Values.create(DATA_POINTS_MAX_AGE_DAYS_DEFAULT*7)
+ AGENT_LINK,
+ new AttributeRef(smartcitySimulatorAgentId, "replaySimulator").toArrayValue()
),
new MetaItem(
- AGENT_LINK,
- new AttributeRef(agent.getId(), agentProtocolConfigName).toArrayValue()),
- new MetaItem(
- SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(SwitchSimulatorElement.ELEMENT_NAME)
- ))
- ),
- new AssetAttribute("light1Dimmer", PERCENTAGE) // No initial value!
- .setMeta(new Meta(
- new MetaItem(
- LABEL,
- Values.create("Light 1 Dimmer")),
- new MetaItem(
- DESCRIPTION,
- Values.create("Dimmer for living room light")),
- new MetaItem(
- RANGE_MIN,
- Values.create(0)),
- new MetaItem(
- RANGE_MAX,
- Values.create(100)),
- new MetaItem(
- AGENT_LINK,
- new AttributeRef(agent.getId(), agentProtocolConfigName).toArrayValue()),
- new MetaItem(
- SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME_RANGE)),
- new MetaItem(
- SimulatorProtocol.CONFIG_MODE,
- Values.create(SimulatorProtocol.Mode.WRITE_THROUGH_DELAYED.toString()))
- )
- ),
- new AssetAttribute("light1Color", COLOR_RGB, new ColorRGB(88, 123, 88).asArrayValue())
- .setMeta(new Meta(
- new MetaItem(
- LABEL,
- Values.create("Light 1 Color")),
- new MetaItem(
- DESCRIPTION,
- Values.create("Color of living room light")),
- new MetaItem(
- AGENT_LINK,
- new AttributeRef(agent.getId(), agentProtocolConfigName).toArrayValue()),
- new MetaItem(
- SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(ColorSimulatorElement.ELEMENT_NAME))
- )
- ),
- new AssetAttribute("light1PowerConsumption", ENERGY, Values.create(12.345))
- .setMeta(new Meta(
- new MetaItem(
- LABEL,
- Values.create("Light 1 Usage")),
- new MetaItem(
- DESCRIPTION,
- Values.create("Total energy consumption of living room light")),
- new MetaItem(
- READ_ONLY,
- Values.create(true)),
- new MetaItem(
- FORMAT,
- Values.create("%3d kWh")),
- new MetaItem(
- AGENT_LINK,
- new AttributeRef(agent.getId(), agentProtocolConfigName).toArrayValue()),
- new MetaItem(
- SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME)),
- new MetaItem(
- STORE_DATA_POINTS, Values.create(true))
- )
- )
- );
- thing = assetStorageService.merge(thing);
- thingId = thing.getId();
-
- // ################################ Demo assets for 'building' realm ###################################
-
- Asset smartBuilding = new Asset();
- smartBuilding.setRealm(this.realmBuildingTenant);
- smartBuilding.setName("Smart Building");
- smartBuilding.setType(BUILDING);
- smartBuilding.setAttributes(
- new AssetAttribute(AttributeType.LOCATION, SMART_BUILDING_LOCATION.toValue()).addMeta(SHOW_ON_DASHBOARD),
- new AssetAttribute(AttributeType.GEO_STREET, Values.create("Kastanjelaan 500")),
- new AssetAttribute(AttributeType.GEO_POSTAL_CODE, Values.create(5616)),
- new AssetAttribute(AttributeType.GEO_CITY, Values.create("Eindhoven")),
- new AssetAttribute(AttributeType.GEO_COUNTRY, Values.create("Netherlands"))
- );
- smartBuilding = assetStorageService.merge(smartBuilding);
- smartBuildingId = smartBuilding.getId();
-
- // The "Apartment 1" is the demo apartment with complex scenes
- Asset apartment1 = createDemoApartment(smartBuilding, "Apartment 1", new GeoJSONPoint(5.454233, 51.446800));
- apartment1 = assetStorageService.merge(apartment1);
- apartment1Id = apartment1.getId();
-
- Asset apartment1ServiceAgent = new Asset("Service Agent (Simulator)", AGENT, apartment1);
- apartment1ServiceAgent.addAttributes(
- initProtocolConfiguration(new AssetAttribute("apartmentSimulator"), SimulatorProtocol.PROTOCOL_NAME)
- .addMeta(
+ SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(ReplaySimulatorElement.ELEMENT_NAME)
+ ),
new MetaItem(
- SimulatorProtocol.CONFIG_MODE,
- Values.create(SimulatorProtocol.Mode.WRITE_THROUGH_IMMEDIATE.toString())
- ))
- );
- apartment1ServiceAgent = assetStorageService.merge(apartment1ServiceAgent);
- apartment1ServiceAgentId = apartment1ServiceAgent.getId();
-
- /* ############################ ROOMS ############################## */
-
- Asset apartment1Livingroom = createDemoApartmentRoom(apartment1, "Living Room 1")
- .addAttributes(
- new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(5.454213, 51.446884).toValue()),
- new AssetAttribute("lightsCeiling", NUMBER, Values.create(0))
- .setMeta(
- new MetaItem(RANGE_MIN, Values.create(0)),
- new MetaItem(RANGE_MAX, Values.create(100)),
- new MetaItem(LABEL, Values.create("Ceiling lights (range)")),
- new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)),
- new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true))
- ),
- new AssetAttribute("lightsStand", AttributeValueType.BOOLEAN, Values.create(true))
- .setMeta(
- new MetaItem(LABEL, Values.create("Floor stand lights (on/off)")),
- new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)),
- new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true))
+ SimulatorProtocol.REPLAY_ATTRIBUTE_LINK_DATA,
+ Values.createArray().addAll(
+ Values.createObject().put("timestamp", midnight.get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(1).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(2).get(SECOND_OF_DAY)).put("value", 4),
+ Values.createObject().put("timestamp", midnight.plusHours(3).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(4).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(5).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(6).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(7).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(8).get(SECOND_OF_DAY)).put("value", 4),
+ Values.createObject().put("timestamp", midnight.plusHours(9).get(SECOND_OF_DAY)).put("value", 7),
+ Values.createObject().put("timestamp", midnight.plusHours(10).get(SECOND_OF_DAY)).put("value", 9),
+ Values.createObject().put("timestamp", midnight.plusHours(11).get(SECOND_OF_DAY)).put("value", 6),
+ Values.createObject().put("timestamp", midnight.plusHours(12).get(SECOND_OF_DAY)).put("value", 2),
+ Values.createObject().put("timestamp", midnight.plusHours(13).get(SECOND_OF_DAY)).put("value", 6),
+ Values.createObject().put("timestamp", midnight.plusHours(14).get(SECOND_OF_DAY)).put("value", 18),
+ Values.createObject().put("timestamp", midnight.plusHours(15).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(16).get(SECOND_OF_DAY)).put("value", 4),
+ Values.createObject().put("timestamp", midnight.plusHours(17).get(SECOND_OF_DAY)).put("value", 29),
+ Values.createObject().put("timestamp", midnight.plusHours(18).get(SECOND_OF_DAY)).put("value", 34),
+ Values.createObject().put("timestamp", midnight.plusHours(19).get(SECOND_OF_DAY)).put("value", 22),
+ Values.createObject().put("timestamp", midnight.plusHours(20).get(SECOND_OF_DAY)).put("value", 14),
+ Values.createObject().put("timestamp", midnight.plusHours(21).get(SECOND_OF_DAY)).put("value", 3),
+ Values.createObject().put("timestamp", midnight.plusHours(22).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(23).get(SECOND_OF_DAY)).put("value", 0)
)
+ )
);
- addDemoApartmentRoomMotionSensor(apartment1Livingroom, true, () -> new MetaItem[]{
- new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
- });
- addDemoApartmentRoomCO2Sensor(apartment1Livingroom, true, () -> new MetaItem[]{
- new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
- });
- addDemoApartmentRoomHumiditySensor(apartment1Livingroom, true, () -> new MetaItem[]{
- new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
});
- addDemoApartmentRoomThermometer(apartment1Livingroom, true, () -> new MetaItem[]{
- new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
- });
- addDemoApartmentTemperatureControl(apartment1Livingroom, true, () -> new MetaItem[]{
- new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
- });
-
- apartment1Livingroom.setId(apartment1LivingroomId);
- apartment1Livingroom = assetStorageService.merge(apartment1Livingroom);
- apartment1LivingroomId = apartment1Livingroom.getId();
+ charger3Asset = assetStorageService.merge(charger3Asset);
- Asset apartment1Kitchen = createDemoApartmentRoom(apartment1, "Kitchen 1")
- .addAttributes(
- new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(5.454122, 51.446800).toValue()),
- new AssetAttribute("lights", AttributeValueType.BOOLEAN, Values.create(true))
- .addMeta(new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)))
- .addMeta(new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)))
+ Asset charger4Asset = createDemoElectricityChargerAsset("Charger 4 Markthal", building3Asset, new GeoJSONPoint(4.486286, 51.919733));
+ charger4Asset.getAttribute("power").ifPresent(assetAttribute -> {
+ assetAttribute.setValue(Values.create(0));
+ assetAttribute.addMeta(
+ new MetaItem(
+ AGENT_LINK,
+ new AttributeRef(smartcitySimulatorAgentId, "replaySimulator").toArrayValue()
+ ),
+ new MetaItem(
+ SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(ReplaySimulatorElement.ELEMENT_NAME)
+ ),
+ new MetaItem(
+ SimulatorProtocol.REPLAY_ATTRIBUTE_LINK_DATA,
+ Values.createArray().addAll(
+ Values.createObject().put("timestamp", midnight.get(SECOND_OF_DAY)).put("value", 3),
+ Values.createObject().put("timestamp", midnight.plusHours(1).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(2).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(3).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(4).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(5).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(6).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(7).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(8).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(9).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(10).get(SECOND_OF_DAY)).put("value", 4),
+ Values.createObject().put("timestamp", midnight.plusHours(11).get(SECOND_OF_DAY)).put("value", 17),
+ Values.createObject().put("timestamp", midnight.plusHours(12).get(SECOND_OF_DAY)).put("value", 15),
+ Values.createObject().put("timestamp", midnight.plusHours(13).get(SECOND_OF_DAY)).put("value", 8),
+ Values.createObject().put("timestamp", midnight.plusHours(14).get(SECOND_OF_DAY)).put("value", 16),
+ Values.createObject().put("timestamp", midnight.plusHours(15).get(SECOND_OF_DAY)).put("value", 4),
+ Values.createObject().put("timestamp", midnight.plusHours(16).get(SECOND_OF_DAY)).put("value", 0),
+ Values.createObject().put("timestamp", midnight.plusHours(17).get(SECOND_OF_DAY)).put("value", 15),
+ Values.createObject().put("timestamp", midnight.plusHours(18).get(SECOND_OF_DAY)).put("value", 34),
+ Values.createObject().put("timestamp", midnight.plusHours(19).get(SECOND_OF_DAY)).put("value", 30),
+ Values.createObject().put("timestamp", midnight.plusHours(20).get(SECOND_OF_DAY)).put("value", 11),
+ Values.createObject().put("timestamp", midnight.plusHours(21).get(SECOND_OF_DAY)).put("value", 16),
+ Values.createObject().put("timestamp", midnight.plusHours(22).get(SECOND_OF_DAY)).put("value", 7),
+ Values.createObject().put("timestamp", midnight.plusHours(23).get(SECOND_OF_DAY)).put("value", 4)
+ )
+ )
);
- addDemoApartmentRoomMotionSensor(apartment1Kitchen, true, () -> new MetaItem[]{
- new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
});
+ charger4Asset = assetStorageService.merge(charger4Asset);
- for (String switchName : new String[]{"A", "B", "C"}) {
- addDemoApartmentSmartSwitch(apartment1Kitchen, switchName, true, attributeIndex -> {
- switch (attributeIndex) {
- case 2:
- return new MetaItem[]{
- new MetaItem(MetaItemType.AGENT_LINK,
- new AttributeRef(apartment1ServiceAgentId,
- "apartmentSimulator").toArrayValue()),
- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT,
- Values.create(NumberSimulatorElement.ELEMENT_NAME))
- };
- case 3:
- return new MetaItem[]{
- new MetaItem(MetaItemType.AGENT_LINK,
- new AttributeRef(apartment1ServiceAgentId,
- "apartmentSimulator").toArrayValue()),
- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT,
- Values.create(NumberSimulatorElement.ELEMENT_NAME))
- };
- case 4:
- return new MetaItem[]{
- new MetaItem(MetaItemType.AGENT_LINK,
- new AttributeRef(apartment1ServiceAgentId,
- "apartmentSimulator").toArrayValue()),
- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT,
- Values.create(NumberSimulatorElement.ELEMENT_NAME))
- };
- }
- return null;
- });
- }
+ // ### Erasmianum ###
- apartment1Kitchen = assetStorageService.merge(apartment1Kitchen);
- apartment1KitchenId = apartment1Kitchen.getId();
+ Asset building4Asset = new Asset("Erasmianum", BUILDING, energyManagement);
+ building4Asset.setAttributes(
+ new AssetAttribute(AttributeType.GEO_STREET, Values.create("Wytemaweg 25")),
+ new AssetAttribute(AttributeType.GEO_POSTAL_CODE, Values.create("3015 CN")),
+ new AssetAttribute(AttributeType.GEO_CITY, Values.create("Rotterdam")),
+ new AssetAttribute(AttributeType.GEO_COUNTRY, Values.create("Netherlands"))
+ );
+ building4Asset = assetStorageService.merge(building4Asset);
- Asset apartment1Hallway = createDemoApartmentRoom(apartment1, "Hallway 1")
- .addAttributes(
- new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(5.454342, 51.446762).toValue()),
- new AssetAttribute("lights", AttributeValueType.BOOLEAN, Values.create(true))
- .addMeta(new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)))
- .addMeta(new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)))
- );
- addDemoApartmentRoomMotionSensor(apartment1Hallway, true, () -> new MetaItem[]{
- new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
- });
+ Asset consumption4Asset = createDemoElectricityConsumerAsset("Consumption Erasmianum", building4Asset, new GeoJSONPoint(4.468324, 51.912062));
+ consumption4Asset = assetStorageService.merge(consumption4Asset);
- apartment1Hallway = assetStorageService.merge(apartment1Hallway);
- apartment1HallwayId = apartment1Hallway.getId();
+ // ### Oostelijk zwembad ###
- Asset apartment1Bedroom1 = createDemoApartmentRoom(apartment1, "Bedroom 1")
- .addAttributes(
- new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(5.454332, 51.446830).toValue()),
- new AssetAttribute("lights", AttributeValueType.BOOLEAN, Values.create(true))
- .addMeta(new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)))
- .addMeta(new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)))
- );
- addDemoApartmentRoomCO2Sensor(apartment1Bedroom1, true, () -> new MetaItem[]{
- new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
- });
- addDemoApartmentRoomHumiditySensor(apartment1Bedroom1, true, () -> new MetaItem[]{
- new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
- });
- addDemoApartmentRoomThermometer(apartment1Bedroom1, true, () -> new MetaItem[]{
- new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ Asset building5Asset = new Asset("Oostelijk zwembad", BUILDING, energyManagement);
+ building5Asset.setAttributes(
+ new AssetAttribute(AttributeType.GEO_STREET, Values.create("Gerdesiaweg 480")),
+ new AssetAttribute(AttributeType.GEO_POSTAL_CODE, Values.create("3061 RA")),
+ new AssetAttribute(AttributeType.GEO_CITY, Values.create("Rotterdam")),
+ new AssetAttribute(AttributeType.GEO_COUNTRY, Values.create("Netherlands"))
+ );
+ building5Asset = assetStorageService.merge(building5Asset);
+
+ Asset consumption5Asset = createDemoElectricityConsumerAsset("Consumption Zwembad", building5Asset, new GeoJSONPoint(4.498048, 51.925770));
+ consumption5Asset = assetStorageService.merge(consumption5Asset);
+
+ Asset production5Asset = createDemoElectricityProducerAsset("Solar Zwembad", building5Asset, new GeoJSONPoint(4.498281, 51.925507));
+ production5Asset.getAttribute("totalPower").ifPresent(assetAttribute -> {
+ assetAttribute.setValue(Values.create(5.13));
+ assetAttribute.addMeta(STORE_DATA_POINTS);
});
- addDemoApartmentTemperatureControl(apartment1Bedroom1, true, () -> new MetaItem[]{
- new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
+ production5Asset.getAttribute("totalEnergy").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(7.44)));
+ production5Asset.getAttribute("installedCapacity").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(12.79)));
+ production5Asset.getAttribute("systemEfficiency").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(86)));
+ production5Asset.getAttribute("panelOrientation").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(ElectricityProducerOrientationType.SOUTH.name())));
+ production5Asset = assetStorageService.merge(production5Asset);
+
+ // ### Weather ###
+
+ Asset weatherHttpApiAgent = new Asset("Weather Agent", AssetType.AGENT, energyManagement);
+ weatherHttpApiAgent.addAttributes(
+ initProtocolConfiguration(new AssetAttribute("weatherApiClient"), HttpClientProtocol.PROTOCOL_NAME)
+ .addMeta(
+ new MetaItem(META_PROTOCOL_BASE_URI, Values.create("https://api.openweathermap.org/data/2.5/")),
+ new MetaItem(META_QUERY_PARAMETERS, Values.createObject()
+ .put("appid", "a6ea6724e5d116ea6d938bee2a8f4689")
+ .put("lat", 51.918849)
+ .put("lon", 4.463250)
+ .put("units", "metric")),
+ new MetaItem(META_HEADERS, Values.createObject()
+ .put("Accept", "application/json")
+ )
+ )
+ );
+ weatherHttpApiAgent = assetStorageService.merge(weatherHttpApiAgent);
+ weatherHttpApiAgentId = weatherHttpApiAgent.getId();
+
+ Asset weather = new Asset("Weather", WEATHER, energyManagement);
+ weather.setId(UniqueIdentifierGenerator.generateId(weather.getName()));
+ weather.addAttributes(
+ new AssetAttribute("currentWeather", OBJECT)
+ .setMeta(
+ new MetaItem(
+ AGENT_LINK,
+ new AttributeRef(weatherHttpApiAgentId, "weatherApiClient").toArrayValue()),
+ new MetaItem(META_ATTRIBUTE_PATH, Values.create("weather")),
+ new MetaItem(META_ATTRIBUTE_POLLING_MILLIS, Values.create(halfHourInMillis)),
+ new MetaItem(LABEL, Values.create("Open Weather Map API weather end point")),
+ new MetaItem(READ_ONLY, Values.create(true)),
+ new MetaItem(ATTRIBUTE_LINK, createWeatherApiAttributeLink(weather.getId(), "main", "temp", "temperature")),
+ new MetaItem(ATTRIBUTE_LINK, createWeatherApiAttributeLink(weather.getId(), "main", "humidity", "humidity")),
+ new MetaItem(ATTRIBUTE_LINK, createWeatherApiAttributeLink(weather.getId(), "wind", "speed", "windSpeed")),
+ new MetaItem(ATTRIBUTE_LINK, createWeatherApiAttributeLink(weather.getId(), "wind", "deg", "windDirection"))
+ ));
+ new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(4.463250, 51.918849).toValue())
+ .addMeta(SHOW_ON_DASHBOARD);
+
+ weather = assetStorageService.merge(weather);
+
+ // ################################ Realm smartcity - Environment monitor ###################################
+
+ Asset environmentMonitor = new Asset();
+ environmentMonitor.setRealm(this.realmCityTenant);
+ environmentMonitor.setName("Environment Monitor");
+ environmentMonitor.setType(THING);
+ environmentMonitor = assetStorageService.merge(environmentMonitor);
+
+ Asset environment1Asset = createDemoEnvironmentAsset("Oudehaven", environmentMonitor, new GeoJSONPoint(4.49313, 51.91885), () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(smartcitySimulatorAgentId, "replaySimulator").toArrayValue()),
new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
});
+ environment1Asset = assetStorageService.merge(environment1Asset);
- apartment1Bedroom1 = assetStorageService.merge(apartment1Bedroom1);
- apartment1Bedroom1Id = apartment1Bedroom1.getId();
-
- Asset apartment1Bathroom = new Asset("Bathroom 1", ROOM, apartment1);
- apartment1Bathroom.addAttributes(
- new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(5.454227,51.446753).toValue()),
- new AssetAttribute("lights", AttributeValueType.BOOLEAN, Values.create(true))
- .setMeta(
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)),
- new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true))
- )
- );
- addDemoApartmentRoomThermometer(apartment1Bathroom, true, () -> new MetaItem[]{
- new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
+ Asset environment2Asset = createDemoEnvironmentAsset("Kaappark", environmentMonitor, new GeoJSONPoint(4.480434, 51.899287), () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(smartcitySimulatorAgentId, "replaySimulator").toArrayValue()),
new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
});
- addDemoApartmentTemperatureControl(apartment1Bathroom, true, () -> new MetaItem[]{
- new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
+ environment2Asset = assetStorageService.merge(environment2Asset);
+
+ Asset environment3Asset = createDemoEnvironmentAsset("Museumpark", environmentMonitor, new GeoJSONPoint(4.472457, 51.912047), () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(smartcitySimulatorAgentId, "replaySimulator").toArrayValue()),
new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
});
- apartment1Bathroom = assetStorageService.merge(apartment1Bathroom);
- apartment1BathroomId = apartment1Bathroom.getId();
+ environment3Asset = assetStorageService.merge(environment3Asset);
-
- addDemoApartmentVentilation(apartment1, true, () -> new MetaItem[]{
- new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ Asset environment4Asset = createDemoEnvironmentAsset("Eendrachtsplein", environmentMonitor, new GeoJSONPoint(4.473599, 51.916292), () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(smartcitySimulatorAgentId, "replaySimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
});
-
- apartment1 = assetStorageService.merge(apartment1);
- apartment1Id = apartment1.getId();
-
- if (importDemoScenes) {
- Asset demoApartment1SceneAgent = createDemoApartmentScenes(
- assetStorageService, apartment1, DEMO_APARTMENT_SCENES, apartment1Livingroom, apartment1Kitchen, apartment1Hallway);
- apartment1SceneAgentId = demoApartment1SceneAgent.getId();
+ environment4Asset = assetStorageService.merge(environment4Asset);
+
+ Asset groundwater1Asset = createDemoGroundwaterAsset("Leuvehaven", environmentMonitor, new GeoJSONPoint(4.48413, 51.91431));
+ Asset groundwater2Asset = createDemoGroundwaterAsset("Steiger", environmentMonitor, new GeoJSONPoint(4.482887, 51.920082));
+ Asset groundwater3Asset = createDemoGroundwaterAsset("Stadhuis", environmentMonitor, new GeoJSONPoint(4.480876, 51.923212));
+
+ Asset[] groundwaterArray = {groundwater1Asset, groundwater2Asset, groundwater3Asset};
+ for (int i = 0; i < groundwaterArray.length; i++) {
+ groundwaterArray[i].getAttribute("soilTemperature").ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem(
+ AGENT_LINK,
+ new AttributeRef(smartcitySimulatorAgentId, "replaySimulator").toArrayValue()
+ ),
+ new MetaItem(
+ SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(ReplaySimulatorElement.ELEMENT_NAME)
+ ),
+ new MetaItem(
+ SimulatorProtocol.REPLAY_ATTRIBUTE_LINK_DATA,
+ Values.createArray().addAll(
+ Values.createObject().put("timestamp", midnight.get(SECOND_OF_DAY)).put("value", 12.2),
+ Values.createObject().put("timestamp", midnight.plusHours(1).get(SECOND_OF_DAY)).put("value", 12.1),
+ Values.createObject().put("timestamp", midnight.plusHours(2).get(SECOND_OF_DAY)).put("value", 12.0),
+ Values.createObject().put("timestamp", midnight.plusHours(3).get(SECOND_OF_DAY)).put("value", 11.8),
+ Values.createObject().put("timestamp", midnight.plusHours(4).get(SECOND_OF_DAY)).put("value", 11.7),
+ Values.createObject().put("timestamp", midnight.plusHours(5).get(SECOND_OF_DAY)).put("value", 11.7),
+ Values.createObject().put("timestamp", midnight.plusHours(6).get(SECOND_OF_DAY)).put("value", 11.9),
+ Values.createObject().put("timestamp", midnight.plusHours(7).get(SECOND_OF_DAY)).put("value", 12.1),
+ Values.createObject().put("timestamp", midnight.plusHours(8).get(SECOND_OF_DAY)).put("value", 12.8),
+ Values.createObject().put("timestamp", midnight.plusHours(9).get(SECOND_OF_DAY)).put("value", 13.5),
+ Values.createObject().put("timestamp", midnight.plusHours(10).get(SECOND_OF_DAY)).put("value", 13.9),
+ Values.createObject().put("timestamp", midnight.plusHours(11).get(SECOND_OF_DAY)).put("value", 15.2),
+ Values.createObject().put("timestamp", midnight.plusHours(12).get(SECOND_OF_DAY)).put("value", 15.3),
+ Values.createObject().put("timestamp", midnight.plusHours(13).get(SECOND_OF_DAY)).put("value", 15.5),
+ Values.createObject().put("timestamp", midnight.plusHours(14).get(SECOND_OF_DAY)).put("value", 15.5),
+ Values.createObject().put("timestamp", midnight.plusHours(15).get(SECOND_OF_DAY)).put("value", 15.4),
+ Values.createObject().put("timestamp", midnight.plusHours(16).get(SECOND_OF_DAY)).put("value", 15.2),
+ Values.createObject().put("timestamp", midnight.plusHours(17).get(SECOND_OF_DAY)).put("value", 15.2),
+ Values.createObject().put("timestamp", midnight.plusHours(18).get(SECOND_OF_DAY)).put("value", 14.6),
+ Values.createObject().put("timestamp", midnight.plusHours(19).get(SECOND_OF_DAY)).put("value", 14.2),
+ Values.createObject().put("timestamp", midnight.plusHours(20).get(SECOND_OF_DAY)).put("value", 13.8),
+ Values.createObject().put("timestamp", midnight.plusHours(21).get(SECOND_OF_DAY)).put("value", 13.4),
+ Values.createObject().put("timestamp", midnight.plusHours(22).get(SECOND_OF_DAY)).put("value", 12.8),
+ Values.createObject().put("timestamp", midnight.plusHours(23).get(SECOND_OF_DAY)).put("value", 12.3)
+ )
+ )
+ );
+ });
+ groundwaterArray[i].getAttribute("waterLevel").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(3.51)));
}
- Asset apartment2 = new Asset("Apartment 2", RESIDENCE, smartBuilding);
- apartment2.addAttributes(
- new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(5.454053, 51.446603).toValue()),
- new AssetAttribute("allLightsOffSwitch", AttributeValueType.BOOLEAN, Values.create(true))
- .setMeta(
- new MetaItem(LABEL, Values.create("All Lights Off Switch")),
- new MetaItem(DESCRIPTION, Values.create("When triggered, turns all lights in the apartment off")),
- new MetaItem(RULE_EVENT, Values.create(true)),
- new MetaItem(RULE_EVENT_EXPIRES, Values.create("3s"))
- )
- );
- apartment2 = assetStorageService.merge(apartment2);
- apartment2Id = apartment2.getId();
-
- Asset apartment2Livingroom = new Asset("Living Room 2", ROOM, apartment2);
- apartment2Livingroom.addAttributes(
- new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(5.454109, 51.446631).toValue()),
- new AssetAttribute("motionSensor", AttributeValueType.BOOLEAN, Values.create(false))
- .setMeta(
- new MetaItem(LABEL, Values.create("Motion Sensor")),
- new MetaItem(DESCRIPTION, Values.create("PIR sensor that sends 'true' when motion is sensed")),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(RULE_EVENT, Values.create(true))
- ),
- new AssetAttribute("presenceDetected", AttributeValueType.BOOLEAN, Values.create(false))
- .setMeta(
- new MetaItem(LABEL, Values.create("Presence Detected")),
- new MetaItem(DESCRIPTION, Values.create("Someone is currently present in the room")),
- new MetaItem(RULE_STATE, Values.create(true))
- ),
- new AssetAttribute("firstPresenceDetected", AttributeValueType.TIMESTAMP)
- .setMeta(
- new MetaItem(LABEL, Values.create("First Presence Timestamp")),
- new MetaItem(DESCRIPTION, Values.create("Timestamp of the first detected presence")),
- new MetaItem(RULE_STATE, Values.create(true))
- ),
- new AssetAttribute("lastPresenceDetected", AttributeValueType.TIMESTAMP)
- .setMeta(
- new MetaItem(LABEL, Values.create("Last Presence Timestamp")),
- new MetaItem(DESCRIPTION, Values.create("Timestamp of last detected presence")),
- new MetaItem(RULE_STATE, Values.create(true))
- ),
- new AssetAttribute("co2Level", AttributeValueType.CO2, Values.create(350))
- .setMeta(
- new MetaItem(LABEL, Values.create("CO2 Level")),
- new MetaItem(RULE_STATE, Values.create(true))
- ),
- new AssetAttribute("lightSwitch", AttributeValueType.BOOLEAN, Values.create(true))
- .setMeta(
- new MetaItem(LABEL, Values.create("Light Switch")),
- new MetaItem(RULE_STATE, Values.create(true))
- ),
- new AssetAttribute("windowOpen", AttributeValueType.BOOLEAN, Values.create(false))
- .setMeta(
- new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true))
- ),
- new AssetAttribute("lightSwitchTriggerTimes", ARRAY, Values.createArray().add(Values.create("1800")).add(Values.create("0830")))
- .setMeta(
- new MetaItem(LABEL, Values.create("Lightswitch Trigger Times")),
- new MetaItem(RULE_STATE, Values.create(true))
- ),
- new AssetAttribute("plantsWaterLevels", OBJECT, Values.createObject().put("cactus", 0.8))
- .setMeta(
- new MetaItem(LABEL, Values.create("Water levels of the plants")),
- new MetaItem(RULE_STATE, Values.create(true))
- )
- );
- apartment2Livingroom = assetStorageService.merge(apartment2Livingroom);
- apartment2LivingroomId = apartment2Livingroom.getId();
-
- Asset apartment2Bathroom = new Asset("Bathroom 2", ROOM, apartment2);
- apartment2Bathroom.addAttributes(
- new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(5.454015, 51.446665).toValue()),
- new AssetAttribute("motionSensor", AttributeValueType.BOOLEAN, Values.create(false))
- .setMeta(
- new MetaItem(LABEL, Values.create("Motion Sensor")),
- new MetaItem(DESCRIPTION, Values.create("PIR sensor that sends 'true' when motion is sensed")),
- new MetaItem(RULE_STATE, Values.create(true)),
- new MetaItem(RULE_EVENT, Values.create(true))
- ),
- new AssetAttribute("presenceDetected", AttributeValueType.BOOLEAN, Values.create(false))
- .setMeta(
- new MetaItem(LABEL, Values.create("Presence Detected")),
- new MetaItem(DESCRIPTION, Values.create("Someone is currently present in the room")),
- new MetaItem(RULE_STATE, Values.create(true))
- ),
- new AssetAttribute("firstPresenceDetected", AttributeValueType.TIMESTAMP)
- .setMeta(
- new MetaItem(LABEL, Values.create("First Presence Timestamp")),
- new MetaItem(DESCRIPTION, Values.create("Timestamp of the first detected presence")),
- new MetaItem(RULE_STATE, Values.create(true))
- ),
- new AssetAttribute("lastPresenceDetected", AttributeValueType.TIMESTAMP)
- .setMeta(
- new MetaItem(LABEL, Values.create("Last Presence Timestamp")),
- new MetaItem(DESCRIPTION, Values.create("Timestamp of last detected presence")),
- new MetaItem(RULE_STATE, Values.create(true))
- ),
- new AssetAttribute("lightSwitch", AttributeValueType.BOOLEAN, Values.create(true))
- .setMeta(
- new MetaItem(LABEL, Values.create("Light Switch")),
- new MetaItem(RULE_STATE, Values.create(true))
- )
- );
- apartment2Bathroom = assetStorageService.merge(apartment2Bathroom);
- apartment2BathroomId = apartment2Bathroom.getId();
-
- Asset apartment3 = new Asset("Apartment 3", RESIDENCE, smartBuilding)
- .addAttributes(new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(5.453859, 51.446379).toValue()));
- apartment3 = assetStorageService.merge(apartment3);
- apartment3Id = apartment3.getId();
-
- Asset apartment3Livingroom = new Asset("Living Room 3", ROOM, apartment3)
- .addAttributes(new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(5.453932, 51.446422).toValue()));
- apartment3Livingroom.addAttributes(
- new AssetAttribute("lightSwitch", AttributeValueType.BOOLEAN)
- );
-
- apartment3Livingroom = assetStorageService.merge(apartment3Livingroom);
- apartment3LivingroomId = apartment3Livingroom.getId();
-
- // ################################ Link demo users and assets ###################################
-
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
- keycloakDemoSetup.testuser3Id,
- apartment1Id));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
- keycloakDemoSetup.testuser3Id,
- apartment1LivingroomId));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
- keycloakDemoSetup.testuser3Id,
- apartment1KitchenId));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
- keycloakDemoSetup.testuser3Id,
- apartment1Bedroom1Id));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
- keycloakDemoSetup.testuser3Id,
- apartment1BathroomId));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
- keycloakDemoSetup.testuser3Id,
- apartment1HallwayId));
-
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
- keycloakDemoSetup.buildingUserId,
- apartment1Id));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
- keycloakDemoSetup.buildingUserId,
- apartment1LivingroomId));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
- keycloakDemoSetup.buildingUserId,
- apartment1KitchenId));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
- keycloakDemoSetup.buildingUserId,
- apartment1Bedroom1Id));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
- keycloakDemoSetup.buildingUserId,
- apartment1BathroomId));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
- keycloakDemoSetup.buildingUserId,
- apartment1HallwayId));
-
- // ################################ Make users restricted ###################################
-
- UserConfiguration testuser3Config = identityService.getUserConfiguration(keycloakDemoSetup.testuser3Id);
- testuser3Config.setRestricted(true);
- testuser3Config = identityService.mergeUserConfiguration(testuser3Config);
-
- UserConfiguration buildingUserConfig = identityService.getUserConfiguration(keycloakDemoSetup.buildingUserId);
- testuser3Config.setRestricted(true);
- buildingUserConfig = identityService.mergeUserConfiguration(buildingUserConfig);
-
- // ################################ Realm smartcity ###################################
-
- ObjectValue smartCityLocation = SMART_CITY_LOCATION.toValue();
-
- Asset smartCity = new Asset();
- smartCity.setRealm(this.realmCityTenant);
- smartCity.setName("Smart City");
- smartCity.setType(CITY);
- smartCity.setAttributes(
- new AssetAttribute(AttributeType.LOCATION, smartCityLocation),
- new AssetAttribute(AttributeType.GEO_CITY, Values.create("Eindhoven")),
- new AssetAttribute(AttributeType.GEO_COUNTRY, Values.create("Netherlands"))
- );
- smartCity = assetStorageService.merge(smartCity);
-
- Asset smartCityServiceAgent = new Asset("Service Agent (Simulator)", AGENT, smartCity);
- smartCityServiceAgent.addAttributes(
- initProtocolConfiguration(new AssetAttribute("citySimulator"), SimulatorProtocol.PROTOCOL_NAME)
- .addMeta(
+ groundwater1Asset = assetStorageService.merge(groundwater1Asset);
+ groundwater2Asset = assetStorageService.merge(groundwater2Asset);
+ groundwater3Asset = assetStorageService.merge(groundwater3Asset);
+
+ // ################################ Realm smartcity - Mobility and Safety ###################################
+
+ Asset mobilityAndSafety = new Asset();
+ mobilityAndSafety.setRealm(this.realmCityTenant);
+ mobilityAndSafety.setName("Mobility and Safety");
+ mobilityAndSafety.setType(THING);
+ mobilityAndSafety = assetStorageService.merge(mobilityAndSafety);
+
+ // ### Parking ###
+
+ Asset parkingGroupAsset = new Asset("Parking group", GROUP, mobilityAndSafety);
+ parkingGroupAsset.getAttribute("childAssetType").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create("urn:openremote:asset:parking")));
+ parkingGroupAsset.addAttributes(
+ new AssetAttribute("totalOccupancy", PERCENTAGE)
+ .addMeta(
+ LABEL.withInitialValue("Percentage of total parking spaces in use"),
+ RULE_STATE,
+ READ_ONLY,
+ STORE_DATA_POINTS));
+ parkingGroupAsset = assetStorageService.merge(parkingGroupAsset);
+
+ Asset parking1Asset = createDemoParkingAsset("Markthal", parkingGroupAsset, new GeoJSONPoint(4.48527, 51.91984));
+ parking1Asset.getAttribute("occupiedSpaces").ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
new MetaItem(
- SimulatorProtocol.CONFIG_MODE,
- Values.create(SimulatorProtocol.Mode.WRITE_THROUGH_IMMEDIATE.toString())
- ))
- );
- smartCityServiceAgent = assetStorageService.merge(smartCityServiceAgent);
- smartCityServiceAgentId = smartCityServiceAgent.getId();
+ AGENT_LINK,
+ new AttributeRef(smartcitySimulatorAgentId, "replaySimulator").toArrayValue()
+ ),
+ new MetaItem(
+ SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(ReplaySimulatorElement.ELEMENT_NAME)
+ ),
+ new MetaItem(
+ SimulatorProtocol.REPLAY_ATTRIBUTE_LINK_DATA,
+ Values.createArray().addAll(
+ Values.createObject().put("timestamp", midnight.get(SECOND_OF_DAY)).put("value", 34),
+ Values.createObject().put("timestamp", midnight.plusHours(1).get(SECOND_OF_DAY)).put("value", 37),
+ Values.createObject().put("timestamp", midnight.plusHours(2).get(SECOND_OF_DAY)).put("value", 31),
+ Values.createObject().put("timestamp", midnight.plusHours(3).get(SECOND_OF_DAY)).put("value", 36),
+ Values.createObject().put("timestamp", midnight.plusHours(4).get(SECOND_OF_DAY)).put("value", 32),
+ Values.createObject().put("timestamp", midnight.plusHours(5).get(SECOND_OF_DAY)).put("value", 39),
+ Values.createObject().put("timestamp", midnight.plusHours(6).get(SECOND_OF_DAY)).put("value", 47),
+ Values.createObject().put("timestamp", midnight.plusHours(7).get(SECOND_OF_DAY)).put("value", 53),
+ Values.createObject().put("timestamp", midnight.plusHours(8).get(SECOND_OF_DAY)).put("value", 165),
+ Values.createObject().put("timestamp", midnight.plusHours(9).get(SECOND_OF_DAY)).put("value", 301),
+ Values.createObject().put("timestamp", midnight.plusHours(10).get(SECOND_OF_DAY)).put("value", 417),
+ Values.createObject().put("timestamp", midnight.plusHours(11).get(SECOND_OF_DAY)).put("value", 442),
+ Values.createObject().put("timestamp", midnight.plusHours(12).get(SECOND_OF_DAY)).put("value", 489),
+ Values.createObject().put("timestamp", midnight.plusHours(13).get(SECOND_OF_DAY)).put("value", 467),
+ Values.createObject().put("timestamp", midnight.plusHours(14).get(SECOND_OF_DAY)).put("value", 490),
+ Values.createObject().put("timestamp", midnight.plusHours(15).get(SECOND_OF_DAY)).put("value", 438),
+ Values.createObject().put("timestamp", midnight.plusHours(16).get(SECOND_OF_DAY)).put("value", 457),
+ Values.createObject().put("timestamp", midnight.plusHours(17).get(SECOND_OF_DAY)).put("value", 402),
+ Values.createObject().put("timestamp", midnight.plusHours(18).get(SECOND_OF_DAY)).put("value", 379),
+ Values.createObject().put("timestamp", midnight.plusHours(19).get(SECOND_OF_DAY)).put("value", 336),
+ Values.createObject().put("timestamp", midnight.plusHours(20).get(SECOND_OF_DAY)).put("value", 257),
+ Values.createObject().put("timestamp", midnight.plusHours(21).get(SECOND_OF_DAY)).put("value", 204),
+ Values.createObject().put("timestamp", midnight.plusHours(22).get(SECOND_OF_DAY)).put("value", 112),
+ Values.createObject().put("timestamp", midnight.plusHours(23).get(SECOND_OF_DAY)).put("value", 75)
+ )
+ )
+ );
+ });
+ parking1Asset.getAttribute("priceHourly").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(3.75)));
+ parking1Asset.getAttribute("priceDaily").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(25.00)));
+ parking1Asset = assetStorageService.merge(parking1Asset);
- // ################################ Realm B Area 1 ###################################
+ Asset parking2Asset = createDemoParkingAsset("Lijnbaan", parkingGroupAsset, new GeoJSONPoint(4.47681, 51.91849));
+ parking2Asset.getAttribute("occupiedSpaces").ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem(
+ AGENT_LINK,
+ new AttributeRef(smartcitySimulatorAgentId, "replaySimulator").toArrayValue()
+ ),
+ new MetaItem(
+ SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(ReplaySimulatorElement.ELEMENT_NAME)
+ ),
+ new MetaItem(
+ SimulatorProtocol.REPLAY_ATTRIBUTE_LINK_DATA,
+ Values.createArray().addAll(
+ Values.createObject().put("timestamp", midnight.get(SECOND_OF_DAY)).put("value", 31),
+ Values.createObject().put("timestamp", midnight.plusHours(1).get(SECOND_OF_DAY)).put("value", 24),
+ Values.createObject().put("timestamp", midnight.plusHours(2).get(SECOND_OF_DAY)).put("value", 36),
+ Values.createObject().put("timestamp", midnight.plusHours(3).get(SECOND_OF_DAY)).put("value", 38),
+ Values.createObject().put("timestamp", midnight.plusHours(4).get(SECOND_OF_DAY)).put("value", 46),
+ Values.createObject().put("timestamp", midnight.plusHours(5).get(SECOND_OF_DAY)).put("value", 48),
+ Values.createObject().put("timestamp", midnight.plusHours(6).get(SECOND_OF_DAY)).put("value", 52),
+ Values.createObject().put("timestamp", midnight.plusHours(7).get(SECOND_OF_DAY)).put("value", 89),
+ Values.createObject().put("timestamp", midnight.plusHours(8).get(SECOND_OF_DAY)).put("value", 142),
+ Values.createObject().put("timestamp", midnight.plusHours(9).get(SECOND_OF_DAY)).put("value", 187),
+ Values.createObject().put("timestamp", midnight.plusHours(10).get(SECOND_OF_DAY)).put("value", 246),
+ Values.createObject().put("timestamp", midnight.plusHours(11).get(SECOND_OF_DAY)).put("value", 231),
+ Values.createObject().put("timestamp", midnight.plusHours(12).get(SECOND_OF_DAY)).put("value", 367),
+ Values.createObject().put("timestamp", midnight.plusHours(13).get(SECOND_OF_DAY)).put("value", 345),
+ Values.createObject().put("timestamp", midnight.plusHours(14).get(SECOND_OF_DAY)).put("value", 386),
+ Values.createObject().put("timestamp", midnight.plusHours(15).get(SECOND_OF_DAY)).put("value", 312),
+ Values.createObject().put("timestamp", midnight.plusHours(16).get(SECOND_OF_DAY)).put("value", 363),
+ Values.createObject().put("timestamp", midnight.plusHours(17).get(SECOND_OF_DAY)).put("value", 276),
+ Values.createObject().put("timestamp", midnight.plusHours(18).get(SECOND_OF_DAY)).put("value", 249),
+ Values.createObject().put("timestamp", midnight.plusHours(19).get(SECOND_OF_DAY)).put("value", 256),
+ Values.createObject().put("timestamp", midnight.plusHours(20).get(SECOND_OF_DAY)).put("value", 123),
+ Values.createObject().put("timestamp", midnight.plusHours(21).get(SECOND_OF_DAY)).put("value", 153),
+ Values.createObject().put("timestamp", midnight.plusHours(22).get(SECOND_OF_DAY)).put("value", 83),
+ Values.createObject().put("timestamp", midnight.plusHours(23).get(SECOND_OF_DAY)).put("value", 25)
+ )
+ )
+ );
+ });
+ parking2Asset.getAttribute("priceHourly").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(3.50)));
+ parking2Asset.getAttribute("priceDaily").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(23.00)));
+ parking2Asset = assetStorageService.merge(parking2Asset);
- Asset assetArea1 = new Asset("Area 1", AREA, smartCity)
- .setAttributes(
- new AssetAttribute(AttributeType.LOCATION, AREA_1_LOCATION.toValue()),
- new AssetAttribute(AttributeType.GEO_POSTAL_CODE, Values.create(5616)),
- new AssetAttribute(AttributeType.GEO_CITY, Values.create("Eindhoven")),
- new AssetAttribute(AttributeType.GEO_COUNTRY, Values.create("Netherlands"))
+ Asset parking3Asset = createDemoParkingAsset("Erasmusbrug", parkingGroupAsset, new GeoJSONPoint(4.48207, 51.91127));
+ parking3Asset.getAttribute("occupiedSpaces").ifPresent(assetAttribute -> {
+ assetAttribute.addMeta(
+ new MetaItem(
+ AGENT_LINK,
+ new AttributeRef(smartcitySimulatorAgentId, "replaySimulator").toArrayValue()
+ ),
+ new MetaItem(
+ SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(ReplaySimulatorElement.ELEMENT_NAME)
+ ),
+ new MetaItem(
+ SimulatorProtocol.REPLAY_ATTRIBUTE_LINK_DATA,
+ Values.createArray().addAll(
+ Values.createObject().put("timestamp", midnight.get(SECOND_OF_DAY)).put("value", 25),
+ Values.createObject().put("timestamp", midnight.plusHours(1).get(SECOND_OF_DAY)).put("value", 23),
+ Values.createObject().put("timestamp", midnight.plusHours(2).get(SECOND_OF_DAY)).put("value", 23),
+ Values.createObject().put("timestamp", midnight.plusHours(3).get(SECOND_OF_DAY)).put("value", 21),
+ Values.createObject().put("timestamp", midnight.plusHours(4).get(SECOND_OF_DAY)).put("value", 18),
+ Values.createObject().put("timestamp", midnight.plusHours(5).get(SECOND_OF_DAY)).put("value", 13),
+ Values.createObject().put("timestamp", midnight.plusHours(6).get(SECOND_OF_DAY)).put("value", 29),
+ Values.createObject().put("timestamp", midnight.plusHours(7).get(SECOND_OF_DAY)).put("value", 36),
+ Values.createObject().put("timestamp", midnight.plusHours(8).get(SECOND_OF_DAY)).put("value", 119),
+ Values.createObject().put("timestamp", midnight.plusHours(9).get(SECOND_OF_DAY)).put("value", 257),
+ Values.createObject().put("timestamp", midnight.plusHours(10).get(SECOND_OF_DAY)).put("value", 357),
+ Values.createObject().put("timestamp", midnight.plusHours(11).get(SECOND_OF_DAY)).put("value", 368),
+ Values.createObject().put("timestamp", midnight.plusHours(12).get(SECOND_OF_DAY)).put("value", 362),
+ Values.createObject().put("timestamp", midnight.plusHours(13).get(SECOND_OF_DAY)).put("value", 349),
+ Values.createObject().put("timestamp", midnight.plusHours(14).get(SECOND_OF_DAY)).put("value", 370),
+ Values.createObject().put("timestamp", midnight.plusHours(15).get(SECOND_OF_DAY)).put("value", 367),
+ Values.createObject().put("timestamp", midnight.plusHours(16).get(SECOND_OF_DAY)).put("value", 355),
+ Values.createObject().put("timestamp", midnight.plusHours(17).get(SECOND_OF_DAY)).put("value", 314),
+ Values.createObject().put("timestamp", midnight.plusHours(18).get(SECOND_OF_DAY)).put("value", 254),
+ Values.createObject().put("timestamp", midnight.plusHours(19).get(SECOND_OF_DAY)).put("value", 215),
+ Values.createObject().put("timestamp", midnight.plusHours(20).get(SECOND_OF_DAY)).put("value", 165),
+ Values.createObject().put("timestamp", midnight.plusHours(21).get(SECOND_OF_DAY)).put("value", 149),
+ Values.createObject().put("timestamp", midnight.plusHours(22).get(SECOND_OF_DAY)).put("value", 108),
+ Values.createObject().put("timestamp", midnight.plusHours(23).get(SECOND_OF_DAY)).put("value", 47)
+ )
+ )
);
- assetArea1 = assetStorageService.merge(assetArea1);
- area1Id = assetArea1.getId();
+ });
+ parking3Asset.getAttribute("priceHourly").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(3.40)));
+ parking3Asset.getAttribute("priceDaily").ifPresent(assetAttribute -> assetAttribute.setValue(Values.create(20.00)));
+ parking3Asset = assetStorageService.merge(parking3Asset);
+
+ // ### Crowd control ###
+
+ Asset assetAreaStation = new Asset("Stationsplein", AREA, mobilityAndSafety)
+ .setAttributes(
+ new AssetAttribute(AttributeType.LOCATION, STATIONSPLEIN_LOCATION.toValue()),
+ new AssetAttribute(AttributeType.GEO_POSTAL_CODE, Values.create("3013 AK")),
+ new AssetAttribute(AttributeType.GEO_CITY, Values.create("Rotterdam")),
+ new AssetAttribute(AttributeType.GEO_COUNTRY, Values.create("Netherlands"))
+ );
+ assetAreaStation = assetStorageService.merge(assetAreaStation);
+ area1Id = assetAreaStation.getId();
- Asset peopleCounter1Asset = createDemoPeopleCounterAsset("PeopleCounter 1", assetArea1, new GeoJSONPoint(5.477126, 51.439137), () -> new MetaItem[]{
- new MetaItem(AGENT_LINK, new AttributeRef(smartCityServiceAgentId, "citySimulator").toArrayValue()),
- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ Asset peopleCounter1Asset = createDemoPeopleCounterAsset("People Counter South", assetAreaStation, new GeoJSONPoint(4.470147, 51.923171), () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(smartcitySimulatorAgentId, "replaySimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
});
peopleCounter1Asset = assetStorageService.merge(peopleCounter1Asset);
- Asset microphone1Asset = createDemoMicrophoneAsset("Microphone 1", assetArea1, new GeoJSONPoint(5.478092, 51.438655), () -> new MetaItem[]{
- new MetaItem(AGENT_LINK, new AttributeRef(smartCityServiceAgentId, "citySimulator").toArrayValue()),
- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ Asset peopleCounter2Asset = createDemoPeopleCounterAsset("People Counter North", assetAreaStation, new GeoJSONPoint(4.469329, 51.923700), () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(smartcitySimulatorAgentId, "replaySimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+ peopleCounter2Asset = assetStorageService.merge(peopleCounter2Asset);
+
+ persistenceService.doTransaction(entityManager ->
+ entityManager.merge(new ConsoleAppConfig(
+ realmCityTenant,
+ "https://demo.openremote.io/mobile/?realm=smartcity&consoleProviders=geofence push storage",
+ true,
+ ConsoleAppConfig.MenuPosition.BOTTOM_LEFT,
+ null,
+ "#FAFAFA",
+ "#AFAFAF",
+ Values.createArray().addAll(
+ Values.createObject()
+ .put("displayText", "Map")
+ .put("pageLink", "https://demo.openremote.io/mobile/#!geofences?realm=smartcity&consoleProviders=geofence push storage"),
+ Values.createObject()
+ .put("displayText", "List")
+ .put("pageLink", "https://demo.openremote.io/mobile/#!geofences?realm=smartcity&consoleProviders=geofence push storage&view=list")
+ )))
+ );
+
+ Asset microphone1Asset = createDemoMicrophoneAsset("Microphone South", assetAreaStation, new GeoJSONPoint(4.470362, 51.923201), () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(smartcitySimulatorAgentId, "replaySimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
});
microphone1Asset = assetStorageService.merge(microphone1Asset);
- microphone1Id = microphone1Asset.getId();
- Asset enviroment1Asset = createDemoEnvironmentAsset("Environment 1", assetArea1, new GeoJSONPoint(5.478907, 51.438943),() -> new MetaItem[]{
- new MetaItem(AGENT_LINK, new AttributeRef(smartCityServiceAgentId, "citySimulator").toArrayValue()),
- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ Asset microphone2Asset = createDemoMicrophoneAsset("Microphone North", assetAreaStation, new GeoJSONPoint(4.469190, 51.923786), () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(smartcitySimulatorAgentId, "replaySimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
});
- enviroment1Asset = assetStorageService.merge(enviroment1Asset);
+ microphone2Asset = assetStorageService.merge(microphone2Asset);
- Asset light1Asset = createDemoLightAsset("Light 1", assetArea1, new GeoJSONPoint(5.476111, 51.438492));
- light1Asset = assetStorageService.merge(light1Asset);
+ Asset lightStation1Asset = createDemoLightAsset("Station Light NW", assetAreaStation, new GeoJSONPoint(4.468874, 51.923881));
+ lightStation1Asset = assetStorageService.merge(lightStation1Asset);
- Asset light2Asset = createDemoLightAsset("Light 2", assetArea1, new GeoJSONPoint(5.477272, 51.439214));
- light2Asset = assetStorageService.merge(light2Asset);
+ Asset lightStation2Asset = createDemoLightAsset("Station Light NE", assetAreaStation, new GeoJSONPoint(4.470539, 51.923991));
+ lightStation2Asset = assetStorageService.merge(lightStation2Asset);
- // ################################ Realm B Area 2 ###################################
+ Asset lightStation3Asset = createDemoLightAsset("Station Light S", assetAreaStation, new GeoJSONPoint(4.470558, 51.923186));
+ lightStation3Asset = assetStorageService.merge(lightStation3Asset);
- Asset assetArea2 = new Asset("Area 2", AREA, smartCity)
- .setAttributes(
- new AssetAttribute(AttributeType.LOCATION, AREA_2_LOCATION.toValue()),
- new AssetAttribute(AttributeType.GEO_POSTAL_CODE, Values.create(5651)),
- new AssetAttribute(AttributeType.GEO_CITY, Values.create("Eindhoven")),
- new AssetAttribute(AttributeType.GEO_COUNTRY, Values.create("Netherlands"))
- );
- assetArea2 = assetStorageService.merge(assetArea2);
+ // ### Lighting controller ###
- Asset peopleCounter2Asset = createDemoPeopleCounterAsset("PeopleCounter 2", assetArea2, new GeoJSONPoint(5.473686, 51.438603), () -> new MetaItem[]{
- new MetaItem(AGENT_LINK, new AttributeRef(smartCityServiceAgentId, "citySimulator").toArrayValue()),
- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
- });
- peopleCounter2Asset = assetStorageService.merge(peopleCounter2Asset);
+ Asset lightingControllerOPAsset = createDemoLightControllerAsset("Lighting Noordereiland", mobilityAndSafety, new GeoJSONPoint(4.496177, 51.915060));
+ lightingControllerOPAsset = assetStorageService.merge(lightingControllerOPAsset);
- Asset environment2Asset = createDemoEnvironmentAsset("Environment 2", assetArea2, new GeoJSONPoint(5.473552, 51.438412), () -> new MetaItem[]{
- new MetaItem(AGENT_LINK, new AttributeRef(smartCityServiceAgentId, "citySimulator").toArrayValue()),
- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
- });
- environment2Asset = assetStorageService.merge(environment2Asset);
+ Asset lightOP1Asset = createDemoLightAsset("OnsPark1", lightingControllerOPAsset, new GeoJSONPoint(4.49626, 51.91516));
+ lightOP1Asset = assetStorageService.merge(lightOP1Asset);
+ Asset lightOP2Asset = createDemoLightAsset("OnsPark2", lightingControllerOPAsset, new GeoJSONPoint(4.49705, 51.91549));
+ lightOP2Asset = assetStorageService.merge(lightOP2Asset);
- // ################################ Realm B Area 3 ###################################
+ Asset lightOP3Asset = createDemoLightAsset("OnsPark3", lightingControllerOPAsset, new GeoJSONPoint(4.49661, 51.91495));
+ lightOP3Asset = assetStorageService.merge(lightOP3Asset);
- Asset assetArea3 = new Asset("Area 3", AREA, smartCity)
- .setAttributes(
- new AssetAttribute(AttributeType.LOCATION, AREA_3_LOCATION.toValue()),
- new AssetAttribute(AttributeType.GEO_POSTAL_CODE, Values.create(5617)),
- new AssetAttribute(AttributeType.GEO_CITY, Values.create("Eindhoven")),
- new AssetAttribute(AttributeType.GEO_COUNTRY, Values.create("Netherlands"))
- );
- assetArea3 = assetStorageService.merge(assetArea3);
+ Asset lightOP4Asset = createDemoLightAsset("OnsPark4", lightingControllerOPAsset, new GeoJSONPoint(4.49704, 51.91520));
+ lightOP4Asset = assetStorageService.merge(lightOP4Asset);
- Asset peopleCounter3Asset = createDemoPeopleCounterAsset("PeopleCounter 3", assetArea3, new GeoJSONPoint(5.487234, 51.447065), () -> new MetaItem[]{
- new MetaItem(AGENT_LINK, new AttributeRef(smartCityServiceAgentId, "citySimulator").toArrayValue()),
- new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
- });
- peopleCounter3Asset = assetStorageService.merge(peopleCounter3Asset);
- peopleCounter3AssetId = peopleCounter3Asset.getId();
-
- Asset lightController_3Asset = createDemoLightControllerAsset("LightController 3", assetArea3, new GeoJSONPoint(5.487478, 51.446979));
- lightController_3Asset = assetStorageService.merge(lightController_3Asset);
-
- persistenceService.doTransaction(entityManager -> {
- entityManager.merge(new ConsoleAppConfig(
- realmCityTenant,
- "https://demo.openremote.io/mobile/?realm=smartcity&consoleProviders=geofence push storage",
- true,
- ConsoleAppConfig.MenuPosition.BOTTOM_LEFT,
- null,
- "#FAFAFA",
- "#AFAFAF",
- Values.createArray().addAll(
- Values.createObject()
- .put("displayText","Map")
- .put("pageLink","https://demo.openremote.io/mobile/#!geofences?realm=smartcity&consoleProviders=geofence push storage"),
- Values.createObject()
- .put("displayText","List")
- .put("pageLink","https://demo.openremote.io/mobile/#!geofences?realm=smartcity&consoleProviders=geofence push storage&view=list")
- )
- ));
- });
+ Asset lightOP5Asset = createDemoLightAsset("OnsPark5", lightingControllerOPAsset, new GeoJSONPoint(4.49758, 51.91440));
+ lightOP5Asset = assetStorageService.merge(lightOP5Asset);
+
+ Asset lightOP6Asset = createDemoLightAsset("OnsPark6", lightingControllerOPAsset, new GeoJSONPoint(4.49786, 51.91452));
+ lightOP6Asset = assetStorageService.merge(lightOP6Asset);
+ }
+
+ @SuppressWarnings("OptionalGetWithoutIsPresent")
+ protected static Value createWeatherApiAttributeLink (String assetId, String jsonParentName, String jsonName, String parameter){
+ return Values.convertToValue(new AttributeLink(
+ new AttributeRef(assetId, parameter),
+ null,
+ new ValueFilter[]{
+ new JsonPathFilter("$." + jsonParentName + "." + jsonName, true, false),
+ }
+ ), Container.JSON.writer()).get();
}
}
diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerTestAgentSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerTestAgentSetup.java
new file mode 100644
index 000000000..ddc45bb0f
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerTestAgentSetup.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2020, 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.manager.setup.builtin;
+
+import org.openremote.agent.protocol.knx.KNXProtocol;
+import org.openremote.agent.protocol.velbus.VelbusSerialProtocol;
+import org.openremote.container.Container;
+import org.openremote.manager.setup.AbstractManagerSetup;
+import org.openremote.model.asset.Asset;
+import org.openremote.model.security.Tenant;
+import org.openremote.model.asset.AssetAttribute;
+import org.openremote.model.attribute.MetaItem;
+import org.openremote.model.value.Values;
+
+import java.util.logging.Logger;
+
+import static org.openremote.container.util.MapAccess.getBoolean;
+import static org.openremote.container.util.MapAccess.getString;
+import static org.openremote.model.asset.AssetType.AGENT;
+import static org.openremote.model.asset.AssetType.THING;
+import static org.openremote.model.asset.agent.ProtocolConfiguration.initProtocolConfiguration;
+
+public class ManagerTestAgentSetup extends AbstractManagerSetup {
+
+ private static final Logger LOG = Logger.getLogger(ManagerDemoAgentSetup.class.getName());
+
+ public static final String SETUP_IMPORT_DEMO_AGENT_KNX = "SETUP_IMPORT_DEMO_AGENT_KNX";
+ public static final String SETUP_IMPORT_DEMO_AGENT_KNX_GATEWAY_IP = "SETUP_IMPORT_DEMO_AGENT_KNX_GATEWAY_IP";
+ public static final String SETUP_IMPORT_DEMO_AGENT_KNX_LOCAL_IP = "SETUP_IMPORT_DEMO_AGENT_KNX_LOCAL_IP";
+
+ public static final String SETUP_IMPORT_DEMO_AGENT_VELBUS = "SETUP_IMPORT_DEMO_AGENT_VELBUS";
+ public static final String SETUP_IMPORT_DEMO_AGENT_VELBUS_COM_PORT = "SETUP_IMPORT_DEMO_AGENT_VELBUS_COM_PORT";
+
+ public String masterRealm;
+
+ final protected boolean knx;
+ final protected String knxGatewayIp;
+ final protected String knxLocalIp;
+
+ final protected boolean velbus;
+ final protected String velbusComPort;
+
+ public ManagerTestAgentSetup(Container container) {
+ super(container);
+
+ this.knx = getBoolean(container.getConfig(), SETUP_IMPORT_DEMO_AGENT_KNX, false);
+ this.knxGatewayIp = getString(container.getConfig(), SETUP_IMPORT_DEMO_AGENT_KNX_GATEWAY_IP, "192.168.0.64");
+ this.knxLocalIp = getString(container.getConfig(), SETUP_IMPORT_DEMO_AGENT_KNX_LOCAL_IP, "192.168.0.65");
+
+ this.velbus = getBoolean(container.getConfig(), SETUP_IMPORT_DEMO_AGENT_VELBUS, false);
+ this.velbusComPort = getString(container.getConfig(), SETUP_IMPORT_DEMO_AGENT_VELBUS_COM_PORT, "COM3");
+ }
+
+ @Override
+ public void onStart() throws Exception {
+
+ KeycloakTestSetup keycloakTestSetup = setupService.getTaskOfType(KeycloakTestSetup.class);
+ Tenant masterTenant = keycloakTestSetup.masterTenant;
+ masterRealm = masterTenant.getRealm();
+
+ Asset agent = new Asset("Demo Agent", AGENT);
+ agent.setRealm(masterRealm);
+ agent = assetStorageService.merge(agent);
+
+ if (knx) {
+ LOG.info("Enable KNX demo protocol configuration, gateway/local IP: " + knxGatewayIp + "/" + knxLocalIp);
+ agent.addAttributes(
+ initProtocolConfiguration(new AssetAttribute("knxConfig"), KNXProtocol.PROTOCOL_NAME)
+ .addMeta(
+ new MetaItem(KNXProtocol.META_KNX_GATEWAY_HOST, Values.create(knxGatewayIp)),
+ new MetaItem(KNXProtocol.META_KNX_LOCAL_HOST, Values.create(knxLocalIp))
+ )
+ );
+ Asset knxDevices = new Asset("KNX Devices", THING, agent, masterRealm);
+ knxDevices = assetStorageService.merge(knxDevices);
+ }
+
+ if (velbus) {
+ LOG.info("Enable Velbus demo protocol configuration, COM port: " + velbusComPort);
+ agent.addAttributes(
+ initProtocolConfiguration(new AssetAttribute("velbusConfig"), VelbusSerialProtocol.PROTOCOL_NAME)
+ .addMeta(
+ new MetaItem(VelbusSerialProtocol.META_VELBUS_SERIAL_PORT, Values.create(velbusComPort))
+ )
+ );
+ Asset velbusDevices = new Asset("VELBUS Devices", THING, agent, masterRealm);
+ velbusDevices = assetStorageService.merge(velbusDevices);
+ }
+
+ agent = assetStorageService.merge(agent);
+ }
+}
diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerTestSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerTestSetup.java
new file mode 100644
index 000000000..5a896976e
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerTestSetup.java
@@ -0,0 +1,766 @@
+/*
+ * Copyright 2020, 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.manager.setup.builtin;
+
+import org.openremote.agent.protocol.simulator.SimulatorProtocol;
+import org.openremote.container.Container;
+import org.openremote.container.util.UniqueIdentifierGenerator;
+import org.openremote.manager.security.UserConfiguration;
+import org.openremote.manager.setup.AbstractManagerSetup;
+import org.openremote.model.apps.ConsoleAppConfig;
+import org.openremote.model.asset.Asset;
+import org.openremote.model.asset.AssetAttribute;
+import org.openremote.model.asset.UserAsset;
+import org.openremote.model.attribute.*;
+import org.openremote.model.geo.GeoJSONPoint;
+import org.openremote.model.security.Tenant;
+import org.openremote.model.simulator.element.ColorSimulatorElement;
+import org.openremote.model.simulator.element.NumberSimulatorElement;
+import org.openremote.model.simulator.element.SwitchSimulatorElement;
+import org.openremote.model.value.ObjectValue;
+import org.openremote.model.value.Values;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.openremote.manager.datapoint.AssetDatapointService.DATA_POINTS_MAX_AGE_DAYS_DEFAULT;
+import static org.openremote.model.asset.AssetType.*;
+import static org.openremote.model.asset.agent.ProtocolConfiguration.initProtocolConfiguration;
+import static org.openremote.model.attribute.AttributeValueType.*;
+import static org.openremote.model.attribute.MetaItemType.*;
+
+public class ManagerTestSetup extends AbstractManagerSetup {
+
+ // Update these numbers whenever you change a RULE_STATE flag in test data
+ public static final int DEMO_RULE_STATES_APARTMENT_1 = 44;
+ public static final int DEMO_RULE_STATES_APARTMENT_2 = 13;
+ 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 = 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;
+ public static GeoJSONPoint SMART_OFFICE_LOCATION = new GeoJSONPoint(5.460315214821094, 51.44541688237109);
+ public static GeoJSONPoint SMART_BUILDING_LOCATION = new GeoJSONPoint(5.454027, 51.446308);
+ public static GeoJSONPoint SMART_CITY_LOCATION = new GeoJSONPoint(5.3814711, 51.4484647);
+ public static GeoJSONPoint AREA_1_LOCATION = new GeoJSONPoint(5.478478, 51.439272);
+ public static GeoJSONPoint AREA_2_LOCATION = new GeoJSONPoint(5.473829, 51.438744);
+ public static GeoJSONPoint AREA_3_LOCATION = new GeoJSONPoint(5.487478, 51.446979);
+ public static final String agentProtocolConfigName = "simulator123";
+ public static final String thingLightToggleAttributeName = "light1Toggle";
+ public static final Scene[] DEMO_APARTMENT_SCENES = new Scene[] {
+ new Scene("morningScene", "Morning scene", "MORNING", "0 0 7 ? *", false, 21d),
+ new Scene("dayScene", "Day scene", "DAY", "0 30 8 ? *", true, 15d),
+ new Scene("eveningScene", "Evening scene", "EVENING", "0 30 17 ? *", false, 22d),
+ new Scene("nightScene", "Night scene", "NIGHT", "0 0 22 ? *", true, 19d)
+ };
+ final protected boolean importDemoScenes;
+ public String smartOfficeId;
+ public String groundFloorId;
+ public String lobbyId;
+ public String agentId;
+ public String thingId;
+ public String smartBuildingId;
+ public String apartment1Id;
+ public String apartment1SceneAgentId;
+ public String apartment1ServiceAgentId;
+ public String apartment1LivingroomId = UniqueIdentifierGenerator.generateId("apartment1LivingroomId");
+ public String apartment1KitchenId;
+ public String apartment1HallwayId;
+ public String apartment1Bedroom1Id;
+ public String apartment1BathroomId;
+ public String apartment2Id;
+ public String apartment3Id;
+ public String apartment2LivingroomId;
+ public String apartment2BathroomId;
+ public String apartment3LivingroomId;
+ public String masterRealm;
+ public String realmBuildingTenant;
+ public String realmCityTenant;
+ public String smartCityServiceAgentId;
+ public String area1Id;
+ public String microphone1Id;
+ public String peopleCounter3AssetId;
+
+ public ManagerTestSetup(Container container, boolean importDemoScenes) {
+ super(container);
+ this.importDemoScenes = importDemoScenes;
+ }
+
+ @Override
+ public void onStart() throws Exception {
+
+ KeycloakTestSetup keycloakTestSetup = setupService.getTaskOfType(KeycloakTestSetup.class);
+ Tenant masterTenant = keycloakTestSetup.masterTenant;
+ Tenant tenantBuilding = keycloakTestSetup.tenantBuilding;
+ Tenant tenantCity = keycloakTestSetup.tenantCity;
+ masterRealm = masterTenant.getRealm();
+ this.realmBuildingTenant = tenantBuilding.getRealm();
+ this.realmCityTenant = tenantCity.getRealm();
+
+ // ################################ Demo assets for 'master' realm ###################################
+
+ ObjectValue locationValue = SMART_OFFICE_LOCATION.toValue();
+
+ Asset smartOffice = new Asset();
+ smartOffice.setRealm(masterRealm);
+ smartOffice.setName("Smart Office");
+ smartOffice.setType(BUILDING);
+ List<AssetAttribute> smartOfficeAttributes = Arrays.asList(
+ new AssetAttribute(AttributeType.LOCATION, locationValue),
+ new AssetAttribute(AttributeType.GEO_STREET, Values.create("Torenallee 20")),
+ new AssetAttribute(AttributeType.GEO_POSTAL_CODE, Values.create("5617")),
+ new AssetAttribute(AttributeType.GEO_CITY, Values.create("Eindhoven")),
+ new AssetAttribute(AttributeType.GEO_COUNTRY, Values.create("Netherlands"))
+ );
+
+ smartOffice.setAttributes(smartOfficeAttributes);
+ smartOffice = assetStorageService.merge(smartOffice);
+ smartOfficeId = smartOffice.getId();
+
+ Asset groundFloor = new Asset("Ground Floor", FLOOR, smartOffice)
+ .addAttributes(new AssetAttribute(AttributeType.LOCATION, locationValue));
+ groundFloor = assetStorageService.merge(groundFloor);
+ groundFloorId = groundFloor.getId();
+
+ Asset lobby = new Asset("Lobby", ROOM, groundFloor)
+ .addAttributes(new AssetAttribute(AttributeType.LOCATION, locationValue));
+ lobby.addAttributes(
+ new AssetAttribute("lobbyLocations", AttributeValueType.ARRAY)
+ );
+
+ lobby = assetStorageService.merge(lobby);
+ lobbyId = lobby.getId();
+
+ Asset agent = new Asset("Demo Agent", AGENT, lobby);
+ agent.addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, locationValue),
+ initProtocolConfiguration(new AssetAttribute(agentProtocolConfigName), SimulatorProtocol.PROTOCOL_NAME)
+ .addMeta(
+ new MetaItem(
+ SimulatorProtocol.CONFIG_MODE,
+ Values.create(SimulatorProtocol.Mode.WRITE_THROUGH_DELAYED.toString())
+ ),
+ new MetaItem(
+ SimulatorProtocol.CONFIG_WRITE_DELAY_MILLISECONDS,
+ Values.create(500)
+ ))
+ );
+
+ agent = assetStorageService.merge(agent);
+ agentId = agent.getId();
+
+ Asset thing = new Asset("Demo Thing", THING, agent)
+ .addAttributes(new AssetAttribute(AttributeType.LOCATION, locationValue)
+ .setMeta(new MetaItem(RULE_STATE, Values.create(true))));
+ thing.addAttributes(
+ new AssetAttribute(thingLightToggleAttributeName, BOOLEAN, Values.create(true))
+ .setMeta(new Meta(
+ new MetaItem(
+ LABEL,
+ Values.create("Light 1 Toggle")),
+ new MetaItem(
+ DESCRIPTION,
+ Values.create("Switch for living room light")),
+ new MetaItem(
+ STORE_DATA_POINTS,
+ Values.create(true)),
+ new MetaItem(
+ DATA_POINTS_MAX_AGE_DAYS,
+ Values.create(DATA_POINTS_MAX_AGE_DAYS_DEFAULT*7)
+ ),
+ new MetaItem(
+ AGENT_LINK,
+ new AttributeRef(agent.getId(), agentProtocolConfigName).toArrayValue()),
+ new MetaItem(
+ SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(SwitchSimulatorElement.ELEMENT_NAME)
+ ))
+ ),
+ new AssetAttribute("light1Dimmer", PERCENTAGE) // No initial value!
+ .setMeta(new Meta(
+ new MetaItem(
+ LABEL,
+ Values.create("Light 1 Dimmer")),
+ new MetaItem(
+ DESCRIPTION,
+ Values.create("Dimmer for living room light")),
+ new MetaItem(
+ RANGE_MIN,
+ Values.create(0)),
+ new MetaItem(
+ RANGE_MAX,
+ Values.create(100)),
+ new MetaItem(
+ AGENT_LINK,
+ new AttributeRef(agent.getId(), agentProtocolConfigName).toArrayValue()),
+ new MetaItem(
+ SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME_RANGE)),
+ new MetaItem(
+ SimulatorProtocol.CONFIG_MODE,
+ Values.create(SimulatorProtocol.Mode.WRITE_THROUGH_DELAYED.toString()))
+ )
+ ),
+ new AssetAttribute("light1Color", COLOR_RGB, new ColorRGB(88, 123, 88).asArrayValue())
+ .setMeta(new Meta(
+ new MetaItem(
+ LABEL,
+ Values.create("Light 1 Color")),
+ new MetaItem(
+ DESCRIPTION,
+ Values.create("Color of living room light")),
+ new MetaItem(
+ AGENT_LINK,
+ new AttributeRef(agent.getId(), agentProtocolConfigName).toArrayValue()),
+ new MetaItem(
+ SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(ColorSimulatorElement.ELEMENT_NAME))
+ )
+ ),
+ new AssetAttribute("light1PowerConsumption", ENERGY, Values.create(12.345))
+ .setMeta(new Meta(
+ new MetaItem(
+ LABEL,
+ Values.create("Light 1 Usage")),
+ new MetaItem(
+ DESCRIPTION,
+ Values.create("Total energy consumption of living room light")),
+ new MetaItem(
+ READ_ONLY,
+ Values.create(true)),
+ new MetaItem(
+ FORMAT,
+ Values.create("%3d kWh")),
+ new MetaItem(
+ AGENT_LINK,
+ new AttributeRef(agent.getId(), agentProtocolConfigName).toArrayValue()),
+ new MetaItem(
+ SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME)),
+ new MetaItem(
+ STORE_DATA_POINTS, Values.create(true))
+ )
+ )
+ );
+ thing = assetStorageService.merge(thing);
+ thingId = thing.getId();
+
+ // ################################ Demo assets for 'building' realm ###################################
+
+ Asset smartBuilding = new Asset();
+ smartBuilding.setRealm(this.realmBuildingTenant);
+ smartBuilding.setName("Smart Building");
+ smartBuilding.setType(BUILDING);
+ smartBuilding.setAttributes(
+ new AssetAttribute(AttributeType.LOCATION, SMART_BUILDING_LOCATION.toValue()).addMeta(SHOW_ON_DASHBOARD),
+ new AssetAttribute(AttributeType.GEO_STREET, Values.create("Kastanjelaan 500")),
+ new AssetAttribute(AttributeType.GEO_POSTAL_CODE, Values.create("5616")),
+ new AssetAttribute(AttributeType.GEO_CITY, Values.create("Eindhoven")),
+ new AssetAttribute(AttributeType.GEO_COUNTRY, Values.create("Netherlands"))
+ );
+ smartBuilding = assetStorageService.merge(smartBuilding);
+ smartBuildingId = smartBuilding.getId();
+
+ // The "Apartment 1" is the demo apartment with complex scenes
+ Asset apartment1 = createDemoApartment(smartBuilding, "Apartment 1", new GeoJSONPoint(5.454233, 51.446800));
+ apartment1 = assetStorageService.merge(apartment1);
+ apartment1Id = apartment1.getId();
+
+ Asset apartment1ServiceAgent = new Asset("Service Agent (Simulator)", AGENT, apartment1);
+ apartment1ServiceAgent.addAttributes(
+ initProtocolConfiguration(new AssetAttribute("apartmentSimulator"), SimulatorProtocol.PROTOCOL_NAME)
+ .addMeta(
+ new MetaItem(
+ SimulatorProtocol.CONFIG_MODE,
+ Values.create(SimulatorProtocol.Mode.WRITE_THROUGH_IMMEDIATE.toString())
+ ))
+ );
+ apartment1ServiceAgent = assetStorageService.merge(apartment1ServiceAgent);
+ apartment1ServiceAgentId = apartment1ServiceAgent.getId();
+
+ /* ############################ ROOMS ############################## */
+
+ Asset apartment1Livingroom = createDemoApartmentRoom(apartment1, "Living Room 1")
+ .addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(5.454213, 51.446884).toValue()),
+ new AssetAttribute("lightsCeiling", NUMBER, Values.create(0))
+ .setMeta(
+ new MetaItem(RANGE_MIN, Values.create(0)),
+ new MetaItem(RANGE_MAX, Values.create(100)),
+ new MetaItem(LABEL, Values.create("Ceiling lights (range)")),
+ new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)),
+ new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true))
+ ),
+ new AssetAttribute("lightsStand", AttributeValueType.BOOLEAN, Values.create(true))
+ .setMeta(
+ new MetaItem(LABEL, Values.create("Floor stand lights (on/off)")),
+ new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)),
+ new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true))
+ )
+ );
+ addDemoApartmentRoomMotionSensor(apartment1Livingroom, true, () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+ addDemoApartmentRoomCO2Sensor(apartment1Livingroom, true, () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+ addDemoApartmentRoomHumiditySensor(apartment1Livingroom, true, () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+ addDemoApartmentRoomThermometer(apartment1Livingroom, true, () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+ addDemoApartmentTemperatureControl(apartment1Livingroom, true, () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+
+ apartment1Livingroom.setId(apartment1LivingroomId);
+ apartment1Livingroom = assetStorageService.merge(apartment1Livingroom);
+ apartment1LivingroomId = apartment1Livingroom.getId();
+
+ Asset apartment1Kitchen = createDemoApartmentRoom(apartment1, "Kitchen 1")
+ .addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(5.454122, 51.446800).toValue()),
+ new AssetAttribute("lights", AttributeValueType.BOOLEAN, Values.create(true))
+ .addMeta(new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)))
+ .addMeta(new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)))
+ );
+ addDemoApartmentRoomMotionSensor(apartment1Kitchen, true, () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+
+ for (String switchName : new String[]{"A", "B", "C"}) {
+ addDemoApartmentSmartSwitch(apartment1Kitchen, switchName, true, attributeIndex -> {
+ switch (attributeIndex) {
+ case 2:
+ return new MetaItem[]{
+ new MetaItem(MetaItemType.AGENT_LINK,
+ new AttributeRef(apartment1ServiceAgentId,
+ "apartmentSimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT,
+ Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ };
+ case 3:
+ return new MetaItem[]{
+ new MetaItem(MetaItemType.AGENT_LINK,
+ new AttributeRef(apartment1ServiceAgentId,
+ "apartmentSimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT,
+ Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ };
+ case 4:
+ return new MetaItem[]{
+ new MetaItem(MetaItemType.AGENT_LINK,
+ new AttributeRef(apartment1ServiceAgentId,
+ "apartmentSimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT,
+ Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ };
+ }
+ return null;
+ });
+ }
+
+ apartment1Kitchen = assetStorageService.merge(apartment1Kitchen);
+ apartment1KitchenId = apartment1Kitchen.getId();
+
+ Asset apartment1Hallway = createDemoApartmentRoom(apartment1, "Hallway 1")
+ .addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(5.454342, 51.446762).toValue()),
+ new AssetAttribute("lights", AttributeValueType.BOOLEAN, Values.create(true))
+ .addMeta(new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)))
+ .addMeta(new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)))
+ );
+ addDemoApartmentRoomMotionSensor(apartment1Hallway, true, () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+
+ apartment1Hallway = assetStorageService.merge(apartment1Hallway);
+ apartment1HallwayId = apartment1Hallway.getId();
+
+ Asset apartment1Bedroom1 = createDemoApartmentRoom(apartment1, "Bedroom 1")
+ .addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(5.454332, 51.446830).toValue()),
+ new AssetAttribute("lights", AttributeValueType.BOOLEAN, Values.create(true))
+ .addMeta(new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)))
+ .addMeta(new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)))
+ );
+ addDemoApartmentRoomCO2Sensor(apartment1Bedroom1, true, () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+ addDemoApartmentRoomHumiditySensor(apartment1Bedroom1, true, () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+ addDemoApartmentRoomThermometer(apartment1Bedroom1, true, () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+ addDemoApartmentTemperatureControl(apartment1Bedroom1, true, () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+
+ apartment1Bedroom1 = assetStorageService.merge(apartment1Bedroom1);
+ apartment1Bedroom1Id = apartment1Bedroom1.getId();
+
+ Asset apartment1Bathroom = new Asset("Bathroom 1", ROOM, apartment1);
+ apartment1Bathroom.addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(5.454227,51.446753).toValue()),
+ new AssetAttribute("lights", AttributeValueType.BOOLEAN, Values.create(true))
+ .setMeta(
+ new MetaItem(RULE_STATE, Values.create(true)),
+ new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)),
+ new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true))
+ )
+ );
+ addDemoApartmentRoomThermometer(apartment1Bathroom, true, () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+ addDemoApartmentTemperatureControl(apartment1Bathroom, true, () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+ apartment1Bathroom = assetStorageService.merge(apartment1Bathroom);
+ apartment1BathroomId = apartment1Bathroom.getId();
+
+
+ addDemoApartmentVentilation(apartment1, true, () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+
+ apartment1 = assetStorageService.merge(apartment1);
+ apartment1Id = apartment1.getId();
+
+ if (importDemoScenes) {
+ Asset demoApartment1SceneAgent = createDemoApartmentScenes(
+ assetStorageService, apartment1, DEMO_APARTMENT_SCENES, apartment1Livingroom, apartment1Kitchen, apartment1Hallway);
+ apartment1SceneAgentId = demoApartment1SceneAgent.getId();
+ }
+
+ Asset apartment2 = new Asset("Apartment 2", RESIDENCE, smartBuilding);
+ apartment2.addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(5.454053, 51.446603).toValue()),
+ new AssetAttribute("allLightsOffSwitch", AttributeValueType.BOOLEAN, Values.create(true))
+ .setMeta(
+ new MetaItem(LABEL, Values.create("All Lights Off Switch")),
+ new MetaItem(DESCRIPTION, Values.create("When triggered, turns all lights in the apartment off")),
+ new MetaItem(RULE_EVENT, Values.create(true)),
+ new MetaItem(RULE_EVENT_EXPIRES, Values.create("3s"))
+ )
+ );
+ apartment2 = assetStorageService.merge(apartment2);
+ apartment2Id = apartment2.getId();
+
+ Asset apartment2Livingroom = new Asset("Living Room 2", ROOM, apartment2);
+ apartment2Livingroom.addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(5.454109, 51.446631).toValue()),
+ new AssetAttribute("motionSensor", AttributeValueType.BOOLEAN, Values.create(false))
+ .setMeta(
+ new MetaItem(LABEL, Values.create("Motion Sensor")),
+ new MetaItem(DESCRIPTION, Values.create("PIR sensor that sends 'true' when motion is sensed")),
+ new MetaItem(RULE_STATE, Values.create(true)),
+ new MetaItem(RULE_EVENT, Values.create(true))
+ ),
+ new AssetAttribute("presenceDetected", AttributeValueType.BOOLEAN, Values.create(false))
+ .setMeta(
+ new MetaItem(LABEL, Values.create("Presence Detected")),
+ new MetaItem(DESCRIPTION, Values.create("Someone is currently present in the room")),
+ new MetaItem(RULE_STATE, Values.create(true))
+ ),
+ new AssetAttribute("firstPresenceDetected", AttributeValueType.TIMESTAMP)
+ .setMeta(
+ new MetaItem(LABEL, Values.create("First Presence Timestamp")),
+ new MetaItem(DESCRIPTION, Values.create("Timestamp of the first detected presence")),
+ new MetaItem(RULE_STATE, Values.create(true))
+ ),
+ new AssetAttribute("lastPresenceDetected", AttributeValueType.TIMESTAMP)
+ .setMeta(
+ new MetaItem(LABEL, Values.create("Last Presence Timestamp")),
+ new MetaItem(DESCRIPTION, Values.create("Timestamp of last detected presence")),
+ new MetaItem(RULE_STATE, Values.create(true))
+ ),
+ new AssetAttribute("co2Level", AttributeValueType.CO2, Values.create(350))
+ .setMeta(
+ new MetaItem(LABEL, Values.create("CO2 Level")),
+ new MetaItem(RULE_STATE, Values.create(true))
+ ),
+ new AssetAttribute("lightSwitch", AttributeValueType.BOOLEAN, Values.create(true))
+ .setMeta(
+ new MetaItem(LABEL, Values.create("Light Switch")),
+ new MetaItem(RULE_STATE, Values.create(true))
+ ),
+ new AssetAttribute("windowOpen", AttributeValueType.BOOLEAN, Values.create(false))
+ .setMeta(
+ new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true))
+ ),
+ new AssetAttribute("lightSwitchTriggerTimes", ARRAY, Values.createArray().add(Values.create("1800")).add(Values.create("0830")))
+ .setMeta(
+ new MetaItem(LABEL, Values.create("Lightswitch Trigger Times")),
+ new MetaItem(RULE_STATE, Values.create(true))
+ ),
+ new AssetAttribute("plantsWaterLevels", OBJECT, Values.createObject().put("cactus", 0.8))
+ .setMeta(
+ new MetaItem(LABEL, Values.create("Water levels of the plants")),
+ new MetaItem(RULE_STATE, Values.create(true))
+ )
+ );
+ apartment2Livingroom = assetStorageService.merge(apartment2Livingroom);
+ apartment2LivingroomId = apartment2Livingroom.getId();
+
+ Asset apartment2Bathroom = new Asset("Bathroom 2", ROOM, apartment2);
+ apartment2Bathroom.addAttributes(
+ new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(5.454015, 51.446665).toValue()),
+ new AssetAttribute("motionSensor", AttributeValueType.BOOLEAN, Values.create(false))
+ .setMeta(
+ new MetaItem(LABEL, Values.create("Motion Sensor")),
+ new MetaItem(DESCRIPTION, Values.create("PIR sensor that sends 'true' when motion is sensed")),
+ new MetaItem(RULE_STATE, Values.create(true)),
+ new MetaItem(RULE_EVENT, Values.create(true))
+ ),
+ new AssetAttribute("presenceDetected", AttributeValueType.BOOLEAN, Values.create(false))
+ .setMeta(
+ new MetaItem(LABEL, Values.create("Presence Detected")),
+ new MetaItem(DESCRIPTION, Values.create("Someone is currently present in the room")),
+ new MetaItem(RULE_STATE, Values.create(true))
+ ),
+ new AssetAttribute("firstPresenceDetected", AttributeValueType.TIMESTAMP)
+ .setMeta(
+ new MetaItem(LABEL, Values.create("First Presence Timestamp")),
+ new MetaItem(DESCRIPTION, Values.create("Timestamp of the first detected presence")),
+ new MetaItem(RULE_STATE, Values.create(true))
+ ),
+ new AssetAttribute("lastPresenceDetected", AttributeValueType.TIMESTAMP)
+ .setMeta(
+ new MetaItem(LABEL, Values.create("Last Presence Timestamp")),
+ new MetaItem(DESCRIPTION, Values.create("Timestamp of last detected presence")),
+ new MetaItem(RULE_STATE, Values.create(true))
+ ),
+ new AssetAttribute("lightSwitch", AttributeValueType.BOOLEAN, Values.create(true))
+ .setMeta(
+ new MetaItem(LABEL, Values.create("Light Switch")),
+ new MetaItem(RULE_STATE, Values.create(true))
+ )
+ );
+ apartment2Bathroom = assetStorageService.merge(apartment2Bathroom);
+ apartment2BathroomId = apartment2Bathroom.getId();
+
+ Asset apartment3 = new Asset("Apartment 3", RESIDENCE, smartBuilding)
+ .addAttributes(new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(5.453859, 51.446379).toValue()));
+ apartment3 = assetStorageService.merge(apartment3);
+ apartment3Id = apartment3.getId();
+
+ Asset apartment3Livingroom = new Asset("Living Room 3", ROOM, apartment3)
+ .addAttributes(new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(5.453932, 51.446422).toValue()));
+ apartment3Livingroom.addAttributes(
+ new AssetAttribute("lightSwitch", AttributeValueType.BOOLEAN)
+ );
+
+ apartment3Livingroom = assetStorageService.merge(apartment3Livingroom);
+ apartment3LivingroomId = apartment3Livingroom.getId();
+
+ // ################################ Link demo users and assets ###################################
+
+ assetStorageService.storeUserAsset(new UserAsset(keycloakTestSetup.tenantBuilding.getRealm(),
+ keycloakTestSetup.testuser3Id,
+ apartment1Id));
+ assetStorageService.storeUserAsset(new UserAsset(keycloakTestSetup.tenantBuilding.getRealm(),
+ keycloakTestSetup.testuser3Id,
+ apartment1LivingroomId));
+ assetStorageService.storeUserAsset(new UserAsset(keycloakTestSetup.tenantBuilding.getRealm(),
+ keycloakTestSetup.testuser3Id,
+ apartment1KitchenId));
+ assetStorageService.storeUserAsset(new UserAsset(keycloakTestSetup.tenantBuilding.getRealm(),
+ keycloakTestSetup.testuser3Id,
+ apartment1Bedroom1Id));
+ assetStorageService.storeUserAsset(new UserAsset(keycloakTestSetup.tenantBuilding.getRealm(),
+ keycloakTestSetup.testuser3Id,
+ apartment1BathroomId));
+ assetStorageService.storeUserAsset(new UserAsset(keycloakTestSetup.tenantBuilding.getRealm(),
+ keycloakTestSetup.testuser3Id,
+ apartment1HallwayId));
+
+ assetStorageService.storeUserAsset(new UserAsset(keycloakTestSetup.tenantBuilding.getRealm(),
+ keycloakTestSetup.buildingUserId,
+ apartment1Id));
+ assetStorageService.storeUserAsset(new UserAsset(keycloakTestSetup.tenantBuilding.getRealm(),
+ keycloakTestSetup.buildingUserId,
+ apartment1LivingroomId));
+ assetStorageService.storeUserAsset(new UserAsset(keycloakTestSetup.tenantBuilding.getRealm(),
+ keycloakTestSetup.buildingUserId,
+ apartment1KitchenId));
+ assetStorageService.storeUserAsset(new UserAsset(keycloakTestSetup.tenantBuilding.getRealm(),
+ keycloakTestSetup.buildingUserId,
+ apartment1Bedroom1Id));
+ assetStorageService.storeUserAsset(new UserAsset(keycloakTestSetup.tenantBuilding.getRealm(),
+ keycloakTestSetup.buildingUserId,
+ apartment1BathroomId));
+ assetStorageService.storeUserAsset(new UserAsset(keycloakTestSetup.tenantBuilding.getRealm(),
+ keycloakTestSetup.buildingUserId,
+ apartment1HallwayId));
+
+ // ################################ Make users restricted ###################################
+
+ UserConfiguration testuser3Config = identityService.getUserConfiguration(keycloakTestSetup.testuser3Id);
+ testuser3Config.setRestricted(true);
+ testuser3Config = identityService.mergeUserConfiguration(testuser3Config);
+
+ UserConfiguration buildingUserConfig = identityService.getUserConfiguration(keycloakTestSetup.buildingUserId);
+ testuser3Config.setRestricted(true);
+ buildingUserConfig = identityService.mergeUserConfiguration(buildingUserConfig);
+
+ // ################################ Realm smartcity ###################################
+
+ ObjectValue smartCityLocation = SMART_CITY_LOCATION.toValue();
+
+ Asset smartCity = new Asset();
+ smartCity.setRealm(this.realmCityTenant);
+ smartCity.setName("Smart City");
+ smartCity.setType(CITY);
+ smartCity.setAttributes(
+ new AssetAttribute(AttributeType.LOCATION, smartCityLocation),
+ new AssetAttribute(AttributeType.GEO_CITY, Values.create("Eindhoven")),
+ new AssetAttribute(AttributeType.GEO_COUNTRY, Values.create("Netherlands"))
+ );
+ smartCity = assetStorageService.merge(smartCity);
+
+ Asset smartCityServiceAgent = new Asset("Service Agent (Simulator)", AGENT, smartCity);
+ smartCityServiceAgent.addAttributes(
+ initProtocolConfiguration(new AssetAttribute("citySimulator"), SimulatorProtocol.PROTOCOL_NAME)
+ .addMeta(
+ new MetaItem(
+ SimulatorProtocol.CONFIG_MODE,
+ Values.create(SimulatorProtocol.Mode.WRITE_THROUGH_IMMEDIATE.toString())
+ ))
+ );
+ smartCityServiceAgent = assetStorageService.merge(smartCityServiceAgent);
+ smartCityServiceAgentId = smartCityServiceAgent.getId();
+
+ // ################################ Realm B Area 1 ###################################
+
+ Asset assetArea1 = new Asset("Area 1", AREA, smartCity)
+ .setAttributes(
+ new AssetAttribute(AttributeType.LOCATION, AREA_1_LOCATION.toValue()),
+ new AssetAttribute(AttributeType.GEO_POSTAL_CODE, Values.create("5616")),
+ new AssetAttribute(AttributeType.GEO_CITY, Values.create("Eindhoven")),
+ new AssetAttribute(AttributeType.GEO_COUNTRY, Values.create("Netherlands"))
+ );
+ assetArea1 = assetStorageService.merge(assetArea1);
+ area1Id = assetArea1.getId();
+
+ Asset peopleCounter1Asset = createDemoPeopleCounterAsset("PeopleCounter 1", assetArea1, new GeoJSONPoint(5.477126, 51.439137), () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(smartCityServiceAgentId, "citySimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+ peopleCounter1Asset = assetStorageService.merge(peopleCounter1Asset);
+
+ Asset microphone1Asset = createDemoMicrophoneAsset("Microphone 1", assetArea1, new GeoJSONPoint(5.478092, 51.438655), () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(smartCityServiceAgentId, "citySimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+ microphone1Asset = assetStorageService.merge(microphone1Asset);
+ microphone1Id = microphone1Asset.getId();
+
+ Asset enviroment1Asset = createDemoEnvironmentAsset("Environment 1", assetArea1, new GeoJSONPoint(5.478907, 51.438943),() -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(smartCityServiceAgentId, "citySimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+ enviroment1Asset = assetStorageService.merge(enviroment1Asset);
+
+ Asset light1Asset = createDemoLightAsset("Light 1", assetArea1, new GeoJSONPoint(5.476111, 51.438492));
+ light1Asset = assetStorageService.merge(light1Asset);
+
+ Asset light2Asset = createDemoLightAsset("Light 2", assetArea1, new GeoJSONPoint(5.477272, 51.439214));
+ light2Asset = assetStorageService.merge(light2Asset);
+
+ // ################################ Realm B Area 2 ###################################
+
+ Asset assetArea2 = new Asset("Area 2", AREA, smartCity)
+ .setAttributes(
+ new AssetAttribute(AttributeType.LOCATION, AREA_2_LOCATION.toValue()),
+ new AssetAttribute(AttributeType.GEO_POSTAL_CODE, Values.create("5651")),
+ new AssetAttribute(AttributeType.GEO_CITY, Values.create("Eindhoven")),
+ new AssetAttribute(AttributeType.GEO_COUNTRY, Values.create("Netherlands"))
+ );
+ assetArea2 = assetStorageService.merge(assetArea2);
+
+ Asset peopleCounter2Asset = createDemoPeopleCounterAsset("PeopleCounter 2", assetArea2, new GeoJSONPoint(5.473686, 51.438603), () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(smartCityServiceAgentId, "citySimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+ peopleCounter2Asset = assetStorageService.merge(peopleCounter2Asset);
+
+ Asset environment2Asset = createDemoEnvironmentAsset("Environment 2", assetArea2, new GeoJSONPoint(5.473552, 51.438412), () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(smartCityServiceAgentId, "citySimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+ environment2Asset = assetStorageService.merge(environment2Asset);
+
+
+ // ################################ Realm B Area 3 ###################################
+
+ Asset assetArea3 = new Asset("Area 3", AREA, smartCity)
+ .setAttributes(
+ new AssetAttribute(AttributeType.LOCATION, AREA_3_LOCATION.toValue()),
+ new AssetAttribute(AttributeType.GEO_POSTAL_CODE, Values.create("5617")),
+ new AssetAttribute(AttributeType.GEO_CITY, Values.create("Eindhoven")),
+ new AssetAttribute(AttributeType.GEO_COUNTRY, Values.create("Netherlands"))
+ );
+ assetArea3 = assetStorageService.merge(assetArea3);
+
+ Asset peopleCounter3Asset = createDemoPeopleCounterAsset("PeopleCounter 3", assetArea3, new GeoJSONPoint(5.487234, 51.447065), () -> new MetaItem[]{
+ new MetaItem(AGENT_LINK, new AttributeRef(smartCityServiceAgentId, "citySimulator").toArrayValue()),
+ new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
+ });
+ peopleCounter3Asset = assetStorageService.merge(peopleCounter3Asset);
+ peopleCounter3AssetId = peopleCounter3Asset.getId();
+
+ Asset lightController_3Asset = createDemoLightControllerAsset("LightController 3", assetArea3, new GeoJSONPoint(5.487478, 51.446979));
+ lightController_3Asset = assetStorageService.merge(lightController_3Asset);
+
+ persistenceService.doTransaction(entityManager -> {
+ entityManager.merge(new ConsoleAppConfig(
+ realmCityTenant,
+ "https://demo.openremote.io/mobile/?realm=smartcity&consoleProviders=geofence push storage",
+ true,
+ ConsoleAppConfig.MenuPosition.BOTTOM_LEFT,
+ null,
+ "#FAFAFA",
+ "#AFAFAF",
+ Values.createArray().addAll(
+ Values.createObject()
+ .put("displayText","Map")
+ .put("pageLink","https://demo.openremote.io/mobile/#!geofences?realm=smartcity&consoleProviders=geofence push storage"),
+ Values.createObject()
+ .put("displayText","List")
+ .put("pageLink","https://demo.openremote.io/mobile/#!geofences?realm=smartcity&consoleProviders=geofence push storage&view=list")
+ )
+ ));
+ });
+ }
+}
diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/RulesDemoSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/RulesDemoSetup.java
index 7d69c619a..f45048c37 100644
--- a/manager/src/main/java/org/openremote/manager/setup/builtin/RulesDemoSetup.java
+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/RulesDemoSetup.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016, OpenRemote Inc.
+ * Copyright 2020, OpenRemote Inc.
*
* See the CONTRIBUTORS.txt file in the distribution for a
* full listing of individual contributors.
@@ -22,7 +22,6 @@ package org.openremote.manager.setup.builtin;
import org.apache.commons.io.IOUtils;
import org.openremote.container.Container;
import org.openremote.manager.setup.AbstractManagerSetup;
-import org.openremote.model.rules.AssetRuleset;
import org.openremote.model.rules.Ruleset;
import org.openremote.model.rules.TenantRuleset;
import org.openremote.model.value.Values;
@@ -31,8 +30,6 @@ import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.logging.Logger;
-import static org.openremote.model.rules.Ruleset.Lang.GROOVY;
-
public class RulesDemoSetup extends AbstractManagerSetup {
private static final Logger LOG = Logger.getLogger(RulesDemoSetup.class.getName());
@@ -41,8 +38,6 @@ public class RulesDemoSetup extends AbstractManagerSetup {
super(container);
}
- public Long apartmentActionsRulesetId;
- public Long tenantBuildingRulesetId;
public Long tenantSmartCityRulesetId;
@Override
@@ -55,69 +50,14 @@ public class RulesDemoSetup extends AbstractManagerSetup {
// ################################ Rules demo data ###################################
- // Apartment 1
- try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/DemoResidencePresenceDetection.groovy")) {
- String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
- Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment1Id, "Demo Residence - Presence Detection with motion and CO2 sensors", Ruleset.Lang.GROOVY, rules
- );
- apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
- }
- try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/DemoResidenceVacationMode.groovy")) {
- String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
- Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment1Id, "Demo Residence - Vacation Mode", Ruleset.Lang.GROOVY, rules
- );
- apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
- }
- try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/DemoResidenceAutoVentilation.groovy")) {
- String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
- Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment1Id, "Demo Residence - Auto Ventilation", Ruleset.Lang.GROOVY, rules
- );
- apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
- }
- try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/DemoResidenceNotifyAlarmTrigger.groovy")) {
- String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
- Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment1Id, "Demo Residence - Notify Alarm Trigger", Ruleset.Lang.GROOVY, rules
- );
- apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
- }
- try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/DemoResidenceSmartSwitch.groovy")) {
- String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
- Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment1Id, "Demo Residence - Smart Start Switch", Ruleset.Lang.GROOVY, rules
- );
- ruleset.setEnabled(false);
- apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
- }
-
- // Apartment 2
- try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/DemoResidenceAllLightsOff.js")) {
- String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
- Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment2Id, "Demo Residence - All Lights Off", Ruleset.Lang.JAVASCRIPT, rules
- );
- apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
- }
-
- try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/DemoConsoleLocation.groovy")) {
- String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
- Ruleset ruleset = new TenantRuleset(
- keycloakDemoSetup.tenantBuilding.getRealm(), "Demo Console Location", Ruleset.Lang.GROOVY, rules
- ).setAccessPublicRead(true);
- tenantBuildingRulesetId = rulesetStorageService.merge(ruleset).getId();
- }
-
// People counter
- try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/DemoSmartCityCamera.groovy")) {
- String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
- Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.peopleCounter3AssetId, "PeopleCounter 3 Rules", GROOVY, rules
- );
- rulesetStorageService.merge(ruleset);
- }
+// try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/DemoSmartCityCamera.groovy")) {
+// String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+// Ruleset ruleset = new AssetRuleset(
+// managerDemoSetup.peopleCounter3AssetId, "PeopleCounter 3 Rules", GROOVY, rules
+// );
+// rulesetStorageService.merge(ruleset);
+// }
// SmartCity geofences
try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/DemoGeofences.json")) {
diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/RulesTestSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/RulesTestSetup.java
new file mode 100644
index 000000000..a0c5d22d3
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/RulesTestSetup.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2020, 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.manager.setup.builtin;
+
+import org.apache.commons.io.IOUtils;
+import org.openremote.container.Container;
+import org.openremote.manager.setup.AbstractManagerSetup;
+import org.openremote.model.rules.AssetRuleset;
+import org.openremote.model.rules.Ruleset;
+import org.openremote.model.rules.TenantRuleset;
+import org.openremote.model.value.Values;
+
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.logging.Logger;
+
+import static org.openremote.model.rules.Ruleset.Lang.GROOVY;
+
+public class RulesTestSetup extends AbstractManagerSetup {
+
+ private static final Logger LOG = Logger.getLogger(RulesTestSetup.class.getName());
+
+ public RulesTestSetup(Container container) {
+ super(container);
+ }
+
+ public Long apartmentActionsRulesetId;
+ public Long tenantBuildingRulesetId;
+ public Long tenantSmartCityRulesetId;
+
+ @Override
+ public void onStart() throws Exception {
+
+ KeycloakTestSetup keycloakTestSetup = setupService.getTaskOfType(KeycloakTestSetup.class);
+ ManagerTestSetup managerTestSetup = setupService.getTaskOfType(ManagerTestSetup.class);
+
+ LOG.info("Importing demo rulesets");
+
+ // ################################ Rules demo data ###################################
+
+ // Apartment 1
+ try (InputStream inputStream = RulesTestSetup.class.getResourceAsStream("/demo/rules/DemoResidencePresenceDetection.groovy")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new AssetRuleset(
+ managerTestSetup.apartment1Id, "Demo Residence - Presence Detection with motion and CO2 sensors", Ruleset.Lang.GROOVY, rules
+ );
+ apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+ try (InputStream inputStream = RulesTestSetup.class.getResourceAsStream("/demo/rules/DemoResidenceVacationMode.groovy")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new AssetRuleset(
+ managerTestSetup.apartment1Id, "Demo Residence - Vacation Mode", Ruleset.Lang.GROOVY, rules
+ );
+ apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+ try (InputStream inputStream = RulesTestSetup.class.getResourceAsStream("/demo/rules/DemoResidenceAutoVentilation.groovy")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new AssetRuleset(
+ managerTestSetup.apartment1Id, "Demo Residence - Auto Ventilation", Ruleset.Lang.GROOVY, rules
+ );
+ apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+ try (InputStream inputStream = RulesTestSetup.class.getResourceAsStream("/demo/rules/DemoResidenceNotifyAlarmTrigger.groovy")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new AssetRuleset(
+ managerTestSetup.apartment1Id, "Demo Residence - Notify Alarm Trigger", Ruleset.Lang.GROOVY, rules
+ );
+ apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+ try (InputStream inputStream = RulesTestSetup.class.getResourceAsStream("/demo/rules/DemoResidenceSmartSwitch.groovy")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new AssetRuleset(
+ managerTestSetup.apartment1Id, "Demo Residence - Smart Start Switch", Ruleset.Lang.GROOVY, rules
+ );
+ ruleset.setEnabled(false);
+ apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+
+ // Apartment 2
+ try (InputStream inputStream = RulesTestSetup.class.getResourceAsStream("/demo/rules/DemoResidenceAllLightsOff.js")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new AssetRuleset(
+ managerTestSetup.apartment2Id, "Demo Residence - All Lights Off", Ruleset.Lang.JAVASCRIPT, rules
+ );
+ apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+
+ try (InputStream inputStream = RulesTestSetup.class.getResourceAsStream("/demo/rules/DemoConsoleLocation.groovy")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new TenantRuleset(
+ keycloakTestSetup.tenantBuilding.getRealm(), "Demo Console Location", Ruleset.Lang.GROOVY, rules
+ ).setAccessPublicRead(true);
+ tenantBuildingRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+
+ // People counter
+ try (InputStream inputStream = RulesTestSetup.class.getResourceAsStream("/demo/rules/DemoSmartCityCamera.groovy")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new AssetRuleset(
+ managerTestSetup.peopleCounter3AssetId, "PeopleCounter 3 Rules", GROOVY, rules
+ );
+ rulesetStorageService.merge(ruleset);
+ }
+
+ // SmartCity geofences
+ try (InputStream inputStream = RulesTestSetup.class.getResourceAsStream("/demo/rules/DemoGeofences.json")) {
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ Ruleset ruleset = new TenantRuleset(
+ keycloakTestSetup.tenantCity.getRealm(), "Demo Geofences", Ruleset.Lang.JSON, rules
+ ).setAccessPublicRead(true).addMeta("showOnMap", Values.create(true)).addMeta("showOnList", Values.create(true));
+ tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();
+ }
+ }
+}
diff --git a/manager/src/main/resources/demo/rules/DemoConsoleLocation.groovy b/manager/src/main/resources/demo/rules/DemoConsoleLocation.groovy
index 8c0a71551..62e9ac11f 100644
--- a/manager/src/main/resources/demo/rules/DemoConsoleLocation.groovy
+++ b/manager/src/main/resources/demo/rules/DemoConsoleLocation.groovy
@@ -1,7 +1,7 @@
package demo.rules
import org.openremote.manager.rules.RulesBuilder
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.asset.AssetType
import org.openremote.model.attribute.AttributeType
import org.openremote.model.notification.Notification
@@ -29,7 +29,7 @@ rules.add()
def consoleIds = facts.matchAssetState(new AssetQuery()
.types(AssetType.CONSOLE)
.attributes(new LocationAttributePredicate(
- new RadialGeofencePredicate(100, ManagerDemoSetup.SMART_BUILDING_LOCATION.y, ManagerDemoSetup.SMART_BUILDING_LOCATION.x))))
+ new RadialGeofencePredicate(100, ManagerTestSetup.SMART_BUILDING_LOCATION.y, ManagerTestSetup.SMART_BUILDING_LOCATION.x))))
.filter({ !facts.getOptional("welcomeHome" + "_${it.id}").isPresent() })
.map({ it.id })
.collect()
diff --git a/model/src/main/java/org/openremote/model/asset/AssetType.java b/model/src/main/java/org/openremote/model/asset/AssetType.java
index 54d32853f..c8fdb8f6f 100644
--- a/model/src/main/java/org/openremote/model/asset/AssetType.java
+++ b/model/src/main/java/org/openremote/model/asset/AssetType.java
@@ -389,6 +389,53 @@ public enum AssetType implements AssetDescriptor {
THING(ASSET_NAMESPACE + ":thing", "cube-outline", null),
ELECTRICITY_CONSUMER(ASSET_NAMESPACE + ":electricityConsumer", "power-plug", "8A293D", false,
+ new AttributeDescriptorImpl("manufacturer", STRING, null,
+ LABEL.withInitialValue("Manufacturer")),
+ new AttributeDescriptorImpl("model", STRING, null,
+ LABEL.withInitialValue("Model")),
+ new AttributeDescriptorImpl("userNotes", STRING, null,
+ LABEL.withInitialValue("User notes")),
+ new AttributeDescriptorImpl("status", STRING, null,
+ LABEL.withInitialValue("Status"),
+ DESCRIPTION.withInitialValue("Status system"),
+ READ_ONLY),
+ new AttributeDescriptorImpl("demandResponseType", STRING, null,
+ LABEL.withInitialValue("Demand response type"),
+ ALLOWED_VALUES.withInitialValue(Values.createArray().addAll(Arrays.stream(ElectricityConsumerDemandResponseType.values()).map(Enum::name).toArray(String[]::new)))),
+ new AttributeDescriptorImpl("energyTariffImport", CURRENCY, null,
+ LABEL.withInitialValue("Energy tariff import"),
+ UNIT_TYPE.withInitialValue(UNITS_EUR_PER_KILOWATT_HOUR)),
+ new AttributeDescriptorImpl("energyTariffExport", CURRENCY, null,
+ LABEL.withInitialValue("Energy tariff export"),
+ UNIT_TYPE.withInitialValue(UNITS_EUR_PER_KILOWATT_HOUR)),
+ new AttributeDescriptorImpl("energyCarbonImport", ENERGY, null,
+ LABEL.withInitialValue("Energy carbon import"),
+ UNIT_TYPE.withInitialValue(UNITS_KILOGRAM_CARBON_PER_KILOWATT_HOUR)),
+ new AttributeDescriptorImpl("energyCarbonExport", ENERGY, null,
+ LABEL.withInitialValue("Energy carbon export"),
+ UNIT_TYPE.withInitialValue(UNITS_KILOGRAM_CARBON_PER_KILOWATT_HOUR)),
+ new AttributeDescriptorImpl("totalPower", POWER, null,
+ LABEL.withInitialValue("Total power"),
+ READ_ONLY),
+ new AttributeDescriptorImpl("forecastPowerDeviation", POWER, null,
+ LABEL.withInitialValue("Forecast power deviation"),
+ READ_ONLY),
+ new AttributeDescriptorImpl("setPointPower", POWER, null,
+ LABEL.withInitialValue("Setpoint power"),
+ DESCRIPTION.withInitialValue("Positive is consuming, negative is delivering to network")),
+ new AttributeDescriptorImpl("availableMaxPower", POWER, null,
+ LABEL.withInitialValue("Available max power"),
+ READ_ONLY),
+ new AttributeDescriptorImpl("availableMinPower", POWER, null,
+ LABEL.withInitialValue("Available min power"),
+ READ_ONLY),
+ new AttributeDescriptorImpl("totalEnergy", ENERGY, null,
+ LABEL.withInitialValue("Total energy"),
+ UNIT_TYPE.withInitialValue(UNITS_ENERGY_KILOWATT_HOUR),
+ READ_ONLY)
+ ),
+
+ ELECTRICITY_CHARGER(ASSET_NAMESPACE + ":electricityCharger", "ev-station", "8A293D", false,
new AttributeDescriptorImpl("manufacturer", STRING, null,
LABEL.withInitialValue("Manufacturer")),
new AttributeDescriptorImpl("model", STRING, null,
@@ -397,42 +444,43 @@ public enum AssetType implements AssetDescriptor {
LABEL.withInitialValue("User notes")),
new AttributeDescriptorImpl("status", STRING, null,
LABEL.withInitialValue("Status"),
- DESCRIPTION.withInitialValue("Status system"),
- READ_ONLY),
- new AttributeDescriptorImpl("demandResponseType", STRING, null,
- LABEL.withInitialValue("Demand response type"),
- ALLOWED_VALUES.withInitialValue(Values.createArray().addAll(Arrays.stream(ElectricityConsumerDemandResponseType.values()).map(Enum::name).toArray(String[]::new)))),
- new AttributeDescriptorImpl("energyTariffImport", CURRENCY, null,
- LABEL.withInitialValue("Energy tariff import"),
- UNIT_TYPE.withInitialValue(UNITS_EUR_PER_KILOWATT_HOUR)),
+ DESCRIPTION.withInitialValue("Status charger"),
+ READ_ONLY,
+ RULE_STATE),
+ new AttributeDescriptorImpl("chargerType", STRING, null,
+ LABEL.withInitialValue("Charger type"),
+ READ_ONLY,
+ RULE_STATE,
+ ALLOWED_VALUES.withInitialValue(Values.createArray().addAll(Arrays.stream(ElectricityChargerConnectionType.values()).map(Enum::name).toArray(String[]::new)))),
+ new AttributeDescriptorImpl("chargerCapacity", POWER, null,
+ LABEL.withInitialValue("Charger capacity"),
+ UNIT_TYPE.withInitialValue(UNITS_POWER_KILOWATT),
+ READ_ONLY,
+ RULE_STATE),
+ new AttributeDescriptorImpl("power", POWER, null,
+ LABEL.withInitialValue("Power consumption"),
+ UNIT_TYPE.withInitialValue(UNITS_POWER_KILOWATT),
+ READ_ONLY,
+ STORE_DATA_POINTS,
+ RULE_STATE),
+ new AttributeDescriptorImpl("energyStartTariff", CURRENCY, null,
+ LABEL.withInitialValue("Start tariff"),
+ READ_ONLY,
+ RULE_STATE,
+ STORE_DATA_POINTS,
+ UNIT_TYPE.withInitialValue(UNITS_CURRENCY_EUR)),
new AttributeDescriptorImpl("energyTariffExport", CURRENCY, null,
- LABEL.withInitialValue("Energy tariff export"),
+ LABEL.withInitialValue("Export tariff"),
+ READ_ONLY,
+ RULE_STATE,
+ STORE_DATA_POINTS,
UNIT_TYPE.withInitialValue(UNITS_EUR_PER_KILOWATT_HOUR)),
- new AttributeDescriptorImpl("energyCarbonImport", ENERGY, null,
- LABEL.withInitialValue("Energy carbon import"),
- UNIT_TYPE.withInitialValue(UNITS_KILOGRAM_CARBON_PER_KILOWATT_HOUR)),
- new AttributeDescriptorImpl("energyCarbonExport", ENERGY, null,
- LABEL.withInitialValue("Energy carbon export"),
- UNIT_TYPE.withInitialValue(UNITS_KILOGRAM_CARBON_PER_KILOWATT_HOUR)),
- new AttributeDescriptorImpl("totalPower", POWER, null,
- LABEL.withInitialValue("Total power"),
- READ_ONLY),
- new AttributeDescriptorImpl("forecastPowerDeviation", POWER, null,
- LABEL.withInitialValue("Forecast power deviation"),
- READ_ONLY),
- new AttributeDescriptorImpl("setPointPower", POWER, null,
- LABEL.withInitialValue("Setpoint power"),
- DESCRIPTION.withInitialValue("Positive is consuming, negative is delivering to network")),
- new AttributeDescriptorImpl("availableMaxPower", POWER, null,
- LABEL.withInitialValue("Available max power"),
- READ_ONLY),
- new AttributeDescriptorImpl("availableMinPower", POWER, null,
- LABEL.withInitialValue("Available min power"),
- READ_ONLY),
- new AttributeDescriptorImpl("totalEnergy", ENERGY, null,
- LABEL.withInitialValue("Total energy"),
- UNIT_TYPE.withInitialValue(UNITS_ENERGY_KILOWATT_HOUR),
- READ_ONLY)
+ new AttributeDescriptorImpl("energyTariffImport", CURRENCY, null,
+ LABEL.withInitialValue("Import tariff"),
+ READ_ONLY,
+ RULE_STATE,
+ STORE_DATA_POINTS,
+ UNIT_TYPE.withInitialValue(UNITS_EUR_PER_KILOWATT_HOUR))
),
ELECTRICITY_PRODUCER(ASSET_NAMESPACE + ":electricityProducer", "white-balance-sunny", "CC9423", false,
@@ -460,7 +508,12 @@ public enum AssetType implements AssetDescriptor {
new AttributeDescriptorImpl("totalEnergy", ENERGY, null,
LABEL.withInitialValue("Total energy"),
UNIT_TYPE.withInitialValue(UNITS_ENERGY_KILOWATT_HOUR),
- READ_ONLY)
+ READ_ONLY),
+ new AttributeDescriptorImpl("panelOrientation", STRING, null,
+ LABEL.withInitialValue("Panel orientation"),
+ DESCRIPTION.withInitialValue("Direction the PV panels are facing"),
+ ALLOWED_VALUES.withInitialValue(Values.createArray().addAll(Arrays.stream(ElectricityProducerOrientationType.values()).map(Enum::name).toArray(String[]::new)))
+ )
),
ELECTRICITY_STORAGE(ASSET_NAMESPACE + ":electricityStorage", "battery-charging", "1B7C89", false,
diff --git a/model/src/main/java/org/openremote/model/asset/ElectricityChargerConnectionType.java b/model/src/main/java/org/openremote/model/asset/ElectricityChargerConnectionType.java
new file mode 100644
index 000000000..25132fe78
--- /dev/null
+++ b/model/src/main/java/org/openremote/model/asset/ElectricityChargerConnectionType.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2020, 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.model.asset;
+
+public enum ElectricityChargerConnectionType {
+ YAZAKI,
+ MENNEKES,
+ LE_GRAND,
+ CHADEMO,
+ COMBO,
+ SCHUKO
+}
diff --git a/model/src/main/java/org/openremote/model/asset/ElectricityProducerOrientationType.java b/model/src/main/java/org/openremote/model/asset/ElectricityProducerOrientationType.java
new file mode 100644
index 000000000..54a435c27
--- /dev/null
+++ b/model/src/main/java/org/openremote/model/asset/ElectricityProducerOrientationType.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2020, 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.model.asset;
+
+public enum ElectricityProducerOrientationType {
+ SOUTH,
+ EAST_WEST
+}
diff --git a/model/src/main/java/org/openremote/model/attribute/AttributeType.java b/model/src/main/java/org/openremote/model/attribute/AttributeType.java
index 572d264b6..3d81a3479 100644
--- a/model/src/main/java/org/openremote/model/attribute/AttributeType.java
+++ b/model/src/main/java/org/openremote/model/attribute/AttributeType.java
@@ -49,7 +49,7 @@ public enum AttributeType implements AttributeDescriptor {
LABEL.withInitialValue(Values.create("Country")),
ABOUT.withInitialValue(Values.create("http://project-haystack.org/tag/geoCountry"))),
- GEO_POSTAL_CODE("postalCode", AttributeValueType.NUMBER,
+ GEO_POSTAL_CODE("postalCode", AttributeValueType.STRING,
LABEL.withInitialValue(Values.create("Postal Code")),
ABOUT.withInitialValue(Values.create("http://project-haystack.org/tag/geoPostalCode"))),
diff --git a/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy b/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy
index 83647c271..8c6a8ce59 100644
--- a/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy
+++ b/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy
@@ -32,6 +32,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_TESTS) : "true",
(SETUP_IMPORT_DEMO_ASSETS) : "true",
(SETUP_IMPORT_DEMO_USERS) : "true",
(SETUP_IMPORT_DEMO_SCENES) : "false",
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovy
index 6719e0ffc..6b50eaf89 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovy
@@ -4,7 +4,7 @@ import org.openremote.agent.protocol.simulator.SimulatorProtocol
import org.openremote.manager.asset.AssetStorageService
import org.openremote.manager.datapoint.AssetDatapointService
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.attribute.AttributeRef
import org.openremote.model.datapoint.DatapointInterval
import org.openremote.model.value.Values
@@ -16,11 +16,9 @@ import java.time.Instant
import java.util.concurrent.TimeUnit
import static java.util.concurrent.TimeUnit.DAYS
-import static java.util.concurrent.TimeUnit.HOURS
import static java.util.concurrent.TimeUnit.SECONDS
-import static org.openremote.manager.datapoint.AssetDatapointService.DATA_POINTS_MAX_AGE_DAYS
import static org.openremote.manager.datapoint.AssetDatapointService.DATA_POINTS_MAX_AGE_DAYS_DEFAULT
-import static org.openremote.manager.setup.builtin.ManagerDemoSetup.thingLightToggleAttributeName
+import static org.openremote.manager.setup.builtin.ManagerTestSetup.thingLightToggleAttributeName
class AssetDatapointTest extends Specification implements ManagerContainerTrait {
@@ -32,71 +30,71 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
when: "the demo agent and thing have been deployed"
def datapointPurgeDays = DATA_POINTS_MAX_AGE_DAYS_DEFAULT
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def simulatorProtocol = container.getService(SimulatorProtocol.class)
def assetStorageService = container.getService(AssetStorageService.class)
def assetDatapointService = container.getService(AssetDatapointService.class)
then: "the simulator elements should have the initial state"
conditions.eventually {
- def state = simulatorProtocol.getValue(managerDemoSetup.thingId, "light1PowerConsumption")
+ def state = simulatorProtocol.getValue(managerTestSetup.thingId, "light1PowerConsumption")
assert Values.getNumber(state.orElse(null)).orElse(null) == 12.345d
}
when: "a simulated sensor receives some values"
advancePseudoClock(10, SECONDS, container)
- simulatorProtocol.putValue(managerDemoSetup.thingId, "light1PowerConsumption", Values.create(13.3d))
+ simulatorProtocol.putValue(managerTestSetup.thingId, "light1PowerConsumption", Values.create(13.3d))
advancePseudoClock(10, SECONDS, container)
- simulatorProtocol.putValue(managerDemoSetup.thingId, "light1PowerConsumption", Values.create(13.3d))
+ simulatorProtocol.putValue(managerTestSetup.thingId, "light1PowerConsumption", Values.create(13.3d))
advancePseudoClock(10, SECONDS, container)
- simulatorProtocol.putValue(managerDemoSetup.thingId, "light1PowerConsumption", Values.create(13.3d))
+ simulatorProtocol.putValue(managerTestSetup.thingId, "light1PowerConsumption", Values.create(13.3d))
and: "we move forward in time more than purge days and a simulated sensor receives a new value"
advancePseudoClock(datapointPurgeDays, DAYS, container)
def datapoint1ExpectedTimestamp = getClockTimeOf(container)
- simulatorProtocol.putValue(managerDemoSetup.thingId, "light1PowerConsumption", Values.create(13.3d))
+ simulatorProtocol.putValue(managerTestSetup.thingId, "light1PowerConsumption", Values.create(13.3d))
then: "the attribute should be updated"
conditions.eventually {
- def thing = assetStorageService.find(managerDemoSetup.thingId, true)
+ def thing = assetStorageService.find(managerTestSetup.thingId, true)
assert thing.getAttribute("light1PowerConsumption").flatMap { it.getValueAsNumber() }.orElse(null) == 13.3d
}
when: "a simulated sensor receives a new value"
advancePseudoClock(10, SECONDS, container)
def datapoint2ExpectedTimestamp = getClockTimeOf(container)
- simulatorProtocol.putValue(managerDemoSetup.thingId, "light1PowerConsumption", Values.create(14.4d))
+ simulatorProtocol.putValue(managerTestSetup.thingId, "light1PowerConsumption", Values.create(14.4d))
then: "the attribute should be updated"
conditions.eventually {
- def thing = assetStorageService.find(managerDemoSetup.thingId, true)
+ def thing = assetStorageService.find(managerTestSetup.thingId, true)
assert thing.getAttribute("light1PowerConsumption").flatMap { it.getValueAsNumber() }.orElse(null) == 14.4d
}
when: "a simulated sensor receives a new value"
advancePseudoClock(10, SECONDS, container)
def datapoint3ExpectedTimestamp = getClockTimeOf(container)
- simulatorProtocol.putValue(managerDemoSetup.thingId, "light1PowerConsumption", Values.create(15.5d))
+ simulatorProtocol.putValue(managerTestSetup.thingId, "light1PowerConsumption", Values.create(15.5d))
then: "the attribute should be updated"
conditions.eventually {
- def thing = assetStorageService.find(managerDemoSetup.thingId, true)
+ def thing = assetStorageService.find(managerTestSetup.thingId, true)
assert thing.getAttribute("light1PowerConsumption").flatMap { it.getValueAsNumber() }.orElse(null) == 15.5d
}
when: "a simulated sensor receives a new value"
advancePseudoClock(10, SECONDS, container)
- simulatorProtocol.putValue(managerDemoSetup.thingId, "light1PowerConsumption", null) // No value!
+ simulatorProtocol.putValue(managerTestSetup.thingId, "light1PowerConsumption", null) // No value!
then: "the attribute should be updated"
conditions.eventually {
- def thing = assetStorageService.find(managerDemoSetup.thingId, true)
+ def thing = assetStorageService.find(managerTestSetup.thingId, true)
assert !thing.getAttribute("light1PowerConsumption").flatMap { it.getValue() }.isPresent()
}
expect: "the datapoints to be stored"
conditions.eventually {
- def datapoints = assetDatapointService.getDatapoints(new AttributeRef(managerDemoSetup.thingId, "light1PowerConsumption"))
+ def datapoints = assetDatapointService.getDatapoints(new AttributeRef(managerTestSetup.thingId, "light1PowerConsumption"))
assert datapoints.size() == 3
// Note that the "No value" sensor update should not have created a datapoint, the first
@@ -114,7 +112,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
and: "the aggregated datapoints should match"
conditions.eventually {
- def thing = assetStorageService.find(managerDemoSetup.thingId, true)
+ def thing = assetStorageService.find(managerTestSetup.thingId, true)
def aggregatedDatapoints = assetDatapointService.getValueDatapoints(
thing.getAttribute("light1PowerConsumption").orElseThrow({ new RuntimeException("Missing attribute")}),
DatapointInterval.MINUTE,
@@ -131,39 +129,39 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
when: "a simulated boolean sensor receives a new value"
advancePseudoClock(10, SECONDS, container)
datapoint1ExpectedTimestamp = getClockTimeOf(container)
- simulatorProtocol.putValue(managerDemoSetup.thingId, thingLightToggleAttributeName, Values.create(false))
+ simulatorProtocol.putValue(managerTestSetup.thingId, thingLightToggleAttributeName, Values.create(false))
then: "the attribute should be updated"
conditions.eventually {
- def thing = assetStorageService.find(managerDemoSetup.thingId, true)
+ def thing = assetStorageService.find(managerTestSetup.thingId, true)
assert !thing.getAttribute(thingLightToggleAttributeName).flatMap { it.getValueAsBoolean() }.orElse(null)
}
when: "a simulated sensor receives a new value"
advancePseudoClock(10, SECONDS, container)
datapoint2ExpectedTimestamp = getClockTimeOf(container)
- simulatorProtocol.putValue(managerDemoSetup.thingId, thingLightToggleAttributeName, Values.create(true))
+ simulatorProtocol.putValue(managerTestSetup.thingId, thingLightToggleAttributeName, Values.create(true))
then: "the attribute should be updated"
conditions.eventually {
- def thing = assetStorageService.find(managerDemoSetup.thingId, true)
+ def thing = assetStorageService.find(managerTestSetup.thingId, true)
assert thing.getAttribute(thingLightToggleAttributeName).flatMap { it.getValueAsBoolean() }.orElse(null)
}
when: "a simulated sensor receives a new value"
advancePseudoClock(10, SECONDS, container)
datapoint3ExpectedTimestamp = getClockTimeOf(container)
- simulatorProtocol.putValue(managerDemoSetup.thingId, thingLightToggleAttributeName, Values.create(false))
+ simulatorProtocol.putValue(managerTestSetup.thingId, thingLightToggleAttributeName, Values.create(false))
then: "the attribute should be updated"
conditions.eventually {
- def thing = assetStorageService.find(managerDemoSetup.thingId, true)
+ def thing = assetStorageService.find(managerTestSetup.thingId, true)
assert !thing.getAttribute(thingLightToggleAttributeName).flatMap { it.getValueAsBoolean() }.orElse(null)
}
expect: "the datapoints to be stored"
conditions.eventually {
- def datapoints = assetDatapointService.getDatapoints(new AttributeRef(managerDemoSetup.thingId, thingLightToggleAttributeName))
+ def datapoints = assetDatapointService.getDatapoints(new AttributeRef(managerTestSetup.thingId, thingLightToggleAttributeName))
assert datapoints.size() == 3
assert !Values.getBoolean(datapoints.get(0).value).orElse(null)
@@ -178,7 +176,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
and: "the aggregated datapoints should match"
conditions.eventually {
- def thing = assetStorageService.find(managerDemoSetup.thingId, true)
+ def thing = assetStorageService.find(managerTestSetup.thingId, true)
def aggregatedDatapoints = assetDatapointService.getValueDatapoints(
thing.getAttribute(thingLightToggleAttributeName).orElseThrow({ new RuntimeException("Missing attribute")}),
DatapointInterval.MINUTE,
@@ -197,15 +195,15 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
and: "the power sensor with default max age receives a new value"
def datapoint4ExpectedTimestamp = getClockTimeOf(container)
- simulatorProtocol.putValue(managerDemoSetup.thingId, "light1PowerConsumption", Values.create(17.5d))
+ simulatorProtocol.putValue(managerTestSetup.thingId, "light1PowerConsumption", Values.create(17.5d))
and: "the toggle sensor with a custom max age of 7 days receives a new value"
- simulatorProtocol.putValue(managerDemoSetup.thingId, thingLightToggleAttributeName, Values.create(true))
+ simulatorProtocol.putValue(managerTestSetup.thingId, thingLightToggleAttributeName, Values.create(true))
then: "the datapoints should be stored"
conditions.eventually {
- def powerDatapoints = assetDatapointService.getDatapoints(new AttributeRef(managerDemoSetup.thingId, "light1PowerConsumption"))
- def toggleDatapoints = assetDatapointService.getDatapoints(new AttributeRef(managerDemoSetup.thingId, thingLightToggleAttributeName))
+ def powerDatapoints = assetDatapointService.getDatapoints(new AttributeRef(managerTestSetup.thingId, "light1PowerConsumption"))
+ def toggleDatapoints = assetDatapointService.getDatapoints(new AttributeRef(managerTestSetup.thingId, thingLightToggleAttributeName))
assert powerDatapoints.size() == 4
assert Values.getNumber(powerDatapoints.get(0).value).orElse(null) == 17.5d
@@ -224,7 +222,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
then: "data points older than purge days should be purged for the power sensor"
conditions.eventually {
- def datapoints = assetDatapointService.getDatapoints(new AttributeRef(managerDemoSetup.thingId, "light1PowerConsumption"))
+ def datapoints = assetDatapointService.getDatapoints(new AttributeRef(managerTestSetup.thingId, "light1PowerConsumption"))
assert datapoints.size() == 1
assert Values.getNumber(datapoints.get(0).value).orElse(null) == 17.5d
assert datapoints.get(0).timestamp == datapoint4ExpectedTimestamp
@@ -232,7 +230,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
and: "no data points should have been purged for the toggle sensor"
conditions.eventually {
- def datapoints = assetDatapointService.getDatapoints(new AttributeRef(managerDemoSetup.thingId, thingLightToggleAttributeName))
+ def datapoints = assetDatapointService.getDatapoints(new AttributeRef(managerTestSetup.thingId, thingLightToggleAttributeName))
assert datapoints.size() == 4
assert Values.getBoolean(datapoints.get(0).value).orElse(false)
assert datapoints.get(0).timestamp == datapoint4ExpectedTimestamp
@@ -246,13 +244,13 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
then: "all data points should be purged for power sensor"
conditions.eventually {
- def datapoints = assetDatapointService.getDatapoints(new AttributeRef(managerDemoSetup.thingId, "light1PowerConsumption"))
+ def datapoints = assetDatapointService.getDatapoints(new AttributeRef(managerTestSetup.thingId, "light1PowerConsumption"))
assert datapoints.isEmpty()
}
and: "no data points should have been purged for the toggle sensor"
conditions.eventually {
- def datapoints = assetDatapointService.getDatapoints(new AttributeRef(managerDemoSetup.thingId, thingLightToggleAttributeName))
+ def datapoints = assetDatapointService.getDatapoints(new AttributeRef(managerTestSetup.thingId, thingLightToggleAttributeName))
assert datapoints.size() == 4
assert Values.getBoolean(datapoints.get(0).value).orElse(false)
assert datapoints.get(0).timestamp == datapoint4ExpectedTimestamp
@@ -266,7 +264,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
then: "data points older than 7 days should have been purged for the toggle sensor"
conditions.eventually {
- def datapoints = assetDatapointService.getDatapoints(new AttributeRef(managerDemoSetup.thingId, thingLightToggleAttributeName))
+ def datapoints = assetDatapointService.getDatapoints(new AttributeRef(managerTestSetup.thingId, thingLightToggleAttributeName))
assert datapoints.size() == 1
assert Values.getBoolean(datapoints.get(0).value).orElse(false)
assert datapoints.get(0).timestamp == datapoint4ExpectedTimestamp
@@ -280,7 +278,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
then: "all data points should have been purged for the toggle sensor"
conditions.eventually {
- def datapoints = assetDatapointService.getDatapoints(new AttributeRef(managerDemoSetup.thingId, thingLightToggleAttributeName))
+ def datapoints = assetDatapointService.getDatapoints(new AttributeRef(managerTestSetup.thingId, thingLightToggleAttributeName))
assert datapoints.isEmpty()
}
}
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovy
index 59407910c..c5f68a903 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovy
@@ -1,8 +1,8 @@
package org.openremote.test.assets
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.KeycloakDemoSetup
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.KeycloakTestSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.asset.AssetResource
import org.openremote.model.asset.Asset
import org.openremote.model.asset.AssetAttribute
@@ -25,8 +25,8 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
def "Test asset changes as superuser"() {
given: "the server container is started"
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
- def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
+ def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
and: "an authenticated admin user"
def accessToken = authenticate(
@@ -42,13 +42,13 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
def assetResource = getClientApiTarget(serverUri, MASTER_REALM, accessToken).proxy(AssetResource.class)
when: "an asset is created in the authenticated realm"
- def testAsset = new Asset("Test Room", AssetType.ROOM, null, keycloakDemoSetup.masterTenant.realm)
+ def testAsset = new Asset("Test Room", AssetType.ROOM, null, keycloakTestSetup.masterTenant.realm)
testAsset = assetResource.create(null, testAsset)
then: "the asset should exist"
testAsset.name == "Test Room"
testAsset.wellKnownType == AssetType.ROOM
- testAsset.realm == keycloakDemoSetup.masterTenant.realm
+ testAsset.realm == keycloakTestSetup.masterTenant.realm
testAsset.parentId == null
when: "an asset is stored with an illegal attribute name"
@@ -130,7 +130,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
when: "an asset is updated with a parent in a different realm"
testAsset = assetResource.get(null, testAsset.getId())
- testAsset.setParentId(managerDemoSetup.smartBuildingId)
+ testAsset.setParentId(managerTestSetup.smartBuildingId)
assetResource.update(null, testAsset.id, testAsset)
then: "the request should be bad"
@@ -138,7 +138,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
ex.response.status == 400
when: "an asset is deleted but has children"
- assetResource.delete(null, [managerDemoSetup.apartment1Id])
+ assetResource.delete(null, [managerTestSetup.apartment1Id])
then: "the request should be bad"
ex = thrown()
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy
index 02d394a5f..8b90fc546 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy
@@ -1,8 +1,8 @@
package org.openremote.test.assets
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.KeycloakDemoSetup
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.KeycloakTestSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.Constants
import org.openremote.model.asset.AssetResource
import org.openremote.model.asset.Asset
@@ -36,8 +36,8 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
def "Access assets as superuser"() {
given: "the server container is started"
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
- def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
+ def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
def conditions = new PollingConditions(delay: 0.2, timeout: 5)
and: "an authenticated admin user"
@@ -63,13 +63,13 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
when: "the root assets of the authenticated realm are retrieved"
assets = assetResource.queryAssets(null,
new AssetQuery()
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
.parents(new ParentPredicate(true))
)
then: "result should match"
assets.length == 1
- assets[0].id == managerDemoSetup.smartOfficeId
+ assets[0].id == managerTestSetup.smartOfficeId
when: "the child assets of an asset in the authenticated realm are retrieved"
assets = assetResource.queryAssets(null,
@@ -79,29 +79,29 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
then: "result should match"
assets.length == 1
- assets[0].id == managerDemoSetup.groundFloorId
+ assets[0].id == managerTestSetup.groundFloorId
when: "the root assets of the authenticated realm are retrieved"
assets = assetResource.queryAssets(null,
new AssetQuery()
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
.parents(new ParentPredicate(true))
)
then: "result should match"
assets.length == 1
- assets[0].id == managerDemoSetup.smartOfficeId
+ assets[0].id == managerTestSetup.smartOfficeId
when: "the root assets of the given realm are retrieved"
assets = assetResource.queryAssets(null,
new AssetQuery()
- .tenant(new TenantPredicate(keycloakDemoSetup.tenantBuilding.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.tenantBuilding.realm))
.parents(new ParentPredicate(true))
)
then: "result should match"
assets.length == 1
- assets[0].id == managerDemoSetup.smartBuildingId
+ assets[0].id == managerTestSetup.smartBuildingId
when: "the child assets of an asset in a foreign realm are retrieved"
assets = assetResource.queryAssets(null,
@@ -112,33 +112,33 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
then: "result should match"
assets.length == 3
// Should be ordered by creation time
- assets[0].id == managerDemoSetup.apartment1Id
- assets[1].id == managerDemoSetup.apartment2Id
- assets[2].id == managerDemoSetup.apartment3Id
+ assets[0].id == managerTestSetup.apartment1Id
+ assets[1].id == managerTestSetup.apartment2Id
+ assets[2].id == managerTestSetup.apartment3Id
when: "an asset is retrieved by ID in the authenticated realm"
- def demoThing = assetResource.get(null, managerDemoSetup.thingId)
+ def demoThing = assetResource.get(null, managerTestSetup.thingId)
then: "result should match"
- demoThing.id == managerDemoSetup.thingId
+ demoThing.id == managerTestSetup.thingId
when: "an asset is retrieved by ID in a foreign realm"
- def demoSmartBuilding = assetResource.get(null, managerDemoSetup.smartBuildingId)
+ def demoSmartBuilding = assetResource.get(null, managerTestSetup.smartBuildingId)
then: "result should match"
- demoSmartBuilding.id == managerDemoSetup.smartBuildingId
+ demoSmartBuilding.id == managerTestSetup.smartBuildingId
/* ############################################## WRITE ####################################### */
when: "an asset is created in the authenticated realm"
- def testAsset = new Asset("Test Room", AssetType.ROOM, null, keycloakDemoSetup.masterTenant.realm)
+ def testAsset = new Asset("Test Room", AssetType.ROOM, null, keycloakTestSetup.masterTenant.realm)
testAsset = assetResource.create(null, testAsset)
testAsset = assetResource.get(null, testAsset.getId())
then: "the asset should exist"
testAsset.name == "Test Room"
testAsset.wellKnownType == AssetType.ROOM
- testAsset.realm == keycloakDemoSetup.masterTenant.realm
+ testAsset.realm == keycloakTestSetup.masterTenant.realm
testAsset.parentId == null
when: "an asset is made public"
@@ -150,12 +150,12 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
testAsset.accessPublicRead
when: "an asset is updated with a new parent in the authenticated realm"
- testAsset.setParentId(managerDemoSetup.groundFloorId)
+ testAsset.setParentId(managerTestSetup.groundFloorId)
assetResource.update(null, testAsset.id, testAsset)
testAsset = assetResource.get(null, testAsset.getId())
then: "the asset should be updated"
- testAsset.parentId == managerDemoSetup.groundFloorId
+ testAsset.parentId == managerTestSetup.groundFloorId
when: "an asset is made a root asset"
testAsset.setParentId(null)
@@ -166,28 +166,28 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
testAsset.parentId == null
when: "an asset is deleted in the authenticated realm"
- assetResource.delete(null, [managerDemoSetup.thingId])
- assetResource.get(null, managerDemoSetup.thingId)
+ assetResource.delete(null, [managerTestSetup.thingId])
+ assetResource.get(null, managerTestSetup.thingId)
then: "the asset should not be found"
WebApplicationException ex = thrown()
ex.response.status == 404
when: "an asset is deleted in a foreign realm"
- assetResource.delete(null, [managerDemoSetup.apartment2LivingroomId])
- assetResource.get(null, managerDemoSetup.apartment2LivingroomId)
+ assetResource.delete(null, [managerTestSetup.apartment2LivingroomId])
+ assetResource.get(null, managerTestSetup.apartment2LivingroomId)
then: "the asset should be not found"
ex = thrown()
ex.response.status == 404
when: "an asset attribute is written in the authenticated realm"
- assetResource.writeAttributeValue(null, managerDemoSetup.smartOfficeId, AttributeType.GEO_STREET.attributeName, Values.create("Teststreet 123").toJson())
+ assetResource.writeAttributeValue(null, managerTestSetup.smartOfficeId, AttributeType.GEO_STREET.attributeName, Values.create("Teststreet 123").toJson())
then: "result should match"
def asset
conditions.eventually {
- asset = assetResource.get(null, managerDemoSetup.smartOfficeId)
+ asset = assetResource.get(null, managerTestSetup.smartOfficeId)
assert asset.getAttribute(AttributeType.GEO_STREET).get().getValue().isPresent()
assert asset.getAttribute(AttributeType.GEO_STREET).get().getValue().get().toJson() == Values.create("Teststreet 123").toJson()
}
@@ -200,18 +200,18 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
ex.response.status == 404
when: "an non-existent attribute is written in the authenticated realm"
- assetResource.writeAttributeValue(null, managerDemoSetup.smartOfficeId, "doesnotexist", Values.create("Teststreet 123").toJson())
+ assetResource.writeAttributeValue(null, managerTestSetup.smartOfficeId, "doesnotexist", Values.create("Teststreet 123").toJson())
then: "the attribute should be not found"
ex = thrown()
ex.response.status == 404
when: "an asset attribute is written in a foreign realm"
- assetResource.writeAttributeValue(null, managerDemoSetup.smartBuildingId, AttributeType.GEO_STREET.attributeName, Values.create("Teststreet 456").toJson())
+ assetResource.writeAttributeValue(null, managerTestSetup.smartBuildingId, AttributeType.GEO_STREET.attributeName, Values.create("Teststreet 456").toJson())
then: "result should match"
conditions.eventually {
- asset = assetResource.get(null, managerDemoSetup.smartBuildingId)
+ asset = assetResource.get(null, managerTestSetup.smartBuildingId)
assert asset.getAttribute(AttributeType.GEO_STREET).get().getValue().isPresent()
assert asset.getAttribute(AttributeType.GEO_STREET).get().getValue().get().toJson() == Values.create("Teststreet 456").toJson()
}
@@ -221,8 +221,8 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
given: "the server container is started"
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
- def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
+ def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
def conditions = new PollingConditions(delay: 0.2, timeout: 10)
and: "an authenticated test user"
@@ -244,7 +244,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
then: "result should match"
assets.length == 1
- assets[0].id == managerDemoSetup.smartOfficeId
+ assets[0].id == managerTestSetup.smartOfficeId
// Assets should not be completely loaded
assets[0].path == null
assets[0].attributesList.size() == 0
@@ -252,13 +252,13 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
when: "the root assets of the authenticated realm are retrieved"
assets = assetResource.queryAssets(null,
new AssetQuery()
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
.parents(new ParentPredicate(true))
)
then: "result should match"
assets.length == 1
- assets[0].id == managerDemoSetup.smartOfficeId
+ assets[0].id == managerTestSetup.smartOfficeId
when: "the child assets of an asset in the authenticated realm are retrieved"
assets = assetResource.queryAssets(null,
@@ -268,7 +268,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
then: "result should match"
assets.length == 1
- assets[0].id == managerDemoSetup.groundFloorId
+ assets[0].id == managerTestSetup.groundFloorId
when: "the root assets of the authenticated realm are retrieved"
assets = assetResource.queryAssets(null,
@@ -278,13 +278,13 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
then: "result should match"
assets.length == 1
- assets[0].id == managerDemoSetup.smartOfficeId
- assets[0].realm == keycloakDemoSetup.masterTenant.realm
+ assets[0].id == managerTestSetup.smartOfficeId
+ assets[0].realm == keycloakTestSetup.masterTenant.realm
when: "the root assets of the given realm are retrieved"
assets = assetResource.queryAssets(null,
new AssetQuery()
- .tenant(new TenantPredicate(keycloakDemoSetup.tenantBuilding.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.tenantBuilding.realm))
.parents(new ParentPredicate(true))
)
@@ -294,20 +294,20 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
when: "the child assets of an asset in a foreign realm are retrieved"
assets = assetResource.queryAssets(null,
new AssetQuery()
- .parents(new ParentPredicate(managerDemoSetup.smartBuildingId))
+ .parents(new ParentPredicate(managerTestSetup.smartBuildingId))
)
then: "result should be empty"
assets.length == 0
when: "an asset is retrieved by ID in the authenticated realm"
- def demoThing = assetResource.get(null, managerDemoSetup.thingId)
+ def demoThing = assetResource.get(null, managerTestSetup.thingId)
then: "result should match"
- demoThing.id == managerDemoSetup.thingId
+ demoThing.id == managerTestSetup.thingId
when: "an asset is retrieved by ID in a foreign realm"
- assetResource.get(null, managerDemoSetup.smartBuildingId)
+ assetResource.get(null, managerTestSetup.smartBuildingId)
then: "access should be forbidden"
WebApplicationException ex = thrown()
@@ -323,19 +323,19 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
then: "the asset should exist"
testAsset.name == "Test Room"
testAsset.wellKnownType == AssetType.ROOM
- testAsset.realm == keycloakDemoSetup.masterTenant.realm
+ testAsset.realm == keycloakTestSetup.masterTenant.realm
testAsset.parentId == null
when: "an asset is updated with a new parent in the authenticated realm"
- testAsset.setParentId(managerDemoSetup.groundFloorId)
+ testAsset.setParentId(managerTestSetup.groundFloorId)
assetResource.update(null, testAsset.id, testAsset)
testAsset = assetResource.get(null, testAsset.getId())
then: "the asset should be updated"
- testAsset.parentId == managerDemoSetup.groundFloorId
+ testAsset.parentId == managerTestSetup.groundFloorId
when: "an asset is moved to a foreign realm and made a root asset"
- testAsset.setRealm(keycloakDemoSetup.tenantBuilding.realm)
+ testAsset.setRealm(keycloakTestSetup.tenantBuilding.realm)
testAsset.setParentId(null)
assetResource.update(null, testAsset.id, testAsset)
@@ -344,7 +344,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
ex.response.status == 403
when: "an asset is updated with a new parent in a foreign realm"
- testAsset.setParentId(managerDemoSetup.smartBuildingId)
+ testAsset.setParentId(managerTestSetup.smartBuildingId)
assetResource.update(null, testAsset.id, testAsset)
then: "access should be forbidden"
@@ -352,32 +352,32 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
ex.response.status == 403
when: "an asset is deleted in the authenticated realm"
- assetResource.delete(null, [managerDemoSetup.thingId])
- assetResource.get(null, managerDemoSetup.thingId)
+ assetResource.delete(null, [managerTestSetup.thingId])
+ assetResource.get(null, managerTestSetup.thingId)
then: "the asset should not be found"
ex = thrown()
ex.response.status == 404
when: "an asset is deleted in a foreign realm"
- assetResource.delete(null, [managerDemoSetup.apartment2LivingroomId])
+ assetResource.delete(null, [managerTestSetup.apartment2LivingroomId])
then: "access should be forbidden"
ex = thrown()
ex.response.status == 403
when: "an asset attribute is written in the authenticated realm"
- assetResource.writeAttributeValue(null, managerDemoSetup.smartOfficeId, AttributeType.GEO_STREET.attributeName, Values.create("Teststreet 123").toJson())
+ assetResource.writeAttributeValue(null, managerTestSetup.smartOfficeId, AttributeType.GEO_STREET.attributeName, Values.create("Teststreet 123").toJson())
then: "result should match"
conditions.eventually {
- def asset = assetResource.get(null, managerDemoSetup.smartOfficeId)
+ def asset = assetResource.get(null, managerTestSetup.smartOfficeId)
assert asset.getAttribute(AttributeType.GEO_STREET).get().getValue().isPresent()
assert asset.getAttribute(AttributeType.GEO_STREET).get().getValue().get().toJson() == Values.create("Teststreet 123").toJson()
}
when: "an asset attribute is written in a foreign realm"
- assetResource.writeAttributeValue(null, managerDemoSetup.smartBuildingId, AttributeType.GEO_STREET.attributeName, Values.create("Teststreet 456").toJson())
+ assetResource.writeAttributeValue(null, managerTestSetup.smartBuildingId, AttributeType.GEO_STREET.attributeName, Values.create("Teststreet 456").toJson())
then: "access should be forbidden"
ex = thrown()
@@ -387,20 +387,20 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
def "Access assets as testuser2"() {
given: "the server container is started"
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
- def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
+ def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
and: "an authenticated test user"
def accessToken = authenticate(
container,
- keycloakDemoSetup.tenantBuilding.realm,
+ keycloakTestSetup.tenantBuilding.realm,
KEYCLOAK_CLIENT_ID,
"testuser2",
"testuser2"
).token
and: "the asset resource"
- def assetResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm, accessToken).proxy(AssetResource.class)
+ def assetResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.tenantBuilding.realm, accessToken).proxy(AssetResource.class)
/* ############################################## READ ####################################### */
@@ -409,7 +409,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
then: "result should match"
assets.length == 1
- assets[0].id == managerDemoSetup.smartBuildingId
+ assets[0].id == managerTestSetup.smartBuildingId
// Assets should not be completely loaded
assets[0].path == null
assets[0].attributesList.size() == 0
@@ -417,7 +417,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
when: "the root assets of a foreign realm are retrieved"
assets = assetResource.queryAssets(null,
new AssetQuery()
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
.parents(new ParentPredicate(true))
)
@@ -432,13 +432,13 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
then: "result should match"
assets.length == 1
- assets[0].id == managerDemoSetup.smartBuildingId
- assets[0].realm == keycloakDemoSetup.tenantBuilding.realm
+ assets[0].id == managerTestSetup.smartBuildingId
+ assets[0].realm == keycloakTestSetup.tenantBuilding.realm
when: "the root assets of the given realm are retrieved"
assets = assetResource.queryAssets(null,
new AssetQuery()
- .tenant(new TenantPredicate(keycloakDemoSetup.tenantCity.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.tenantCity.realm))
.parents(new ParentPredicate(true))
)
@@ -448,20 +448,20 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
when: "the child assets of an asset in a foreign realm are retrieved"
assets = assetResource.queryAssets(null,
new AssetQuery()
- .parents(new ParentPredicate(managerDemoSetup.thingId))
+ .parents(new ParentPredicate(managerTestSetup.thingId))
)
then: "result should be empty"
assets.length == 0
when: "an asset is retrieved by ID in the authenticated realm"
- def demoSmartBuilding = assetResource.get(null, managerDemoSetup.smartBuildingId)
+ def demoSmartBuilding = assetResource.get(null, managerTestSetup.smartBuildingId)
then: "result should match"
- demoSmartBuilding.id == managerDemoSetup.smartBuildingId
+ demoSmartBuilding.id == managerTestSetup.smartBuildingId
when: "an asset is retrieved by ID in a foreign realm"
- assetResource.get(null, managerDemoSetup.thingId)
+ assetResource.get(null, managerTestSetup.thingId)
then: "access should be forbidden"
WebApplicationException ex = thrown()
@@ -470,7 +470,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
/* ############################################## WRITE ####################################### */
when: "an asset is created in a foreign realm"
- def testAsset = new Asset("Test Room", AssetType.ROOM, null, keycloakDemoSetup.masterTenant.realm)
+ def testAsset = new Asset("Test Room", AssetType.ROOM, null, keycloakTestSetup.masterTenant.realm)
assetResource.create(null, testAsset)
then: "access should be forbidden"
@@ -478,7 +478,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
ex.response.status == 403
when: "an asset is made a root asset in the authenticated realm"
- testAsset = assetResource.get(null, managerDemoSetup.apartment1Id)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1Id)
testAsset.setParentId(null)
assetResource.update(null, testAsset.id, testAsset)
@@ -487,7 +487,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
ex.response.status == 403
when: "an asset is created in the authenticated realm"
- testAsset = new Asset("Test Room", AssetType.ROOM, null, keycloakDemoSetup.tenantBuilding.realm)
+ testAsset = new Asset("Test Room", AssetType.ROOM, null, keycloakTestSetup.tenantBuilding.realm)
assetResource.create(null, testAsset)
then: "access should be forbidden"
@@ -495,28 +495,28 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
ex.response.status == 403
when: "an asset is deleted in the authenticated realm"
- assetResource.delete(null, [managerDemoSetup.apartment2LivingroomId])
+ assetResource.delete(null, [managerTestSetup.apartment2LivingroomId])
then: "access should be forbidden"
ex = thrown()
ex.response.status == 403
when: "an asset is deleted in a foreign realm"
- assetResource.delete(null, [managerDemoSetup.thingId])
+ assetResource.delete(null, [managerTestSetup.thingId])
then: "access should be forbidden"
ex = thrown()
ex.response.status == 403
when: "an asset attribute is written in the authenticated realm"
- assetResource.writeAttributeValue(null, managerDemoSetup.smartBuildingId, AttributeType.GEO_STREET.attributeName, Values.create("Teststreet 123").toJson())
+ assetResource.writeAttributeValue(null, managerTestSetup.smartBuildingId, AttributeType.GEO_STREET.attributeName, Values.create("Teststreet 123").toJson())
then: "access should be forbidden"
ex = thrown()
ex.response.status == 403
when: "an asset attribute is written in a foreign realm"
- assetResource.writeAttributeValue(null, managerDemoSetup.smartOfficeId, AttributeType.GEO_STREET.attributeName, Values.create("Teststreet 456").toJson())
+ assetResource.writeAttributeValue(null, managerTestSetup.smartOfficeId, AttributeType.GEO_STREET.attributeName, Values.create("Teststreet 456").toJson())
then: "access should be forbidden"
ex = thrown()
@@ -526,21 +526,21 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
def "Access assets as testuser3"() {
given: "the server container is started"
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
- def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
+ def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
def conditions = new PollingConditions(delay: 0.2, timeout: 5)
and: "an authenticated test user"
def accessToken = authenticate(
container,
- keycloakDemoSetup.tenantBuilding.realm,
+ keycloakTestSetup.tenantBuilding.realm,
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
).token
and: "the asset resource"
- def assetResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm, accessToken).proxy(AssetResource.class)
+ def assetResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.tenantBuilding.realm, accessToken).proxy(AssetResource.class)
/* ############################################## READ ####################################### */
@@ -550,39 +550,39 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
then: "result should match"
assets.length == 6
Asset apartment1 = assets[0]
- apartment1.id == managerDemoSetup.apartment1Id
+ apartment1.id == managerTestSetup.apartment1Id
apartment1.name == "Apartment 1"
apartment1.createdOn.getTime() < System.currentTimeMillis()
- apartment1.realm == keycloakDemoSetup.tenantBuilding.realm
+ apartment1.realm == keycloakTestSetup.tenantBuilding.realm
apartment1.type == AssetType.RESIDENCE.type
- apartment1.parentId == managerDemoSetup.smartBuildingId
+ apartment1.parentId == managerTestSetup.smartBuildingId
apartment1.path == null
apartment1.attributesList.size() == 0
Asset apartment1Livingroom = assets[1]
- apartment1Livingroom.id == managerDemoSetup.apartment1LivingroomId
+ apartment1Livingroom.id == managerTestSetup.apartment1LivingroomId
apartment1Livingroom.name == "Living Room 1"
Asset apartment1Kitchen = assets[2]
- apartment1Kitchen.id == managerDemoSetup.apartment1KitchenId
+ apartment1Kitchen.id == managerTestSetup.apartment1KitchenId
apartment1Kitchen.name == "Kitchen 1"
Asset apartment1Hallway = assets[3]
- apartment1Hallway.id == managerDemoSetup.apartment1HallwayId
+ apartment1Hallway.id == managerTestSetup.apartment1HallwayId
apartment1Hallway.name == "Hallway 1"
Asset apartment1Bedroom1 = assets[4]
- apartment1Bedroom1.id == managerDemoSetup.apartment1Bedroom1Id
+ apartment1Bedroom1.id == managerTestSetup.apartment1Bedroom1Id
apartment1Bedroom1.name == "Bedroom 1"
Asset apartment1Bathroom = assets[5]
- apartment1Bathroom.id == managerDemoSetup.apartment1BathroomId
+ apartment1Bathroom.id == managerTestSetup.apartment1BathroomId
apartment1Bathroom.name == "Bathroom 1"
when: "the root assets of a foreign realm are retrieved"
assets = assetResource.queryAssets(null,
new AssetQuery()
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
.parents(new ParentPredicate(true))
)
@@ -601,7 +601,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
when: "the root assets of the given realm are retrieved"
assets = assetResource.queryAssets(null,
new AssetQuery()
- .tenant(new TenantPredicate(keycloakDemoSetup.tenantCity.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.tenantCity.realm))
.parents(new ParentPredicate(true))
)
@@ -611,7 +611,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
when: "the child assets of linked asset are retrieved"
assets = assetResource.queryAssets(null,
new AssetQuery()
- .parents(new ParentPredicate(managerDemoSetup.apartment1Id))
+ .parents(new ParentPredicate(managerTestSetup.apartment1Id))
)
then: "result should match"
@@ -620,7 +620,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
when: "the child assets of an asset in the authenticated realm are retrieved"
assets = assetResource.queryAssets(null,
new AssetQuery()
- .parents(new ParentPredicate(managerDemoSetup.smartBuildingId))
+ .parents(new ParentPredicate(managerTestSetup.smartBuildingId))
)
then: "result should match"
@@ -629,24 +629,24 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
when: "the child assets of an asset in a foreign realm are retrieved"
assets = assetResource.queryAssets(null,
new AssetQuery()
- .parents(new ParentPredicate(managerDemoSetup.thingId))
+ .parents(new ParentPredicate(managerTestSetup.thingId))
)
then: "result should be empty"
assets.length == 0
when: "an asset is retrieved by ID in the authenticated realm"
- assetResource.get(null, managerDemoSetup.smartBuildingId)
+ assetResource.get(null, managerTestSetup.smartBuildingId)
then: "access should be forbidden"
WebApplicationException ex = thrown()
ex.response.status == 403
when: "a user asset is retrieved by ID in the authenticated realm"
- apartment1Livingroom = assetResource.get(null, managerDemoSetup.apartment1LivingroomId)
+ apartment1Livingroom = assetResource.get(null, managerTestSetup.apartment1LivingroomId)
then: "the restricted asset details should be available"
- apartment1Livingroom.id == managerDemoSetup.apartment1LivingroomId
+ apartment1Livingroom.id == managerTestSetup.apartment1LivingroomId
apartment1Livingroom.name == "Living Room 1"
def resultAttributes = apartment1Livingroom.getAttributesList()
resultAttributes.size() == 7
@@ -664,7 +664,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
resultMeta.stream().filter(isMetaNameEqualTo(UNIT_TYPE)).findFirst().get().getValueAsString().get() == Constants.UNITS_TEMPERATURE_CELSIUS
when: "an asset is retrieved by ID in a foreign realm"
- assetResource.get(null, managerDemoSetup.thingId)
+ assetResource.get(null, managerTestSetup.thingId)
then: "access should be forbidden"
ex = thrown()
@@ -673,7 +673,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
/* ############################################## WRITE ####################################### */
when: "an asset is created in a foreign realm"
- def testAsset = new Asset("Test Room", AssetType.ROOM, null, keycloakDemoSetup.masterTenant.realm)
+ def testAsset = new Asset("Test Room", AssetType.ROOM, null, keycloakTestSetup.masterTenant.realm)
assetResource.create(null, testAsset)
then: "access should be forbidden"
@@ -681,43 +681,43 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
ex.response.status == 403
when: "an asset is made a root asset in the authenticated realm"
- testAsset = assetResource.get(null, managerDemoSetup.apartment1LivingroomId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1LivingroomId)
testAsset.setParentId(null)
assetResource.update(null, testAsset.id, testAsset)
- testAsset = assetResource.get(null, managerDemoSetup.apartment1LivingroomId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1LivingroomId)
then: "the update should be ignored"
- assert testAsset.getParentId() == managerDemoSetup.apartment1Id
+ assert testAsset.getParentId() == managerTestSetup.apartment1Id
when: "an asset is moved to a new parent in the authenticated realm"
- testAsset = assetResource.get(null, managerDemoSetup.apartment1LivingroomId)
- testAsset.setParentId(managerDemoSetup.apartment2Id)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1LivingroomId)
+ testAsset.setParentId(managerTestSetup.apartment2Id)
assetResource.update(null, testAsset.id, testAsset)
- testAsset = assetResource.get(null, managerDemoSetup.apartment1LivingroomId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1LivingroomId)
then: "the update should be ignored"
- assert testAsset.getParentId() == managerDemoSetup.apartment1Id
+ assert testAsset.getParentId() == managerTestSetup.apartment1Id
when: "an asset is made public"
- testAsset = assetResource.get(null, managerDemoSetup.apartment1LivingroomId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1LivingroomId)
testAsset.setAccessPublicRead(true)
assetResource.update(null, testAsset.id, testAsset)
- testAsset = assetResource.get(null, managerDemoSetup.apartment1LivingroomId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1LivingroomId)
then: "the update should be ignored"
assert !testAsset.isAccessPublicRead()
when: "an asset is renamed"
- testAsset = assetResource.get(null, managerDemoSetup.apartment1LivingroomId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1LivingroomId)
testAsset.setName("Ignored")
assetResource.update(null, testAsset.id, testAsset)
- testAsset = assetResource.get(null, managerDemoSetup.apartment1LivingroomId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1LivingroomId)
then: "the update should be ignored"
assert testAsset.getName() == "Living Room 1"
when: "an asset is created in the authenticated realm"
- testAsset = new Asset("Test Room", AssetType.ROOM, null, keycloakDemoSetup.tenantBuilding.realm)
+ testAsset = new Asset("Test Room", AssetType.ROOM, null, keycloakTestSetup.tenantBuilding.realm)
assetResource.create(null, testAsset)
then: "access should be forbidden"
@@ -725,28 +725,28 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
ex.response.status == 403
when: "an asset is deleted in the authenticated realm"
- assetResource.delete(null, [managerDemoSetup.apartment1LivingroomId])
+ assetResource.delete(null, [managerTestSetup.apartment1LivingroomId])
then: "access should be forbidden"
ex = thrown()
ex.response.status == 403
when: "an asset is deleted in a foreign realm"
- assetResource.delete(null, [managerDemoSetup.thingId])
+ assetResource.delete(null, [managerTestSetup.thingId])
then: "access should be forbidden"
ex = thrown()
ex.response.status == 403
when: "a private asset attribute is written on a user asset"
- assetResource.writeAttributeValue(null, managerDemoSetup.apartment1LivingroomId, "lightSwitch", Values.create(false).toJson())
+ assetResource.writeAttributeValue(null, managerTestSetup.apartment1LivingroomId, "lightSwitch", Values.create(false).toJson())
then: "the attribute should be not found"
ex = thrown()
ex.response.status == 404
when: "a restricted read-only asset attribute is written on a user asset"
- assetResource.writeAttributeValue(null, managerDemoSetup.apartment1LivingroomId, "currentTemperature", Values.create(22.123d).toJson())
+ assetResource.writeAttributeValue(null, managerTestSetup.apartment1LivingroomId, "currentTemperature", Values.create(22.123d).toJson())
then: "the request should be forbidden"
ex = thrown()
@@ -760,53 +760,53 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
ex.response.status == 404
when: "an non-existent attribute is written on a user asset"
- assetResource.writeAttributeValue(null, managerDemoSetup.apartment1LivingroomId, "doesnotexist", Values.create("foo").toJson())
+ assetResource.writeAttributeValue(null, managerTestSetup.apartment1LivingroomId, "doesnotexist", Values.create("foo").toJson())
then: "the attribute should be not found"
ex = thrown()
ex.response.status == 404
when: "an asset attribute is written on a non-user asset"
- assetResource.writeAttributeValue(null, managerDemoSetup.apartment3LivingroomId, "lightSwitch", Values.create(false).toJson())
+ assetResource.writeAttributeValue(null, managerTestSetup.apartment3LivingroomId, "lightSwitch", Values.create(false).toJson())
then: "access should be forbidden"
ex = thrown()
ex.response.status == 403
when: "an asset attribute is written in a foreign realm"
- assetResource.writeAttributeValue(null, managerDemoSetup.smartOfficeId, AttributeType.GEO_STREET.attributeName, Values.create("Teststreet 123").toJson())
+ assetResource.writeAttributeValue(null, managerTestSetup.smartOfficeId, AttributeType.GEO_STREET.attributeName, Values.create("Teststreet 123").toJson())
then: "access should be forbidden"
ex = thrown()
ex.response.status == 403
when: "a non-writable attribute value is written on a user asset"
- assetResource.writeAttributeValue(null, managerDemoSetup.apartment1KitchenId, "presenceDetected", Values.create(true).toJson())
+ assetResource.writeAttributeValue(null, managerTestSetup.apartment1KitchenId, "presenceDetected", Values.create(true).toJson())
then: "access should be forbidden"
ex = thrown()
ex.response.status == 403
when: "a non-writable attribute value is updated on a user asset"
- testAsset = assetResource.get(null, managerDemoSetup.apartment1KitchenId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1KitchenId)
testAsset.getAttribute("presenceDetected").get().setValue(Values.create(true))
assetResource.update(null, testAsset.id, testAsset)
- testAsset = assetResource.get(null, managerDemoSetup.apartment1KitchenId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1KitchenId)
then: "the update should be ignored"
assert !testAsset.getAttribute("presenceDetected").get().getValue().isPresent()
when: "a non-writable attribute is updated on a user asset"
- testAsset = assetResource.get(null, managerDemoSetup.apartment1KitchenId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1KitchenId)
testAsset.replaceAttribute(new AssetAttribute("presenceDetected", BOOLEAN, Values.create(true)))
assetResource.update(null, testAsset.id, testAsset)
- testAsset = assetResource.get(null, managerDemoSetup.apartment1KitchenId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1KitchenId)
then: "the update should be ignored"
assert !testAsset.getAttribute("presenceDetected").get().getValue().isPresent()
when: "a non-writable attribute's meta item value is updated"
- testAsset = assetResource.get(null, managerDemoSetup.apartment1KitchenId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1KitchenId)
testAsset.getAttribute("presenceDetected").orElse(null).getMetaItem(STORE_DATA_POINTS).orElse(null).setValue(Values.create(false))
assetResource.update(null, testAsset.id, testAsset)
@@ -814,61 +814,61 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
assert testAsset.getAttribute("presenceDetected").get().getMetaItem(STORE_DATA_POINTS).get().getValue().get()
when: "a non-writable attribute's meta item value is added"
- testAsset = assetResource.get(null, managerDemoSetup.apartment1KitchenId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1KitchenId)
testAsset.getAttribute("presenceDetected").orElse(null).addMeta(new MetaItem(ABOUT, Values.create("Ignored")))
assetResource.update(null, testAsset.id, testAsset)
- testAsset = assetResource.get(null, managerDemoSetup.apartment1KitchenId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1KitchenId)
then: "the update should be ignored"
assert !testAsset.getAttribute("presenceDetected").get().getMetaItem(ABOUT).isPresent()
when: "a new attribute is added on a user asset"
- testAsset = assetResource.get(null, managerDemoSetup.apartment1KitchenId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1KitchenId)
testAsset.addAttributes(new AssetAttribute("myCustomAttribute", NUMBER, Values.create(123)))
assetResource.update(null, testAsset.id, testAsset)
- testAsset = assetResource.get(null, managerDemoSetup.apartment1KitchenId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1KitchenId)
then: "result should match"
assert testAsset.getAttribute("myCustomAttribute").get().getValue().get() == Values.create(123)
when: "a writable attribute value is written on a user asset"
- assetResource.writeAttributeValue(null, managerDemoSetup.apartment1KitchenId, "myCustomAttribute", Values.create(456).toJson())
+ assetResource.writeAttributeValue(null, managerTestSetup.apartment1KitchenId, "myCustomAttribute", Values.create(456).toJson())
then: "result should match"
conditions.eventually {
- testAsset = assetResource.get(null, managerDemoSetup.apartment1KitchenId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1KitchenId)
assert testAsset.getAttribute("myCustomAttribute").get().getValue().get() == Values.create(456)
}
when: "a writable attribute has a non-writable meta item"
- testAsset = assetResource.get(null, managerDemoSetup.apartment1KitchenId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1KitchenId)
testAsset.getAttribute("myCustomAttribute").get().addMeta(new MetaItem(PROTOCOL_CONFIGURATION, Values.create("Ignored")))
- testAsset = assetResource.get(null, managerDemoSetup.apartment1KitchenId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1KitchenId)
assetResource.update(null, testAsset.id, testAsset)
then: "the update should be ignored"
assert !testAsset.getAttribute("presenceDetected").get().getMetaItem(PROTOCOL_CONFIGURATION).isPresent()
when: "a writable attribute has a writable meta item"
- testAsset = assetResource.get(null, managerDemoSetup.apartment1KitchenId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1KitchenId)
testAsset.getAttribute("myCustomAttribute").get().addMeta(new MetaItem(LABEL, Values.create("My label")))
assetResource.update(null, testAsset.id, testAsset)
- testAsset = assetResource.get(null, managerDemoSetup.apartment1KitchenId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1KitchenId)
then: "the result should match"
assert testAsset.getAttribute("myCustomAttribute").get().getMetaItem(LABEL).get().getValue().get() == Values.create("My label")
when: "a writable attribute has a writable meta item value update"
- testAsset = assetResource.get(null, managerDemoSetup.apartment1KitchenId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1KitchenId)
testAsset.getAttribute("myCustomAttribute").get().getMetaItem(LABEL).get().setValue(Values.create("My label update"))
assetResource.update(null, testAsset.id, testAsset)
- testAsset = assetResource.get(null, managerDemoSetup.apartment1KitchenId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1KitchenId)
then: "the result should match"
assert testAsset.getAttribute("myCustomAttribute").get().getMetaItem(LABEL).get().getValue().get() == Values.create("My label update")
when: "a writable attribute replaces a writable meta item with several new items"
- testAsset = assetResource.get(null, managerDemoSetup.apartment1KitchenId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1KitchenId)
testAsset.getAttribute("myCustomAttribute").get().getMeta().removeIf(isMetaNameEqualTo(LABEL))
testAsset.getAttribute("myCustomAttribute").get().addMeta(
new MetaItem(LABEL, Values.create("Label1")),
@@ -876,7 +876,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
new MetaItem(LABEL, Values.create("Label3")),
)
assetResource.update(null, testAsset.id, testAsset)
- testAsset = assetResource.get(null, managerDemoSetup.apartment1KitchenId)
+ testAsset = assetResource.get(null, managerTestSetup.apartment1KitchenId)
then: "the result should match"
assert testAsset.getAttribute("myCustomAttribute").get().getMetaItems(LABEL.getUrn()).length == 3
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy
index d7bb06758..ae022a52d 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy
@@ -6,8 +6,8 @@ import org.openremote.manager.asset.*
import org.openremote.manager.datapoint.AssetDatapointService
import org.openremote.manager.rules.RulesService
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.KeycloakDemoSetup
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.KeycloakTestSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.asset.Asset
import org.openremote.model.asset.AssetAttribute
import org.openremote.model.asset.AssetType
@@ -147,8 +147,8 @@ class AssetProcessingTest extends Specification implements ManagerContainerTrait
def container = startContainer(defaultConfig(), defaultServices(mockProtocol))
def assetStorageService = container.getService(AssetStorageService.class)
def assetProcessingService = container.getService(AssetProcessingService.class)
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
- def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
+ def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
then: "the container should be running and initialised"
conditions.eventually {
@@ -169,7 +169,7 @@ class AssetProcessingTest extends Specification implements ManagerContainerTrait
mockAgent.setAttributes(
ProtocolConfiguration.initProtocolConfiguration(new AssetAttribute("mock123"), mockProtocolName)
)
- mockAgent.setRealm(keycloakDemoSetup.masterTenant.realm)
+ mockAgent.setRealm(keycloakTestSetup.masterTenant.realm)
mockAgent = assetStorageService.merge(mockAgent)
and: "a mock thing asset is created with a valid protocol attribute, an invalid protocol attribute and a plain attribute"
@@ -194,7 +194,7 @@ class AssetProcessingTest extends Specification implements ManagerContainerTrait
),
new MetaItem(
MetaItemType.AGENT_LINK,
- new AttributeRef("INVALID AGENT ID", managerDemoSetup.agentProtocolConfigName).toArrayValue()
+ new AttributeRef("INVALID AGENT ID", managerTestSetup.agentProtocolConfigName).toArrayValue()
)
),
new AssetAttribute("plainAttribute", AttributeValueType.STRING, Values.create("demo"))
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetPublicQueryTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetPublicQueryTest.groovy
index ea7559c92..06b089597 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetPublicQueryTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetPublicQueryTest.groovy
@@ -1,11 +1,11 @@
package org.openremote.test.assets
-import org.openremote.container.Container
+
import org.openremote.container.persistence.PersistenceService
import org.openremote.manager.asset.AssetStorageService
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.KeycloakDemoSetup
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.KeycloakTestSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.asset.Asset
import org.openremote.model.asset.AssetAttribute
import org.openremote.model.asset.AssetResource
@@ -17,18 +17,17 @@ import spock.lang.Shared
import spock.lang.Specification
import static org.openremote.model.Constants.MASTER_REALM
-import static org.openremote.model.attribute.MetaItemType.ACCESS_PUBLIC_READ
-import static org.openremote.model.attribute.MetaItemType.LABEL
import static org.openremote.model.asset.AssetType.THING
import static org.openremote.model.attribute.AttributeValueType.NUMBER
-import static org.openremote.model.query.AssetQuery.Select
+import static org.openremote.model.attribute.MetaItemType.ACCESS_PUBLIC_READ
+import static org.openremote.model.attribute.MetaItemType.LABEL
class AssetPublicQueryTest extends Specification implements ManagerContainerTrait {
@Shared
- static ManagerDemoSetup managerDemoSetup
+ static ManagerTestSetup managerTestSetup
@Shared
- static KeycloakDemoSetup keycloakDemoSetup
+ static KeycloakTestSetup keycloakTestSetup
@Shared
static AssetStorageService assetStorageService
@Shared
@@ -41,8 +40,8 @@ class AssetPublicQueryTest extends Specification implements ManagerContainerTrai
def setupSpec() {
given: "the server container is started"
def container = startContainer(defaultConfig(), defaultServices())
- managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
- keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
+ managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
+ keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
assetStorageService = container.getService(AssetStorageService.class)
persistenceService = container.getService(PersistenceService.class)
assetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM).proxy(AssetResource.class)
@@ -51,7 +50,7 @@ class AssetPublicQueryTest extends Specification implements ManagerContainerTrai
for (int i = 0; i < 10; i++) {
Asset somePublicAsset = new Asset("Some Public Asset", THING)
- somePublicAsset.setParentId(managerDemoSetup.smartOfficeId)
+ somePublicAsset.setParentId(managerTestSetup.smartOfficeId)
somePublicAsset.setAccessPublicRead(true)
somePublicAsset.setAttributes(
new AssetAttribute("somePrivateAttribute", NUMBER, Values.create(123)).addMeta(
@@ -83,8 +82,8 @@ class AssetPublicQueryTest extends Specification implements ManagerContainerTrai
assets[0].id == returnedAssets.get(0).id
assets[0].name == "Some Public Asset"
assets[0].wellKnownType == THING
- assets[0].parentId == managerDemoSetup.smartOfficeId
- assets[0].realm == keycloakDemoSetup.masterTenant.realm
+ assets[0].parentId == managerTestSetup.smartOfficeId
+ assets[0].realm == keycloakTestSetup.masterTenant.realm
!assets[0].getAttribute("somePrivateAttribute").isPresent()
assets[0].getAttribute("somePublicAttribute").get().getValue().get() == Values.create(456)
assets[0].getAttribute("somePublicAttribute").get().getMeta().size() == 1
@@ -100,8 +99,8 @@ class AssetPublicQueryTest extends Specification implements ManagerContainerTrai
assets[0].id == returnedAssets.get(0).id
assets[0].name == "Some Public Asset"
assets[0].wellKnownType == THING
- assets[0].parentId == managerDemoSetup.smartOfficeId
- assets[0].realm == keycloakDemoSetup.masterTenant.realm
+ assets[0].parentId == managerTestSetup.smartOfficeId
+ assets[0].realm == keycloakTestSetup.masterTenant.realm
!assets[0].getAttribute("somePrivateAttribute").isPresent()
assets[0].getAttribute("somePublicAttribute").get().getValue().get() == Values.create(456)
assets[0].getAttribute("somePublicAttribute").get().getMeta().size() == 1
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy
index 95c566c82..6cd3c1dbd 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy
@@ -5,8 +5,8 @@ import org.openremote.container.persistence.PersistenceService
import org.openremote.manager.asset.AssetProcessingService
import org.openremote.manager.asset.AssetStorageService
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.KeycloakDemoSetup
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.KeycloakTestSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.asset.Asset
import org.openremote.model.asset.AssetAttribute
import org.openremote.model.asset.AssetType
@@ -45,9 +45,9 @@ import static org.openremote.model.query.AssetQuery.Select.selectExcludePathAndA
class AssetQueryTest extends Specification implements ManagerContainerTrait {
@Shared
- static ManagerDemoSetup managerDemoSetup
+ static ManagerTestSetup managerTestSetup
@Shared
- static KeycloakDemoSetup keycloakDemoSetup
+ static KeycloakTestSetup keycloakTestSetup
@Shared
static AssetStorageService assetStorageService
@Shared
@@ -58,8 +58,8 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
def setupSpec() {
given: "the server container is started"
def container = startContainer(defaultConfig(), defaultServices())
- managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
- keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
+ managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
+ keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
assetStorageService = container.getService(AssetStorageService.class)
assetProcessingService = container.getService(AssetProcessingService.class)
persistenceService = container.getService(PersistenceService.class)
@@ -72,41 +72,41 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new AssetQuery()
.select(Select.selectExcludePathAndParentInfo())
.types(AssetType.AGENT)
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
)
then: "agent assets should be retrieved"
assets.size() == 1
- assets[0].id == managerDemoSetup.agentId
+ assets[0].id == managerTestSetup.agentId
assets[0].name == "Demo Agent"
assets[0].type == AssetType.AGENT.getType()
- assets[0].parentId == managerDemoSetup.lobbyId
+ assets[0].parentId == managerTestSetup.lobbyId
assets[0].parentName == null
assets[0].parentType == null
- assets[0].realm == managerDemoSetup.masterRealm
+ assets[0].realm == managerTestSetup.masterRealm
assets[0].path == null
when: "a user filtering query is executed that returns only IDs, names and attribute names and label meta"
assets = assetStorageService.findAll(
new AssetQuery()
.select(Select.selectExcludeAll().excludeAttributes(false).excludeAttributeMeta(false).meta(MetaItemType.LABEL))
- .userIds(keycloakDemoSetup.testuser3Id)
+ .userIds(keycloakTestSetup.testuser3Id)
)
then: "only the users assets should be retrieved"
assets.size() == 6
- assets.get(0).id == managerDemoSetup.apartment1Id
- assets.get(1).id == managerDemoSetup.apartment1LivingroomId
+ assets.get(0).id == managerTestSetup.apartment1Id
+ assets.get(1).id == managerTestSetup.apartment1LivingroomId
assets.get(1).getAttributesList().size() == 11
assets.get(1).getAttribute("motionSensor").isPresent()
!assets.get(1).getAttribute("currentTemperature").get().getValue().isPresent()
assets.get(1).getAttribute("currentTemperature").get().meta.size() == 1
!assets.get(1).getAttribute("targetTemperature").get().getValue().isPresent()
assets.get(1).getAttribute("targetTemperature").get().meta.size() == 1
- assets.get(2).id == managerDemoSetup.apartment1KitchenId
- assets.get(3).id == managerDemoSetup.apartment1HallwayId
- assets.get(4).id == managerDemoSetup.apartment1Bedroom1Id
- assets.get(5).id == managerDemoSetup.apartment1BathroomId
+ assets.get(2).id == managerTestSetup.apartment1KitchenId
+ assets.get(3).id == managerTestSetup.apartment1HallwayId
+ assets.get(4).id == managerTestSetup.apartment1Bedroom1Id
+ assets.get(5).id == managerTestSetup.apartment1BathroomId
when: "a user filtering query is executed that returns only IDs, names and attribute names with labels and limits to protected attributes"
assets = assetStorageService.findAll(
@@ -115,14 +115,14 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.excludeAttributes(false)
.excludeAttributeMeta(false)
.meta(MetaItemType.LABEL))
- .userIds(keycloakDemoSetup.testuser3Id)
+ .userIds(keycloakTestSetup.testuser3Id)
.access(PROTECTED)
)
then: "only the users assets should be retrieved"
assets.size() == 6
- assets.get(0).id == managerDemoSetup.apartment1Id
- assets.get(1).id == managerDemoSetup.apartment1LivingroomId
+ assets.get(0).id == managerTestSetup.apartment1Id
+ assets.get(1).id == managerTestSetup.apartment1LivingroomId
assets.get(1).getAttributesList().size() == 7
!assets.get(1).getAttribute("motionSensor").isPresent()
!assets.get(1).getAttribute("currentTemperature").get().getValue().isPresent()
@@ -131,22 +131,22 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
assets[1].getAttribute("currentTemperature").get().getLabelOrName().get() == "Current temperature"
!assets.get(1).getAttribute("targetTemperature").get().getValue().isPresent()
assets.get(1).getAttribute("targetTemperature").get().meta.size() == 1
- assets.get(2).id == managerDemoSetup.apartment1KitchenId
- assets.get(3).id == managerDemoSetup.apartment1HallwayId
- assets.get(4).id == managerDemoSetup.apartment1Bedroom1Id
- assets.get(5).id == managerDemoSetup.apartment1BathroomId
+ assets.get(2).id == managerTestSetup.apartment1KitchenId
+ assets.get(3).id == managerTestSetup.apartment1HallwayId
+ assets.get(4).id == managerTestSetup.apartment1Bedroom1Id
+ assets.get(5).id == managerTestSetup.apartment1BathroomId
when: "a query is executed that returns a protected attribute without any other meta items"
assets = assetStorageService.findAll(
new AssetQuery()
.select(new Select().excludePath(true))
- .ids(managerDemoSetup.apartment2LivingroomId)
+ .ids(managerTestSetup.apartment2LivingroomId)
.access(PROTECTED)
)
then: "only one asset should be retrieved"
assets.size() == 1
- assets.get(0).id == managerDemoSetup.apartment2LivingroomId
+ assets.get(0).id == managerTestSetup.apartment2LivingroomId
assets.get(0).getAttributesList().size() == 1
assets.get(0).getAttribute("windowOpen").isPresent()
!assets.get(0).getAttribute("windowOpen").get().getValueAsBoolean().get()
@@ -155,7 +155,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
when: "a recursive query is executed to select asset id, name and attribute names for apartment 1 assets"
assets = assetStorageService.findAll(
new AssetQuery()
- .ids(managerDemoSetup.smartBuildingId)
+ .ids(managerTestSetup.smartBuildingId)
.select(Select.selectExcludeAll().excludeAttributes(false))
.orderBy(new OrderBy(CREATED_ON))
.recursive(true)
@@ -164,15 +164,15 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
then: "result should contain only basic info and attribute names"
assets.size() == 13
- assets.find {it.id == managerDemoSetup.smartBuildingId}.name == "Smart Building"
- def apartment1 = assets.find {it.id == managerDemoSetup.apartment1Id}
+ assets.find {it.id == managerTestSetup.smartBuildingId}.name == "Smart Building"
+ def apartment1 = assets.find {it.id == managerTestSetup.apartment1Id}
apartment1.name == "Apartment 1"
apartment1.type == AssetType.RESIDENCE.getType()
apartment1.createdOn != null
- apartment1.parentId == managerDemoSetup.smartBuildingId
+ apartment1.parentId == managerTestSetup.smartBuildingId
apartment1.parentName == null
apartment1.parentType == null
- apartment1.realm == managerDemoSetup.realmBuildingTenant
+ apartment1.realm == managerTestSetup.realmBuildingTenant
apartment1.path == null
apartment1.getAttributesList().size() == 7
apartment1.getAttribute("ventilationAuto").isPresent()
@@ -183,76 +183,76 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
apartment1.getAttribute("presenceDetected").isPresent()
apartment1.getAttribute("location").isPresent()
apartment1.getAttribute("alarmEnabled").get().meta.size() == 0
- assets.find {it.id == managerDemoSetup.apartment1ServiceAgentId} != null
- assets.find {it.id == managerDemoSetup.apartment1LivingroomId} != null
- assets.find {it.id == managerDemoSetup.apartment1KitchenId} != null
- assets.find {it.id == managerDemoSetup.apartment1HallwayId} != null
- assets.find {it.id == managerDemoSetup.apartment1Bedroom1Id} != null
- assets.find {it.id == managerDemoSetup.apartment1BathroomId} != null
- assets.find {it.id == managerDemoSetup.apartment2Id} != null
- assets.find {it.id == managerDemoSetup.apartment2LivingroomId} != null
- assets.find {it.id == managerDemoSetup.apartment2BathroomId} != null
- assets.find {it.id == managerDemoSetup.apartment3Id} != null
- assets.find {it.id == managerDemoSetup.apartment3LivingroomId} != null
+ assets.find {it.id == managerTestSetup.apartment1ServiceAgentId} != null
+ assets.find {it.id == managerTestSetup.apartment1LivingroomId} != null
+ assets.find {it.id == managerTestSetup.apartment1KitchenId} != null
+ assets.find {it.id == managerTestSetup.apartment1HallwayId} != null
+ assets.find {it.id == managerTestSetup.apartment1Bedroom1Id} != null
+ assets.find {it.id == managerTestSetup.apartment1BathroomId} != null
+ assets.find {it.id == managerTestSetup.apartment2Id} != null
+ assets.find {it.id == managerTestSetup.apartment2LivingroomId} != null
+ assets.find {it.id == managerTestSetup.apartment2BathroomId} != null
+ assets.find {it.id == managerTestSetup.apartment3Id} != null
+ assets.find {it.id == managerTestSetup.apartment3LivingroomId} != null
when: "an asset is loaded by identifier through JPA"
def asset = persistenceService.doReturningTransaction(new Function<EntityManager, Asset>() {
@Override
Asset apply(EntityManager em) {
- em.find(Asset.class, managerDemoSetup.apartment1Id)
+ em.find(Asset.class, managerTestSetup.apartment1Id)
}
})
then: "result should match (and some values should be empty because we need an AssetQuery to get them)"
- asset.id == managerDemoSetup.apartment1Id
+ asset.id == managerTestSetup.apartment1Id
asset.createdOn.time < System.currentTimeMillis()
asset.name == "Apartment 1"
asset.wellKnownType == AssetType.RESIDENCE
- asset.parentId == managerDemoSetup.smartBuildingId
+ asset.parentId == managerTestSetup.smartBuildingId
asset.parentName == null
asset.parentType == null
- asset.realm == keycloakDemoSetup.tenantBuilding.realm
+ asset.realm == keycloakTestSetup.tenantBuilding.realm
asset.path.length == 2
- asset.path[0] == managerDemoSetup.apartment1Id
- asset.path[1] == managerDemoSetup.smartBuildingId
+ asset.path[0] == managerTestSetup.apartment1Id
+ asset.path[1] == managerTestSetup.smartBuildingId
asset.attributesList.size() > 0
when: "a query is executed"
asset = assetStorageService.find(
new AssetQuery()
.select(selectExcludePathAndAttributes())
- .ids(managerDemoSetup.smartOfficeId)
+ .ids(managerTestSetup.smartOfficeId)
)
then: "result should match"
- asset.id == managerDemoSetup.smartOfficeId
+ asset.id == managerTestSetup.smartOfficeId
asset.createdOn.time < System.currentTimeMillis()
asset.name == "Smart Office"
asset.wellKnownType == AssetType.BUILDING
asset.parentId == null
asset.parentName == null
asset.parentType == null
- asset.realm == keycloakDemoSetup.masterTenant.realm
+ asset.realm == keycloakTestSetup.masterTenant.realm
asset.path == null
asset.attributesList.size() == 0
when: "a query is executed"
asset = assetStorageService.find(
new AssetQuery()
- .ids(managerDemoSetup.smartOfficeId)
+ .ids(managerTestSetup.smartOfficeId)
)
then: "result should match"
- asset.id == managerDemoSetup.smartOfficeId
+ asset.id == managerTestSetup.smartOfficeId
asset.createdOn.time < System.currentTimeMillis()
asset.name == "Smart Office"
asset.wellKnownType == AssetType.BUILDING
asset.parentId == null
asset.parentName == null
asset.parentType == null
- asset.realm == keycloakDemoSetup.masterTenant.realm
+ asset.realm == keycloakTestSetup.masterTenant.realm
asset.path.length == 1
- asset.path[0] == managerDemoSetup.smartOfficeId
+ asset.path[0] == managerTestSetup.smartOfficeId
asset.getAttribute(AttributeType.GEO_STREET).get().getValueAsString().get() == "Torenallee 20"
when: "a query is executed"
@@ -260,19 +260,19 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new AssetQuery()
.select(selectExcludePathAndAttributes())
.parents(new ParentPredicate(true))
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
)
then: "result should match"
assets.size() == 1
- assets.get(0).id == managerDemoSetup.smartOfficeId
+ assets.get(0).id == managerTestSetup.smartOfficeId
assets.get(0).createdOn.time < System.currentTimeMillis()
assets.get(0).name == "Smart Office"
assets.get(0).wellKnownType == AssetType.BUILDING
assets.get(0).parentId == null
assets.get(0).parentName == null
assets.get(0).parentType == null
- assets.get(0).realm == keycloakDemoSetup.masterTenant.realm
+ assets.get(0).realm == keycloakTestSetup.masterTenant.realm
assets.get(0).path == null
assets.get(0).attributesList.size() == 0
@@ -280,80 +280,80 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
assets = assetStorageService.findAll(
new AssetQuery()
.parents(new ParentPredicate(true))
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
)
then: "result should match"
assets.size() == 1
- assets.get(0).id == managerDemoSetup.smartOfficeId
+ assets.get(0).id == managerTestSetup.smartOfficeId
assets.get(0).createdOn.time < System.currentTimeMillis()
assets.get(0).name == "Smart Office"
assets.get(0).wellKnownType == AssetType.BUILDING
assets.get(0).parentId == null
assets.get(0).parentName == null
assets.get(0).parentType == null
- assets.get(0).realm == keycloakDemoSetup.masterTenant.realm
+ assets.get(0).realm == keycloakTestSetup.masterTenant.realm
assets.get(0).path.length == 1
- assets.get(0).path[0] == managerDemoSetup.smartOfficeId
+ assets.get(0).path[0] == managerTestSetup.smartOfficeId
assets.get(0).getAttribute(AttributeType.GEO_STREET).get().getValueAsString().get() == "Torenallee 20"
when: "a query is executed"
assets = assetStorageService.findAll(
new AssetQuery()
.select(selectExcludePathAndAttributes())
- .parents(new ParentPredicate(managerDemoSetup.smartBuildingId))
+ .parents(new ParentPredicate(managerTestSetup.smartBuildingId))
)
then: "result should match"
assets.size() == 3
- assets.get(0).id == managerDemoSetup.apartment1Id
+ assets.get(0).id == managerTestSetup.apartment1Id
assets.get(0).createdOn.time < System.currentTimeMillis()
assets.get(0).name == "Apartment 1"
assets.get(0).wellKnownType == AssetType.RESIDENCE
- assets.get(0).parentId == managerDemoSetup.smartBuildingId
+ assets.get(0).parentId == managerTestSetup.smartBuildingId
assets.get(0).parentName == "Smart Building"
assets.get(0).parentType == AssetType.BUILDING.type
- assets.get(0).realm == keycloakDemoSetup.tenantBuilding.realm
+ assets.get(0).realm == keycloakTestSetup.tenantBuilding.realm
assets.get(0).path == null
assets.get(0).attributesList.size() == 0
- assets.get(1).id == managerDemoSetup.apartment2Id
- assets.get(2).id == managerDemoSetup.apartment3Id
+ assets.get(1).id == managerTestSetup.apartment2Id
+ assets.get(2).id == managerTestSetup.apartment3Id
when: "a query is executed"
assets = assetStorageService.findAll(
new AssetQuery()
.select(selectExcludePathAndAttributes())
- .parents(new ParentPredicate(managerDemoSetup.smartBuildingId))
- .tenant(new TenantPredicate(keycloakDemoSetup.tenantBuilding.realm))
+ .parents(new ParentPredicate(managerTestSetup.smartBuildingId))
+ .tenant(new TenantPredicate(keycloakTestSetup.tenantBuilding.realm))
)
then: "result should match"
assets.size() == 3
- assets.get(0).id == managerDemoSetup.apartment1Id
- assets.get(1).id == managerDemoSetup.apartment2Id
- assets.get(2).id == managerDemoSetup.apartment3Id
+ assets.get(0).id == managerTestSetup.apartment1Id
+ assets.get(1).id == managerTestSetup.apartment2Id
+ assets.get(2).id == managerTestSetup.apartment3Id
when: "a query is executed"
assets = assetStorageService.findAll(
new AssetQuery()
.select(selectExcludePathAndAttributes())
- .parents(new ParentPredicate(managerDemoSetup.smartBuildingId))
- .tenant(new TenantPredicate(keycloakDemoSetup.tenantBuilding.realm))
+ .parents(new ParentPredicate(managerTestSetup.smartBuildingId))
+ .tenant(new TenantPredicate(keycloakTestSetup.tenantBuilding.realm))
.orderBy(new OrderBy(NAME, true))
)
then: "result should match"
assets.size() == 3
- assets.get(0).id == managerDemoSetup.apartment3Id
- assets.get(1).id == managerDemoSetup.apartment2Id
- assets.get(2).id == managerDemoSetup.apartment1Id
+ assets.get(0).id == managerTestSetup.apartment3Id
+ assets.get(1).id == managerTestSetup.apartment2Id
+ assets.get(2).id == managerTestSetup.apartment1Id
when: "a query is executed"
assets = assetStorageService.findAll(
new AssetQuery()
.select(selectExcludePathAndAttributes())
- .parents(new ParentPredicate(managerDemoSetup.smartBuildingId))
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .parents(new ParentPredicate(managerTestSetup.smartBuildingId))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
)
then: "result should match"
@@ -363,61 +363,61 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
assets = assetStorageService.findAll(
new AssetQuery()
.select(selectExcludePathAndAttributes())
- .paths(new PathPredicate(assetStorageService.find(managerDemoSetup.apartment1Id, true).getPath()))
+ .paths(new PathPredicate(assetStorageService.find(managerTestSetup.apartment1Id, true).getPath()))
)
then: "result should match"
assets.size() == 7
- assets.find {it.id == managerDemoSetup.apartment1Id} != null
- assets.find {it.id == managerDemoSetup.apartment1ServiceAgentId} != null
- assets.find {it.id == managerDemoSetup.apartment1LivingroomId} != null
- assets.find {it.id == managerDemoSetup.apartment1KitchenId} != null
- assets.find {it.id == managerDemoSetup.apartment1HallwayId} != null
- assets.find {it.id == managerDemoSetup.apartment1Bedroom1Id} != null
- assets.find {it.id == managerDemoSetup.apartment1BathroomId} != null
+ assets.find {it.id == managerTestSetup.apartment1Id} != null
+ assets.find {it.id == managerTestSetup.apartment1ServiceAgentId} != null
+ assets.find {it.id == managerTestSetup.apartment1LivingroomId} != null
+ assets.find {it.id == managerTestSetup.apartment1KitchenId} != null
+ assets.find {it.id == managerTestSetup.apartment1HallwayId} != null
+ assets.find {it.id == managerTestSetup.apartment1Bedroom1Id} != null
+ assets.find {it.id == managerTestSetup.apartment1BathroomId} != null
when: "a query is executed"
assets = assetStorageService.findAll(
new AssetQuery()
.select(selectExcludePathAndAttributes())
- .paths(new PathPredicate(assetStorageService.find(managerDemoSetup.apartment1Id, true).getPath()))
+ .paths(new PathPredicate(assetStorageService.find(managerTestSetup.apartment1Id, true).getPath()))
.types(AssetType.ROOM)
)
then: "result should match"
assets.size() == 5
- assets.find {it.id == managerDemoSetup.apartment1LivingroomId} != null
- assets.find {it.id == managerDemoSetup.apartment1KitchenId} != null
- assets.find {it.id == managerDemoSetup.apartment1HallwayId} != null
- assets.find {it.id == managerDemoSetup.apartment1Bedroom1Id} != null
- assets.find {it.id == managerDemoSetup.apartment1BathroomId} != null
+ assets.find {it.id == managerTestSetup.apartment1LivingroomId} != null
+ assets.find {it.id == managerTestSetup.apartment1KitchenId} != null
+ assets.find {it.id == managerTestSetup.apartment1HallwayId} != null
+ assets.find {it.id == managerTestSetup.apartment1Bedroom1Id} != null
+ assets.find {it.id == managerTestSetup.apartment1BathroomId} != null
when: "a query is executed"
assets = assetStorageService.findAll(
new AssetQuery()
- .userIds(keycloakDemoSetup.testuser3Id)
+ .userIds(keycloakTestSetup.testuser3Id)
.access(PROTECTED)
)
then: "result should match"
assets.size() == 6
- assets.find {it.id == managerDemoSetup.apartment1Id} != null
- def livingroom = assets.find {it.id == managerDemoSetup.apartment1LivingroomId}
+ assets.find {it.id == managerTestSetup.apartment1Id} != null
+ def livingroom = assets.find {it.id == managerTestSetup.apartment1LivingroomId}
livingroom != null
livingroom.getAttributesList().size() == 7
!livingroom.getAttribute("currentTemperature").get().getValue().isPresent()
livingroom.getAttribute("currentTemperature").get().meta.size() == 7
!livingroom.getAttribute("targetTemperature").get().getValue().isPresent()
livingroom.getAttribute("targetTemperature").get().meta.size() == 6
- assets.find {it.id == managerDemoSetup.apartment1KitchenId} != null
- assets.find {it.id == managerDemoSetup.apartment1HallwayId} != null
- assets.find {it.id == managerDemoSetup.apartment1Bedroom1Id} != null
- assets.find {it.id == managerDemoSetup.apartment1BathroomId} != null
+ assets.find {it.id == managerTestSetup.apartment1KitchenId} != null
+ assets.find {it.id == managerTestSetup.apartment1HallwayId} != null
+ assets.find {it.id == managerTestSetup.apartment1Bedroom1Id} != null
+ assets.find {it.id == managerTestSetup.apartment1BathroomId} != null
when: "a query is executed"
assets = assetStorageService.findAll(
new AssetQuery()
- .userIds(keycloakDemoSetup.testuser2Id)
+ .userIds(keycloakTestSetup.testuser2Id)
.access(PROTECTED)
)
@@ -425,15 +425,15 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
assets.size() == 0
expect: "a result to match the executed query "
- assetStorageService.isUserAsset(keycloakDemoSetup.testuser3Id, managerDemoSetup.apartment1Id)
- assetStorageService.isUserAsset(keycloakDemoSetup.testuser3Id, managerDemoSetup.apartment1LivingroomId)
- assetStorageService.isUserAsset(keycloakDemoSetup.testuser3Id, managerDemoSetup.apartment1HallwayId)
- assetStorageService.isUserAsset(keycloakDemoSetup.testuser3Id, managerDemoSetup.apartment1KitchenId)
- assetStorageService.isUserAsset(keycloakDemoSetup.testuser3Id, managerDemoSetup.apartment1Bedroom1Id)
- assetStorageService.isUserAsset(keycloakDemoSetup.testuser3Id, managerDemoSetup.apartment1BathroomId)
- !assetStorageService.isUserAsset(keycloakDemoSetup.testuser3Id, managerDemoSetup.apartment2Id)
- !assetStorageService.isUserAsset(keycloakDemoSetup.testuser3Id, managerDemoSetup.apartment3Id)
- !assetStorageService.isUserAsset(keycloakDemoSetup.testuser3Id, managerDemoSetup.smartOfficeId)
+ assetStorageService.isUserAsset(keycloakTestSetup.testuser3Id, managerTestSetup.apartment1Id)
+ assetStorageService.isUserAsset(keycloakTestSetup.testuser3Id, managerTestSetup.apartment1LivingroomId)
+ assetStorageService.isUserAsset(keycloakTestSetup.testuser3Id, managerTestSetup.apartment1HallwayId)
+ assetStorageService.isUserAsset(keycloakTestSetup.testuser3Id, managerTestSetup.apartment1KitchenId)
+ assetStorageService.isUserAsset(keycloakTestSetup.testuser3Id, managerTestSetup.apartment1Bedroom1Id)
+ assetStorageService.isUserAsset(keycloakTestSetup.testuser3Id, managerTestSetup.apartment1BathroomId)
+ !assetStorageService.isUserAsset(keycloakTestSetup.testuser3Id, managerTestSetup.apartment2Id)
+ !assetStorageService.isUserAsset(keycloakTestSetup.testuser3Id, managerTestSetup.apartment3Id)
+ !assetStorageService.isUserAsset(keycloakTestSetup.testuser3Id, managerTestSetup.smartOfficeId)
}
// Specs too large, split up features
@@ -448,21 +448,21 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
then: "result should match"
assets.size() == 3
- assets.find {it.id == managerDemoSetup.agentId} != null
- assets.find {it.id == managerDemoSetup.apartment1ServiceAgentId} != null
- assets.find {it.id == managerDemoSetup.smartCityServiceAgentId} != null
+ assets.find {it.id == managerTestSetup.agentId} != null
+ assets.find {it.id == managerTestSetup.apartment1ServiceAgentId} != null
+ assets.find {it.id == managerTestSetup.smartCityServiceAgentId} != null
when: "a query is executed"
assets = assetStorageService.findAll(
new AssetQuery()
.select(selectExcludePathAndAttributes())
.types(THING)
- .parents(new ParentPredicate(managerDemoSetup.agentId))
+ .parents(new ParentPredicate(managerTestSetup.agentId))
)
then: "result should match"
assets.size() == 1
- assets.get(0).id == managerDemoSetup.thingId
+ assets.get(0).id == managerTestSetup.thingId
when: "a query is executed"
assets = assetStorageService.findAll(
@@ -474,20 +474,20 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
then: "result should match"
assets.size() == 1
- assets.get(0).id == managerDemoSetup.thingId
+ assets.get(0).id == managerTestSetup.thingId
when: "a query is executed"
assets = assetStorageService.findAll(
new AssetQuery()
.select(selectExcludePathAndAttributes())
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
.attributeMeta(new MetaPredicate(MetaItemType.STORE_DATA_POINTS, new BooleanPredicate(true)))
)
then: "result should match"
assets.size() == 1
- assets.get(0).id == managerDemoSetup.thingId
+ assets.get(0).id == managerTestSetup.thingId
when: "a query is executed"
assets = assetStorageService.findAll(
@@ -498,7 +498,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
then: "result should match"
assets.size() == 1
- assets.get(0).id == managerDemoSetup.thingId
+ assets.get(0).id == managerTestSetup.thingId
when: "a query is executed"
assets = assetStorageService.findAll(
@@ -507,15 +507,15 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.attributeMeta(
new RefPredicate(
MetaItemType.AGENT_LINK,
- managerDemoSetup.agentId,
- managerDemoSetup.agentProtocolConfigName
+ managerTestSetup.agentId,
+ managerTestSetup.agentProtocolConfigName
)
)
)
then: "result should match"
assets.size() == 1
- assets.get(0).id == managerDemoSetup.thingId
+ assets.get(0).id == managerTestSetup.thingId
when: "a query is executed"
assets = assetStorageService.findAll(
@@ -524,8 +524,8 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.attributeMeta(
new RefPredicate(
MetaItemType.AGENT_LINK,
- managerDemoSetup.agentId,
- managerDemoSetup.agentProtocolConfigName
+ managerTestSetup.agentId,
+ managerTestSetup.agentProtocolConfigName
)
)
.names(new StringPredicate(Match.CONTAINS, false, "thing"))
@@ -533,7 +533,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
then: "result should match"
assets.size() == 1
- assets.get(0).id == managerDemoSetup.thingId
+ assets.get(0).id == managerTestSetup.thingId
when: "a query is executed"
assets = assetStorageService.findAll(
@@ -542,8 +542,8 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.attributeMeta(
new RefPredicate(
MetaItemType.AGENT_LINK,
- managerDemoSetup.agentId,
- managerDemoSetup.agentProtocolConfigName
+ managerTestSetup.agentId,
+ managerTestSetup.agentProtocolConfigName
)
)
.names(new StringPredicate(Match.CONTAINS, true, "thing"))
@@ -559,16 +559,16 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.attributeMeta(
new RefPredicate(
MetaItemType.AGENT_LINK,
- managerDemoSetup.agentId,
- managerDemoSetup.agentProtocolConfigName
+ managerTestSetup.agentId,
+ managerTestSetup.agentProtocolConfigName
)
)
- .parents(new ParentPredicate(managerDemoSetup.agentId))
+ .parents(new ParentPredicate(managerTestSetup.agentId))
)
then: "result should match"
assets.size() == 1
- assets.get(0).id == managerDemoSetup.thingId
+ assets.get(0).id == managerTestSetup.thingId
when: "a query is executed"
assets = assetStorageService.findAll(
@@ -577,11 +577,11 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.attributeMeta(
new RefPredicate(
MetaItemType.AGENT_LINK,
- managerDemoSetup.agentId,
- managerDemoSetup.agentProtocolConfigName
+ managerTestSetup.agentId,
+ managerTestSetup.agentProtocolConfigName
)
)
- .parents(new ParentPredicate(managerDemoSetup.apartment1LivingroomId))
+ .parents(new ParentPredicate(managerTestSetup.apartment1LivingroomId))
)
then: "result should match"
@@ -593,34 +593,34 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.select(selectExcludePathAndAttributes())
.attributeMeta(
new RefPredicate(
- managerDemoSetup.agentId,
- managerDemoSetup.agentProtocolConfigName
+ managerTestSetup.agentId,
+ managerTestSetup.agentProtocolConfigName
)
)
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
)
then: "result should match"
assets.size() == 1
- assets.get(0).id == managerDemoSetup.thingId
+ assets.get(0).id == managerTestSetup.thingId
when: "a query is executed to select a subset of attributes"
def asset = assetStorageService.find(
new AssetQuery()
- .ids(managerDemoSetup.apartment1LivingroomId)
+ .ids(managerTestSetup.apartment1LivingroomId)
.select(new Select().attributes("co2Level", "lastPresenceDetected", "motionSensor"))
.access(PRIVATE)
)
then: "result should match"
- asset.id == managerDemoSetup.apartment1LivingroomId
+ asset.id == managerTestSetup.apartment1LivingroomId
asset.createdOn.time < System.currentTimeMillis()
asset.name == "Living Room 1"
asset.wellKnownType == AssetType.ROOM
asset.parentId != null
asset.parentName == "Apartment 1"
asset.parentType == AssetType.RESIDENCE.getType()
- asset.realm == keycloakDemoSetup.tenantBuilding.realm
+ asset.realm == keycloakTestSetup.tenantBuilding.realm
asset.path != null
asset.getAttributesList().size() == 3
asset.getAttribute("co2Level").isPresent()
@@ -633,20 +633,20 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
when: "a query is executed to select a subset of protected attributes"
asset = assetStorageService.find(
new AssetQuery()
- .ids(managerDemoSetup.apartment1LivingroomId)
+ .ids(managerTestSetup.apartment1LivingroomId)
.select(new Select().attributes("co2Level", "lastPresenceDetected", "motionSensor"))
.access(PROTECTED)
)
then: "result should contain only matches that are protected"
- asset.id == managerDemoSetup.apartment1LivingroomId
+ asset.id == managerTestSetup.apartment1LivingroomId
asset.createdOn.time < System.currentTimeMillis()
asset.name == "Living Room 1"
asset.wellKnownType == AssetType.ROOM
asset.parentId != null
asset.parentName == "Apartment 1"
asset.parentType == AssetType.RESIDENCE.getType()
- asset.realm == keycloakDemoSetup.tenantBuilding.realm
+ asset.realm == keycloakTestSetup.tenantBuilding.realm
asset.path != null
asset.getAttributesList().size() == 1
asset.getAttribute("co2Level").isPresent()
@@ -749,20 +749,20 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new AssetQuery()
.select(Select.selectExcludeAll())
.attributes(new LocationAttributePredicate(new RadialGeofencePredicate(10, 51.44541688237109d, 5.460315214821094d)))
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
.orderBy(new OrderBy(NAME))
)
then: "assets in the queried region should be retrieved"
assets.size() == 5
- assets.find {it.id == managerDemoSetup.agentId}.name == "Demo Agent"
- assets.find {it.id == managerDemoSetup.thingId}.name == "Demo Thing"
- assets.find {it.id == managerDemoSetup.groundFloorId}.name == "Ground Floor"
- assets.find {it.id == managerDemoSetup.lobbyId}.name == "Lobby"
- assets.find {it.id == managerDemoSetup.smartOfficeId}.name == "Smart Office"
+ assets.find {it.id == managerTestSetup.agentId}.name == "Demo Agent"
+ assets.find {it.id == managerTestSetup.thingId}.name == "Demo Thing"
+ assets.find {it.id == managerTestSetup.groundFloorId}.name == "Ground Floor"
+ assets.find {it.id == managerTestSetup.lobbyId}.name == "Lobby"
+ assets.find {it.id == managerTestSetup.smartOfficeId}.name == "Smart Office"
when: "one of the assets in the region is moved"
- def lobby = assetStorageService.find(managerDemoSetup.lobbyId, true)
+ def lobby = assetStorageService.find(managerTestSetup.lobbyId, true)
lobby.setCoordinates(new GeoJSONPoint(5.46108d, 51.44593d))
lobby = assetStorageService.merge(lobby)
@@ -776,7 +776,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new AssetQuery()
.select(Select.selectExcludeAll())
.attributes(new LocationAttributePredicate(new RadialGeofencePredicate(10, 51.44541688237109d, 5.460315214821094d)))
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
.orderBy(new OrderBy(NAME))
)
@@ -789,24 +789,24 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new AssetQuery()
.select(Select.selectExcludeAll())
.attributes(new LocationAttributePredicate(new RectangularGeofencePredicate(51.44540d, 5.46031d, 51.44594d, 5.46110d)))
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
.orderBy(new OrderBy(NAME))
)
then: "all 5 assets should be returned"
assets.size() == 5
- assets.find {it.id == managerDemoSetup.agentId}.name == "Demo Agent"
- assets.find {it.id == managerDemoSetup.thingId}.name == "Demo Thing"
- assets.find {it.id == managerDemoSetup.groundFloorId}.name == "Ground Floor"
- assets.find {it.id == managerDemoSetup.lobbyId}.name == "Lobby"
- assets.find {it.id == managerDemoSetup.smartOfficeId}.name == "Smart Office"
+ assets.find {it.id == managerTestSetup.agentId}.name == "Demo Agent"
+ assets.find {it.id == managerTestSetup.thingId}.name == "Demo Thing"
+ assets.find {it.id == managerTestSetup.groundFloorId}.name == "Ground Floor"
+ assets.find {it.id == managerTestSetup.lobbyId}.name == "Lobby"
+ assets.find {it.id == managerTestSetup.smartOfficeId}.name == "Smart Office"
when: "a rectangular region is used that doesn't cover any assets"
assets = assetStorageService.findAll(
new AssetQuery()
.select(Select.selectExcludeAll())
.attributes(new LocationAttributePredicate(new RectangularGeofencePredicate(51.44542d, 5.46032d, 51.44590d, 5.46100d)))
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
.orderBy(new OrderBy(NAME))
)
@@ -818,17 +818,17 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new AssetQuery()
.select(Select.selectExcludeAll())
.attributes(new LocationAttributePredicate(new RectangularGeofencePredicate(51.44542d, 5.46032d, 51.44590d, 5.46100d).negate()))
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
.orderBy(new OrderBy(NAME))
)
then: "all 5 realm assets should be returned"
assets.size() == 5
- assets.find {it.id == managerDemoSetup.agentId}.name == "Demo Agent"
- assets.find {it.id == managerDemoSetup.thingId}.name == "Demo Thing"
- assets.find {it.id == managerDemoSetup.groundFloorId}.name == "Ground Floor"
- assets.find {it.id == managerDemoSetup.lobbyId}.name == "Lobby"
- assets.find {it.id == managerDemoSetup.smartOfficeId}.name == "Smart Office"
+ assets.find {it.id == managerTestSetup.agentId}.name == "Demo Agent"
+ assets.find {it.id == managerTestSetup.thingId}.name == "Demo Thing"
+ assets.find {it.id == managerTestSetup.groundFloorId}.name == "Ground Floor"
+ assets.find {it.id == managerTestSetup.lobbyId}.name == "Lobby"
+ assets.find {it.id == managerTestSetup.smartOfficeId}.name == "Smart Office"
}
def "Calendar queries"() {
@@ -836,7 +836,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
def conditions = new PollingConditions(timeout: 10, delay: 0.2)
when: "an asset is given a calendar event configuration attribute"
- def lobby = assetStorageService.find(managerDemoSetup.lobbyId, true)
+ def lobby = assetStorageService.find(managerTestSetup.lobbyId, true)
def calendar = Calendar.getInstance(Locale.ROOT)
calendar.setTimeInMillis(1517151600000) // 28/01/2018 @ 3:00pm (UTC)
def start = calendar.getTime()
@@ -858,21 +858,21 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
def assets = assetStorageService.findAll(
new AssetQuery()
.select(new Select().excludePath(true).excludeAttributeMeta(true)) // Need attributes to do calendar filtering
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
.attributes(new AttributePredicate(new StringPredicate("test"), new CalendarEventPredicate(new Date(1517155200000)))) // 30/01/2018 @ 6:00pm (UTC)
.orderBy(new OrderBy(NAME))
)
then: "the lobby asset should be returned"
assets.size() == 1
- assets[0].id == managerDemoSetup.lobbyId
+ assets[0].id == managerTestSetup.lobbyId
assets[0].name == "Lobby"
when: "a calendar event filtering query is executed for future event on a correct day but wrong time"
assets = assetStorageService.findAll(
new AssetQuery()
.select(new Select().excludePath(true))
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
.attributes(new AttributePredicate(new StringPredicate("test"), new CalendarEventPredicate(new Date(1517335200000)))) // 30/01/2018 @ 6:00pm (UTC)
.orderBy(new OrderBy(NAME))
)
@@ -884,7 +884,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
assets = assetStorageService.findAll(
new AssetQuery()
.select(new Select().excludePath(true))
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
.attributes(new AttributePredicate(new StringPredicate("test"), new CalendarEventPredicate(new Date(1517238600000)))) // 29/01/2018 @ 3:10pm (UTC)
.orderBy(new OrderBy(NAME))
)
@@ -896,20 +896,20 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
assets = assetStorageService.findAll(
new AssetQuery()
.select(new Select().excludePath(true)) // Need attributes to do calendar filtering
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
.attributes(new AttributePredicate(new StringPredicate("test"), new CalendarEventPredicate(new Date(1517849400000)))) // 05/02/2018 @ 4:50pm (UTC))
.orderBy(new OrderBy(NAME))
)
then: "the lobby asset should be returned"
assets.size() == 1
- assets[0].id == managerDemoSetup.lobbyId
+ assets[0].id == managerTestSetup.lobbyId
when: "a calendar event filtering query is executed for some time after the last occurrence"
assets = assetStorageService.findAll(
new AssetQuery()
.select(new Select().excludePath(true))
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
.attributes(new AttributePredicate(new StringPredicate("test"), new CalendarEventPredicate(new Date(1518017520000)))) // 02/07/2018 @ 3:32pm (UTC)
.orderBy(new OrderBy(NAME))
)
@@ -920,7 +920,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
def "DateTime queries"() {
when: "the lobby has an opening date and the date falls is between the filtering date"
- def lobby = assetStorageService.find(managerDemoSetup.lobbyId, true)
+ def lobby = assetStorageService.find(managerTestSetup.lobbyId, true)
lobby.addAttributes(
new AssetAttribute("openingDate", TIMESTAMP_ISO8601, Values.create("2018-01-28T15:00:00+00:00"))
@@ -933,7 +933,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
def assets = assetStorageService.findAll(
new AssetQuery()
.select(selectExcludePathAndAttributes())
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
.attributeValue(
"openingDate",
new DateTimePredicate(rangeStart.format(ISO_ZONED_DATE_TIME), rangeEnd.format(ISO_ZONED_DATE_TIME))
@@ -949,7 +949,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
assets = assetStorageService.findAll(
new AssetQuery()
.select(selectExcludePathAndAttributes())
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
.attributeValue(
"openingDate",
new DateTimePredicate(Operator.GREATER_THAN, rangeStart.format(ISO_ZONED_DATE_TIME)))
@@ -964,7 +964,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
assets = assetStorageService.findAll(
new AssetQuery()
.select(selectExcludePathAndAttributes())
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
.attributeValue(
"openingDate",
new DateTimePredicate(Operator.LESS_THAN, rangeEnd.format(ISO_ZONED_DATE_TIME)))
@@ -981,7 +981,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
assets = assetStorageService.findAll(
new AssetQuery()
.select(selectExcludePathAndAttributes())
- .tenant(new TenantPredicate(keycloakDemoSetup.masterTenant.realm))
+ .tenant(new TenantPredicate(keycloakTestSetup.masterTenant.realm))
.attributeValue(
"openingDate",
new DateTimePredicate(Operator.EQUALS, rangeStart.format(ISO_ZONED_DATE_TIME)))
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetUserLinkingTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetUserLinkingTest.groovy
index 90c02f26f..8d020b58c 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetUserLinkingTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetUserLinkingTest.groovy
@@ -3,8 +3,8 @@ package org.openremote.test.assets
import org.openremote.container.timer.TimerService
import org.openremote.manager.security.ManagerIdentityService
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.KeycloakDemoSetup
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.KeycloakTestSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.asset.AssetResource
import org.openremote.model.asset.UserAsset
import org.openremote.test.ManagerContainerTrait
@@ -24,8 +24,8 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
def container = startContainer(defaultConfig(), defaultServices())
def timerService = container.getService(TimerService.class)
def identityService = container.getService(ManagerIdentityService.class)
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
- def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
+ def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
and: "an authenticated admin user"
def accessToken = authenticate(
@@ -42,114 +42,114 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
/* ############################################## READ ####################################### */
expect: "some users to be restricted"
- !identityService.getIdentityProvider().isRestrictedUser(keycloakDemoSetup.testuser1Id)
- !identityService.getIdentityProvider().isRestrictedUser(keycloakDemoSetup.testuser2Id)
- identityService.getIdentityProvider().isRestrictedUser(keycloakDemoSetup.testuser3Id)
+ !identityService.getIdentityProvider().isRestrictedUser(keycloakTestSetup.testuser1Id)
+ !identityService.getIdentityProvider().isRestrictedUser(keycloakTestSetup.testuser2Id)
+ identityService.getIdentityProvider().isRestrictedUser(keycloakTestSetup.testuser3Id)
when: "all user assets are retrieved of a realm"
- def userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantBuilding.realm, null, null)
+ def userAssets = assetResource.getUserAssetLinks(null, keycloakTestSetup.tenantBuilding.realm, null, null)
then: "result should match"
userAssets.length == 12
userAssets.any {
- it.id.realm == keycloakDemoSetup.tenantBuilding.realm &&
- it.id.userId == keycloakDemoSetup.testuser3Id &&
- it.id.assetId == managerDemoSetup.apartment1Id &&
+ it.id.realm == keycloakTestSetup.tenantBuilding.realm &&
+ it.id.userId == keycloakTestSetup.testuser3Id &&
+ it.id.assetId == managerTestSetup.apartment1Id &&
it.assetName == "Apartment 1" &&
it.parentAssetName == "Smart Building" &&
it.userFullName == "testuser3 (DemoA3 DemoLast)"
}
userAssets.any {
- it.id.realm == keycloakDemoSetup.tenantBuilding.realm &&
- it.id.userId == keycloakDemoSetup.testuser3Id &&
- it.id.assetId == managerDemoSetup.apartment1LivingroomId &&
+ it.id.realm == keycloakTestSetup.tenantBuilding.realm &&
+ it.id.userId == keycloakTestSetup.testuser3Id &&
+ it.id.assetId == managerTestSetup.apartment1LivingroomId &&
it.assetName == "Living Room 1" &&
it.parentAssetName == "Apartment 1" &&
it.userFullName == "testuser3 (DemoA3 DemoLast)"
}
userAssets.any {
- it.id.realm == keycloakDemoSetup.tenantBuilding.realm &&
- it.id.userId == keycloakDemoSetup.testuser3Id &&
- it.id.assetId == managerDemoSetup.apartment1KitchenId &&
+ it.id.realm == keycloakTestSetup.tenantBuilding.realm &&
+ it.id.userId == keycloakTestSetup.testuser3Id &&
+ it.id.assetId == managerTestSetup.apartment1KitchenId &&
it.assetName == "Kitchen 1" &&
it.parentAssetName == "Apartment 1" &&
it.userFullName == "testuser3 (DemoA3 DemoLast)"
}
userAssets.any {
- it.id.realm == keycloakDemoSetup.tenantBuilding.realm &&
- it.id.userId == keycloakDemoSetup.testuser3Id &&
- it.id.assetId == managerDemoSetup.apartment1HallwayId &&
+ it.id.realm == keycloakTestSetup.tenantBuilding.realm &&
+ it.id.userId == keycloakTestSetup.testuser3Id &&
+ it.id.assetId == managerTestSetup.apartment1HallwayId &&
it.assetName == "Hallway 1" &&
it.parentAssetName == "Apartment 1" &&
it.userFullName == "testuser3 (DemoA3 DemoLast)"
}
userAssets.any {
- it.id.realm == keycloakDemoSetup.tenantBuilding.realm &&
- it.id.userId == keycloakDemoSetup.testuser3Id &&
- it.id.assetId == managerDemoSetup.apartment1Bedroom1Id &&
+ it.id.realm == keycloakTestSetup.tenantBuilding.realm &&
+ it.id.userId == keycloakTestSetup.testuser3Id &&
+ it.id.assetId == managerTestSetup.apartment1Bedroom1Id &&
it.assetName == "Bedroom 1" &&
it.parentAssetName == "Apartment 1" &&
it.userFullName == "testuser3 (DemoA3 DemoLast)"
}
userAssets.any {
- it.id.realm == keycloakDemoSetup.tenantBuilding.realm &&
- it.id.userId == keycloakDemoSetup.testuser3Id &&
- it.id.assetId == managerDemoSetup.apartment1BathroomId &&
+ it.id.realm == keycloakTestSetup.tenantBuilding.realm &&
+ it.id.userId == keycloakTestSetup.testuser3Id &&
+ it.id.assetId == managerTestSetup.apartment1BathroomId &&
it.assetName == "Bathroom 1" &&
it.parentAssetName == "Apartment 1" &&
it.userFullName == "testuser3 (DemoA3 DemoLast)"
}
when: "all user assets are retrieved of a realm and user"
- userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantBuilding.realm, keycloakDemoSetup.testuser3Id, null)
+ userAssets = assetResource.getUserAssetLinks(null, keycloakTestSetup.tenantBuilding.realm, keycloakTestSetup.testuser3Id, null)
then: "result should match"
userAssets.length == 6
when: "the realm and user don't match"
- assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantCity.realm, keycloakDemoSetup.testuser3Id, null)
+ assetResource.getUserAssetLinks(null, keycloakTestSetup.tenantCity.realm, keycloakTestSetup.testuser3Id, null)
then: "an error response should be returned"
WebApplicationException ex = thrown()
ex.response.status == 400
when: "the realm doesn't exist"
- assetResource.getUserAssetLinks(null, "doesnotexist", keycloakDemoSetup.testuser3Id, null)
+ assetResource.getUserAssetLinks(null, "doesnotexist", keycloakTestSetup.testuser3Id, null)
then: "an error response should be returned"
ex = thrown()
ex.response.status == 404
when: "all user assets are retrieved of a realm and user"
- userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantBuilding.realm, null, managerDemoSetup.apartment1Id)
+ userAssets = assetResource.getUserAssetLinks(null, keycloakTestSetup.tenantBuilding.realm, null, managerTestSetup.apartment1Id)
then: "result should match"
userAssets.length == 2
userAssets.any {
- it.id.realm == keycloakDemoSetup.tenantBuilding.realm &&
- it.id.userId == keycloakDemoSetup.testuser3Id &&
- it.id.assetId == managerDemoSetup.apartment1Id &&
+ it.id.realm == keycloakTestSetup.tenantBuilding.realm &&
+ it.id.userId == keycloakTestSetup.testuser3Id &&
+ it.id.assetId == managerTestSetup.apartment1Id &&
it.assetName == "Apartment 1" &&
it.parentAssetName == "Smart Building" &&
it.userFullName == "testuser3 (DemoA3 DemoLast)"
}
when: "all user assets are retrieved of a realm and user and asset"
- userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantBuilding.realm, keycloakDemoSetup.testuser3Id, managerDemoSetup.apartment1Id)
+ userAssets = assetResource.getUserAssetLinks(null, keycloakTestSetup.tenantBuilding.realm, keycloakTestSetup.testuser3Id, managerTestSetup.apartment1Id)
then: "result should match"
userAssets.length == 1
userAssets.any {
- it.id.realm == keycloakDemoSetup.tenantBuilding.realm &&
- it.id.userId == keycloakDemoSetup.testuser3Id &&
- it.id.assetId == managerDemoSetup.apartment1Id &&
+ it.id.realm == keycloakTestSetup.tenantBuilding.realm &&
+ it.id.userId == keycloakTestSetup.testuser3Id &&
+ it.id.assetId == managerTestSetup.apartment1Id &&
it.assetName == "Apartment 1" &&
it.parentAssetName == "Smart Building" &&
it.userFullName == "testuser3 (DemoA3 DemoLast)"
}
when: "all user assets are retrieved of a realm and user and asset"
- userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantBuilding.realm, keycloakDemoSetup.testuser2Id, managerDemoSetup.apartment1Id)
+ userAssets = assetResource.getUserAssetLinks(null, keycloakTestSetup.tenantBuilding.realm, keycloakTestSetup.testuser2Id, managerTestSetup.apartment1Id)
then: "result should match"
userAssets.length == 0
@@ -157,16 +157,16 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
/* ############################################## WRITE ####################################### */
when: "an asset is linked to a user"
- UserAsset userAsset = new UserAsset(keycloakDemoSetup.tenantBuilding.realm, keycloakDemoSetup.testuser2Id, managerDemoSetup.apartment2Id)
+ UserAsset userAsset = new UserAsset(keycloakTestSetup.tenantBuilding.realm, keycloakTestSetup.testuser2Id, managerTestSetup.apartment2Id)
assetResource.createUserAsset(null, userAsset)
- userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantBuilding.realm, keycloakDemoSetup.testuser2Id, null)
+ userAssets = assetResource.getUserAssetLinks(null, keycloakTestSetup.tenantBuilding.realm, keycloakTestSetup.testuser2Id, null)
then: "result should match"
userAssets.length == 1
userAssets.any {
- it.id.realm == keycloakDemoSetup.tenantBuilding.realm &&
- it.id.userId == keycloakDemoSetup.testuser2Id &&
- it.id.assetId == managerDemoSetup.apartment2Id &&
+ it.id.realm == keycloakTestSetup.tenantBuilding.realm &&
+ it.id.userId == keycloakTestSetup.testuser2Id &&
+ it.id.assetId == managerTestSetup.apartment2Id &&
it.assetName == "Apartment 2" &&
it.parentAssetName == "Smart Building" &&
it.userFullName == "testuser2 (DemoA2 DemoLast)" &&
@@ -174,8 +174,8 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
}
when: "an asset link is deleted"
- assetResource.deleteUserAsset(null, keycloakDemoSetup.tenantBuilding.realm, keycloakDemoSetup.testuser2Id, managerDemoSetup.apartment2Id)
- userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantBuilding.realm, keycloakDemoSetup.testuser2Id, null)
+ assetResource.deleteUserAsset(null, keycloakTestSetup.tenantBuilding.realm, keycloakTestSetup.testuser2Id, managerTestSetup.apartment2Id)
+ userAssets = assetResource.getUserAssetLinks(null, keycloakTestSetup.tenantBuilding.realm, keycloakTestSetup.testuser2Id, null)
then: "result should match"
userAssets.length == 0
diff --git a/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy b/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy
index 07f53aff4..7076aee47 100644
--- a/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy
@@ -11,8 +11,8 @@ import org.openremote.manager.rules.RulesService
import org.openremote.manager.rules.RulesetStorageService
import org.openremote.manager.rules.geofence.ORConsoleGeofenceAssetAdapter
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.KeycloakDemoSetup
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.KeycloakTestSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.asset.Asset
import org.openremote.model.asset.AssetResource
import org.openremote.model.attribute.AttributeRef
@@ -40,8 +40,8 @@ import javax.ws.rs.WebApplicationException
import java.util.concurrent.TimeUnit
import java.util.stream.IntStream
-import static org.openremote.manager.setup.builtin.ManagerDemoSetup.DEMO_RULE_STATES_SMART_BUILDING
-import static org.openremote.manager.setup.builtin.ManagerDemoSetup.SMART_BUILDING_LOCATION
+import static org.openremote.manager.setup.builtin.ManagerTestSetup.DEMO_RULE_STATES_SMART_BUILDING
+import static org.openremote.manager.setup.builtin.ManagerTestSetup.SMART_BUILDING_LOCATION
import static org.openremote.model.Constants.KEYCLOAK_CLIENT_ID
import static org.openremote.model.asset.AssetResource.Util.WRITE_ATTRIBUTE_HTTP_METHOD
import static org.openremote.model.asset.AssetResource.Util.getWriteAttributeUrl
@@ -67,8 +67,8 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
def pushNotificationHandler = container.getService(PushNotificationHandler.class)
def notificationService = container.getService(NotificationService.class)
def assetStorageService = container.getService(AssetStorageService.class)
- def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def rulesService = container.getService(RulesService.class)
def rulesetStorageService = container.getService(RulesetStorageService.class)
@@ -96,7 +96,7 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
and: "the demo location predicate console rules are loaded"
Ruleset ruleset = new TenantRuleset(
- keycloakDemoSetup.tenantBuilding.realm,
+ keycloakTestSetup.tenantBuilding.realm,
"Demo Tenant Building - Console Location",
Ruleset.Lang.GROOVY,
getClass().getResource("/demo/rules/DemoConsoleLocation.groovy").text)
@@ -104,7 +104,7 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
expect: "the rule engine to become available and be running"
conditions.eventually {
- def tenantBuildingEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuilding.realm)
+ def tenantBuildingEngine = rulesService.tenantEngines.get(keycloakTestSetup.tenantBuilding.realm)
assert tenantBuildingEngine != null
assert tenantBuildingEngine.isRunning()
assert tenantBuildingEngine.assetStates.size() == DEMO_RULE_STATES_SMART_BUILDING
@@ -113,19 +113,19 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
and: "an authenticated user"
def accessToken = authenticate(
container,
- keycloakDemoSetup.tenantBuilding.realm,
+ keycloakTestSetup.tenantBuilding.realm,
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
).token
and: "authenticated and anonymous console, rules and asset resources"
- def authenticatedConsoleResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm, accessToken).proxy(ConsoleResource.class)
- def authenticatedRulesResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm, accessToken).proxy(RulesResource.class)
- def authenticatedAssetResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm, accessToken).proxy(AssetResource.class)
- def anonymousConsoleResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm).proxy(ConsoleResource.class)
- def anonymousRulesResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm).proxy(RulesResource.class)
- def anonymousAssetResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm).proxy(AssetResource.class)
+ def authenticatedConsoleResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.tenantBuilding.realm, accessToken).proxy(ConsoleResource.class)
+ def authenticatedRulesResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.tenantBuilding.realm, accessToken).proxy(RulesResource.class)
+ def authenticatedAssetResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.tenantBuilding.realm, accessToken).proxy(AssetResource.class)
+ def anonymousConsoleResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.tenantBuilding.realm).proxy(ConsoleResource.class)
+ def anonymousRulesResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.tenantBuilding.realm).proxy(RulesResource.class)
+ def anonymousAssetResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.tenantBuilding.realm).proxy(AssetResource.class)
when: "a console registers with an authenticated user"
def consoleRegistration = new ConsoleRegistration(null,
@@ -183,7 +183,7 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
}.orElse(null) == "23123213ad2313b0897efd"
and: "the console should have been linked to the authenticated user"
- def userAssets = assetStorageService.findUserAssets(keycloakDemoSetup.tenantBuilding.realm, keycloakDemoSetup.testuser3Id, consoleId)
+ def userAssets = assetStorageService.findUserAssets(keycloakTestSetup.tenantBuilding.realm, keycloakTestSetup.testuser3Id, consoleId)
assert userAssets.size() == 1
assert userAssets.get(0).assetName == "Test Console"
@@ -260,7 +260,7 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
assert consoleTestProvider.data == null
when: "a console registers with the id of another existing asset"
- consoleRegistration.setId(managerDemoSetup.thingId)
+ consoleRegistration.setId(managerTestSetup.thingId)
authenticatedConsoleResource.register(null, consoleRegistration)
then: "the result should be bad request"
@@ -416,7 +416,7 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
assert asset != null
assert asset.getAttribute(LOCATION.attributeName).flatMap { it.valueTimestamp }.orElse(Long.MIN_VALUE) > timestamp
assert notificationIds.size() == 1
- def tenantBuildingEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuilding.realm)
+ def tenantBuildingEngine = rulesService.tenantEngines.get(keycloakTestSetup.tenantBuilding.realm)
assert tenantBuildingEngine != null
assert tenantBuildingEngine.isRunning()
assert !tenantBuildingEngine.facts.getOptional("welcomeHome_${testUser3Console2.id}").isPresent()
diff --git a/test/src/test/groovy/org/openremote/test/failure/RulesExecutionFailureTest.groovy b/test/src/test/groovy/org/openremote/test/failure/RulesExecutionFailureTest.groovy
index 534ebdf63..aa1e60052 100644
--- a/test/src/test/groovy/org/openremote/test/failure/RulesExecutionFailureTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/failure/RulesExecutionFailureTest.groovy
@@ -7,7 +7,7 @@ import org.openremote.manager.rules.RulesLoopException
import org.openremote.manager.rules.RulesService
import org.openremote.manager.rules.RulesetStorageService
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.rules.AssetRuleset
import org.openremote.model.rules.Ruleset
import org.openremote.model.rules.RulesetStatus
@@ -26,14 +26,14 @@ class RulesExecutionFailureTest extends Specification implements ManagerContaine
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def conditions = new PollingConditions(timeout: 20, delay: 0.2)
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def rulesService = container.getService(RulesService.class)
def rulesetStorageService = container.getService(RulesetStorageService.class)
RulesEngine apartment2Engine
and: "some rules"
Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment2Id,
+ managerTestSetup.apartment2Id,
"Failure Ruleset",
Ruleset.Lang.GROOVY,
getClass().getResource("/org/openremote/test/failure/RulesFailureConditionInvalidReturn.groovy").text)
@@ -41,7 +41,7 @@ class RulesExecutionFailureTest extends Specification implements ManagerContaine
expect: "the rule engine should have an error (first firing after initial asset state insert)"
conditions.eventually {
- apartment2Engine = rulesService.assetEngines.get(managerDemoSetup.apartment2Id)
+ apartment2Engine = rulesService.assetEngines.get(managerTestSetup.apartment2Id)
assert apartment2Engine != null
assert apartment2Engine.isError()
assert apartment2Engine.getError() instanceof RuntimeException
@@ -62,14 +62,14 @@ class RulesExecutionFailureTest extends Specification implements ManagerContaine
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def conditions = new PollingConditions(timeout: 20, delay: 0.2)
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def rulesService = container.getService(RulesService.class)
def rulesetStorageService = container.getService(RulesetStorageService.class)
RulesEngine apartment2Engine
and: "some rules"
Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment2Id,
+ managerTestSetup.apartment2Id,
"Failure Ruleset",
Ruleset.Lang.GROOVY,
getClass().getResource("/org/openremote/test/failure/RulesFailureConditionThrowsException.groovy").text)
@@ -77,7 +77,7 @@ class RulesExecutionFailureTest extends Specification implements ManagerContaine
expect: "the rule engine should have an error (first firing after initial asset state insert)"
conditions.eventually {
- apartment2Engine = rulesService.assetEngines.get(managerDemoSetup.apartment2Id)
+ apartment2Engine = rulesService.assetEngines.get(managerTestSetup.apartment2Id)
assert apartment2Engine != null
assert apartment2Engine.deployments[ruleset.id].status == RulesetStatus.EXECUTION_ERROR
assert apartment2Engine.deployments[ruleset.id].error instanceof RuntimeException
@@ -98,14 +98,14 @@ class RulesExecutionFailureTest extends Specification implements ManagerContaine
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def conditions = new PollingConditions(timeout: 20, delay: 0.2)
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def rulesService = container.getService(RulesService.class)
def rulesetStorageService = container.getService(RulesetStorageService.class)
RulesEngine apartment2Engine
and: "some rules"
Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment2Id,
+ managerTestSetup.apartment2Id,
"Failure Ruleset",
Ruleset.Lang.GROOVY,
getClass().getResource("/org/openremote/test/failure/RulesFailureActionThrowsException.groovy").text)
@@ -113,7 +113,7 @@ class RulesExecutionFailureTest extends Specification implements ManagerContaine
expect: "the rule engine should have an error (first firing after initial asset state insert)"
conditions.eventually {
- apartment2Engine = rulesService.assetEngines.get(managerDemoSetup.apartment2Id)
+ apartment2Engine = rulesService.assetEngines.get(managerTestSetup.apartment2Id)
assert apartment2Engine != null
assert apartment2Engine.deployments[ruleset.id].status == RulesetStatus.EXECUTION_ERROR
assert apartment2Engine.deployments[ruleset.id].error instanceof RuntimeException
@@ -134,14 +134,14 @@ class RulesExecutionFailureTest extends Specification implements ManagerContaine
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def conditions = new PollingConditions(timeout: 20, delay: 0.2)
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def rulesService = container.getService(RulesService.class)
def rulesetStorageService = container.getService(RulesetStorageService.class)
RulesEngine apartment2Engine
and: "some rules"
Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment2Id,
+ managerTestSetup.apartment2Id,
"Failure Ruleset",
Ruleset.Lang.GROOVY,
getClass().getResource("/org/openremote/test/failure/RulesFailureLoop.groovy").text)
@@ -150,7 +150,7 @@ class RulesExecutionFailureTest extends Specification implements ManagerContaine
expect: "the rule engine should have an error (first firing after initial asset state insert)"
conditions.eventually {
- apartment2Engine = rulesService.assetEngines.get(managerDemoSetup.apartment2Id)
+ apartment2Engine = rulesService.assetEngines.get(managerTestSetup.apartment2Id)
assert apartment2Engine != null
assert apartment2Engine.deployments[ruleset.id].status == RulesetStatus.LOOP_ERROR
assert apartment2Engine.deployments[ruleset.id].error instanceof RulesLoopException
diff --git a/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy b/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy
index d0c8dbfb1..531081a47 100644
--- a/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy
@@ -20,7 +20,7 @@ import org.openremote.manager.gateway.GatewayService
import org.openremote.manager.security.ManagerIdentityService
import org.openremote.manager.security.ManagerKeycloakIdentityProvider
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.asset.*
import org.openremote.model.asset.agent.ConnectionStatus
import org.openremote.model.attribute.*
@@ -59,7 +59,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
def timerService = container.getService(TimerService.class)
def assetStorageService = container.getService(AssetStorageService.class)
def gatewayService = container.getService(GatewayService.class)
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def identityProvider = container.getService(ManagerIdentityService.class).identityProvider as ManagerKeycloakIdentityProvider
def httpClientProtocol = container.getService(HttpClientProtocol.class)
@@ -69,11 +69,11 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
}
when: "a gateway is provisioned in this manager"
- def gateway = assetStorageService.merge(new Asset("Test gateway", AssetType.GATEWAY, null, managerDemoSetup.realmBuildingTenant))
+ def gateway = assetStorageService.merge(new Asset("Test gateway", AssetType.GATEWAY, null, managerTestSetup.realmBuildingTenant))
then: "a keycloak client should have been created for this gateway"
conditions.eventually {
- def client = identityProvider.getClient(managerDemoSetup.realmBuildingTenant, GatewayService.GATEWAY_CLIENT_ID_PREFIX + gateway.getId())
+ def client = identityProvider.getClient(managerTestSetup.realmBuildingTenant, GatewayService.GATEWAY_CLIENT_ID_PREFIX + gateway.getId())
assert client != null
}
@@ -93,9 +93,9 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
when: "the Gateway client is created"
def gatewayClient = new WebsocketIoClient<String>(
- new URIBuilder("ws://127.0.0.1:$serverPort/websocket/events?Auth-Realm=$managerDemoSetup.realmBuildingTenant").build(),
+ new URIBuilder("ws://127.0.0.1:$serverPort/websocket/events?Auth-Realm=$managerTestSetup.realmBuildingTenant").build(),
null,
- new OAuthClientCredentialsGrant("http://127.0.0.1:$serverPort/auth/realms/$managerDemoSetup.realmBuildingTenant/protocol/openid-connect/token",
+ new OAuthClientCredentialsGrant("http://127.0.0.1:$serverPort/auth/realms/$managerTestSetup.realmBuildingTenant/protocol/openid-connect/token",
gateway.getAttribute("clientId").flatMap{it.getValueAsString()}.orElse(""),
gateway.getAttribute("clientSecret").flatMap{it.getValueAsString()}.orElse(""),
null).setBasicAuthHeader(true),
@@ -285,15 +285,15 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
assert syncedAssets.stream().filter{syncedAsset -> sendAssets.stream().anyMatch{it.id == syncedAsset.id}}.count() == sendAssets.size()
assert syncedAssets.find {it.id == agentAssetIds[0]}.getName() == "Test Agent 1"
assert syncedAssets.find {it.id == agentAssetIds[0]}.getType() == AssetType.AGENT.type
- assert syncedAssets.find {it.id == agentAssetIds[0]}.getRealm() == managerDemoSetup.realmBuildingTenant
+ assert syncedAssets.find {it.id == agentAssetIds[0]}.getRealm() == managerTestSetup.realmBuildingTenant
assert syncedAssets.find {it.id == agentAssetIds[0]}.getParentId() == gateway.getId()
assert syncedAssets.find {it.id == agentAssetIds[4]}.getName() == "Test Agent 5"
assert syncedAssets.find {it.id == agentAssetIds[4]}.getType() == AssetType.AGENT.type
- assert syncedAssets.find {it.id == agentAssetIds[4]}.getRealm() == managerDemoSetup.realmBuildingTenant
+ assert syncedAssets.find {it.id == agentAssetIds[4]}.getRealm() == managerTestSetup.realmBuildingTenant
assert syncedAssets.find {it.id == agentAssetIds[4]}.getParentId() == gateway.getId()
assert syncedAssets.find {it.id == assetIds[0]}.getName() == "Test Building 1"
assert syncedAssets.find {it.id == assetIds[0]}.getType() == AssetType.BUILDING.type
- assert syncedAssets.find {it.id == assetIds[0]}.getRealm() == managerDemoSetup.realmBuildingTenant
+ assert syncedAssets.find {it.id == assetIds[0]}.getRealm() == managerTestSetup.realmBuildingTenant
assert syncedAssets.find {it.id == assetIds[0]}.getParentId() == gateway.getId()
assert syncedAssets.find {it.id == assetIds[0]}.getAttribute(AttributeType.LOCATION).flatMap {GeoJSONPoint.fromValue(it.getValue().orElse(null))}.get().x == 10
assert syncedAssets.find {it.id == assetIds[0]}.getAttribute(AttributeType.LOCATION).flatMap {GeoJSONPoint.fromValue(it.getValue().orElse(null))}.get().y == 11
@@ -301,13 +301,13 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
assert syncedAssets.find {it.id == assetIds[0]}.getAttribute(AttributeType.SURFACE_AREA).flatMap {it.getValueAsNumber()}.orElse(0d) == 1000
assert syncedAssets.find {it.id == assetIds[1]}.getName() == "Test Building 1 Room 1"
assert syncedAssets.find {it.id == assetIds[1]}.getType() == AssetType.ROOM.type
- assert syncedAssets.find {it.id == assetIds[1]}.getRealm() == managerDemoSetup.realmBuildingTenant
+ assert syncedAssets.find {it.id == assetIds[1]}.getRealm() == managerTestSetup.realmBuildingTenant
assert syncedAssets.find {it.id == assetIds[1]}.getParentId() == assetIds[0]
assert syncedAssets.find {it.id == assetIds[1]}.getAttribute("temp").map{it.hasMetaItem(MetaItemType.AGENT_LINK)}.orElse(false)
assert syncedAssets.find {it.id == assetIds[1]}.getAttribute("tempSetpoint").map{it.hasMetaItem(MetaItemType.AGENT_LINK)}.orElse(false)
assert syncedAssets.find {it.id == assetIds[5]}.getName() == "Test Building 2"
assert syncedAssets.find {it.id == assetIds[5]}.getType() == AssetType.BUILDING.type
- assert syncedAssets.find {it.id == assetIds[5]}.getRealm() == managerDemoSetup.realmBuildingTenant
+ assert syncedAssets.find {it.id == assetIds[5]}.getRealm() == managerTestSetup.realmBuildingTenant
assert syncedAssets.find {it.id == assetIds[5]}.getParentId() == gateway.getId()
assert syncedAssets.find {it.id == assetIds[5]}.getAttribute(AttributeType.LOCATION).flatMap {GeoJSONPoint.fromValue(it.getValue().orElse(null))}.get().x == 10
assert syncedAssets.find {it.id == assetIds[5]}.getAttribute(AttributeType.LOCATION).flatMap {GeoJSONPoint.fromValue(it.getValue().orElse(null))}.get().y == 11
@@ -315,7 +315,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
assert syncedAssets.find {it.id == assetIds[5]}.getAttribute(AttributeType.SURFACE_AREA).flatMap {it.getValueAsNumber()}.orElse(0d) == 1000
assert syncedAssets.find {it.id == assetIds[6]}.getName() == "Test Building 2 Room 1"
assert syncedAssets.find {it.id == assetIds[6]}.getType() == AssetType.ROOM.type
- assert syncedAssets.find {it.id == assetIds[6]}.getRealm() == managerDemoSetup.realmBuildingTenant
+ assert syncedAssets.find {it.id == assetIds[6]}.getRealm() == managerTestSetup.realmBuildingTenant
assert syncedAssets.find {it.id == assetIds[6]}.getParentId() == assetIds[5]
assert syncedAssets.find {it.id == assetIds[6]}.getAttribute("temp").map{it.hasMetaItem(MetaItemType.AGENT_LINK)}.orElse(false)
assert syncedAssets.find {it.id == assetIds[6]}.getAttribute("tempSetpoint").map{it.hasMetaItem(MetaItemType.AGENT_LINK)}.orElse(false)
@@ -425,7 +425,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
assert building1Room5Asset != null
assert building1Room5Asset.getName() == "Test Building 1 Room 5"
assert building1Room5Asset.getType() == AssetType.ROOM.type
- assert building1Room5Asset.getRealm() == managerDemoSetup.realmBuildingTenant
+ assert building1Room5Asset.getRealm() == managerTestSetup.realmBuildingTenant
assert building1Room5Asset.getParentId() == assetIds[0]
assert building1Room5Asset.getAttributesList().size() == 3
}
@@ -449,7 +449,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
assert building1Room5Asset.getVersion() == 1
assert building1Room5Asset.getName() == "Test Building 1 Room 5 Updated"
assert building1Room5Asset.getType() == AssetType.ROOM.type
- assert building1Room5Asset.getRealm() == managerDemoSetup.realmBuildingTenant
+ assert building1Room5Asset.getRealm() == managerTestSetup.realmBuildingTenant
assert building1Room5Asset.getParentId() == assetIds[0]
assert building1Room5Asset.getAttributesList().size() == 4
assert building1Room5Asset.getAttribute("co2Level").flatMap{it.getValueAsNumber()}.orElse(0d) == 500d
@@ -508,7 +508,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
assert building1Room5Asset.getVersion() == 2
assert building1Room5Asset.getName() == "Test Building 1 Room 5"
assert building1Room5Asset.getType() == AssetType.ROOM.type
- assert building1Room5Asset.getRealm() == managerDemoSetup.realmBuildingTenant
+ assert building1Room5Asset.getRealm() == managerTestSetup.realmBuildingTenant
assert building1Room5Asset.getParentId() == assetIds[0]
assert building1Room5Asset.getAttributesList().size() == 3
assert assetStorageService.find(building1Room5AssetId).version == building1Room5Asset.version
@@ -572,7 +572,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
gateway.id,
(String)null,
(String)null,
- managerDemoSetup.realmBuildingTenant,
+ managerTestSetup.realmBuildingTenant,
(String[])[UniqueIdentifierGenerator.generateId("Failed asset")].toArray(new String[0]),
null).addAttributes(
new AssetAttribute(AttributeType.LOCATION, new GeoJSONPoint(10,11).toValue())
@@ -745,7 +745,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
then: "the keycloak client should also be removed"
assert deleted
conditions.eventually {
- assert identityProvider.getClient(managerDemoSetup.realmBuildingTenant, GatewayService.GATEWAY_CLIENT_ID_PREFIX + gateway.getId()) == null
+ assert identityProvider.getClient(managerTestSetup.realmBuildingTenant, GatewayService.GATEWAY_CLIENT_ID_PREFIX + gateway.getId()) == null
}
}
@@ -850,7 +850,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
def gatewayService = container.getService(GatewayService.class)
def gatewayClientService = container.getService(GatewayClientService.class)
def simulatorProtocol = container.getService(SimulatorProtocol.class)
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
and: "an authenticated admin user"
def accessToken = authenticate(
@@ -870,7 +870,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
}
when: "a gateway is provisioned in this manager in the building realm"
- def gateway = assetStorageService.merge(new Asset("Test gateway", AssetType.GATEWAY, null, managerDemoSetup.realmBuildingTenant))
+ def gateway = assetStorageService.merge(new Asset("Test gateway", AssetType.GATEWAY, null, managerTestSetup.realmBuildingTenant))
then: "a set of credentials should have been created for this gateway and be stored against the gateway for easy reference"
conditions.eventually {
@@ -890,17 +890,17 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
def gatewayConnection = new GatewayConnection(
"127.0.0.1",
serverPort,
- managerDemoSetup.realmBuildingTenant,
+ managerTestSetup.realmBuildingTenant,
gateway.getAttribute("clientId").flatMap{it.getValueAsString()}.orElse(""),
gateway.getAttribute("clientSecret").flatMap{it.getValueAsString()}.orElse(""),
false,
false
)
- gatewayClientResource.setConnection(null, managerDemoSetup.realmCityTenant, gatewayConnection)
+ gatewayClientResource.setConnection(null, managerTestSetup.realmCityTenant, gatewayConnection)
then: "the gateway client should become connected"
conditions.eventually {
- assert gatewayClientService.clientRealmMap.get(managerDemoSetup.realmCityTenant) != null
+ assert gatewayClientService.clientRealmMap.get(managerTestSetup.realmCityTenant) != null
}
and: "the gateway asset connection status should become CONNECTED"
@@ -916,7 +916,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
}
when: "a gateway client asset is modified"
- def microphone1 = assetStorageService.find(managerDemoSetup.microphone1Id)
+ def microphone1 = assetStorageService.find(managerTestSetup.microphone1Id)
microphone1.setName("Microphone 1 Updated")
microphone1.getAttribute("microphoneLevel").ifPresent{it.addMeta(MetaItemType.UNIT_TYPE.withInitialValue(UNITS_SOUND_DECIBELS))}
microphone1.addAttributes(
@@ -926,7 +926,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
then: "the mirrored asset under the gateway should have also been updated"
conditions.eventually {
- def mirroredMicrophone = assetStorageService.find(realIdToFakeIdMap.get(managerDemoSetup.microphone1Id))
+ def mirroredMicrophone = assetStorageService.find(realIdToFakeIdMap.get(managerTestSetup.microphone1Id))
assert mirroredMicrophone != null
assert mirroredMicrophone.getAttribute("microphoneLevel").flatMap{it.getMetaItem(MetaItemType.UNIT_TYPE)}.flatMap{it.getValueAsString()}.orElse("") == UNITS_SOUND_DECIBELS
assert mirroredMicrophone.getAttribute("test").isPresent()
@@ -934,10 +934,10 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
}
when: "a gateway client asset is added"
- def microphone2 = new Asset("Microphone 2", AssetType.MICROPHONE, null, managerDemoSetup.realmCityTenant).addAttributes(
+ def microphone2 = new Asset("Microphone 2", AssetType.MICROPHONE, null, managerTestSetup.realmCityTenant).addAttributes(
new AssetAttribute("test", AttributeValueType.STRING, Values.create("testValue"))
)
- microphone2.setParentId(managerDemoSetup.area1Id)
+ microphone2.setParentId(managerTestSetup.area1Id)
microphone2 = assetStorageService.merge(microphone2)
then: "the new asset should have been created in the gateway and also mirrored under the gateway asset"
@@ -951,7 +951,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
when: "an asset is added under the gateway client"
def microphone3 = new Asset()
- Asset.map(microphone1, microphone3, "Microphone 3", managerDemoSetup.realmBuildingTenant, realIdToFakeIdMap.get(managerDemoSetup.area1Id), null, null, null)
+ Asset.map(microphone1, microphone3, "Microphone 3", managerTestSetup.realmBuildingTenant, realIdToFakeIdMap.get(managerTestSetup.area1Id), null, null, null)
microphone3 = assetStorageService.merge(microphone3)
then: "the new asset should have been created in the gateway and also mirrored under the gateway asset"
@@ -995,12 +995,12 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
}
when: "a gateway client asset is deleted"
- def deleted = assetStorageService.delete(Collections.singletonList(managerDemoSetup.microphone1Id))
+ def deleted = assetStorageService.delete(Collections.singletonList(managerTestSetup.microphone1Id))
then: "the client asset should have been deleted and also the mirrored asset under the gateway should also be deleted"
assert deleted
conditions.eventually {
- assert assetStorageService.find(realIdToFakeIdMap.get(managerDemoSetup.microphone1Id)) == null
+ assert assetStorageService.find(realIdToFakeIdMap.get(managerTestSetup.microphone1Id)) == null
}
}
}
diff --git a/test/src/test/groovy/org/openremote/test/mqtt/MqttBrokerTest.groovy b/test/src/test/groovy/org/openremote/test/mqtt/MqttBrokerTest.groovy
index 5c2017b54..3f122cd14 100644
--- a/test/src/test/groovy/org/openremote/test/mqtt/MqttBrokerTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/mqtt/MqttBrokerTest.groovy
@@ -8,7 +8,7 @@ import org.openremote.manager.asset.AssetProcessingService
import org.openremote.manager.asset.AssetStorageService
import org.openremote.manager.mqtt.MqttBrokerService
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.attribute.AttributeEvent
import org.openremote.model.attribute.AttributeRef
import org.openremote.model.value.Values
@@ -47,13 +47,13 @@ class MqttBrokerTest extends Specification implements ManagerContainerTrait {
def services = Lists.newArrayList(defaultServices())
services.replaceAll { it instanceof MqttBrokerService ? spyMqttBrokerService : it }
def container = startContainer(defaultConfig(), services)
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def mqttBrokerService = container.getService(MqttBrokerService.class)
def assetProcessingService = container.getService(AssetProcessingService.class)
def assetStorageService = container.getService(AssetStorageService.class)
- def mqttClientId = managerDemoSetup.realmBuildingTenant + MQTT_CLIENT_ID_SEPARATOR + UniqueIdentifierGenerator.generateId()
- def clientId = MqttBrokerService.MQTT_CLIENT_ID_PREFIX + UniqueIdentifierGenerator.generateId(managerDemoSetup.realmBuildingTenant)
- def clientSecret = UniqueIdentifierGenerator.generateId(managerDemoSetup.realmBuildingTenant)
+ def mqttClientId = managerTestSetup.realmBuildingTenant + MQTT_CLIENT_ID_SEPARATOR + UniqueIdentifierGenerator.generateId()
+ def clientId = MqttBrokerService.MQTT_CLIENT_ID_PREFIX + UniqueIdentifierGenerator.generateId(managerTestSetup.realmBuildingTenant)
+ def clientSecret = UniqueIdentifierGenerator.generateId(managerTestSetup.realmBuildingTenant)
def mqttHost = getString(container.getConfig(), MQTT_SERVER_LISTEN_HOST, BrokerConstants.HOST);
def mqttPort = getInteger(container.getConfig(), MQTT_SERVER_LISTEN_PORT, BrokerConstants.PORT);
@@ -131,7 +131,7 @@ class MqttBrokerTest extends Specification implements ManagerContainerTrait {
}
when: "a mqtt client subscribes to an asset in another realm"
- def topic = "assets/" + managerDemoSetup.thingId
+ def topic = "assets/" + managerTestSetup.thingId
remainingLength = 4 + topic.size() + 1 //plus one for the QoS byte
client
@@ -173,7 +173,7 @@ class MqttBrokerTest extends Specification implements ManagerContainerTrait {
}
when: "a mqtt client subscribes to an asset"
- topic = "assets/" + managerDemoSetup.apartment1HallwayId
+ topic = "assets/" + managerTestSetup.apartment1HallwayId
remainingLength = 4 + topic.size() + 1 //plus one for the QoS byte
client
@@ -194,7 +194,7 @@ class MqttBrokerTest extends Specification implements ManagerContainerTrait {
}
when: "An asset attribute changed the client is subscribed on"
- def attributeEvent = new AttributeEvent(managerDemoSetup.apartment1HallwayId, "motionSensor", Values.create(50))
+ def attributeEvent = new AttributeEvent(managerTestSetup.apartment1HallwayId, "motionSensor", Values.create(50))
assetProcessingService.sendAttributeEvent(attributeEvent)
then: "A publish event message should be sent"
@@ -203,7 +203,7 @@ class MqttBrokerTest extends Specification implements ManagerContainerTrait {
}
when: "Another asset attribute changed the client is subscribed on"
- attributeEvent = new AttributeEvent(managerDemoSetup.apartment1HallwayId, "presenceDetected", Values.create(true))
+ attributeEvent = new AttributeEvent(managerTestSetup.apartment1HallwayId, "presenceDetected", Values.create(true))
assetProcessingService.sendAttributeEvent(attributeEvent)
then: "A second publish event message should be sent"
@@ -212,7 +212,7 @@ class MqttBrokerTest extends Specification implements ManagerContainerTrait {
}
when: "a mqtt client publishes to an asset attribute which is readonly"
- topic = "assets/" + managerDemoSetup.apartment1HallwayId
+ topic = "assets/" + managerTestSetup.apartment1HallwayId
def payload = Values.createObject().put("motionSensor", 70).toJson()
remainingLength = 2 + topic.size() + payload.length()
@@ -226,12 +226,12 @@ class MqttBrokerTest extends Specification implements ManagerContainerTrait {
then: "The value of the attribute shouldn't be updated"
conditions.eventually {
- def asset = assetStorageService.find(managerDemoSetup.apartment1HallwayId)
+ def asset = assetStorageService.find(managerTestSetup.apartment1HallwayId)
assert asset.getAttribute("motionSensor").get().valueAsNumber.orElse(0) == 50d
}
when: "a mqtt client publishes to an asset attribute"
- topic = "assets/" + managerDemoSetup.apartment1HallwayId
+ topic = "assets/" + managerTestSetup.apartment1HallwayId
payload = Values.createObject().put("lights", false).toJson()
remainingLength = 2 + topic.size() + payload.length()
@@ -245,13 +245,13 @@ class MqttBrokerTest extends Specification implements ManagerContainerTrait {
then: "The value of the attribute should be updated and another publish event should be sent"
conditions.eventually {
- def asset = assetStorageService.find(managerDemoSetup.apartment1HallwayId)
+ def asset = assetStorageService.find(managerTestSetup.apartment1HallwayId)
assert !asset.getAttribute("lights").get().valueAsBoolean.orElse(true)
assert mqttBrokerServiceAttributeEventCalls == 3
}
when: "a mqtt client unsubscribes to an asset"
- topic = "assets/" + managerDemoSetup.apartment1HallwayId
+ topic = "assets/" + managerTestSetup.apartment1HallwayId
remainingLength = 4 + topic.size()
client
@@ -272,7 +272,7 @@ class MqttBrokerTest extends Specification implements ManagerContainerTrait {
}
when: "Another asset attribute changed without any subscriptions"
- attributeEvent = new AttributeEvent(managerDemoSetup.apartment1HallwayId, "presenceDetected", Values.create(false))
+ attributeEvent = new AttributeEvent(managerTestSetup.apartment1HallwayId, "presenceDetected", Values.create(false))
assetProcessingService.sendAttributeEvent(attributeEvent)
then: "No publish event message should be sent"
@@ -281,7 +281,7 @@ class MqttBrokerTest extends Specification implements ManagerContainerTrait {
}
when: "a mqtt client subscribes to an asset attribute"
- topic = "assets/" + managerDemoSetup.apartment1HallwayId + "/motionSensor"
+ topic = "assets/" + managerTestSetup.apartment1HallwayId + "/motionSensor"
remainingLength = 4 + topic.size() + 1 //plus one for the QoS byte
client
@@ -298,14 +298,14 @@ class MqttBrokerTest extends Specification implements ManagerContainerTrait {
then: "the subscription should be established"
conditions.eventually {
- assert mqttBrokerService.mqttConnectionMap.get(mqttClientId).assetAttributeSubscriptions.containsKey(new AttributeRef(managerDemoSetup.apartment1HallwayId, "motionSensor"))
+ assert mqttBrokerService.mqttConnectionMap.get(mqttClientId).assetAttributeSubscriptions.containsKey(new AttributeRef(managerTestSetup.apartment1HallwayId, "motionSensor"))
}
when: "time advances"
advancePseudoClock(1, TimeUnit.SECONDS, container)
and: "that attribute changed"
- attributeEvent = new AttributeEvent(managerDemoSetup.apartment1HallwayId, "motionSensor", Values.create(30))
+ attributeEvent = new AttributeEvent(managerTestSetup.apartment1HallwayId, "motionSensor", Values.create(30))
assetProcessingService.sendAttributeEvent(attributeEvent)
then: "A publish event message should be sent"
@@ -314,7 +314,7 @@ class MqttBrokerTest extends Specification implements ManagerContainerTrait {
}
when: "Another asset attribute changed without any subscriptions on that attribute"
- attributeEvent = new AttributeEvent(managerDemoSetup.apartment1HallwayId, "presenceDetected", Values.create(true))
+ attributeEvent = new AttributeEvent(managerTestSetup.apartment1HallwayId, "presenceDetected", Values.create(true))
assetProcessingService.sendAttributeEvent(attributeEvent)
then: "No publish event message should be sent"
@@ -323,7 +323,7 @@ class MqttBrokerTest extends Specification implements ManagerContainerTrait {
}
when: "a mqtt client unsubscribes to an asset attribute"
- topic = "assets/" + managerDemoSetup.apartment1HallwayId + "/motionSensor"
+ topic = "assets/" + managerTestSetup.apartment1HallwayId + "/motionSensor"
remainingLength = 4 + topic.size()
client
@@ -344,7 +344,7 @@ class MqttBrokerTest extends Specification implements ManagerContainerTrait {
}
when: "a mqtt client subscribes to an asset attribute value"
- topic = "assets/" + managerDemoSetup.apartment1HallwayId + "/motionSensor/value"
+ topic = "assets/" + managerTestSetup.apartment1HallwayId + "/motionSensor/value"
remainingLength = 4 + topic.size() + 1 //plus one for the QoS byte
client
@@ -361,14 +361,14 @@ class MqttBrokerTest extends Specification implements ManagerContainerTrait {
then: "the subscription should be established"
conditions.eventually {
- assert mqttBrokerService.mqttConnectionMap.get(mqttClientId).assetAttributeValueSubscriptions.containsKey(new AttributeRef(managerDemoSetup.apartment1HallwayId, "motionSensor"))
+ assert mqttBrokerService.mqttConnectionMap.get(mqttClientId).assetAttributeValueSubscriptions.containsKey(new AttributeRef(managerTestSetup.apartment1HallwayId, "motionSensor"))
}
when: "time advances"
advancePseudoClock(1, TimeUnit.SECONDS, container)
and: "that attribute changed"
- attributeEvent = new AttributeEvent(managerDemoSetup.apartment1HallwayId, "motionSensor", Values.create(40))
+ attributeEvent = new AttributeEvent(managerTestSetup.apartment1HallwayId, "motionSensor", Values.create(40))
assetProcessingService.sendAttributeEvent(attributeEvent)
then: "A publish value message should be sent"
@@ -377,7 +377,7 @@ class MqttBrokerTest extends Specification implements ManagerContainerTrait {
}
when: "Another asset attribute changed without any subscriptions on that attribute"
- attributeEvent = new AttributeEvent(managerDemoSetup.apartment1HallwayId, "presenceDetected", Values.create(false))
+ attributeEvent = new AttributeEvent(managerTestSetup.apartment1HallwayId, "presenceDetected", Values.create(false))
assetProcessingService.sendAttributeEvent(attributeEvent)
then: "No publish value message should be sent"
@@ -386,7 +386,7 @@ class MqttBrokerTest extends Specification implements ManagerContainerTrait {
}
when: "a mqtt client unsubscribes to an asset attribute value"
- topic = "assets/" + managerDemoSetup.apartment1HallwayId + "/motionSensor/value"
+ topic = "assets/" + managerTestSetup.apartment1HallwayId + "/motionSensor/value"
remainingLength = 4 + topic.size()
client
diff --git a/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy b/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy
index 3057b27a5..ec0a70a2d 100644
--- a/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy
@@ -10,8 +10,8 @@ import org.openremote.manager.notification.NotificationService
import org.openremote.manager.notification.PushNotificationHandler
import org.openremote.manager.rules.geofence.ORConsoleGeofenceAssetAdapter
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.KeycloakDemoSetup
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.KeycloakTestSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.asset.AssetAttribute
import org.openremote.model.attribute.AttributeRef
import org.openremote.model.attribute.AttributeType
@@ -49,8 +49,8 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
given: "the container environment is started with the mock handler"
def container = startContainer(defaultConfig(), defaultServices())
- def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def notificationService = container.getService(NotificationService.class)
def pushNotificationHandler = container.getService(PushNotificationHandler.class)
def consoleResource = (ConsoleResourceImpl)container.getService(WebService.class).getApiSingletons().find {it instanceof ConsoleResourceImpl}
@@ -74,7 +74,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
notificationService.notificationHandlerMap.put(pushNotificationHandler.getTypeName(), mockPushNotificationHandler)
and: "an authenticated test user"
- def realm = keycloakDemoSetup.tenantBuilding.realm
+ def realm = keycloakTestSetup.tenantBuilding.realm
def testuser1AccessToken = authenticate(
container,
MASTER_REALM,
@@ -111,7 +111,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
"Click to cancel",
writeAttributeValueAction(
new AttributeRef(
- managerDemoSetup.apartment1LivingroomId,
+ managerTestSetup.apartment1LivingroomId,
"alarmEnabled"
),
Values.create(false)), null, null), null, null, null)
@@ -121,7 +121,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
def testuser2NotificationResource = getClientApiTarget(serverUri(serverPort), realm, testuser2AccessToken).proxy(NotificationResource.class)
def testuser3NotificationResource = getClientApiTarget(serverUri(serverPort), realm, testuser3AccessToken).proxy(NotificationResource.class)
def adminNotificationResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, adminAccessToken).proxy(NotificationResource.class)
- def anonymousNotificationResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm).proxy(NotificationResource.class)
+ def anonymousNotificationResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.tenantBuilding.realm).proxy(NotificationResource.class)
def testuser1ConsoleResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, testuser1AccessToken).proxy(ConsoleResource.class)
def testuser2ConsoleResource = getClientApiTarget(serverUri(serverPort), realm, testuser2AccessToken).proxy(ConsoleResource.class)
def testuser3ConsoleResource = getClientApiTarget(serverUri(serverPort), realm, testuser3AccessToken).proxy(ConsoleResource.class)
@@ -171,7 +171,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
anonymousConsole.id != null
when: "the admin user sends a push notification to an entire realm"
- notification.targets = [new Notification.Target(Notification.TargetType.TENANT, keycloakDemoSetup.tenantBuilding.realm)]
+ notification.targets = [new Notification.Target(Notification.TargetType.TENANT, keycloakTestSetup.tenantBuilding.realm)]
adminNotificationResource.sendNotification(null, notification)
then: "all consoles in that realm should have been sent a notification"
@@ -191,7 +191,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
ex.response.status == 403
when: "the admin user sends a notification to a user in a different realm"
- notification.targets = [new Notification.Target(Notification.TargetType.USER, keycloakDemoSetup.testuser2Id)]
+ notification.targets = [new Notification.Target(Notification.TargetType.USER, keycloakTestSetup.testuser2Id)]
advancePseudoClock(1, TimeUnit.HOURS, container)
adminNotificationResource.sendNotification(null, notification)
@@ -199,7 +199,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
notificationIds.size() == 5
when: "a regular user sends a push notification to a user in a different realm"
- notification.targets = [new Notification.Target(Notification.TargetType.USER, keycloakDemoSetup.testuser2Id)]
+ notification.targets = [new Notification.Target(Notification.TargetType.USER, keycloakTestSetup.testuser2Id)]
testuser1NotificationResource.sendNotification(null, notification)
then: "access should be forbidden"
@@ -207,7 +207,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
ex.response.status == 403
when: "a restricted user sends a push notification to another user in the same realm"
- notification.targets = [new Notification.Target(Notification.TargetType.USER, keycloakDemoSetup.testuser2Id)]
+ notification.targets = [new Notification.Target(Notification.TargetType.USER, keycloakTestSetup.testuser2Id)]
testuser3NotificationResource.sendNotification(null, notification)
then: "access should be forbidden"
@@ -535,7 +535,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
given: "the container environment is started with the mock handler"
def conditions = new PollingConditions(timeout: 10, delay: 0.2)
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def notificationService = container.getService(NotificationService.class)
def emailNotificationHandler = container.getService(EmailNotificationHandler.class)
def assetStorageService = container.getService(AssetStorageService.class)
@@ -567,8 +567,8 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
def notification = new Notification(
"Test",
new EmailNotificationMessage().setSubject("Test").setText("Hello world!"),
- Collections.singletonList(new Notification.Target(Notification.TargetType.TENANT, managerDemoSetup.realmBuildingTenant)), null, null)
- notificationService.sendNotification(notification, Notification.Source.TENANT_RULESET, managerDemoSetup.realmBuildingTenant)
+ Collections.singletonList(new Notification.Target(Notification.TargetType.TENANT, managerTestSetup.realmBuildingTenant)), null, null)
+ notificationService.sendNotification(notification, Notification.Source.TENANT_RULESET, managerTestSetup.realmBuildingTenant)
then: "the email should have been sent to all tenant users"
conditions.eventually {
@@ -583,12 +583,12 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
}
when: "an email attribute is added to an asset"
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId)
kitchen.addAttributes(new AssetAttribute(AttributeType.EMAIL, Values.create("[email protected]")))
kitchen = assetStorageService.merge(kitchen)
and: "an email notification is sent to a parent asset"
- notification.setTargets([new Notification.Target(Notification.TargetType.ASSET, managerDemoSetup.apartment1Id)])
+ notification.setTargets([new Notification.Target(Notification.TargetType.ASSET, managerTestSetup.apartment1Id)])
notificationService.sendNotification(notification)
then: "the child asset with the email attribute should have been sent an email"
diff --git a/test/src/test/groovy/org/openremote/test/protocol/MacroProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/MacroProtocolTest.groovy
index faa40b5c4..00df11efb 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/MacroProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/MacroProtocolTest.groovy
@@ -4,7 +4,7 @@ import org.openremote.container.timer.TimerService
import org.openremote.manager.asset.AssetProcessingService
import org.openremote.manager.asset.AssetStorageService
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.attribute.AttributeEvent
import org.openremote.model.attribute.AttributeExecuteStatus
import org.openremote.model.value.Values
@@ -24,13 +24,13 @@ class MacroProtocolTest extends Specification implements ManagerContainerTrait {
def container = startContainerWithDemoScenesAndRules(defaultConfig(), defaultServices())
def assetStorageService = container.getService(AssetStorageService.class)
def assetProcessingService = container.getService(AssetProcessingService.class)
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
then: "the container should be running and attributes linked"
conditions.eventually {
assert noEventProcessedIn(assetProcessingService, 500)
- def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def apartment1 = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert apartment1.getAttribute("morningScene").get().getValueAsString().orElse("") == AttributeExecuteStatus.READY.toString()
assert apartment1.getAttribute("dayScene").get().getValueAsString().orElse("") == AttributeExecuteStatus.READY.toString()
assert apartment1.getAttribute("eveningScene").get().getValueAsString().orElse("") == AttributeExecuteStatus.READY.toString()
@@ -40,13 +40,13 @@ class MacroProtocolTest extends Specification implements ManagerContainerTrait {
}
when: "Apartment 1 home scene is executed"
- def macroExecute = new AttributeEvent(managerDemoSetup.apartment1Id, "morningScene", AttributeExecuteStatus.REQUEST_START.asValue())
+ def macroExecute = new AttributeEvent(managerTestSetup.apartment1Id, "morningScene", AttributeExecuteStatus.REQUEST_START.asValue())
assetProcessingService.sendAttributeEvent(macroExecute)
then: "Apartment 1 alarm enabled, last scene and living room target temp attribute values should be updated to match the scene"
conditions.eventually {
- def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)
- def livingRoom = assetStorageService.find(managerDemoSetup.apartment1LivingroomId, true)
+ def apartment1 = assetStorageService.find(managerTestSetup.apartment1Id, true)
+ def livingRoom = assetStorageService.find(managerTestSetup.apartment1LivingroomId, true)
assert !apartment1.getAttribute("alarmEnabled").get().getValueAsBoolean().orElse(true)
assert apartment1.getAttribute("lastExecutedScene").get().getValueAsString().orElse("") == "MORNING"
assert livingRoom.getAttribute("targetTemperature").get().getValueAsNumber().orElse(0d) == 21d
@@ -54,7 +54,7 @@ class MacroProtocolTest extends Specification implements ManagerContainerTrait {
then: "Apartment 1 home scene attribute status should show as COMPLETED"
conditions.eventually {
- def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def apartment1 = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert apartment1.getAttribute("morningScene").get().getValueAsString().orElse("") == AttributeExecuteStatus.COMPLETED.toString()
}
@@ -62,13 +62,13 @@ class MacroProtocolTest extends Specification implements ManagerContainerTrait {
advancePseudoClock(1, TimeUnit.SECONDS, container)
and: "Apartment 1 away scene is executed"
- macroExecute = new AttributeEvent(managerDemoSetup.apartment1Id, "dayScene", AttributeExecuteStatus.REQUEST_START.asValue())
+ macroExecute = new AttributeEvent(managerTestSetup.apartment1Id, "dayScene", 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 livingRoom = assetStorageService.find(managerDemoSetup.apartment1LivingroomId, true)
+ def apartment1 = assetStorageService.find(managerTestSetup.apartment1Id, true)
+ def livingRoom = assetStorageService.find(managerTestSetup.apartment1LivingroomId, true)
assert apartment1.getAttribute("alarmEnabled").get().getValueAsBoolean().orElse(false)
assert apartment1.getAttribute("lastExecutedScene").get().getValueAsString().orElse("") == "DAY"
assert livingRoom.getAttribute("targetTemperature").get().getValueAsNumber().orElse(0d) == 15d
@@ -76,7 +76,7 @@ class MacroProtocolTest extends Specification implements ManagerContainerTrait {
then: "Apartment 1 away scene attribute status should show as COMPLETED"
conditions.eventually {
- def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def apartment1 = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert apartment1.getAttribute("dayScene").get().getValueAsString().orElse("") == AttributeExecuteStatus.COMPLETED.toString()
}
@@ -84,12 +84,12 @@ class MacroProtocolTest extends Specification implements ManagerContainerTrait {
advancePseudoClock(1, TimeUnit.SECONDS, container)
and: "The target temperature of the home scene is modified via the apartment attribute"
- def updateTargetTemp = new AttributeEvent(managerDemoSetup.apartment1Id, "morningSceneTargetTemperature", Values.create(10d))
+ def updateTargetTemp = new AttributeEvent(managerTestSetup.apartment1Id, "morningSceneTargetTemperature", Values.create(10d))
assetProcessingService.sendAttributeEvent(updateTargetTemp)
then: "Apartment 1 home scene attribute status should reset to show as READY and home target temp should show new value"
conditions.eventually {
- def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def apartment1 = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert apartment1.getAttribute("morningScene").get().getValueAsString().orElse("") == AttributeExecuteStatus.READY.toString()
assert apartment1.getAttribute("morningSceneTargetTemperature").get().getValueAsNumber().orElse(0d) == 10d
assert !apartment1.getAttribute("morningSceneAlarmEnabled").get().getValueAsBoolean().orElse(true)
@@ -99,13 +99,13 @@ class MacroProtocolTest extends Specification implements ManagerContainerTrait {
advancePseudoClock(1, TimeUnit.SECONDS, container)
and: "Apartment 1 home scene is executed"
- macroExecute = new AttributeEvent(managerDemoSetup.apartment1Id, "morningScene", AttributeExecuteStatus.REQUEST_START.asValue())
+ macroExecute = new AttributeEvent(managerTestSetup.apartment1Id, "morningScene", AttributeExecuteStatus.REQUEST_START.asValue())
assetProcessingService.sendAttributeEvent(macroExecute)
then: "Apartment 1 alarm enabled, last scene and living room target temp attribute values should be updated to match the scene"
conditions.eventually {
- def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)
- def livingRoom = assetStorageService.find(managerDemoSetup.apartment1LivingroomId, true)
+ def apartment1 = assetStorageService.find(managerTestSetup.apartment1Id, true)
+ def livingRoom = assetStorageService.find(managerTestSetup.apartment1LivingroomId, true)
assert !apartment1.getAttribute("alarmEnabled").get().getValueAsBoolean().orElse(true)
assert apartment1.getAttribute("lastExecutedScene").get().getValueAsString().orElse("") == "MORNING"
assert livingRoom.getAttribute("targetTemperature").get().getValueAsNumber().orElse(0d) == 10d
@@ -113,7 +113,7 @@ class MacroProtocolTest extends Specification implements ManagerContainerTrait {
then: "Apartment 1 home scene attribute status should show as COMPLETED"
conditions.eventually {
- def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def apartment1 = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert apartment1.getAttribute("morningScene").get().getValueAsString().orElse("") == AttributeExecuteStatus.COMPLETED.toString()
}
}
diff --git a/test/src/test/groovy/org/openremote/test/protocol/TimerProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/TimerProtocolTest.groovy
index 082b7fc78..36fea6572 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/TimerProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/TimerProtocolTest.groovy
@@ -6,7 +6,7 @@ import org.openremote.manager.asset.AssetProcessingService
import org.openremote.manager.asset.AssetStorageService
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.asset.Asset
import org.openremote.model.asset.AssetAttribute
import org.openremote.model.query.AssetQuery
@@ -33,7 +33,7 @@ class TimerProtocolTest extends Specification implements ManagerContainerTrait {
def container = startContainerWithDemoScenesAndRules(defaultConfig(), defaultServices())
def assetStorageService = container.getService(AssetStorageService.class)
def assetProcessingService = container.getService(AssetProcessingService.class)
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def timerProtocol = container.getService(TimerProtocol.class)
Asset sceneAgent
Asset apartment1
@@ -43,8 +43,8 @@ class TimerProtocolTest extends Specification implements ManagerContainerTrait {
assert isContainerRunning()
assert noEventProcessedIn(assetProcessingService, 500)
- apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id, true)
- sceneAgent = assetStorageService.find(new AssetQuery().names("Scene Agent").types(AssetType.AGENT).parents(managerDemoSetup.apartment1Id))
+ apartment1 = assetStorageService.find(managerTestSetup.apartment1Id, true)
+ sceneAgent = assetStorageService.find(new AssetQuery().names("Scene Agent").types(AssetType.AGENT).parents(managerTestSetup.apartment1Id))
sceneAgent = assetStorageService.find(sceneAgent.id, true)
assert apartment1.getAttribute("daySceneTimeFRIDAY").get().getValueAsString().orElse("") == "08:30:00"
assert sceneAgent != null
@@ -78,7 +78,7 @@ class TimerProtocolTest extends Specification implements ManagerContainerTrait {
}
when: "a trigger is disabled"
- def disableScene = new AttributeEvent(managerDemoSetup.apartment1Id, "daySceneEnabledFRIDAY", Values.create(false))
+ def disableScene = new AttributeEvent(managerTestSetup.apartment1Id, "daySceneEnabledFRIDAY", Values.create(false))
assetProcessingService.sendAttributeEvent(disableScene)
then: "the corresponding cron job should be removed from the cron scheduler"
@@ -98,7 +98,7 @@ class TimerProtocolTest extends Specification implements ManagerContainerTrait {
}
when: "the trigger is re-enabled"
- def enableScene = new AttributeEvent(managerDemoSetup.apartment1Id, "daySceneEnabledFRIDAY", Values.create(true))
+ def enableScene = new AttributeEvent(managerTestSetup.apartment1Id, "daySceneEnabledFRIDAY", Values.create(true))
assetProcessingService.sendAttributeEvent(enableScene)
then: "the quartz job should be recreated and have the correct time"
@@ -116,7 +116,7 @@ class TimerProtocolTest extends Specification implements ManagerContainerTrait {
}
when: "a trigger time is modified"
- def modifyTime = new AttributeEvent(managerDemoSetup.apartment1Id, "daySceneTimeFRIDAY", Values.create("04:00:00"))
+ def modifyTime = new AttributeEvent(managerTestSetup.apartment1Id, "daySceneTimeFRIDAY", Values.create("04:00:00"))
assetProcessingService.sendAttributeEvent(modifyTime)
then: "the quartz job should have the new trigger time"
@@ -150,7 +150,7 @@ class TimerProtocolTest extends Specification implements ManagerContainerTrait {
}
when: "the trigger cron expression is modified"
- def modifyCron = new AttributeEvent(managerDemoSetup.apartment1Id, "daySceneCronFRIDAY", Values.create("0 0 4 ? * MON,FRI *"))
+ def modifyCron = new AttributeEvent(managerTestSetup.apartment1Id, "daySceneCronFRIDAY", Values.create("0 0 4 ? * MON,FRI *"))
assetProcessingService.sendAttributeEvent(modifyCron)
then: "the quartz job should have the new cron expression"
diff --git a/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientProtocolTest.groovy
index 456d15972..b61426708 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
@@ -30,7 +30,7 @@ import org.openremote.manager.agent.AgentService
import org.openremote.manager.asset.AssetProcessingService
import org.openremote.manager.asset.AssetStorageService
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.Constants
import org.openremote.model.asset.*
import org.openremote.model.asset.agent.ConnectionStatus
@@ -115,7 +115,7 @@ class WebsocketClientProtocolTest extends Specification implements ManagerContai
def assetStorageService = container.getService(AssetStorageService.class)
def assetProcessingService = container.getService(AssetProcessingService.class)
def agentService = container.getService(AgentService.class)
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
when: "the web target builder is configured to use the mock HTTP server (to test subscriptions)"
if (!websocketClientProtocol.client.configuration.isRegistered(mockServer)) {
@@ -150,7 +150,7 @@ class WebsocketClientProtocolTest extends Specification implements ManagerContai
new WebsocketSubscription().body(EventSubscription.SUBSCRIBE_MESSAGE_PREFIX + Container.JSON.writeValueAsString(
new EventSubscription(
AttributeEvent.class,
- new AssetFilter<AttributeEvent>().setAssetIds(managerDemoSetup.apartment1LivingroomId),
+ new AssetFilter<AttributeEvent>().setAssetIds(managerTestSetup.apartment1LivingroomId),
"1",
null))),
new WebsocketHttpSubscription()
@@ -159,7 +159,7 @@ class WebsocketClientProtocolTest extends Specification implements ManagerContai
.headers(Values.<ObjectValue>parse(/{"header1": "header1Value1", "header2": ["header2Value1","header2Value2"]}/).get())
.uri("https://mockapi/assets")
.body(
- Container.JSON.writeValueAsString(new AssetQuery().ids(managerDemoSetup.apartment1LivingroomId))
+ Container.JSON.writeValueAsString(new AssetQuery().ids(managerTestSetup.apartment1LivingroomId))
)
))
).orElse(null)
@@ -190,7 +190,7 @@ class WebsocketClientProtocolTest extends Specification implements ManagerContai
new MetaItem(MetaItemType.AGENT_LINK, new AttributeRef(agent.id, "protocolConfig").toArrayValue()),
new MetaItem(Protocol.META_ATTRIBUTE_WRITE_VALUE, Values.create("\'" + SharedEvent.MESSAGE_PREFIX +
Container.JSON.writeValueAsString(new AttributeEvent(
- managerDemoSetup.apartment1LivingroomId,
+ managerTestSetup.apartment1LivingroomId,
"targetTemperature",
Values.create(0.12345))).replace("0.12345", Protocol.DYNAMIC_VALUE_PLACEHOLDER) + "\'")),
new MetaItem(WebsocketClientProtocol.META_ATTRIBUTE_MATCH_FILTERS,
@@ -213,7 +213,7 @@ class WebsocketClientProtocolTest extends Specification implements ManagerContai
Values.convertToValue(
[
new WebsocketSubscription().body(SharedEvent.MESSAGE_PREFIX + Container.JSON.writeValueAsString(
- new ReadAssetAttributeEvent(managerDemoSetup.apartment1LivingroomId, "targetTemperature")
+ new ReadAssetAttributeEvent(managerTestSetup.apartment1LivingroomId, "targetTemperature")
))
], Container.JSON.writer()).orElse(null))
),
@@ -241,7 +241,7 @@ class WebsocketClientProtocolTest extends Specification implements ManagerContai
Values.convertToValue(
[
new WebsocketSubscription().body(SharedEvent.MESSAGE_PREFIX + Container.JSON.writeValueAsString(
- new ReadAssetAttributeEvent(managerDemoSetup.apartment1LivingroomId, "co2Level")
+ new ReadAssetAttributeEvent(managerTestSetup.apartment1LivingroomId, "co2Level")
))
]
, Container.JSON.writer()).orElse(null))
@@ -272,7 +272,7 @@ class WebsocketClientProtocolTest extends Specification implements ManagerContai
when: "the co2level changes"
def co2LevelIncrement = new AttributeEvent(
- managerDemoSetup.apartment1LivingroomId, "co2Level", Values.create(600)
+ managerTestSetup.apartment1LivingroomId, "co2Level", Values.create(600)
)
simulatorProtocol.putValue(co2LevelIncrement)
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.groovy
index 3bc94f249..cc6134aee 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
@@ -31,7 +31,7 @@ import org.openremote.manager.asset.AssetProcessingService
import org.openremote.manager.asset.AssetStorageService
import org.openremote.manager.concurrent.ManagerExecutorService
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.asset.AssetFilter
import org.openremote.model.asset.agent.AgentStatusEvent
import org.openremote.model.asset.agent.ConnectionStatus
@@ -91,7 +91,7 @@ class WebsocketClientTest extends Specification implements ManagerContainerTrait
def assetProcessingService = container.getService(AssetProcessingService.class)
def assetStorageService = container.getService(AssetStorageService.class)
def agentService = container.getService(AgentService.class)
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
and: "a simple Websocket client"
def client = new WebsocketIoClient<String>(
@@ -134,7 +134,7 @@ class WebsocketClientTest extends Specification implements ManagerContainerTrait
client.sendMessage(messageToString(EventSubscription.SUBSCRIBE_MESSAGE_PREFIX,
new EventSubscription(
AttributeEvent.class,
- new AssetFilter<AttributeEvent>().setAssetIds(managerDemoSetup.apartment1LivingroomId),
+ new AssetFilter<AttributeEvent>().setAssetIds(managerTestSetup.apartment1LivingroomId),
"1",
null)))
@@ -148,7 +148,7 @@ class WebsocketClientTest extends Specification implements ManagerContainerTrait
when: "when apartment 1 living room temp changes"
receivedMessages.clear()
- assetProcessingService.sendAttributeEvent(new AttributeEvent(managerDemoSetup.apartment1LivingroomId, "targetTemperature", Values.create(5)))
+ assetProcessingService.sendAttributeEvent(new AttributeEvent(managerTestSetup.apartment1LivingroomId, "targetTemperature", Values.create(5)))
then: "the client receives the event"
conditions.eventually {
@@ -156,7 +156,7 @@ class WebsocketClientTest extends Specification implements ManagerContainerTrait
def triggeredEvent = messageFromString(receivedMessages[0], TriggeredEventSubscription.MESSAGE_PREFIX, TriggeredEventSubscription.class)
assert triggeredEvent.subscriptionId == "1"
assert triggeredEvent.events.size() == 1
- assert ((AttributeEvent)triggeredEvent.events[0]).entityId == managerDemoSetup.apartment1LivingroomId
+ assert ((AttributeEvent)triggeredEvent.events[0]).entityId == managerTestSetup.apartment1LivingroomId
assert ((AttributeEvent)triggeredEvent.events[0]).attributeName == "targetTemperature"
assert ((AttributeEvent)triggeredEvent.events[0]).value.flatMap{Values.getNumber(it)}.orElse(0) == 5
}
@@ -166,7 +166,7 @@ class WebsocketClientTest extends Specification implements ManagerContainerTrait
and: "when apartment 1 living room temp is set to the same value again"
receivedMessages.clear()
- assetProcessingService.sendAttributeEvent(new AttributeEvent(managerDemoSetup.apartment1LivingroomId, "targetTemperature", Values.create(5)))
+ assetProcessingService.sendAttributeEvent(new AttributeEvent(managerTestSetup.apartment1LivingroomId, "targetTemperature", Values.create(5)))
then: "the client should receive the event"
conditions.eventually {
@@ -174,7 +174,7 @@ class WebsocketClientTest extends Specification implements ManagerContainerTrait
def triggeredEvent = messageFromString(receivedMessages[0], TriggeredEventSubscription.MESSAGE_PREFIX, TriggeredEventSubscription.class)
assert triggeredEvent.subscriptionId == "1"
assert triggeredEvent.events.size() == 1
- assert ((AttributeEvent)triggeredEvent.events[0]).entityId == managerDemoSetup.apartment1LivingroomId
+ assert ((AttributeEvent)triggeredEvent.events[0]).entityId == managerTestSetup.apartment1LivingroomId
assert ((AttributeEvent)triggeredEvent.events[0]).attributeName == "targetTemperature"
assert ((AttributeEvent)triggeredEvent.events[0]).value.flatMap{Values.getNumber(it)}.orElse(0) == 5
}
@@ -184,7 +184,7 @@ class WebsocketClientTest extends Specification implements ManagerContainerTrait
and: "when apartment 1 living room temp is set to null"
receivedMessages.clear()
- assetProcessingService.sendAttributeEvent(new AttributeEvent(managerDemoSetup.apartment1LivingroomId, "targetTemperature", null))
+ assetProcessingService.sendAttributeEvent(new AttributeEvent(managerTestSetup.apartment1LivingroomId, "targetTemperature", null))
then: "the client receives the event"
conditions.eventually {
@@ -192,7 +192,7 @@ class WebsocketClientTest extends Specification implements ManagerContainerTrait
def triggeredEvent = messageFromString(receivedMessages[0], TriggeredEventSubscription.MESSAGE_PREFIX, TriggeredEventSubscription.class)
assert triggeredEvent.subscriptionId == "1"
assert triggeredEvent.events.size() == 1
- assert ((AttributeEvent)triggeredEvent.events[0]).entityId == managerDemoSetup.apartment1LivingroomId
+ assert ((AttributeEvent)triggeredEvent.events[0]).entityId == managerTestSetup.apartment1LivingroomId
assert ((AttributeEvent)triggeredEvent.events[0]).attributeName == "targetTemperature"
assert !((AttributeEvent)triggeredEvent.events[0]).value.isPresent()
}
@@ -202,11 +202,11 @@ class WebsocketClientTest extends Specification implements ManagerContainerTrait
and: "when apartment 1 bathroom temp changes"
receivedMessages.clear()
- assetProcessingService.sendAttributeEvent(new AttributeEvent(managerDemoSetup.apartment1BathroomId, "targetTemperature", Values.create(10)))
+ assetProcessingService.sendAttributeEvent(new AttributeEvent(managerTestSetup.apartment1BathroomId, "targetTemperature", Values.create(10)))
then: "the bathroom target temp should have changed"
conditions.eventually {
- def bathroom = assetStorageService.find(managerDemoSetup.apartment1BathroomId)
+ def bathroom = assetStorageService.find(managerTestSetup.apartment1BathroomId)
assert bathroom.getAttribute("targetTemperature").flatMap{it.getValueAsNumber()}.orElse(0d) == 10d
}
@@ -234,8 +234,8 @@ class WebsocketClientTest extends Specification implements ManagerContainerTrait
when: "an existing protocol configuration is disabled"
receivedMessages.clear()
- def agent = assetStorageService.find(managerDemoSetup.agentId, true)
- agent.getAttribute(managerDemoSetup.agentProtocolConfigName).get().addMeta(
+ def agent = assetStorageService.find(managerTestSetup.agentId, true)
+ agent.getAttribute(managerTestSetup.agentProtocolConfigName).get().addMeta(
new MetaItem(MetaItemType.DISABLED)
)
agent = assetStorageService.merge(agent)
@@ -248,14 +248,14 @@ class WebsocketClientTest extends Specification implements ManagerContainerTrait
assert waitingEvent.subscriptionId == "2"
assert waitingEvent.events.size() == 1
assert waitingEvent.events[0] instanceof AgentStatusEvent
- assert (waitingEvent.events[0] as AgentStatusEvent).protocolConfiguration.entityId == managerDemoSetup.agentId
- assert (waitingEvent.events[0] as AgentStatusEvent).protocolConfiguration.attributeName == managerDemoSetup.agentProtocolConfigName
+ assert (waitingEvent.events[0] as AgentStatusEvent).protocolConfiguration.entityId == managerTestSetup.agentId
+ assert (waitingEvent.events[0] as AgentStatusEvent).protocolConfiguration.attributeName == managerTestSetup.agentProtocolConfigName
assert (waitingEvent.events[0] as AgentStatusEvent).connectionStatus == ConnectionStatus.WAITING
assert disabledEvent.subscriptionId == "2"
assert disabledEvent.events.size() == 1
assert disabledEvent.events[0] instanceof AgentStatusEvent
- assert (disabledEvent.events[0] as AgentStatusEvent).protocolConfiguration.entityId == managerDemoSetup.agentId
- assert (disabledEvent.events[0] as AgentStatusEvent).protocolConfiguration.attributeName == managerDemoSetup.agentProtocolConfigName
+ assert (disabledEvent.events[0] as AgentStatusEvent).protocolConfiguration.entityId == managerTestSetup.agentId
+ assert (disabledEvent.events[0] as AgentStatusEvent).protocolConfiguration.attributeName == managerTestSetup.agentProtocolConfigName
assert (disabledEvent.events[0] as AgentStatusEvent).connectionStatus == ConnectionStatus.DISABLED
}
@@ -267,7 +267,7 @@ class WebsocketClientTest extends Specification implements ManagerContainerTrait
"2")))
and: "the existing protocol configuration is re-enabled"
- agent.getAttribute(managerDemoSetup.agentProtocolConfigName).get().getMeta().removeIf(
+ agent.getAttribute(managerTestSetup.agentProtocolConfigName).get().getMeta().removeIf(
isMetaNameEqualTo(MetaItemType.DISABLED)
)
agent = assetStorageService.merge(agent)
@@ -275,7 +275,7 @@ class WebsocketClientTest extends Specification implements ManagerContainerTrait
then: "the protocol should be CONNECTED but no new events should have been received"
conditions.eventually {
assert agentService.getProtocolConnectionStatus(
- new AttributeRef(managerDemoSetup.agentId, managerDemoSetup.agentProtocolConfigName)
+ new AttributeRef(managerTestSetup.agentId, managerTestSetup.agentProtocolConfigName)
) == ConnectionStatus.CONNECTED
assert receivedMessages.isEmpty()
}
diff --git a/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovy b/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovy
index c13e2793b..e88542156 100644
--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovy
@@ -7,8 +7,8 @@ import org.openremote.manager.rules.RulesService
import org.openremote.manager.rules.RulesetStorageService
import org.openremote.manager.security.ManagerIdentityService
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.KeycloakDemoSetup
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.KeycloakTestSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.rules.AssetRuleset
import org.openremote.model.rules.GlobalRuleset
import org.openremote.model.rules.Ruleset
@@ -35,14 +35,14 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
and: "the container is started"
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
- def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
+ def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
def rulesService = container.getService(RulesService.class)
def identityService = container.getService(ManagerIdentityService.class)
def rulesetStorageService = container.getService(RulesetStorageService.class)
and: "some test rulesets have been imported"
- def rulesImport = new BasicRulesImport(rulesetStorageService, keycloakDemoSetup, managerDemoSetup)
+ def rulesImport = new BasicRulesImport(rulesetStorageService, keycloakTestSetup, managerTestSetup)
and: "an authenticated user"
def accessToken = authenticate(
@@ -55,7 +55,7 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
expect: "the rules engines to be ready"
new PollingConditions(timeout: 10, delay: 0.2).eventually {
- rulesImport.assertEnginesReady(rulesService, keycloakDemoSetup, managerDemoSetup)
+ rulesImport.assertEnginesReady(rulesService, keycloakTestSetup, managerTestSetup)
}
when: "a new global rule definition is added"
@@ -76,7 +76,7 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
when: "a new tenant rule definition is added to Building"
ruleset = new TenantRuleset(
- keycloakDemoSetup.tenantBuilding.realm,
+ keycloakTestSetup.tenantBuilding.realm,
"Some more building tenant rules",
GROOVY,
getClass().getResource("/org/openremote/test/rules/BasicMatchAllAssetStates2.groovy").text)
@@ -84,7 +84,7 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
then: "Building rules engine should load this definition and restart successfully"
conditions.eventually {
- def tenantBuildingEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuilding.realm)
+ def tenantBuildingEngine = rulesService.tenantEngines.get(keycloakTestSetup.tenantBuilding.realm)
assert tenantBuildingEngine != null
assert tenantBuildingEngine.isRunning()
assert tenantBuildingEngine.deployments.size() == 2
@@ -94,7 +94,7 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
when: "a new tenant rule definition is added to City"
ruleset = new TenantRuleset(
- keycloakDemoSetup.tenantCity.realm,
+ keycloakTestSetup.tenantCity.realm,
"Some more smartcity tenant rules",
GROOVY,
getClass().getResource("/org/openremote/test/rules/BasicMatchAllAssetStates2.groovy").text)
@@ -102,7 +102,7 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
then: "a tenant rules engine should be created for City and load this definition and start successfully"
conditions.eventually {
- def tenantCity = rulesService.tenantEngines.get(keycloakDemoSetup.tenantCity.realm)
+ def tenantCity = rulesService.tenantEngines.get(keycloakTestSetup.tenantCity.realm)
assert rulesService.tenantEngines.size() == 3
assert tenantCity != null
assert tenantCity.isRunning()
@@ -117,7 +117,7 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
then: "City rule engine should load this definition and restart successfully"
conditions.eventually {
- def tenantCity = rulesService.tenantEngines.get(keycloakDemoSetup.tenantCity.realm)
+ def tenantCity = rulesService.tenantEngines.get(keycloakTestSetup.tenantCity.realm)
assert rulesService.tenantEngines.size() == 3
assert tenantCity != null
assert tenantCity.isRunning()
@@ -134,7 +134,7 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
then: "City rule engine should remove it again"
conditions.eventually {
- def tenantCity = rulesService.tenantEngines.get(keycloakDemoSetup.tenantCity.realm)
+ def tenantCity = rulesService.tenantEngines.get(keycloakTestSetup.tenantCity.realm)
assert tenantCity != null
assert tenantCity.isRunning()
assert tenantCity.deployments.size() == 1
@@ -147,8 +147,8 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
then: "the apartment rules engine should be removed"
conditions.eventually {
assert rulesService.assetEngines.size() == 1
- def apartment2Engine = rulesService.assetEngines.get(managerDemoSetup.apartment2Id)
- def apartment3Engine = rulesService.assetEngines.get(managerDemoSetup.apartment3Id)
+ def apartment2Engine = rulesService.assetEngines.get(managerTestSetup.apartment2Id)
+ def apartment3Engine = rulesService.assetEngines.get(managerTestSetup.apartment3Id)
assert apartment2Engine == null
assert apartment3Engine != null
assert apartment3Engine.isRunning()
@@ -185,9 +185,9 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
}
when: "a tenant is disabled"
- def tenantBuildingEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuilding.realm)
- def apartment3Engine = rulesService.assetEngines.get(managerDemoSetup.apartment3Id)
- def tenantBuildingTenant = keycloakDemoSetup.tenantBuilding
+ def tenantBuildingEngine = rulesService.tenantEngines.get(keycloakTestSetup.tenantBuilding.realm)
+ def apartment3Engine = rulesService.assetEngines.get(managerTestSetup.apartment3Id)
+ def tenantBuildingTenant = keycloakTestSetup.tenantBuilding
tenantBuildingTenant.setEnabled(false)
identityService.getIdentityProvider().updateTenant(tenantBuildingTenant)
@@ -195,18 +195,18 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
conditions.eventually {
assert !tenantBuildingEngine.isRunning()
assert tenantBuildingEngine.deployments.size() == 2
- assert rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuilding.realm) == null
+ assert rulesService.tenantEngines.get(keycloakTestSetup.tenantBuilding.realm) == null
assert !apartment3Engine.isRunning()
assert apartment3Engine.deployments.size() == 1
- assert rulesService.assetEngines.get(managerDemoSetup.apartment3Id) == null
+ assert rulesService.assetEngines.get(managerTestSetup.apartment3Id) == null
}
and: "other rule engines should be unaffected"
conditions.eventually {
assert rulesService.tenantEngines.size() == 2
assert rulesService.assetEngines.size() == 0
- def masterEngine = rulesService.tenantEngines.get(keycloakDemoSetup.masterTenant.realm)
- def cityEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantCity.realm)
+ def masterEngine = rulesService.tenantEngines.get(keycloakTestSetup.masterTenant.realm)
+ def cityEngine = rulesService.tenantEngines.get(keycloakTestSetup.tenantCity.realm)
assert masterEngine != null
assert masterEngine.isRunning()
assert cityEngine != null
@@ -219,8 +219,8 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
then: "the tenants rule engine should start and all asset rule engines from this realm should also start"
conditions.eventually {
- tenantBuildingEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuilding.realm)
- apartment3Engine = rulesService.assetEngines.get(managerDemoSetup.apartment3Id)
+ tenantBuildingEngine = rulesService.tenantEngines.get(keycloakTestSetup.tenantBuilding.realm)
+ apartment3Engine = rulesService.assetEngines.get(managerTestSetup.apartment3Id)
assert rulesService.tenantEngines.size() == 3
assert rulesService.assetEngines.size() == 1
assert tenantBuildingEngine != null
@@ -234,7 +234,7 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
when: "a new tenant rule definition is added to Building"
ruleset = new TenantRuleset(
- keycloakDemoSetup.tenantBuilding.realm,
+ keycloakTestSetup.tenantBuilding.realm,
"Throw Failure Exception",
GROOVY,
getClass().getResource("/org/openremote/test/failure/RulesFailureActionThrowsException.groovy").text)
@@ -243,7 +243,7 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
then: "the tenants A rule engine should run with one deployment as error"
conditions.eventually {
- tenantBuildingEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuilding.realm)
+ tenantBuildingEngine = rulesService.tenantEngines.get(keycloakTestSetup.tenantBuilding.realm)
assert tenantBuildingEngine != null
assert tenantBuildingEngine.isRunning()
assert tenantBuildingEngine.deployments.size() == 3
@@ -253,7 +253,7 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
when: "a new tenant rule definition is added to Building"
ruleset = new TenantRuleset(
- keycloakDemoSetup.tenantBuilding.realm,
+ keycloakTestSetup.tenantBuilding.realm,
"Looping error",
GROOVY,
getClass().getResource("/org/openremote/test/failure/RulesFailureLoop.groovy").text)
@@ -262,7 +262,7 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
then: "the tenants A rule engine should have an error"
conditions.eventually {
- tenantBuildingEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuilding.realm)
+ tenantBuildingEngine = rulesService.tenantEngines.get(keycloakTestSetup.tenantBuilding.realm)
assert tenantBuildingEngine != null
assert !tenantBuildingEngine.isRunning()
assert tenantBuildingEngine.deployments.size() == 4
@@ -281,13 +281,13 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
// conditions.eventually {
// assert tenantBuildingEngine.isRunning() == false
// assert tenantBuildingEngine.allRulesets.length == 0
-// assert rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuildingTenant.id) == null
+// assert rulesService.tenantEngines.get(keycloakTestSetup.tenantBuildingTenant.id) == null
// assert smartHomeEngine.isRunning() == false
// assert smartHomeEngine.allRulesets.length == 0
-// assert rulesService.assetEngines.get(managerDemoSetup.smartBuildingId) == null
+// assert rulesService.assetEngines.get(managerTestSetup.smartBuildingId) == null
// assert apartment3Engine.isRunning() == false
// assert apartment3Engine.allRulesets.length == 0
-// assert rulesService.assetEngines.get(managerDemoSetup.apartment3Id) == null
+// assert rulesService.assetEngines.get(managerTestSetup.apartment3Id) == null
// }
//
// and: "other rule engines should be unaffected"
@@ -295,7 +295,7 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
// assert rulesService.tenantEngines.size() == 2
// assert rulesService.assetEngines.size() == 0
// def masterEngine = rulesService.tenantEngines.get(Constants.MASTER_REALM)
-// def tenantCity = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBTenant.id)
+// def tenantCity = rulesService.tenantEngines.get(keycloakTestSetup.tenantBTenant.id)
// assert masterEngine != null
// assert masterEngine.isRunning()
// assert tenantCity != null
diff --git a/test/src/test/groovy/org/openremote/test/rules/BasicRulesImport.groovy b/test/src/test/groovy/org/openremote/test/rules/BasicRulesImport.groovy
index d505ba837..115ce2632 100644
--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesImport.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesImport.groovy
@@ -3,8 +3,9 @@ package org.openremote.test.rules
import org.openremote.manager.rules.RulesEngine
import org.openremote.manager.rules.RulesService
import org.openremote.manager.rules.RulesetStorageService
-import org.openremote.manager.setup.builtin.KeycloakDemoSetup
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.KeycloakTestSetup
+import org.openremote.manager.setup.builtin.KeycloakTestSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.rules.AssetRuleset
import org.openremote.model.rules.GlobalRuleset
import org.openremote.model.rules.Ruleset
@@ -33,8 +34,8 @@ class BasicRulesImport {
RulesEngine apartment3Engine
BasicRulesImport(RulesetStorageService rulesetStorageService,
- KeycloakDemoSetup keycloakDemoSetup,
- ManagerDemoSetup managerDemoSetup) {
+ KeycloakTestSetup keycloakTestSetup,
+ ManagerTestSetup managerTestSetup) {
Ruleset ruleset = new GlobalRuleset(
"Some global demo rules", GROOVY,
@@ -48,21 +49,21 @@ class BasicRulesImport {
globalRuleset2Id = rulesetStorageService.merge(ruleset).id
ruleset = new TenantRuleset(
- keycloakDemoSetup.masterTenant.realm,
+ keycloakTestSetup.masterTenant.realm,
"Some master tenant demo rules",
GROOVY,
getClass().getResource("/org/openremote/test/rules/BasicMatchAllAssetStates.groovy").text)
masterRulesetId = rulesetStorageService.merge(ruleset).id
ruleset = new TenantRuleset(
- keycloakDemoSetup.tenantBuilding.realm,
+ keycloakTestSetup.tenantBuilding.realm,
"Some building tenant demo rules",
GROOVY,
getClass().getResource("/org/openremote/test/rules/BasicMatchAllAssetStates.groovy").text)
tenantBuildingRulesetId = rulesetStorageService.merge(ruleset).id
ruleset = new TenantRuleset(
- keycloakDemoSetup.tenantCity.realm,
+ keycloakTestSetup.tenantCity.realm,
"Some smartcity tenant demo rules",
GROOVY,
getClass().getResource("/org/openremote/test/rules/BasicMatchAllAssetStates.groovy").text)
@@ -70,7 +71,7 @@ class BasicRulesImport {
tenantCityRulesetId = rulesetStorageService.merge(ruleset).id
ruleset = new AssetRuleset(
- managerDemoSetup.apartment1Id,
+ managerTestSetup.apartment1Id,
"Some apartment 1 demo rules",
GROOVY,
getClass().getResource("/org/openremote/test/rules/BasicMatchAllAssetStates.groovy").text)
@@ -78,7 +79,7 @@ class BasicRulesImport {
apartment1RulesetId = rulesetStorageService.merge(ruleset).id
ruleset = new AssetRuleset(
- managerDemoSetup.apartment2Id,
+ managerTestSetup.apartment2Id,
"Some apartment 2 demo rules",
GROOVY,
getClass().getResource("/org/openremote/test/rules/BasicMatchAllAssetStates.groovy").text)
@@ -86,7 +87,7 @@ class BasicRulesImport {
apartment2RulesetId = rulesetStorageService.merge(ruleset).id
ruleset = new AssetRuleset(
- managerDemoSetup.apartment3Id,
+ managerTestSetup.apartment3Id,
"Some apartment 3 demo rules",
GROOVY,
getClass().getResource("/org/openremote/test/rules/BasicMatchAllAssetStates.groovy").text)
@@ -95,8 +96,8 @@ class BasicRulesImport {
@SuppressWarnings("GroovyAccessibility")
boolean assertEnginesReady(RulesService rulesService,
- KeycloakDemoSetup keycloakDemoSetup,
- ManagerDemoSetup managerDemoSetup) {
+ KeycloakTestSetup keycloakTestSetup,
+ ManagerTestSetup managerTestSetup) {
globalEngine = rulesService.globalEngine
globalEngine.disableTemporaryFactExpiration = true
@@ -106,34 +107,34 @@ class BasicRulesImport {
assert globalEngine.deployments.values().any { it -> it.name == "Some global demo rules" && it.status == DEPLOYED }
assert rulesService.tenantEngines.size() == 2
- masterEngine = rulesService.tenantEngines.get(keycloakDemoSetup.masterTenant.realm)
+ masterEngine = rulesService.tenantEngines.get(keycloakTestSetup.masterTenant.realm)
masterEngine.disableTemporaryFactExpiration = true
assert masterEngine != null
assert masterEngine.isRunning()
assert masterEngine.deployments.size() == 1
assert masterEngine.deployments.values().iterator().next().name == "Some master tenant demo rules"
assert masterEngine.deployments.values().iterator().next().status == DEPLOYED
- tenantBuildingEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuilding.realm)
+ tenantBuildingEngine = rulesService.tenantEngines.get(keycloakTestSetup.tenantBuilding.realm)
assert tenantBuildingEngine != null
tenantBuildingEngine.disableTemporaryFactExpiration = true
assert tenantBuildingEngine.isRunning()
assert tenantBuildingEngine.deployments.size() == 1
assert tenantBuildingEngine.deployments.values().iterator().next().name == "Some building tenant demo rules"
assert tenantBuildingEngine.deployments.values().iterator().next().status == DEPLOYED
- def tenantCityEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantCity.realm)
+ def tenantCityEngine = rulesService.tenantEngines.get(keycloakTestSetup.tenantCity.realm)
assert tenantCityEngine == null
assert rulesService.assetEngines.size() == 2
- apartment1Engine = rulesService.assetEngines.get(managerDemoSetup.apartment1Id)
+ apartment1Engine = rulesService.assetEngines.get(managerTestSetup.apartment1Id)
assert apartment1Engine == null
- apartment2Engine = rulesService.assetEngines.get(managerDemoSetup.apartment2Id)
+ apartment2Engine = rulesService.assetEngines.get(managerTestSetup.apartment2Id)
assert apartment2Engine != null
apartment2Engine.disableTemporaryFactExpiration = true
assert apartment2Engine.isRunning()
assert apartment2Engine.deployments.size() == 1
assert apartment2Engine.deployments.values().iterator().next().name == "Some apartment 2 demo rules"
assert apartment2Engine.deployments.values().iterator().next().status == DEPLOYED
- apartment3Engine = rulesService.assetEngines.get(managerDemoSetup.apartment3Id)
+ apartment3Engine = rulesService.assetEngines.get(managerTestSetup.apartment3Id)
assert apartment3Engine != null
apartment3Engine.disableTemporaryFactExpiration = true
assert apartment3Engine.isRunning()
diff --git a/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy b/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy
index 1b0917194..e5a9127e6 100644
--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy
@@ -7,8 +7,8 @@ import org.openremote.manager.rules.RulesEngine
import org.openremote.manager.rules.RulesService
import org.openremote.manager.rules.RulesetStorageService
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.KeycloakDemoSetup
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.KeycloakTestSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.asset.Asset
import org.openremote.model.asset.AssetAttribute
import org.openremote.model.asset.AssetType
@@ -24,7 +24,7 @@ import spock.util.concurrent.PollingConditions
import java.util.concurrent.TimeUnit
-import static org.openremote.manager.setup.builtin.ManagerDemoSetup.*
+import static org.openremote.manager.setup.builtin.ManagerTestSetup.*
import static org.openremote.model.rules.RulesetStatus.*
import static org.openremote.test.rules.BasicRulesImport.assertRulesFired
@@ -38,18 +38,18 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
- def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
+ def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
def rulesService = container.getService(RulesService.class)
def rulesetStorageService = container.getService(RulesetStorageService.class)
def assetProcessingService = container.getService(AssetProcessingService.class)
and: "some test rulesets have been imported"
- def rulesImport = new BasicRulesImport(rulesetStorageService, keycloakDemoSetup, managerDemoSetup)
+ def rulesImport = new BasicRulesImport(rulesetStorageService, keycloakTestSetup, managerTestSetup)
expect: "the rules engines to be ready"
conditions.eventually {
- assert rulesImport.assertEnginesReady(rulesService, keycloakDemoSetup, managerDemoSetup)
+ assert rulesImport.assertEnginesReady(rulesService, keycloakTestSetup, managerTestSetup)
assert noRuleEngineFiringScheduled()
}
@@ -65,7 +65,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
when: "a LHS filtering test rule definition is loaded into the Smart Building asset"
def assetRuleset = new AssetRuleset(
- managerDemoSetup.smartBuildingId,
+ managerTestSetup.smartBuildingId,
"Some Smart Building asset rules",
Ruleset.Lang.GROOVY,
getClass().getResource("/org/openremote/test/rules/BasicSmartHomeMatchAllAssetStates.groovy").text)
@@ -74,7 +74,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
then: "the Smart Building rule engine should have ben created, loaded the new rule definition and facts and started"
conditions.eventually {
- smartHomeEngine = rulesService.assetEngines.get(managerDemoSetup.smartBuildingId)
+ smartHomeEngine = rulesService.assetEngines.get(managerTestSetup.smartBuildingId)
assert smartHomeEngine != null
assert smartHomeEngine.isRunning()
assert smartHomeEngine.deployments.size() == 1
@@ -100,7 +100,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
when: "an attribute event occurs"
rulesImport.resetRulesFired(smartHomeEngine)
def apartment2LivingRoomPresenceDetectedChange = new AttributeEvent(
- managerDemoSetup.apartment2LivingroomId, "presenceDetected", Values.create(true)
+ managerTestSetup.apartment2LivingroomId, "presenceDetected", Values.create(true)
)
assetProcessingService.sendAttributeEvent(apartment2LivingRoomPresenceDetectedChange)
@@ -129,26 +129,26 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
- def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
+ def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
def rulesService = container.getService(RulesService.class)
def rulesetStorageService = container.getService(RulesetStorageService.class)
def assetStorageService = container.getService(AssetStorageService.class)
def assetProcessingService = container.getService(AssetProcessingService.class)
and: "some test rulesets have been imported"
- def rulesImport = new BasicRulesImport(rulesetStorageService, keycloakDemoSetup, managerDemoSetup)
+ def rulesImport = new BasicRulesImport(rulesetStorageService, keycloakTestSetup, managerTestSetup)
expect: "the rules engines to be ready"
conditions.eventually {
- assert rulesImport.assertEnginesReady(rulesService, keycloakDemoSetup, managerDemoSetup)
+ assert rulesImport.assertEnginesReady(rulesService, keycloakTestSetup, managerTestSetup)
assert noRuleEngineFiringScheduled()
}
when: "a Kitchen room asset is inserted into apartment that contains a RULE_STATE = true meta flag"
- def apartment2 = assetStorageService.find(managerDemoSetup.apartment2Id)
+ def apartment2 = assetStorageService.find(managerTestSetup.apartment2Id)
def asset = new Asset("Kitchen", AssetType.ROOM, apartment2)
- asset.setRealm(keycloakDemoSetup.tenantBuilding.getRealm())
+ asset.setRealm(keycloakTestSetup.tenantBuilding.getRealm())
def attributes = [
new AssetAttribute("testString", AttributeValueType.STRING, Values.create("test"))
.setMeta(
@@ -202,13 +202,13 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
def apartment2LastFireTimestamp = rulesImport.apartment2Engine.lastFireTimestamp
def apartment3LastFireTimestamp = rulesImport.apartment3Engine.lastFireTimestamp
def apartment2LivingRoomWindowOpenChange = new AttributeEvent(
- managerDemoSetup.apartment2LivingroomId, "windowOpen", Values.create(true)
+ managerTestSetup.apartment2LivingroomId, "windowOpen", Values.create(true)
)
assetProcessingService.sendAttributeEvent(apartment2LivingRoomWindowOpenChange)
then: "the attribute event should have been processed"
conditions.eventually {
- def apartment2LivingRoom = assetStorageService.find(managerDemoSetup.apartment2LivingroomId, true)
+ def apartment2LivingRoom = assetStorageService.find(managerTestSetup.apartment2LivingroomId, true)
assert apartment2LivingRoom.getAttribute("windowOpen").flatMap{it.getValueAsBoolean()}.orElse(false)
}
@@ -358,24 +358,24 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
- def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
+ def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
def rulesService = container.getService(RulesService.class)
def rulesetStorageService = container.getService(RulesetStorageService.class)
def assetProcessingService = container.getService(AssetProcessingService.class)
and: "some test rulesets have been imported"
- def rulesImport = new BasicRulesImport(rulesetStorageService, keycloakDemoSetup, managerDemoSetup)
+ def rulesImport = new BasicRulesImport(rulesetStorageService, keycloakTestSetup, managerTestSetup)
expect: "the rules engines to be ready"
conditions.eventually {
- assert rulesImport.assertEnginesReady(rulesService, keycloakDemoSetup, managerDemoSetup)
+ assert rulesImport.assertEnginesReady(rulesService, keycloakTestSetup, managerTestSetup)
assert noRuleEngineFiringScheduled()
}
when: "a broken RHS rule is loaded into the building engine"
def ruleset = new TenantRuleset(
- keycloakDemoSetup.tenantBuilding.realm,
+ keycloakTestSetup.tenantBuilding.realm,
"Some broken test rules",
Ruleset.Lang.GROOVY,
getClass().getResource("/org/openremote/test/rules/BasicBrokenRules.groovy").text)
@@ -405,7 +405,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
def apartment2LastFireTimestamp = rulesImport.apartment2Engine.lastFireTimestamp
def apartment3LastFireTimestamp = rulesImport.apartment3Engine.lastFireTimestamp
def apartment2LivingRoomPresenceDetectedChange = new AttributeEvent(
- managerDemoSetup.apartment2LivingroomId, "presenceDetected", Values.create(true)
+ managerTestSetup.apartment2LivingroomId, "presenceDetected", Values.create(true)
)
assetProcessingService.sendAttributeEvent(apartment2LivingRoomPresenceDetectedChange)
diff --git a/test/src/test/groovy/org/openremote/test/rules/BasicRulesTimedExecutionTest.groovy b/test/src/test/groovy/org/openremote/test/rules/BasicRulesTimedExecutionTest.groovy
index df905ca2c..d3a5236b2 100644
--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesTimedExecutionTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesTimedExecutionTest.groovy
@@ -12,7 +12,7 @@ import spock.lang.Specification
import spock.util.concurrent.PollingConditions
import static java.util.concurrent.TimeUnit.SECONDS
-import static org.openremote.manager.setup.builtin.ManagerDemoSetup.DEMO_RULE_STATES_GLOBAL
+import static org.openremote.manager.setup.builtin.ManagerTestSetup.DEMO_RULE_STATES_GLOBAL
@Ignore // TODO Implement timer/deferred actions in rules engine
class BasicRulesTimedExecutionTest extends Specification implements ManagerContainerTrait {
diff --git a/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy b/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy
index daee5e1a2..ebe5a03bb 100644
--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy
@@ -3,8 +3,8 @@ package org.openremote.test.rules
import org.openremote.manager.rules.RulesService
import org.openremote.manager.rules.RulesetStorageService
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.KeycloakDemoSetup
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.KeycloakTestSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.rules.AssetRuleset
import org.openremote.model.rules.GlobalRuleset
import org.openremote.model.rules.RulesResource
@@ -32,11 +32,11 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def rulesetStorageService = container.getService(RulesetStorageService.class)
def rulesService = container.getService(RulesService.class)
- def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
and: "some test rulesets have been imported"
- def rulesImport = new BasicRulesImport(rulesetStorageService, keycloakDemoSetup, managerDemoSetup)
+ def rulesImport = new BasicRulesImport(rulesetStorageService, keycloakTestSetup, managerTestSetup)
and: "an authenticated admin user"
def accessToken = authenticate(
@@ -52,7 +52,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
expect: "the rules engines to be ready"
new PollingConditions(timeout: 10, delay: 0.2).eventually {
- rulesImport.assertEnginesReady(rulesService, keycloakDemoSetup, managerDemoSetup)
+ rulesImport.assertEnginesReady(rulesService, keycloakTestSetup, managerTestSetup)
}
/* ############################################## READ ####################################### */
@@ -67,7 +67,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ruleDefinitions[0].rules == null // Don't retrieve the (large) rules data when getting a list of rule definitions
when: "some tenant rules are retrieved"
- ruleDefinitions = rulesetResource.getTenantRulesets(null, keycloakDemoSetup.masterTenant.realm, null, false)
+ ruleDefinitions = rulesetResource.getTenantRulesets(null, keycloakTestSetup.masterTenant.realm, null, false)
then: "result should match"
ruleDefinitions.length == 1
@@ -75,7 +75,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ruleDefinitions[0].lang == GROOVY
when: "some tenant rules in a non-authenticated realm are retrieved"
- ruleDefinitions = rulesetResource.getTenantRulesets(null, keycloakDemoSetup.tenantBuilding.realm, null, false)
+ ruleDefinitions = rulesetResource.getTenantRulesets(null, keycloakTestSetup.tenantBuilding.realm, null, false)
then: "result should match"
ruleDefinitions.length == 1
@@ -83,7 +83,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ruleDefinitions[0].enabled
when: "some asset rules are retrieved"
- ruleDefinitions = rulesetResource.getAssetRulesets(null, managerDemoSetup.apartment2Id, null, false)
+ ruleDefinitions = rulesetResource.getAssetRulesets(null, managerTestSetup.apartment2Id, null, false)
then: "result should match"
ruleDefinitions.length == 1
@@ -139,9 +139,9 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 404
when: "a tenant ruleset is created in the authenticated realm"
- def tenantRuleset = new TenantRuleset(keycloakDemoSetup.masterTenant.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
+ def tenantRuleset = new TenantRuleset(keycloakTestSetup.masterTenant.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
rulesetResource.createTenantRuleset(null, tenantRuleset)
- rulesetId = rulesetResource.getTenantRulesets(null, keycloakDemoSetup.masterTenant.realm, null, false)[1].id
+ rulesetId = rulesetResource.getTenantRulesets(null, keycloakTestSetup.masterTenant.realm, null, false)[1].id
tenantRuleset = rulesetResource.getTenantRuleset(null, rulesetId)
lastModified = tenantRuleset.lastModified
@@ -152,7 +152,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
lastModified.time < System.currentTimeMillis()
tenantRuleset.name == "Test tenant definition"
tenantRuleset.rules == "SomeRulesCode"
- tenantRuleset.realm == keycloakDemoSetup.masterTenant.realm
+ tenantRuleset.realm == keycloakTestSetup.masterTenant.realm
when: "a tenant ruleset is updated"
tenantRuleset.name = "Renamed test tenant definition"
@@ -167,7 +167,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
lastModified.time < System.currentTimeMillis()
tenantRuleset.name == "Renamed test tenant definition"
tenantRuleset.rules == "SomeRulesCodeModified"
- tenantRuleset.realm == keycloakDemoSetup.masterTenant.realm
+ tenantRuleset.realm == keycloakTestSetup.masterTenant.realm
when: "a tenant ruleset is updated with an invalid realm"
tenantRuleset.realm = "thisdoesnotexist"
@@ -178,7 +178,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 400
when: "a tenant ruleset is updated with an invalid id"
- tenantRuleset.realm = keycloakDemoSetup.masterTenant.realm
+ tenantRuleset.realm = keycloakTestSetup.masterTenant.realm
tenantRuleset.id = 1234567890l
rulesetResource.updateTenantRuleset(null, rulesetId, tenantRuleset)
@@ -202,9 +202,9 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 404
when: "a tenant ruleset is created in a non-authenticated realm"
- tenantRuleset = new TenantRuleset(keycloakDemoSetup.tenantBuilding.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
+ tenantRuleset = new TenantRuleset(keycloakTestSetup.tenantBuilding.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
rulesetResource.createTenantRuleset(null, tenantRuleset)
- rulesetId = rulesetResource.getTenantRulesets(null, keycloakDemoSetup.tenantBuilding.realm, null, false)[1].id
+ rulesetId = rulesetResource.getTenantRulesets(null, keycloakTestSetup.tenantBuilding.realm, null, false)[1].id
tenantRuleset = rulesetResource.getTenantRuleset(null, rulesetId)
lastModified = tenantRuleset.lastModified
@@ -215,12 +215,12 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
lastModified.time < System.currentTimeMillis()
tenantRuleset.name == "Test tenant definition"
tenantRuleset.rules == "SomeRulesCode"
- tenantRuleset.realm == keycloakDemoSetup.tenantBuilding.realm
+ tenantRuleset.realm == keycloakTestSetup.tenantBuilding.realm
when: "an asset ruleset is created in the authenticated realm"
- def assetRuleset = new AssetRuleset(managerDemoSetup.smartOfficeId, "Test asset definition", GROOVY, "SomeRulesCode")
+ def assetRuleset = new AssetRuleset(managerTestSetup.smartOfficeId, "Test asset definition", GROOVY, "SomeRulesCode")
rulesetResource.createAssetRuleset(null, assetRuleset)
- rulesetId = rulesetResource.getAssetRulesets(null, managerDemoSetup.smartOfficeId, null, false)[0].id
+ rulesetId = rulesetResource.getAssetRulesets(null, managerTestSetup.smartOfficeId, null, false)[0].id
assetRuleset = rulesetResource.getAssetRuleset(null, rulesetId)
lastModified = assetRuleset.lastModified
@@ -231,7 +231,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
lastModified.time < System.currentTimeMillis()
assetRuleset.name == "Test asset definition"
assetRuleset.rules == "SomeRulesCode"
- assetRuleset.assetId == managerDemoSetup.smartOfficeId
+ assetRuleset.assetId == managerTestSetup.smartOfficeId
when: "an asset ruleset is updated"
assetRuleset.name = "Renamed test asset definition"
@@ -246,7 +246,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
lastModified.time < System.currentTimeMillis()
assetRuleset.name == "Renamed test asset definition"
assetRuleset.rules == "SomeRulesCodeModified"
- assetRuleset.assetId == managerDemoSetup.smartOfficeId
+ assetRuleset.assetId == managerTestSetup.smartOfficeId
when: "an asset ruleset is updated with an invalid asset ID"
assetRuleset.assetId = "thisdoesnotexist"
@@ -257,7 +257,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 400
when: "an asset ruleset is updated with an invalid id"
- assetRuleset.assetId = managerDemoSetup.smartOfficeId
+ assetRuleset.assetId = managerTestSetup.smartOfficeId
assetRuleset.id = 1234567890l
rulesetResource.updateAssetRuleset(null, rulesetId, assetRuleset)
@@ -281,9 +281,9 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 404
when: "an asset ruleset is created in a non-authenticated realm"
- assetRuleset = new AssetRuleset(managerDemoSetup.apartment2Id, "Test asset definition", GROOVY, "SomeRulesCode")
+ assetRuleset = new AssetRuleset(managerTestSetup.apartment2Id, "Test asset definition", GROOVY, "SomeRulesCode")
rulesetResource.createAssetRuleset(null, assetRuleset)
- rulesetId = rulesetResource.getAssetRulesets(null, managerDemoSetup.apartment2Id, null, false)[1].id
+ rulesetId = rulesetResource.getAssetRulesets(null, managerTestSetup.apartment2Id, null, false)[1].id
assetRuleset = rulesetResource.getAssetRuleset(null, rulesetId)
lastModified = assetRuleset.lastModified
@@ -294,7 +294,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
lastModified.time < System.currentTimeMillis()
assetRuleset.name == "Test asset definition"
assetRuleset.rules == "SomeRulesCode"
- assetRuleset.assetId == managerDemoSetup.apartment2Id
+ assetRuleset.assetId == managerTestSetup.apartment2Id
cleanup: "the static rules time variable is reset"
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = expirationMillis
@@ -308,11 +308,11 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
def container = startContainer(defaultConfig(), defaultServices())
def rulesetStorageService = container.getService(RulesetStorageService.class)
def rulesService = container.getService(RulesService.class)
- def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
and: "some imported rulesets"
- def rulesImport = new BasicRulesImport(rulesetStorageService, keycloakDemoSetup, managerDemoSetup)
+ def rulesImport = new BasicRulesImport(rulesetStorageService, keycloakTestSetup, managerTestSetup)
and: "an authenticated test user"
def accessToken = authenticate(
@@ -328,7 +328,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
expect: "the rules engines to be ready"
new PollingConditions(timeout: 10, delay: 0.2).eventually {
- rulesImport.assertEnginesReady(rulesService, keycloakDemoSetup, managerDemoSetup)
+ rulesImport.assertEnginesReady(rulesService, keycloakTestSetup, managerTestSetup)
}
/* ############################################## READ ####################################### */
@@ -341,21 +341,21 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 403
when: "some tenant rules are retrieved"
- def ruleDefinitions = rulesetResource.getTenantRulesets(null, keycloakDemoSetup.masterTenant.realm, null, false)
+ def ruleDefinitions = rulesetResource.getTenantRulesets(null, keycloakTestSetup.masterTenant.realm, null, false)
then: "result should match"
ruleDefinitions.length == 1
ruleDefinitions[0].name == "Some master tenant demo rules"
when: "some tenant rules in a non-authenticated realm are retrieved"
- rulesetResource.getTenantRulesets(null, keycloakDemoSetup.tenantBuilding.realm, null, false)
+ rulesetResource.getTenantRulesets(null, keycloakTestSetup.tenantBuilding.realm, null, false)
then: "access should be forbidden"
ex = thrown()
ex.response.status == 403
when: "some asset rules in a non-authenticated realm are retrieved"
- rulesetResource.getAssetRulesets(null, managerDemoSetup.apartment2Id, null, false)
+ rulesetResource.getAssetRulesets(null, managerTestSetup.apartment2Id, null, false)
then: "access should be forbidden"
ex = thrown()
@@ -386,9 +386,9 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 403
when: "a tenant ruleset is created in the authenticated realm"
- def tenantRuleset = new TenantRuleset(keycloakDemoSetup.masterTenant.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
+ def tenantRuleset = new TenantRuleset(keycloakTestSetup.masterTenant.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
rulesetResource.createTenantRuleset(null, tenantRuleset)
- def rulesetId = rulesetResource.getTenantRulesets(null, keycloakDemoSetup.masterTenant.realm, null, false)[1].id
+ def rulesetId = rulesetResource.getTenantRulesets(null, keycloakTestSetup.masterTenant.realm, null, false)[1].id
tenantRuleset = rulesetResource.getTenantRuleset(null, rulesetId)
def lastModified = tenantRuleset.lastModified
@@ -399,7 +399,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
lastModified.time < System.currentTimeMillis()
tenantRuleset.name == "Test tenant definition"
tenantRuleset.rules == "SomeRulesCode"
- tenantRuleset.realm == keycloakDemoSetup.masterTenant.realm
+ tenantRuleset.realm == keycloakTestSetup.masterTenant.realm
when: "a tenant ruleset is updated"
tenantRuleset.name = "Renamed test tenant definition"
@@ -414,7 +414,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
lastModified.time < System.currentTimeMillis()
tenantRuleset.name == "Renamed test tenant definition"
tenantRuleset.rules == "SomeRulesCodeModified"
- tenantRuleset.realm == keycloakDemoSetup.masterTenant.realm
+ tenantRuleset.realm == keycloakTestSetup.masterTenant.realm
when: "a tenant ruleset is updated with an invalid realm"
tenantRuleset.realm = "thisdoesnotexist"
@@ -425,7 +425,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 400
when: "a tenant ruleset is updated with an invalid id"
- tenantRuleset.realm = keycloakDemoSetup.masterTenant.realm
+ tenantRuleset.realm = keycloakTestSetup.masterTenant.realm
tenantRuleset.id = 1234567890l
rulesetResource.updateTenantRuleset(null, rulesetId, tenantRuleset)
@@ -449,7 +449,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 404
when: "a tenant ruleset is created in a non-authenticated realm"
- tenantRuleset = new TenantRuleset(keycloakDemoSetup.tenantBuilding.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
+ tenantRuleset = new TenantRuleset(keycloakTestSetup.tenantBuilding.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
rulesetResource.createTenantRuleset(null, tenantRuleset)
then: "access should be forbidden"
@@ -457,9 +457,9 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 403
when: "an asset ruleset is created in the authenticated realm"
- def assetRuleset = new AssetRuleset(managerDemoSetup.smartOfficeId, "Test asset definition", GROOVY, "SomeRulesCode")
+ def assetRuleset = new AssetRuleset(managerTestSetup.smartOfficeId, "Test asset definition", GROOVY, "SomeRulesCode")
rulesetResource.createAssetRuleset(null, assetRuleset)
- rulesetId = rulesetResource.getAssetRulesets(null, managerDemoSetup.smartOfficeId, null, false)[0].id
+ rulesetId = rulesetResource.getAssetRulesets(null, managerTestSetup.smartOfficeId, null, false)[0].id
assetRuleset = rulesetResource.getAssetRuleset(null, rulesetId)
lastModified = assetRuleset.lastModified
@@ -470,7 +470,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
lastModified.time < System.currentTimeMillis()
assetRuleset.name == "Test asset definition"
assetRuleset.rules == "SomeRulesCode"
- assetRuleset.assetId == managerDemoSetup.smartOfficeId
+ assetRuleset.assetId == managerTestSetup.smartOfficeId
when: "an asset ruleset is updated"
assetRuleset.name = "Renamed test asset definition"
@@ -485,7 +485,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
lastModified.time < System.currentTimeMillis()
assetRuleset.name == "Renamed test asset definition"
assetRuleset.rules == "SomeRulesCodeModified"
- assetRuleset.assetId == managerDemoSetup.smartOfficeId
+ assetRuleset.assetId == managerTestSetup.smartOfficeId
when: "an asset ruleset is updated with an invalid asset ID"
assetRuleset.assetId = "thisdoesnotexist"
@@ -496,7 +496,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 400
when: "an asset ruleset is updated with an invalid id"
- assetRuleset.assetId = managerDemoSetup.smartOfficeId
+ assetRuleset.assetId = managerTestSetup.smartOfficeId
assetRuleset.id = 1234567890l
rulesetResource.updateAssetRuleset(null, rulesetId, assetRuleset)
@@ -520,7 +520,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 404
when: "an asset ruleset is created in a non-authenticated realm"
- assetRuleset = new AssetRuleset(managerDemoSetup.apartment2Id, "Test asset definition", GROOVY, "SomeRulesCode")
+ assetRuleset = new AssetRuleset(managerTestSetup.apartment2Id, "Test asset definition", GROOVY, "SomeRulesCode")
rulesetResource.createAssetRuleset(null, assetRuleset)
then: "access should be forbidden"
@@ -539,27 +539,27 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def rulesetStorageService = container.getService(RulesetStorageService.class)
def rulesService = container.getService(RulesService.class)
- def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
and: "some imported rulesets"
- def rulesImport = new BasicRulesImport(rulesetStorageService, keycloakDemoSetup, managerDemoSetup)
+ def rulesImport = new BasicRulesImport(rulesetStorageService, keycloakTestSetup, managerTestSetup)
and: "an authenticated test user"
def accessToken = authenticate(
container,
- keycloakDemoSetup.tenantBuilding.realm,
+ keycloakTestSetup.tenantBuilding.realm,
KEYCLOAK_CLIENT_ID,
"testuser2",
"testuser2"
).token
and: "the ruleset resource"
- def rulesetResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm, accessToken).proxy(RulesResource.class)
+ def rulesetResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.tenantBuilding.realm, accessToken).proxy(RulesResource.class)
expect: "the rules engines to be ready"
new PollingConditions(timeout: 10, delay: 0.2).eventually {
- rulesImport.assertEnginesReady(rulesService, keycloakDemoSetup, managerDemoSetup)
+ rulesImport.assertEnginesReady(rulesService, keycloakTestSetup, managerTestSetup)
}
/* ############################################## READ ####################################### */
@@ -572,20 +572,20 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 403
when: "some tenant rules in a non-authenticated realm are retrieved"
- rulesetResource.getTenantRulesets(null, keycloakDemoSetup.masterTenant.realm, null, false)
+ rulesetResource.getTenantRulesets(null, keycloakTestSetup.masterTenant.realm, null, false)
then: "access should be forbidden"
ex = thrown()
ex.response.status == 403
when: "some tenant rules in the authenticated realm are retrieved by user without rules read role"
- def rulesets = rulesetResource.getTenantRulesets(null, keycloakDemoSetup.tenantBuilding.realm, null, false)
+ def rulesets = rulesetResource.getTenantRulesets(null, keycloakTestSetup.tenantBuilding.realm, null, false)
then: "no rulesets should be returned"
rulesets.length == 0
when: "some asset rules in the authenticated realm are retrieved by the user without rules read role"
- rulesets = rulesetResource.getAssetRulesets(null, managerDemoSetup.apartment2Id, null, false)
+ rulesets = rulesetResource.getAssetRulesets(null, managerTestSetup.apartment2Id, null, false)
then: "no rulesets should be returned"
rulesets.length == 0
@@ -615,7 +615,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 403
when: "a tenant ruleset is created in the authenticated realm"
- def tenantRuleset = new TenantRuleset(keycloakDemoSetup.tenantBuilding.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
+ def tenantRuleset = new TenantRuleset(keycloakTestSetup.tenantBuilding.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
rulesetResource.createTenantRuleset(null, tenantRuleset)
then: "access should be forbidden"
@@ -637,7 +637,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 403
when: "a tenant ruleset is created in a non-authenticated realm"
- tenantRuleset = new TenantRuleset(keycloakDemoSetup.tenantCity.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
+ tenantRuleset = new TenantRuleset(keycloakTestSetup.tenantCity.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
rulesetResource.createTenantRuleset(null, tenantRuleset)
then: "access should be forbidden"
@@ -645,7 +645,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 403
when: "a tenant ruleset is created in the authenticated realm"
- def assetRuleset = new AssetRuleset(keycloakDemoSetup.tenantBuilding.realm, "Test asset definition", GROOVY, "SomeRulesCode")
+ def assetRuleset = new AssetRuleset(keycloakTestSetup.tenantBuilding.realm, "Test asset definition", GROOVY, "SomeRulesCode")
rulesetResource.createAssetRuleset(null, assetRuleset)
then: "access should be forbidden"
@@ -667,7 +667,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 403
when: "a tenant ruleset is created in a non-authenticated realm"
- assetRuleset = new AssetRuleset(keycloakDemoSetup.tenantCity.realm, "Test asset definition", GROOVY, "SomeRulesCode")
+ assetRuleset = new AssetRuleset(keycloakTestSetup.tenantCity.realm, "Test asset definition", GROOVY, "SomeRulesCode")
rulesetResource.createAssetRuleset(null, assetRuleset)
then: "access should be forbidden"
@@ -686,27 +686,27 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def rulesetStorageService = container.getService(RulesetStorageService.class)
def rulesService = container.getService(RulesService.class)
- def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
and: "some imported rulesets"
- def rulesImport = new BasicRulesImport(rulesetStorageService, keycloakDemoSetup, managerDemoSetup)
+ def rulesImport = new BasicRulesImport(rulesetStorageService, keycloakTestSetup, managerTestSetup)
and: "an authenticated test user"
def accessToken = authenticate(
container,
- keycloakDemoSetup.tenantBuilding.realm,
+ keycloakTestSetup.tenantBuilding.realm,
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
).token
and: "the ruleset resource"
- def rulesetResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm, accessToken).proxy(RulesResource.class)
+ def rulesetResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.tenantBuilding.realm, accessToken).proxy(RulesResource.class)
expect: "the rules engines to be ready"
new PollingConditions(timeout: 10, delay: 0.2).eventually {
- rulesImport.assertEnginesReady(rulesService, keycloakDemoSetup, managerDemoSetup)
+ rulesImport.assertEnginesReady(rulesService, keycloakTestSetup, managerTestSetup)
}
/* ############################################## READ ####################################### */
@@ -719,27 +719,27 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 403
when: "some tenant rules in a non-authenticated realm are retrieved"
- rulesetResource.getTenantRulesets(null, keycloakDemoSetup.masterTenant.realm, null, false)
+ rulesetResource.getTenantRulesets(null, keycloakTestSetup.masterTenant.realm, null, false)
then: "access should be forbidden"
ex = thrown()
ex.response.status == 403
when: "some tenant rules in the authenticated realm are retrieved by the restricted user"
- def rulesets = rulesetResource.getTenantRulesets(null, keycloakDemoSetup.tenantBuilding.realm, null, false)
+ def rulesets = rulesetResource.getTenantRulesets(null, keycloakTestSetup.tenantBuilding.realm, null, false)
then: "no rulesets should be returned"
rulesets.length == 0
when: "some asset rules of a protected assigned asset are retrieved"
- def ruleDefinitions = rulesetResource.getAssetRulesets(null, managerDemoSetup.apartment1Id, null, false)
+ def ruleDefinitions = rulesetResource.getAssetRulesets(null, managerTestSetup.apartment1Id, null, false)
then: "result should match"
ruleDefinitions.length == 1
ruleDefinitions[0].name == "Some apartment 1 demo rules"
when: "some asset rules of a protected but not assigned asset are retrieved"
- rulesetResource.getAssetRulesets(null, managerDemoSetup.apartment2Id, null, false)
+ rulesetResource.getAssetRulesets(null, managerTestSetup.apartment2Id, null, false)
then: "no rulesets should be returned"
rulesets.length == 0
@@ -769,7 +769,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 403
when: "a tenant ruleset is created in the authenticated realm"
- def tenantRuleset = new TenantRuleset(keycloakDemoSetup.tenantBuilding.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
+ def tenantRuleset = new TenantRuleset(keycloakTestSetup.tenantBuilding.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
rulesetResource.createTenantRuleset(null, tenantRuleset)
then: "access should be forbidden"
@@ -792,7 +792,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 404
when: "a tenant ruleset is created in a non-authenticated realm"
- tenantRuleset = new TenantRuleset(keycloakDemoSetup.tenantCity.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
+ tenantRuleset = new TenantRuleset(keycloakTestSetup.tenantCity.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
rulesetResource.createTenantRuleset(null, tenantRuleset)
then: "access should be forbidden"
@@ -801,12 +801,12 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
when: "an asset ruleset is created in the authenticated realm"
def assetRuleset = new AssetRuleset(
- managerDemoSetup.apartment1Id,
+ managerTestSetup.apartment1Id,
"Test asset definition",
GROOVY, "SomeRulesCode")
.addMeta("visible", Values.create(true))
rulesetResource.createAssetRuleset(null, assetRuleset)
- def rulesetId = rulesetResource.getAssetRulesets(null, managerDemoSetup.apartment1Id, null, false)[1].id
+ def rulesetId = rulesetResource.getAssetRulesets(null, managerTestSetup.apartment1Id, null, false)[1].id
assetRuleset = rulesetResource.getAssetRuleset(null, rulesetId)
def lastModified = assetRuleset.lastModified
@@ -817,7 +817,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
lastModified.time < System.currentTimeMillis()
assetRuleset.name == "Test asset definition"
assetRuleset.rules == "SomeRulesCode"
- assetRuleset.assetId == managerDemoSetup.apartment1Id
+ assetRuleset.assetId == managerTestSetup.apartment1Id
assetRuleset.meta.getBoolean("visible").orElse(false)
when: "an asset ruleset is updated"
@@ -833,10 +833,10 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
lastModified.time < System.currentTimeMillis()
assetRuleset.name == "Renamed test asset definition"
assetRuleset.rules == "SomeRulesCodeModified"
- assetRuleset.assetId == managerDemoSetup.apartment1Id
+ assetRuleset.assetId == managerTestSetup.apartment1Id
when: "an asset ruleset is updated with a changed asset ID"
- assetRuleset.assetId = managerDemoSetup.apartment3Id
+ assetRuleset.assetId = managerTestSetup.apartment3Id
rulesetResource.updateAssetRuleset(null, rulesetId, assetRuleset)
then: "the request should be bad"
@@ -852,7 +852,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 400
when: "an asset ruleset is updated with an invalid id"
- assetRuleset.assetId = managerDemoSetup.apartment1Id
+ assetRuleset.assetId = managerTestSetup.apartment1Id
assetRuleset.id = 1234567890l
rulesetResource.updateAssetRuleset(null, rulesetId, assetRuleset)
@@ -876,7 +876,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 404
when: "an asset ruleset is created in the authenticated realm but on a forbidden asset "
- assetRuleset = new AssetRuleset(managerDemoSetup.apartment3Id, "Test asset definition", GROOVY, "SomeRulesCode")
+ assetRuleset = new AssetRuleset(managerTestSetup.apartment3Id, "Test asset definition", GROOVY, "SomeRulesCode")
rulesetResource.createAssetRuleset(null, assetRuleset)
then: "access should be forbidden"
@@ -884,7 +884,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 403
when: "an asset ruleset is created in a non-authenticated realm"
- assetRuleset = new AssetRuleset(managerDemoSetup.smartOfficeId, "Test asset definition", GROOVY, "SomeRulesCode")
+ assetRuleset = new AssetRuleset(managerTestSetup.smartOfficeId, "Test asset definition", GROOVY, "SomeRulesCode")
rulesetResource.createAssetRuleset(null, assetRuleset)
then: "access should be forbidden"
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.groovy
index 50e7386ce..5629dd62c 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
@@ -7,7 +7,7 @@ import org.openremote.manager.rules.FlowRulesBuilder
import org.openremote.manager.rules.RulesService
import org.openremote.manager.rules.RulesetStorageService
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.attribute.AttributeEvent
import org.openremote.model.rules.GlobalRuleset
import org.openremote.model.rules.Ruleset
@@ -30,7 +30,7 @@ class FlowRulesTest extends Specification implements ManagerContainerTrait {
def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def rulesService = container.getService(RulesService.class)
def rulesetStorageService = container.getService(RulesetStorageService.class)
def assetStorageService = container.getService(AssetStorageService.class)
@@ -39,21 +39,21 @@ class FlowRulesTest extends Specification implements ManagerContainerTrait {
and: "relevant attributes have been populated"
assetProcessingService.sendAttributeEvent(new AttributeEvent(
- managerDemoSetup.apartment1LivingroomId,
+ managerTestSetup.apartment1LivingroomId,
"targetTemperature",
Values.create(startTemperature)
))
assetProcessingService.sendAttributeEvent(new AttributeEvent(
- managerDemoSetup.apartment1Bedroom1Id,
+ managerTestSetup.apartment1Bedroom1Id,
"targetTemperature",
Values.create(0)
))
when: "a valid node collection is added"
String json = getClass().getResource("/org/openremote/test/rules/BasicFlowRules.json").text
- json = json.replaceAll("%LIVING ROOM ID%", managerDemoSetup.apartment1LivingroomId)
- json = json.replaceAll("%BEDROOM ID%", managerDemoSetup.apartment1Bedroom1Id)
+ json = json.replaceAll("%LIVING ROOM ID%", managerTestSetup.apartment1LivingroomId)
+ json = json.replaceAll("%BEDROOM ID%", managerTestSetup.apartment1Bedroom1Id)
NodeCollection realCollection = container.JSON.readValue(json, NodeCollection.class)
def ruleset = (new GlobalRuleset(
realCollection.name,
@@ -72,7 +72,7 @@ class FlowRulesTest extends Specification implements ManagerContainerTrait {
and: "the flow should be executed correctly"
conditions.eventually {
def bedroomTargetTemp = assetStorageService.
- find(managerDemoSetup.apartment1Bedroom1Id).
+ find(managerTestSetup.apartment1Bedroom1Id).
getAttribute("targetTemperature").get().getValueAsNumber().get()
assert bedroomTargetTemp.intValue() == (startTemperature.intValue() + 10) : ("it was actually " + bedroomTargetTemp.intValue())//convert to int considering floating point inaccuracy
}
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.groovy
index 5cf04564b..079c196d1 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
@@ -15,8 +15,8 @@ import org.openremote.manager.rules.RulesetDeployment
import org.openremote.manager.rules.RulesetStorageService
import org.openremote.manager.rules.geofence.ORConsoleGeofenceAssetAdapter
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.KeycloakDemoSetup
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.KeycloakTestSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.attribute.AttributeEvent
import org.openremote.model.calendar.CalendarEvent
import org.openremote.model.calendar.RecurrenceRule
@@ -44,7 +44,7 @@ import java.time.temporal.ChronoUnit
import static java.util.concurrent.TimeUnit.HOURS
import static java.util.concurrent.TimeUnit.MILLISECONDS
-import static org.openremote.manager.setup.builtin.ManagerDemoSetup.DEMO_RULE_STATES_SMART_BUILDING
+import static org.openremote.manager.setup.builtin.ManagerTestSetup.DEMO_RULE_STATES_SMART_BUILDING
import static org.openremote.model.Constants.KEYCLOAK_CLIENT_ID
import static org.openremote.model.attribute.AttributeType.LOCATION
import static org.openremote.model.value.Values.parse
@@ -72,8 +72,8 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
def pushNotificationHandler = container.getService(PushNotificationHandler.class)
def emailNotificationHandler = container.getService(EmailNotificationHandler.class)
def notificationService = container.getService(NotificationService.class)
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
- def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
+ def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
def rulesService = container.getService(RulesService.class)
def rulesetStorageService = container.getService(RulesetStorageService.class)
def timerService = container.getService(TimerService.class)
@@ -115,7 +115,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
and: "some rules"
Ruleset ruleset = new TenantRuleset(
- keycloakDemoSetup.tenantBuilding.realm,
+ keycloakTestSetup.tenantBuilding.realm,
"Demo Apartment - All Lights Off",
Ruleset.Lang.JSON,
getClass().getResource("/org/openremote/test/rules/BasicJsonRules.json").text)
@@ -123,7 +123,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
expect: "the rule engines to become available and be running with asset states inserted and no longer tracking location rules"
conditions.eventually {
- tenantBuildingEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuilding.realm)
+ tenantBuildingEngine = rulesService.tenantEngines.get(keycloakTestSetup.tenantBuilding.realm)
assert tenantBuildingEngine != null
assert tenantBuildingEngine.isRunning()
assert tenantBuildingEngine.assetStates.size() == DEMO_RULE_STATES_SMART_BUILDING
@@ -132,25 +132,25 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
and: "the room lights in an apartment to be on"
conditions.eventually {
- def livingroomAsset = assetStorageService.find(managerDemoSetup.apartment2LivingroomId, true)
+ def livingroomAsset = assetStorageService.find(managerTestSetup.apartment2LivingroomId, true)
assert livingroomAsset.getAttribute("lightSwitch").get().valueAsBoolean.get()
assert livingroomAsset.getAttribute("lightSwitchTriggerTimes").get().valueAsArray.get().length() == 2
assert livingroomAsset.getAttribute("plantsWaterLevels").get().valueAsObject.get().getNumber("cactus").get() == 0.8
- def bathRoomAsset = assetStorageService.find(managerDemoSetup.apartment2BathroomId, true)
+ def bathRoomAsset = assetStorageService.find(managerTestSetup.apartment2BathroomId, true)
assert bathRoomAsset.getAttribute("lightSwitch").get().valueAsBoolean.get()
}
when: "a user authenticates"
def accessToken = authenticate(
container,
- keycloakDemoSetup.tenantBuilding.realm,
+ keycloakTestSetup.tenantBuilding.realm,
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
).token
and: "a console is registered by that user"
- def authenticatedConsoleResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm, accessToken).proxy(ConsoleResource.class)
+ def authenticatedConsoleResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.tenantBuilding.realm, accessToken).proxy(ConsoleResource.class)
def consoleRegistration = new ConsoleRegistration(null,
"Test Console",
"1.0",
@@ -188,7 +188,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
}
when: "the console location is set to the apartment"
- assetProcessingService.sendAttributeEvent(new AttributeEvent(consoleRegistration.id, LOCATION.attributeName, ManagerDemoSetup.SMART_BUILDING_LOCATION.toValue()), AttributeEvent.Source.CLIENT)
+ assetProcessingService.sendAttributeEvent(new AttributeEvent(consoleRegistration.id, LOCATION.attributeName, ManagerTestSetup.SMART_BUILDING_LOCATION.toValue()), AttributeEvent.Source.CLIENT)
then: "the consoles location should have been updated"
conditions.eventually {
@@ -198,16 +198,16 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
GeoJSONPoint.fromValue(it)
}.orElse(null)
assert assetLocation != null
- assert assetLocation.x == ManagerDemoSetup.SMART_BUILDING_LOCATION.x
- assert assetLocation.y == ManagerDemoSetup.SMART_BUILDING_LOCATION.y
- assert assetLocation.z == ManagerDemoSetup.SMART_BUILDING_LOCATION.z
+ assert assetLocation.x == ManagerTestSetup.SMART_BUILDING_LOCATION.x
+ assert assetLocation.y == ManagerTestSetup.SMART_BUILDING_LOCATION.y
+ assert assetLocation.z == ManagerTestSetup.SMART_BUILDING_LOCATION.z
}
then: "the console location asset state should be in the rule engine"
conditions.eventually {
assert tenantBuildingEngine.assetStates.find {
it.id == consoleRegistration.id && it.value.flatMap { GeoJSONPoint.fromValue(it) }.map {
- it.x == ManagerDemoSetup.SMART_BUILDING_LOCATION.x && it.y == ManagerDemoSetup.SMART_BUILDING_LOCATION.y ? it : null
+ it.x == ManagerTestSetup.SMART_BUILDING_LOCATION.x && it.y == ManagerTestSetup.SMART_BUILDING_LOCATION.y ? it : null
}.isPresent()
} != null
}
@@ -217,11 +217,11 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
then: "the apartment lights should be switched off"
conditions.eventually {
- def livingroomAsset = assetStorageService.find(managerDemoSetup.apartment2LivingroomId, true)
+ def livingroomAsset = assetStorageService.find(managerTestSetup.apartment2LivingroomId, true)
assert !livingroomAsset.getAttribute("lightSwitch").get().valueAsBoolean.get()
assert livingroomAsset.getAttribute("lightSwitchTriggerTimes").get().valueAsArray.get().length() == 2
assert livingroomAsset.getAttribute("plantsWaterLevels").get().valueAsObject.get().getNumber("cactus").get() == 0.8
- def bathRoomAsset = assetStorageService.find(managerDemoSetup.apartment2BathroomId, true)
+ def bathRoomAsset = assetStorageService.find(managerTestSetup.apartment2BathroomId, true)
assert !bathRoomAsset.getAttribute("lightSwitch").get().valueAsBoolean.get()
}
@@ -247,7 +247,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
when: "the console device moves back inside the home geofence (as defined in the rule)"
def lastFireTimestamp = tenantBuildingEngine.lastFireTimestamp
- assetProcessingService.sendAttributeEvent(new AttributeEvent(consoleRegistration.id, LOCATION.attributeName, ManagerDemoSetup.SMART_BUILDING_LOCATION.toValue()), AttributeEvent.Source.CLIENT)
+ assetProcessingService.sendAttributeEvent(new AttributeEvent(consoleRegistration.id, LOCATION.attributeName, ManagerTestSetup.SMART_BUILDING_LOCATION.toValue()), AttributeEvent.Source.CLIENT)
and: "the engine fires at least one more time"
conditions.eventually {
@@ -294,7 +294,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
when: "the console device moves back inside the home geofence (as defined in the rule)"
lastFireTimestamp = tenantBuildingEngine.lastFireTimestamp
- assetProcessingService.sendAttributeEvent(new AttributeEvent(consoleRegistration.id, LOCATION.attributeName, ManagerDemoSetup.SMART_BUILDING_LOCATION.toValue()), AttributeEvent.Source.CLIENT)
+ assetProcessingService.sendAttributeEvent(new AttributeEvent(consoleRegistration.id, LOCATION.attributeName, ManagerTestSetup.SMART_BUILDING_LOCATION.toValue()), AttributeEvent.Source.CLIENT)
then: "the engine fires at least one more time"
conditions.eventually {
@@ -312,7 +312,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
when: "the console device moves back inside the home geofence (as defined in the rule)"
lastFireTimestamp = tenantBuildingEngine.lastFireTimestamp
- assetProcessingService.sendAttributeEvent(new AttributeEvent(consoleRegistration.id, LOCATION.attributeName, ManagerDemoSetup.SMART_BUILDING_LOCATION.toValue()), AttributeEvent.Source.CLIENT)
+ assetProcessingService.sendAttributeEvent(new AttributeEvent(consoleRegistration.id, LOCATION.attributeName, ManagerTestSetup.SMART_BUILDING_LOCATION.toValue()), AttributeEvent.Source.CLIENT)
then: "the engine fires at least one more time"
conditions.eventually {
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.groovy
index 5394592fb..3724ce089 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
@@ -6,7 +6,7 @@ import org.openremote.manager.rules.RulesEngine
import org.openremote.manager.rules.RulesService
import org.openremote.manager.rules.RulesetStorageService
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.attribute.AttributeEvent
import org.openremote.model.rules.AssetRuleset
import org.openremote.model.rules.Ruleset
@@ -17,7 +17,7 @@ import spock.lang.Specification
import spock.util.concurrent.PollingConditions
import static java.util.concurrent.TimeUnit.SECONDS
-import static org.openremote.manager.setup.builtin.ManagerDemoSetup.DEMO_RULE_STATES_APARTMENT_2
+import static org.openremote.manager.setup.builtin.ManagerTestSetup.DEMO_RULE_STATES_APARTMENT_2
class ResidenceAllLightsOffTest extends Specification implements ManagerContainerTrait {
@@ -28,7 +28,7 @@ class ResidenceAllLightsOffTest extends Specification implements ManagerContaine
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def conditions = new PollingConditions(timeout: 10, delay: 0.2)
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def rulesService = container.getService(RulesService.class)
def rulesetStorageService = container.getService(RulesetStorageService.class)
def assetProcessingService = container.getService(AssetProcessingService.class)
@@ -37,7 +37,7 @@ class ResidenceAllLightsOffTest extends Specification implements ManagerContaine
and: "some rules"
Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment2Id,
+ managerTestSetup.apartment2Id,
"Demo Apartment - All Lights Off",
Ruleset.Lang.JAVASCRIPT,
getClass().getResource("/demo/rules/DemoResidenceAllLightsOff.js").text)
@@ -45,7 +45,7 @@ class ResidenceAllLightsOffTest extends Specification implements ManagerContaine
expect: "the rule engines to become available and be running"
conditions.eventually {
- apartment2Engine = rulesService.assetEngines.get(managerDemoSetup.apartment2Id)
+ apartment2Engine = rulesService.assetEngines.get(managerTestSetup.apartment2Id)
assert apartment2Engine != null
assert apartment2Engine.isRunning()
}
@@ -57,15 +57,15 @@ class ResidenceAllLightsOffTest extends Specification implements ManagerContaine
and: "the room lights in an apartment to be on"
conditions.eventually {
- def livingroomAsset = assetStorageService.find(managerDemoSetup.apartment2LivingroomId, true)
+ def livingroomAsset = assetStorageService.find(managerTestSetup.apartment2LivingroomId, true)
assert livingroomAsset.getAttribute("lightSwitch").get().valueAsBoolean.get()
- def bathRoomAsset = assetStorageService.find(managerDemoSetup.apartment2BathroomId, true)
+ def bathRoomAsset = assetStorageService.find(managerTestSetup.apartment2BathroomId, true)
assert bathRoomAsset.getAttribute("lightSwitch").get().valueAsBoolean.get()
}
when: "the ALL LIGHTS OFF push-button is pressed for an apartment"
def lightsOffEvent = new AttributeEvent(
- managerDemoSetup.apartment2Id, "allLightsOffSwitch", Values.create(true), getClockTimeOf(container)
+ managerTestSetup.apartment2Id, "allLightsOffSwitch", Values.create(true), getClockTimeOf(container)
)
assetProcessingService.sendAttributeEvent(lightsOffEvent)
@@ -73,9 +73,9 @@ class ResidenceAllLightsOffTest extends Specification implements ManagerContaine
conditions.eventually {
assert apartment2Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_2
assert apartment2Engine.assetEvents.size() == 1
- def livingroomAsset = assetStorageService.find(managerDemoSetup.apartment2LivingroomId, true)
+ def livingroomAsset = assetStorageService.find(managerTestSetup.apartment2LivingroomId, true)
assert !livingroomAsset.getAttribute("lightSwitch").get().valueAsBoolean.get()
- def bathRoomAsset = assetStorageService.find(managerDemoSetup.apartment2BathroomId, true)
+ def bathRoomAsset = assetStorageService.find(managerTestSetup.apartment2BathroomId, true)
assert !bathRoomAsset.getAttribute("lightSwitch").get().valueAsBoolean.get()
}
@@ -84,14 +84,14 @@ class ResidenceAllLightsOffTest extends Specification implements ManagerContaine
and: "we turn the light on again in a room"
assetProcessingService.sendAttributeEvent(
- new AttributeEvent(managerDemoSetup.apartment2LivingroomId, "lightSwitch", Values.create(true))
+ new AttributeEvent(managerTestSetup.apartment2LivingroomId, "lightSwitch", Values.create(true))
)
then: "the light should still be on after a few seconds (the all lights off event expires after 3 seconds)"
new PollingConditions(timeout: 5, initialDelay: 3).eventually {
assert apartment2Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_2
assert apartment2Engine.assetEvents.size() == 0
- def livingroomAsset = assetStorageService.find(managerDemoSetup.apartment2LivingroomId, true)
+ def livingroomAsset = assetStorageService.find(managerTestSetup.apartment2LivingroomId, true)
assert livingroomAsset.getAttribute("lightSwitch").get().valueAsBoolean.get()
}
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.groovy
index 8b94a98b8..ed20d767f 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
@@ -7,7 +7,7 @@ import org.openremote.manager.rules.RulesEngine
import org.openremote.manager.rules.RulesService
import org.openremote.manager.rules.RulesetStorageService
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.attribute.AttributeEvent
import org.openremote.model.rules.AssetRuleset
import org.openremote.model.rules.Ruleset
@@ -19,7 +19,7 @@ import spock.lang.Specification
import spock.util.concurrent.PollingConditions
import static java.util.concurrent.TimeUnit.MINUTES
-import static org.openremote.manager.setup.builtin.ManagerDemoSetup.DEMO_RULE_STATES_APARTMENT_1
+import static org.openremote.manager.setup.builtin.ManagerTestSetup.DEMO_RULE_STATES_APARTMENT_1
import 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
@@ -35,7 +35,7 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerConta
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def conditions = new PollingConditions(timeout: 20, delay: 0.2)
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def rulesService = container.getService(RulesService.class)
def assetStorageService = container.getService(AssetStorageService.class)
def assetProcessingService = container.getService(AssetProcessingService.class)
@@ -45,7 +45,7 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerConta
and: "some rules"
Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment1Id,
+ managerTestSetup.apartment1Id,
"Demo Apartment - Auto Ventilation",
Ruleset.Lang.GROOVY,
getClass().getResource("/demo/rules/DemoResidenceAutoVentilation.groovy").text)
@@ -53,7 +53,7 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerConta
expect: "the rule engines to become available, running and settled"
conditions.eventually {
- apartment1Engine = rulesService.assetEngines.get(managerDemoSetup.apartment1Id)
+ apartment1Engine = rulesService.assetEngines.get(managerTestSetup.apartment1Id)
assert apartment1Engine != null
assert apartment1Engine.isRunning()
assert apartment1Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_1
@@ -62,14 +62,14 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerConta
and: "the ventilation should be off"
conditions.eventually {
- def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def apartment = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert !apartment.getAttribute("ventilationAuto").get().getValue().isPresent()
assert !apartment.getAttribute("ventilationLevel").get().getValue().isPresent()
}
when: "auto ventilation is turned on"
assetProcessingService.sendAttributeEvent(
- new AttributeEvent(managerDemoSetup.apartment1Id, "ventilationAuto", Values.create(true))
+ new AttributeEvent(managerTestSetup.apartment1Id, "ventilationAuto", Values.create(true))
)
then: "the rule engines should settle"
@@ -79,7 +79,7 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerConta
then: "auto ventilation should be on"
conditions.eventually {
- def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def apartment = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert apartment.getAttribute("ventilationAuto").get().getValueAsBoolean().get()
assert !apartment.getAttribute("ventilationLevel").get().getValue().isPresent()
}
@@ -89,7 +89,7 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerConta
for (i in 1..3) {
def co2LevelIncrement = new AttributeEvent(
- managerDemoSetup.apartment1LivingroomId, "co2Level", Values.create(700 + i)
+ managerTestSetup.apartment1LivingroomId, "co2Level", Values.create(700 + i)
)
simulatorProtocol.putValue(co2LevelIncrement)
@@ -111,13 +111,13 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerConta
then: "ventilation level of the apartment should be MEDIUM"
conditions.eventually {
- def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def apartment = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert apartment.getAttribute("ventilationLevel").get().getValueAsNumber().get() == 128d
}
when: "CO2 is decreasing in a room"
def co2LevelDecrement = new AttributeEvent(
- managerDemoSetup.apartment1LivingroomId, "co2Level", Values.create(500)
+ managerTestSetup.apartment1LivingroomId, "co2Level", Values.create(500)
)
simulatorProtocol.putValue(co2LevelDecrement)
@@ -139,7 +139,7 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerConta
then: "ventilation level of the apartment should be LOW"
conditions.eventually {
- def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def apartment = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert apartment.getAttribute("ventilationLevel").get().getValueAsNumber().get() == 64d
}
@@ -148,7 +148,7 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerConta
for (i in 1..3) {
def co2LevelIncrement = new AttributeEvent(
- managerDemoSetup.apartment1LivingroomId, "co2Level", Values.create(1000 + i)
+ managerTestSetup.apartment1LivingroomId, "co2Level", Values.create(1000 + i)
)
simulatorProtocol.putValue(co2LevelIncrement)
@@ -170,13 +170,13 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerConta
then: "ventilation level of the apartment should be HIGH"
conditions.eventually {
- def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def apartment = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert apartment.getAttribute("ventilationLevel").get().getValueAsNumber().get() == 255d
}
when: "CO2 is decreasing in a room"
def co2LevelDecrement2 = new AttributeEvent(
- managerDemoSetup.apartment1LivingroomId, "co2Level", Values.create(800)
+ managerTestSetup.apartment1LivingroomId, "co2Level", Values.create(800)
)
simulatorProtocol.putValue(co2LevelDecrement2)
conditions.eventually {
@@ -196,13 +196,13 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerConta
then: "ventilation level of the apartment should be MEDIUM"
conditions.eventually {
- def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def apartment = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert apartment.getAttribute("ventilationLevel").get().getValueAsNumber().get() == 128d
}
when: "CO2 is decreasing in a room"
def co2LevelDecrement3 = new AttributeEvent(
- managerDemoSetup.apartment1LivingroomId, "co2Level", Values.create(500)
+ managerTestSetup.apartment1LivingroomId, "co2Level", Values.create(500)
)
simulatorProtocol.putValue(co2LevelDecrement3)
conditions.eventually {
@@ -222,7 +222,7 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerConta
then: "ventilation level of the apartment should be LOW"
conditions.eventually {
- def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def apartment = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert apartment.getAttribute("ventilationLevel").get().getValueAsNumber().get() == 64d
}
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.groovy
index d532de026..34d4b70f6 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
@@ -11,7 +11,7 @@ import org.openremote.manager.rules.RulesService
import org.openremote.manager.rules.RulesetStorageService
import org.openremote.manager.rules.geofence.ORConsoleGeofenceAssetAdapter
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.attribute.AttributeEvent
import org.openremote.model.attribute.AttributeRef
import org.openremote.model.console.ConsoleProvider
@@ -32,7 +32,7 @@ import spock.util.concurrent.PollingConditions
import java.util.concurrent.TimeUnit
-import static org.openremote.manager.setup.builtin.ManagerDemoSetup.DEMO_RULE_STATES_APARTMENT_1
+import static org.openremote.manager.setup.builtin.ManagerTestSetup.DEMO_RULE_STATES_APARTMENT_1
import static org.openremote.model.Constants.KEYCLOAK_CLIENT_ID
import static org.openremote.model.asset.AssetResource.Util.WRITE_ATTRIBUTE_HTTP_METHOD
import static org.openremote.model.asset.AssetResource.Util.getWriteAttributeUrl
@@ -52,7 +52,7 @@ class ResidenceNotifyAlarmTriggerTest extends Specification implements ManagerCo
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def conditions = new PollingConditions(timeout: 20, delay: 0.2)
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def rulesService = container.getService(RulesService.class)
def notificationService = container.getService(NotificationService.class)
def pushNotificationHandler = container.getService(PushNotificationHandler.class)
@@ -81,23 +81,23 @@ class ResidenceNotifyAlarmTriggerTest extends Specification implements ManagerCo
and: "some rules"
Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment1Id,
+ managerTestSetup.apartment1Id,
"Demo Apartment - Notify Alarm Trigger",
Ruleset.Lang.GROOVY, getClass().getResource("/demo/rules/DemoResidenceNotifyAlarmTrigger.groovy").text)
rulesetStorageService.merge(ruleset)
expect: "the rule engines to become available and be running"
conditions.eventually {
- apartment1Engine = rulesService.assetEngines.get(managerDemoSetup.apartment1Id)
+ apartment1Engine = rulesService.assetEngines.get(managerTestSetup.apartment1Id)
assert apartment1Engine != null
assert apartment1Engine.isRunning()
assert apartment1Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_1
}
and: "the alarm enabled, presence detected flag of room should not be set"
- def apartment1Asset = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def apartment1Asset = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert !apartment1Asset.getAttribute("alarmEnabled").get().valueAsBoolean.orElse(null)
- def livingRoomAsset = assetStorageService.find(managerDemoSetup.apartment1LivingroomId, true)
+ def livingRoomAsset = assetStorageService.find(managerTestSetup.apartment1LivingroomId, true)
assert !livingRoomAsset.getAttribute("presenceDetected").orElse(null).valueAsBoolean.orElse(null)
and: "an authenticated test user"
@@ -149,23 +149,23 @@ class ResidenceNotifyAlarmTriggerTest extends Specification implements ManagerCo
when: "the alarm is enabled"
assetProcessingService.sendAttributeEvent(new AttributeEvent(
- managerDemoSetup.apartment1Id, "alarmEnabled", Values.create(true), getClockTimeOf(container)
+ managerTestSetup.apartment1Id, "alarmEnabled", Values.create(true), getClockTimeOf(container)
))
then: "that value should be stored"
conditions.eventually {
- def asset = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def asset = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert asset.getAttribute("alarmEnabled").get().valueAsBoolean
}
when: "the presence is detected in Living room of apartment 1"
assetProcessingService.sendAttributeEvent(new AttributeEvent(
- managerDemoSetup.apartment1LivingroomId, "presenceDetected", Values.create(true), getClockTimeOf(container)
+ managerTestSetup.apartment1LivingroomId, "presenceDetected", Values.create(true), getClockTimeOf(container)
))
then: "that value should be stored"
conditions.eventually {
- def asset = assetStorageService.find(managerDemoSetup.apartment1LivingroomId, true)
+ def asset = assetStorageService.find(managerTestSetup.apartment1LivingroomId, true)
assert asset.getAttribute("presenceDetected").get().valueAsBoolean.orElse(null)
}
@@ -185,7 +185,7 @@ class ResidenceNotifyAlarmTriggerTest extends Specification implements ManagerCo
assert !pushMessage.buttons[0].action.openInBrowser
assert !pushMessage.buttons[0].action.silent
assert pushMessage.buttons[1].title == "Alarm uit"
- assert pushMessage.buttons[1].action.url == getWriteAttributeUrl(new AttributeRef(managerDemoSetup.apartment1Id, "alarmEnabled"))
+ assert pushMessage.buttons[1].action.url == getWriteAttributeUrl(new AttributeRef(managerTestSetup.apartment1Id, "alarmEnabled"))
assert pushMessage.buttons[1].action.httpMethod == WRITE_ATTRIBUTE_HTTP_METHOD
assert !Values.getBoolean(pushMessage.buttons[1].action.data).orElse(true)
assert !pushMessage.buttons[1].action.openInBrowser
@@ -195,12 +195,12 @@ class ResidenceNotifyAlarmTriggerTest extends Specification implements ManagerCo
when: "time moves on and other events happen that trigger evaluation in the rule engine"
advancePseudoClock(20, TimeUnit.MINUTES, container)
assetProcessingService.sendAttributeEvent(new AttributeEvent(
- managerDemoSetup.apartment1LivingroomId, "co2Level", Values.create(444), getClockTimeOf(container)
+ managerTestSetup.apartment1LivingroomId, "co2Level", Values.create(444), getClockTimeOf(container)
))
then: "still only one notification should have been sent"
conditions.eventually {
- def asset = assetStorageService.find(managerDemoSetup.apartment1LivingroomId, true)
+ def asset = assetStorageService.find(managerTestSetup.apartment1LivingroomId, true)
assert asset.getAttribute("co2Level").get().valueAsInteger.orElse(null) == 444
assert notificationIds.size() == 1
}
@@ -216,12 +216,12 @@ class ResidenceNotifyAlarmTriggerTest extends Specification implements ManagerCo
when: "the presence is no longer triggered in Living room of apartment 1"
advancePseudoClock(5, TimeUnit.SECONDS, container)
assetProcessingService.sendAttributeEvent(new AttributeEvent(
- managerDemoSetup.apartment1LivingroomId, "presenceDetected", Values.create(false), getClockTimeOf(container)
+ managerTestSetup.apartment1LivingroomId, "presenceDetected", Values.create(false), getClockTimeOf(container)
))
then: "that value should be stored"
conditions.eventually {
- def asset = assetStorageService.find(managerDemoSetup.apartment1LivingroomId, true)
+ def asset = assetStorageService.find(managerTestSetup.apartment1LivingroomId, true)
assert !asset.getAttribute("presenceDetected").get().valueAsBoolean.orElse(null)
}
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.groovy
index 3a7037e10..c7bfcec29 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
@@ -7,7 +7,7 @@ import org.openremote.manager.rules.RulesEngine
import org.openremote.manager.rules.RulesService
import org.openremote.manager.rules.RulesetStorageService
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.attribute.AttributeEvent
import org.openremote.model.rules.AssetRuleset
import org.openremote.model.rules.Ruleset
@@ -19,7 +19,7 @@ import spock.lang.Specification
import spock.util.concurrent.PollingConditions
import static java.util.concurrent.TimeUnit.MINUTES
-import static org.openremote.manager.setup.builtin.ManagerDemoSetup.DEMO_RULE_STATES_APARTMENT_1
+import static org.openremote.manager.setup.builtin.ManagerTestSetup.DEMO_RULE_STATES_APARTMENT_1
import 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
@@ -34,7 +34,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def conditions = new PollingConditions(timeout: 30, delay: 0.2)
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def rulesService = container.getService(RulesService.class)
def assetStorageService = container.getService(AssetStorageService.class)
def rulesetStorageService = container.getService(RulesetStorageService.class)
@@ -43,7 +43,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
and: "some rules"
Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment1Id,
+ managerTestSetup.apartment1Id,
"Demo Apartment - Presence Detection with motion and CO2 sensors",
Ruleset.Lang.GROOVY,
getClass().getResource("/demo/rules/DemoResidencePresenceDetection.groovy").text)
@@ -51,7 +51,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
expect: "the rule engines to become available and be running"
conditions.eventually {
- apartment1Engine = rulesService.assetEngines.get(managerDemoSetup.apartment1Id)
+ apartment1Engine = rulesService.assetEngines.get(managerTestSetup.apartment1Id)
assert apartment1Engine != null
assert apartment1Engine.isRunning()
assert apartment1Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_1
@@ -64,12 +64,12 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
and: "the presence detected flag and timestamp should not be set"
conditions.eventually {
- def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def apartment = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert !apartment.getAttribute("presenceDetected").get().getValue().isPresent()
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert !kitchen.getAttribute("presenceDetected").get().getValue().isPresent()
assert !kitchen.getAttribute("lastPresenceDetected").get().getValue().isPresent()
- def hallway = assetStorageService.find(managerDemoSetup.apartment1HallwayId, true)
+ def hallway = assetStorageService.find(managerTestSetup.apartment1HallwayId, true)
assert !hallway.getAttribute("presenceDetected").get().getValue().isPresent()
assert !hallway.getAttribute("lastPresenceDetected").get().getValue().isPresent()
}
@@ -77,11 +77,11 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
when: "motion sensor is triggered in all rooms"
double expectedLastPresenceDetected = getClockTimeOf(container)
def kitchenMotionSensorEvent = new AttributeEvent(
- managerDemoSetup.apartment1KitchenId, "motionSensor", Values.create(1)
+ managerTestSetup.apartment1KitchenId, "motionSensor", Values.create(1)
)
simulatorProtocol.putValue(kitchenMotionSensorEvent)
def hallwayMotionSensorEvent = new AttributeEvent(
- managerDemoSetup.apartment1HallwayId, "motionSensor", Values.create(1)
+ managerTestSetup.apartment1HallwayId, "motionSensor", Values.create(1)
)
simulatorProtocol.putValue(hallwayMotionSensorEvent)
@@ -92,12 +92,12 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
then: "presence should be detected in all rooms"
conditions.eventually {
- def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def apartment = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert apartment.getAttribute("presenceDetected").get().getValueAsBoolean().get()
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert kitchen.getAttribute("presenceDetected").get().getValueAsBoolean().get()
assert kitchen.getAttribute("lastPresenceDetected").get().getValueAsNumber().get() == expectedLastPresenceDetected
- def hallway = assetStorageService.find(managerDemoSetup.apartment1HallwayId, true)
+ def hallway = assetStorageService.find(managerTestSetup.apartment1HallwayId, true)
assert hallway.getAttribute("presenceDetected").get().getValueAsBoolean().get()
assert hallway.getAttribute("lastPresenceDetected").get().getValueAsNumber().get() == expectedLastPresenceDetected
}
@@ -108,7 +108,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
and: "motion sensor is triggered a room again"
double expectedLastPresenceDetected2 = getClockTimeOf(container)
kitchenMotionSensorEvent = new AttributeEvent(
- managerDemoSetup.apartment1KitchenId, "motionSensor", Values.create(1)
+ managerTestSetup.apartment1KitchenId, "motionSensor", Values.create(1)
)
simulatorProtocol.putValue(kitchenMotionSensorEvent)
@@ -119,12 +119,12 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
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)
+ def apartment = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert apartment.getAttribute("presenceDetected").get().getValueAsBoolean().get()
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert kitchen.getAttribute("presenceDetected").get().getValueAsBoolean().get()
assert kitchen.getAttribute("lastPresenceDetected").get().getValueAsNumber().get() == expectedLastPresenceDetected2
- def hallway = assetStorageService.find(managerDemoSetup.apartment1HallwayId, true)
+ def hallway = assetStorageService.find(managerTestSetup.apartment1HallwayId, true)
assert hallway.getAttribute("presenceDetected").get().getValueAsBoolean().get()
assert hallway.getAttribute("lastPresenceDetected").get().getValueAsNumber().get() == expectedLastPresenceDetected
}
@@ -134,7 +134,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
and: "motion sensor is not triggered in a room"
kitchenMotionSensorEvent = new AttributeEvent(
- managerDemoSetup.apartment1KitchenId, "motionSensor", Values.create(0)
+ managerTestSetup.apartment1KitchenId, "motionSensor", Values.create(0)
)
simulatorProtocol.putValue(kitchenMotionSensorEvent)
@@ -145,12 +145,12 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
then: "some presence should still be detected and timestamps are still available"
conditions.eventually {
- def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def apartment = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert apartment.getAttribute("presenceDetected").get().getValueAsBoolean().get()
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert !kitchen.getAttribute("presenceDetected").get().getValueAsBoolean().get()
assert kitchen.getAttribute("lastPresenceDetected").get().getValueAsNumber().get() == expectedLastPresenceDetected2
- def hallway = assetStorageService.find(managerDemoSetup.apartment1HallwayId, true)
+ def hallway = assetStorageService.find(managerTestSetup.apartment1HallwayId, true)
assert hallway.getAttribute("presenceDetected").get().getValueAsBoolean().get()
assert hallway.getAttribute("lastPresenceDetected").get().getValueAsNumber().get() == expectedLastPresenceDetected
}
@@ -160,7 +160,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
and: "motion sensor is not triggered in another room"
hallwayMotionSensorEvent = new AttributeEvent(
- managerDemoSetup.apartment1HallwayId, "motionSensor", Values.create(0)
+ managerTestSetup.apartment1HallwayId, "motionSensor", Values.create(0)
)
simulatorProtocol.putValue(hallwayMotionSensorEvent)
@@ -171,12 +171,12 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
then: "no presence should be detected but the last timestamp still available"
conditions.eventually {
- def apartment = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def apartment = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert !apartment.getAttribute("presenceDetected").get().getValueAsBoolean().get()
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert !kitchen.getAttribute("presenceDetected").get().getValueAsBoolean().get()
assert kitchen.getAttribute("lastPresenceDetected").get().getValueAsNumber().get() == expectedLastPresenceDetected2
- def hallway = assetStorageService.find(managerDemoSetup.apartment1HallwayId, true)
+ def hallway = assetStorageService.find(managerTestSetup.apartment1HallwayId, true)
assert !hallway.getAttribute("presenceDetected").get().getValueAsBoolean().get()
assert hallway.getAttribute("lastPresenceDetected").get().getValueAsNumber().get() == expectedLastPresenceDetected
}
@@ -192,7 +192,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def conditions = new PollingConditions(timeout: 20, delay: 0.2)
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def rulesService = container.getService(RulesService.class)
def assetProcessingService = container.getService(AssetProcessingService.class)
def assetStorageService = container.getService(AssetStorageService.class)
@@ -202,7 +202,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
and: "some rules"
Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment1Id,
+ managerTestSetup.apartment1Id,
"Demo Apartment - Presence Detection with motion sensor",
Ruleset.Lang.GROOVY,
getClass().getResource("/demo/rules/DemoResidencePresenceDetection.groovy").text)
@@ -210,7 +210,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
expect: "the rule engines to become available and be running"
conditions.eventually {
- apartment1Engine = rulesService.assetEngines.get(managerDemoSetup.apartment1Id)
+ apartment1Engine = rulesService.assetEngines.get(managerTestSetup.apartment1Id)
assert apartment1Engine != null
assert apartment1Engine.isRunning()
assert apartment1Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_1
@@ -223,7 +223,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
and: "the presence detected flag and timestamp of the room should not be set"
conditions.eventually {
- def roomAsset = assetStorageService.find(managerDemoSetup.apartment1LivingroomId, true)
+ def roomAsset = assetStorageService.find(managerTestSetup.apartment1LivingroomId, true)
assert !roomAsset.getAttribute("presenceDetected").get().getValue().isPresent()
assert !roomAsset.getAttribute("lastPresenceDetected").get().getValue().isPresent()
}
@@ -231,14 +231,14 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
when: "motion sensor is triggered"
double expectedLastPresenceDetected = getClockTimeOf(container)
def motionSensorTrigger = new AttributeEvent(
- managerDemoSetup.apartment1LivingroomId, "motionSensor", Values.create(1)
+ managerTestSetup.apartment1LivingroomId, "motionSensor", Values.create(1)
)
simulatorProtocol.putValue(motionSensorTrigger)
/* See rules, this leads to many false negatives when windows are open in the room
then: "presence should not be detected"
new PollingConditions(initialDelay: 3, timeout: 5, delay: 1).eventually {
- def roomAsset = assetStorageService.find(managerDemoSetup.apartment1LivingroomId, true)
+ def roomAsset = assetStorageService.find(managerTestSetup.apartment1LivingroomId, true)
assert !roomAsset.getAttribute("presenceDetected").get().getValue().isPresent()
assert !roomAsset.getAttribute("lastPresenceDetected").get().getValue().isPresent()
}
@@ -251,7 +251,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
for (i in 1..3) {
def co2LevelIncrement = new AttributeEvent(
- managerDemoSetup.apartment1LivingroomId, "co2Level", Values.create(400 + i)
+ managerTestSetup.apartment1LivingroomId, "co2Level", Values.create(400 + i)
)
simulatorProtocol.putValue(co2LevelIncrement)
@@ -274,14 +274,14 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
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)
+ def roomAsset = assetStorageService.find(managerTestSetup.apartment1LivingroomId, true)
assert roomAsset.getAttribute("presenceDetected").get().getValueAsBoolean().get()
assert roomAsset.getAttribute("lastPresenceDetected").get().getValueAsNumber().get() == expectedLastPresenceDetected
}
when: "motion sensor is not triggered (someone might be resting in the room)"
def motionSensorNoTrigger = new AttributeEvent(
- managerDemoSetup.apartment1LivingroomId, "motionSensor", Values.create(0)
+ managerTestSetup.apartment1LivingroomId, "motionSensor", Values.create(0)
)
simulatorProtocol.putValue(motionSensorNoTrigger)
@@ -290,7 +290,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
for (i in 1..3) {
def co2LevelIncrement = new AttributeEvent(
- managerDemoSetup.apartment1LivingroomId, "co2Level", Values.create(400 + i)
+ managerTestSetup.apartment1LivingroomId, "co2Level", Values.create(400 + i)
)
simulatorProtocol.putValue(co2LevelIncrement)
@@ -310,7 +310,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
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)
+ def roomAsset = assetStorageService.find(managerTestSetup.apartment1LivingroomId, true)
assert roomAsset.getAttribute("presenceDetected").get().getValueAsBoolean().get()
assert roomAsset.getAttribute("lastPresenceDetected").get().getValueAsNumber().get() == expectedLastPresenceDetected
}
@@ -325,7 +325,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
then: "presence should be gone but the last timestamp still available"
conditions.eventually {
- def roomAsset = assetStorageService.find(managerDemoSetup.apartment1LivingroomId, true)
+ def roomAsset = assetStorageService.find(managerTestSetup.apartment1LivingroomId, true)
assert !roomAsset.getAttribute("presenceDetected").get().getValueAsBoolean().get()
assert roomAsset.getAttribute("lastPresenceDetected").get().getValueAsNumber().get() == expectedLastPresenceDetected
}
@@ -340,7 +340,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
given: "the container environment is started"
def conditions = new PollingConditions(timeout: 100, delay: 0.2)
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def rulesService = container.getService(RulesService.class)
def assetStorageService = container.getService(AssetStorageService.class)
def rulesetStorageService = container.getService(RulesetStorageService.class)
@@ -350,14 +350,14 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
and: "some rules"
Ruleset ruleset = new AssetRuleset(
"Demo Apartment - Presence Detection with motion sensor",
- managerDemoSetup.apartment1Id,
+ managerTestSetup.apartment1Id,
getClass().getResource("/demo/rules/LegacyDemoApartmentPresencePrediction.drl").text
)
rulesetStorageService.merge(ruleset)
expect: "the rule engines to become available and be running"
conditions.eventually {
- apartment1Engine = rulesService.assetEngines.get(managerDemoSetup.apartment1Id)
+ apartment1Engine = rulesService.assetEngines.get(managerTestSetup.apartment1Id)
assert apartment1Engine != null
assert apartment1Engine.isRunning()
// assert apartment1Engine.knowledgeSession.factCount == DEMO_RULE_STATES_APARTMENT_1
diff --git a/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceSmartSwitchTest.groovy b/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceSmartSwitchTest.groovy
index adef3f28f..d96fd7842 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
@@ -6,7 +6,7 @@ import org.openremote.manager.rules.RulesEngine
import org.openremote.manager.rules.RulesService
import org.openremote.manager.rules.RulesetStorageService
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.attribute.AttributeEvent
import org.openremote.model.rules.AssetRuleset
import org.openremote.model.rules.Ruleset
@@ -17,7 +17,7 @@ import spock.lang.Specification
import spock.util.concurrent.PollingConditions
import static java.util.concurrent.TimeUnit.HOURS
-import static org.openremote.manager.setup.builtin.ManagerDemoSetup.DEMO_RULE_STATES_APARTMENT_1
+import static org.openremote.manager.setup.builtin.ManagerTestSetup.DEMO_RULE_STATES_APARTMENT_1
class ResidenceSmartSwitchTest extends Specification implements ManagerContainerTrait {
@@ -30,7 +30,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def rulesService = container.getService(RulesService.class)
def assetStorageService = container.getService(AssetStorageService.class)
def assetProcessingService = container.getService(AssetProcessingService.class)
@@ -39,7 +39,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
and: "some rules"
Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment1Id,
+ managerTestSetup.apartment1Id,
"Demo Apartment - Smart Start",
Ruleset.Lang.GROOVY,
getClass().getResource("/demo/rules/DemoResidenceSmartSwitch.groovy").text)
@@ -47,7 +47,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
expect: "the rule engines to become available and be running"
conditions.eventually {
- apartment1Engine = rulesService.assetEngines.get(managerDemoSetup.apartment1Id)
+ apartment1Engine = rulesService.assetEngines.get(managerTestSetup.apartment1Id)
assert apartment1Engine != null
assert apartment1Engine.isRunning()
assert apartment1Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_1
@@ -55,7 +55,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
and: "smart switches should be off"
conditions.eventually {
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert !kitchen.getAttribute("smartSwitchModeA").get().getValue().isPresent()
assert !kitchen.getAttribute("smartSwitchBeginEndA").get().getValue().isPresent()
assert !kitchen.getAttribute("smartSwitchStartTimeA").get().getValue().isPresent()
@@ -75,13 +75,13 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
when: "mode is set to ON_AT"
assetProcessingService.sendAttributeEvent(
- new AttributeEvent(managerDemoSetup.apartment1KitchenId, "smartSwitchModeA", Values.create("ON_AT"))
+ new AttributeEvent(managerTestSetup.apartment1KitchenId, "smartSwitchModeA", Values.create("ON_AT"))
)
noEventProcessedIn(assetProcessingService, 500)
then: "mode should be ON_AT but actuator not enabled"
conditions.eventually {
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert kitchen.getAttribute("smartSwitchModeA").get().getValueAsString().get() == "ON_AT"
assert !kitchen.getAttribute("smartSwitchBeginEndA").get().getValue().isPresent()
assert !kitchen.getAttribute("smartSwitchStartTimeA").get().getValue().isPresent()
@@ -102,13 +102,13 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
when: "begin/end cycle time is set to future"
long oneMinuteInFutureMillis = getClockTimeOf(container) + 60000
assetProcessingService.sendAttributeEvent(
- new AttributeEvent(managerDemoSetup.apartment1KitchenId, "smartSwitchBeginEndA", Values.create(oneMinuteInFutureMillis))
+ new AttributeEvent(managerTestSetup.apartment1KitchenId, "smartSwitchBeginEndA", Values.create(oneMinuteInFutureMillis))
)
noEventProcessedIn(assetProcessingService, 500)
then: "mode should be ON_AT and actuator enabled with correct start/stop time"
conditions.eventually {
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert kitchen.getAttribute("smartSwitchModeA").get().getValueAsString().get() == "ON_AT"
assert kitchen.getAttribute("smartSwitchBeginEndA").get().getValueAsNumber().get() == (double)oneMinuteInFutureMillis
assert kitchen.getAttribute("smartSwitchStartTimeA").get().getValueAsNumber().get() == Math.floor((double)oneMinuteInFutureMillis/1000)
@@ -131,7 +131,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
then: "mode should be NOW_ON and actuator not enabled"
conditions.eventually {
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert kitchen.getAttribute("smartSwitchModeA").get().getValueAsString().get() == "NOW_ON"
assert !kitchen.getAttribute("smartSwitchBeginEndA").get().getValue().isPresent()
assert kitchen.getAttribute("smartSwitchStartTimeA").get().getValueAsNumber().get() == 0
@@ -160,7 +160,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def rulesService = container.getService(RulesService.class)
def assetStorageService = container.getService(AssetStorageService.class)
def assetProcessingService = container.getService(AssetProcessingService.class)
@@ -169,7 +169,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
and: "some rules"
Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment1Id,
+ managerTestSetup.apartment1Id,
"Demo Apartment - Smart Start",
Ruleset.Lang.GROOVY,
getClass().getResource("/demo/rules/DemoResidenceSmartSwitch.groovy").text)
@@ -177,7 +177,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
expect: "the rule engines to become available and be running"
conditions.eventually {
- apartment1Engine = rulesService.assetEngines.get(managerDemoSetup.apartment1Id)
+ apartment1Engine = rulesService.assetEngines.get(managerTestSetup.apartment1Id)
assert apartment1Engine != null
assert apartment1Engine.isRunning()
assert apartment1Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_1
@@ -185,7 +185,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
and: "smart switches should be off"
conditions.eventually {
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert !kitchen.getAttribute("smartSwitchModeA").get().getValue().isPresent()
assert !kitchen.getAttribute("smartSwitchStartTimeA").get().getValue().isPresent()
assert !kitchen.getAttribute("smartSwitchStopTimeA").get().getValue().isPresent()
@@ -202,13 +202,13 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
when: "mode is set to ON_AT"
assetProcessingService.sendAttributeEvent(
- new AttributeEvent(managerDemoSetup.apartment1KitchenId, "smartSwitchModeA", Values.create("ON_AT"))
+ new AttributeEvent(managerTestSetup.apartment1KitchenId, "smartSwitchModeA", Values.create("ON_AT"))
)
noEventProcessedIn(assetProcessingService, 500)
then: "mode should be ON_AT but actuator not enabled"
conditions.eventually {
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert kitchen.getAttribute("smartSwitchModeA").get().getValueAsString().get() == "ON_AT"
assert !kitchen.getAttribute("smartSwitchStartTimeA").get().getValue().isPresent()
assert !kitchen.getAttribute("smartSwitchStopTimeA").get().getValue().isPresent()
@@ -226,13 +226,13 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
when: "begin/end cycle time is set to past"
long fiveMinutesInPastMillis = getClockTimeOf(container) - (5 * 60 * 1000)
assetProcessingService.sendAttributeEvent(
- new AttributeEvent(managerDemoSetup.apartment1KitchenId, "smartSwitchBeginEndA", Values.create(fiveMinutesInPastMillis))
+ new AttributeEvent(managerTestSetup.apartment1KitchenId, "smartSwitchBeginEndA", Values.create(fiveMinutesInPastMillis))
)
noEventProcessedIn(assetProcessingService, 500)
then: "mode should be ON_AT and actuator not enabled"
conditions.eventually {
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert kitchen.getAttribute("smartSwitchModeA").get().getValueAsString().get() == "ON_AT"
assert !kitchen.getAttribute("smartSwitchStartTimeA").get().getValue().isPresent()
assert !kitchen.getAttribute("smartSwitchStopTimeA").get().getValue().isPresent()
@@ -258,7 +258,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def rulesService = container.getService(RulesService.class)
def assetStorageService = container.getService(AssetStorageService.class)
def assetProcessingService = container.getService(AssetProcessingService.class)
@@ -267,7 +267,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
and: "some rules"
Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment1Id,
+ managerTestSetup.apartment1Id,
"Demo Apartment - Smart Start",
Ruleset.Lang.GROOVY,
getClass().getResource("/demo/rules/DemoResidenceSmartSwitch.groovy").text)
@@ -275,7 +275,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
expect: "the rule engines to become available and be running"
conditions.eventually {
- apartment1Engine = rulesService.assetEngines.get(managerDemoSetup.apartment1Id)
+ apartment1Engine = rulesService.assetEngines.get(managerTestSetup.apartment1Id)
assert apartment1Engine != null
assert apartment1Engine.isRunning()
assert apartment1Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_1
@@ -283,7 +283,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
and: "smart switches should be off"
conditions.eventually {
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert !kitchen.getAttribute("smartSwitchModeA").get().getValue().isPresent()
assert !kitchen.getAttribute("smartSwitchStartTimeA").get().getValue().isPresent()
assert !kitchen.getAttribute("smartSwitchStopTimeA").get().getValue().isPresent()
@@ -300,13 +300,13 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
when: "mode is set to READY_AT"
assetProcessingService.sendAttributeEvent(
- new AttributeEvent(managerDemoSetup.apartment1KitchenId, "smartSwitchModeA", Values.create("READY_AT"))
+ new AttributeEvent(managerTestSetup.apartment1KitchenId, "smartSwitchModeA", Values.create("READY_AT"))
)
noEventProcessedIn(assetProcessingService, 500)
then: "mode should be READY_AT but actuator not enabled"
conditions.eventually {
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert kitchen.getAttribute("smartSwitchModeA").get().getValueAsString().get() == "READY_AT"
assert !kitchen.getAttribute("smartSwitchStartTimeA").get().getValue().isPresent()
assert !kitchen.getAttribute("smartSwitchStopTimeA").get().getValue().isPresent()
@@ -324,13 +324,13 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
when: "begin/end cycle time is set to future"
long threeHoursInFutureMillis = getClockTimeOf(container) + (3 * 60 * 60 * 1000)
assetProcessingService.sendAttributeEvent(
- new AttributeEvent(managerDemoSetup.apartment1KitchenId, "smartSwitchBeginEndA", Values.create(threeHoursInFutureMillis))
+ new AttributeEvent(managerTestSetup.apartment1KitchenId, "smartSwitchBeginEndA", Values.create(threeHoursInFutureMillis))
)
noEventProcessedIn(assetProcessingService, 500)
then: "mode should be READY_AT and actuator enabled with correct start/stop time"
conditions.eventually {
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert kitchen.getAttribute("smartSwitchModeA").get().getValueAsString().get() == "READY_AT"
assert kitchen.getAttribute("smartSwitchBeginEndA").get().getValueAsNumber().get() == (double)threeHoursInFutureMillis
assert kitchen.getAttribute("smartSwitchStartTimeA").get().getValueAsNumber().get() == Math.floor((double)getClockTimeOf(container)/1000)
@@ -351,7 +351,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
then: "mode should be NOW_ON and actuator not enabled"
conditions.eventually {
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert kitchen.getAttribute("smartSwitchModeA").get().getValueAsString().get() == "NOW_ON"
assert !kitchen.getAttribute("smartSwitchBeginEndA").get().getValue().isPresent()
assert kitchen.getAttribute("smartSwitchStartTimeA").get().getValueAsNumber().get() == 0
@@ -380,7 +380,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def rulesService = container.getService(RulesService.class)
def assetStorageService = container.getService(AssetStorageService.class)
def assetProcessingService = container.getService(AssetProcessingService.class)
@@ -389,7 +389,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
and: "some rules"
Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment1Id,
+ managerTestSetup.apartment1Id,
"Demo Apartment - Smart Start",
Ruleset.Lang.GROOVY,
getClass().getResource("/demo/rules/DemoResidenceSmartSwitch.groovy").text)
@@ -397,7 +397,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
expect: "the rule engines to become available and be running"
conditions.eventually {
- apartment1Engine = rulesService.assetEngines.get(managerDemoSetup.apartment1Id)
+ apartment1Engine = rulesService.assetEngines.get(managerTestSetup.apartment1Id)
assert apartment1Engine != null
assert apartment1Engine.isRunning()
assert apartment1Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_1
@@ -405,7 +405,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
and: "smart switches should be off"
conditions.eventually {
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert !kitchen.getAttribute("smartSwitchModeA").get().getValue().isPresent()
assert !kitchen.getAttribute("smartSwitchStartTimeA").get().getValue().isPresent()
assert !kitchen.getAttribute("smartSwitchStopTimeA").get().getValue().isPresent()
@@ -422,13 +422,13 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
when: "mode is set to READY_AT"
assetProcessingService.sendAttributeEvent(
- new AttributeEvent(managerDemoSetup.apartment1KitchenId, "smartSwitchModeA", Values.create("READY_AT"))
+ new AttributeEvent(managerTestSetup.apartment1KitchenId, "smartSwitchModeA", Values.create("READY_AT"))
)
noEventProcessedIn(assetProcessingService, 500)
then: "mode should be READY_AT but actuator not enabled"
conditions.eventually {
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert kitchen.getAttribute("smartSwitchModeA").get().getValueAsString().get() == "READY_AT"
assert !kitchen.getAttribute("smartSwitchStartTimeA").get().getValue().isPresent()
assert !kitchen.getAttribute("smartSwitchStopTimeA").get().getValue().isPresent()
@@ -446,13 +446,13 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
when: "begin/end cycle time is set to past"
long fiveMinutesInPastMillis = getClockTimeOf(container) - (5 * 60 * 1000)
assetProcessingService.sendAttributeEvent(
- new AttributeEvent(managerDemoSetup.apartment1KitchenId, "smartSwitchBeginEndA", Values.create(fiveMinutesInPastMillis))
+ new AttributeEvent(managerTestSetup.apartment1KitchenId, "smartSwitchBeginEndA", Values.create(fiveMinutesInPastMillis))
)
noEventProcessedIn(assetProcessingService, 500)
then: "mode should be READY_AT but actuator not enabled"
conditions.eventually {
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert kitchen.getAttribute("smartSwitchModeA").get().getValueAsString().get() == "READY_AT"
assert kitchen.getAttribute("smartSwitchBeginEndA").get().getValueAsNumber().get() == (double)fiveMinutesInPastMillis
assert !kitchen.getAttribute("smartSwitchStartTimeA").get().getValue().isPresent()
@@ -479,7 +479,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def rulesService = container.getService(RulesService.class)
def assetStorageService = container.getService(AssetStorageService.class)
def assetProcessingService = container.getService(AssetProcessingService.class)
@@ -488,7 +488,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
and: "some rules"
Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment1Id,
+ managerTestSetup.apartment1Id,
"Demo Apartment - Smart Start",
Ruleset.Lang.GROOVY,
getClass().getResource("/demo/rules/DemoResidenceSmartSwitch.groovy").text)
@@ -496,7 +496,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
expect: "the rule engines to become available and be running"
conditions.eventually {
- apartment1Engine = rulesService.assetEngines.get(managerDemoSetup.apartment1Id)
+ apartment1Engine = rulesService.assetEngines.get(managerTestSetup.apartment1Id)
assert apartment1Engine != null
assert apartment1Engine.isRunning()
assert apartment1Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_1
@@ -504,7 +504,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
and: "smart switches should be off"
conditions.eventually {
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert !kitchen.getAttribute("smartSwitchModeA").get().getValue().isPresent()
assert !kitchen.getAttribute("smartSwitchStartTimeA").get().getValue().isPresent()
assert !kitchen.getAttribute("smartSwitchStopTimeA").get().getValue().isPresent()
@@ -521,13 +521,13 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
when: "mode is set to READY_AT"
assetProcessingService.sendAttributeEvent(
- new AttributeEvent(managerDemoSetup.apartment1KitchenId, "smartSwitchModeA", Values.create("READY_AT"))
+ new AttributeEvent(managerTestSetup.apartment1KitchenId, "smartSwitchModeA", Values.create("READY_AT"))
)
noEventProcessedIn(assetProcessingService, 500)
then: "mode should be READY_AT but actuator not enabled"
conditions.eventually {
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert kitchen.getAttribute("smartSwitchModeA").get().getValueAsString().get() == "READY_AT"
assert !kitchen.getAttribute("smartSwitchStartTimeA").get().getValue().isPresent()
assert !kitchen.getAttribute("smartSwitchStopTimeA").get().getValue().isPresent()
@@ -545,13 +545,13 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
when: "begin/end cycle time is set insufficient future time"
long fiveMinutesInFuture = getClockTimeOf(container) + (5 * 60 * 1000)
assetProcessingService.sendAttributeEvent(
- new AttributeEvent(managerDemoSetup.apartment1KitchenId, "smartSwitchBeginEndA", Values.create(fiveMinutesInFuture))
+ new AttributeEvent(managerTestSetup.apartment1KitchenId, "smartSwitchBeginEndA", Values.create(fiveMinutesInFuture))
)
noEventProcessedIn(assetProcessingService, 500)
then: "mode should be READY_AT but actuator not enabled"
conditions.eventually {
- def kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId, true)
+ def kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId, true)
assert kitchen.getAttribute("smartSwitchModeA").get().getValueAsString().get() == "READY_AT"
assert kitchen.getAttribute("smartSwitchBeginEndA").get().getValueAsNumber().get() == (double)fiveMinutesInFuture
assert !kitchen.getAttribute("smartSwitchStartTimeA").get().getValue().isPresent()
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.groovy
index be02ccf71..77b3d29ae 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
@@ -6,7 +6,7 @@ import org.openremote.manager.rules.RulesEngine
import org.openremote.manager.rules.RulesService
import org.openremote.manager.rules.RulesetStorageService
import org.openremote.manager.setup.SetupService
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.attribute.AttributeEvent
import org.openremote.model.attribute.AttributeExecuteStatus
import org.openremote.model.rules.AssetRuleset
@@ -21,7 +21,7 @@ import java.time.DayOfWeek
import static java.util.concurrent.TimeUnit.DAYS
import static java.util.concurrent.TimeUnit.HOURS
-import static org.openremote.manager.setup.builtin.ManagerDemoSetup.DEMO_RULE_STATES_APARTMENT_1_WITH_SCENES
+import static org.openremote.manager.setup.builtin.ManagerTestSetup.DEMO_RULE_STATES_APARTMENT_1_WITH_SCENES
class ResidenceVacationModeTest extends Specification implements ManagerContainerTrait {
@@ -32,7 +32,7 @@ class ResidenceVacationModeTest extends Specification implements ManagerContaine
def expirationMillis = TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS
TemporaryFact.GUARANTEED_MIN_EXPIRATION_MILLIS = 500
def container = startContainer(defaultConfig(), defaultServices())
- def managerDemoSetup = container.getService(SetupService.class).getTaskOfType(ManagerDemoSetup.class)
+ def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def rulesService = container.getService(RulesService.class)
def assetProcessingService = container.getService(AssetProcessingService.class)
def assetStorageService = container.getService(AssetStorageService.class)
@@ -40,19 +40,19 @@ class ResidenceVacationModeTest extends Specification implements ManagerContaine
RulesEngine apartment1Engine
and: "scenes are added to apartment1 rooms"
- def apartment1 = assetStorageService.find(managerDemoSetup.apartment1Id)
- def apartment1Livingroom = assetStorageService.find(managerDemoSetup.apartment1LivingroomId)
- def apartment1Kitchen = assetStorageService.find(managerDemoSetup.apartment1KitchenId)
- def apartment1Hallway = assetStorageService.find(managerDemoSetup.apartment1HallwayId)
- ManagerDemoSetup.createDemoApartmentScenes(
+ def apartment1 = assetStorageService.find(managerTestSetup.apartment1Id)
+ def apartment1Livingroom = assetStorageService.find(managerTestSetup.apartment1LivingroomId)
+ def apartment1Kitchen = assetStorageService.find(managerTestSetup.apartment1KitchenId)
+ def apartment1Hallway = assetStorageService.find(managerTestSetup.apartment1HallwayId)
+ ManagerTestSetup.createDemoApartmentScenes(
assetStorageService,
apartment1,
- ManagerDemoSetup.DEMO_APARTMENT_SCENES,
+ ManagerTestSetup.DEMO_APARTMENT_SCENES,
apartment1Livingroom, apartment1Kitchen, apartment1Hallway)
and: "some rules"
Ruleset ruleset = new AssetRuleset(
- managerDemoSetup.apartment1Id,
+ managerTestSetup.apartment1Id,
"Demo Apartment - Vacation Mode",
Ruleset.Lang.GROOVY,
getClass().getResource("/demo/rules/DemoResidenceVacationMode.groovy").text)
@@ -60,13 +60,13 @@ class ResidenceVacationModeTest extends Specification implements ManagerContaine
expect: "the rule engines to become available and be running"
conditions.eventually {
- apartment1Engine = rulesService.assetEngines.get(managerDemoSetup.apartment1Id)
+ apartment1Engine = rulesService.assetEngines.get(managerTestSetup.apartment1Id)
assert apartment1Engine != null
assert apartment1Engine.isRunning()
assert apartment1Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_1_WITH_SCENES
// The macro should be ready
- def asset = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def asset = assetStorageService.find(managerTestSetup.apartment1Id, true)
def executionStatus = AttributeExecuteStatus.fromString(
asset.getAttribute("dayScene").get().getValueAsString().get()
).get()
@@ -76,12 +76,12 @@ class ResidenceVacationModeTest extends Specification implements ManagerContaine
when: "the vacation days are set to 5"
double fiveDaysInFuture = getClockTimeOf(container) + (5 * 24 * 60 * 60 * 1000)
assetProcessingService.sendAttributeEvent(new AttributeEvent(
- managerDemoSetup.apartment1Id, "vacationUntil", Values.create(fiveDaysInFuture)
+ managerTestSetup.apartment1Id, "vacationUntil", Values.create(fiveDaysInFuture)
))
then: "the DAY scene should be executed and scene timers disabled"
conditions.eventually {
- def asset = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def asset = assetStorageService.find(managerTestSetup.apartment1Id, true)
def executionStatus = AttributeExecuteStatus.fromString(
asset.getAttribute("dayScene").get().getValueAsString().get()
).get()
@@ -100,7 +100,7 @@ class ResidenceVacationModeTest extends Specification implements ManagerContaine
then: "vacation mode is still on"
conditions.eventually {
- def asset = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def asset = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert asset.getAttribute("vacationUntil").get().getValueAsNumber().get() == fiveDaysInFuture
assert !asset.getAttribute("sceneTimerEnabled").get().getValueAsBoolean().get()
DayOfWeek.values().each {
@@ -116,7 +116,7 @@ class ResidenceVacationModeTest extends Specification implements ManagerContaine
then: "vacation mode is off and scene timers are enabled"
conditions.eventually {
- def asset = assetStorageService.find(managerDemoSetup.apartment1Id, true)
+ def asset = assetStorageService.find(managerTestSetup.apartment1Id, true)
assert !asset.getAttribute("vacationUntil").get().getValue().isPresent()
assert asset.getAttribute("sceneTimerEnabled").get().getValueAsBoolean().get()
DayOfWeek.values().each {
diff --git a/test/src/test/resources/org/openremote/test/rules/BasicLocationPredicates.groovy b/test/src/test/resources/org/openremote/test/rules/BasicLocationPredicates.groovy
index 070ac2d8f..e6fee1e34 100644
--- a/test/src/test/resources/org/openremote/test/rules/BasicLocationPredicates.groovy
+++ b/test/src/test/resources/org/openremote/test/rules/BasicLocationPredicates.groovy
@@ -1,7 +1,7 @@
package org.openremote.test.rules
import org.openremote.manager.rules.RulesBuilder
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.query.AssetQuery
import org.openremote.model.query.filter.LocationAttributePredicate
import org.openremote.model.query.filter.RadialGeofencePredicate
@@ -25,7 +25,7 @@ rules.add()
.name("Duplicate radial location predicate")
.when(
{ facts ->
- facts.matchFirstAssetState(new AssetQuery().attributes(new LocationAttributePredicate(new RadialGeofencePredicate(100, ManagerDemoSetup.SMART_BUILDING_LOCATION.y, ManagerDemoSetup.SMART_BUILDING_LOCATION.x)))).isPresent() &&
+ facts.matchFirstAssetState(new AssetQuery().attributes(new LocationAttributePredicate(new RadialGeofencePredicate(100, ManagerTestSetup.SMART_BUILDING_LOCATION.y, ManagerTestSetup.SMART_BUILDING_LOCATION.x)))).isPresent() &&
!facts.matchFirst("DuplicateLocation").isPresent()
})
.then(
diff --git a/test/src/test/resources/org/openremote/test/rules/BasicLocationPredicates2.groovy b/test/src/test/resources/org/openremote/test/rules/BasicLocationPredicates2.groovy
index c83de786d..8d242d819 100644
--- a/test/src/test/resources/org/openremote/test/rules/BasicLocationPredicates2.groovy
+++ b/test/src/test/resources/org/openremote/test/rules/BasicLocationPredicates2.groovy
@@ -1,7 +1,7 @@
package org.openremote.test.rules
import org.openremote.manager.rules.RulesBuilder
-import org.openremote.manager.setup.builtin.ManagerDemoSetup
+import org.openremote.manager.setup.builtin.ManagerTestSetup
import org.openremote.model.query.AssetQuery
import org.openremote.model.query.filter.LocationAttributePredicate
import org.openremote.model.query.filter.RadialGeofencePredicate
@@ -25,7 +25,7 @@ rules.add()
.name("Duplicate radial location predicate")
.when(
{ facts ->
- facts.matchFirstAssetState(new AssetQuery().attributes(new LocationAttributePredicate(new RadialGeofencePredicate(100, ManagerDemoSetup.SMART_BUILDING_LOCATION.y, ManagerDemoSetup.SMART_BUILDING_LOCATION.x)))).isPresent() &&
+ facts.matchFirstAssetState(new AssetQuery().attributes(new LocationAttributePredicate(new RadialGeofencePredicate(100, ManagerTestSetup.SMART_BUILDING_LOCATION.y, ManagerTestSetup.SMART_BUILDING_LOCATION.x)))).isPresent() &&
!facts.matchFirst("Location").isPresent()
})
.then(
diff --git a/ui/app/or-app/src/pages/page-assets.ts b/ui/app/or-app/src/pages/page-assets.ts
index 8b48528d5..3cc11ba37 100644
--- a/ui/app/or-app/src/pages/page-assets.ts
+++ b/ui/app/or-app/src/pages/page-assets.ts
@@ -315,7 +315,7 @@ export const PAGE_ASSETS_DEFAULT_CONFIG: PageAssetsConfig = {
default: {
panels: {
"attributes": {
- exclude: ["location", "userNotes", "manufacturer", "model"]
+ exclude: ["location", "userNotes", "manufacturer", "model", "status"]
},
"info": {
exclude: ["accessPublicRead"]