Skip to content

armgit / core

Public Imported from GitHub
0

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

Apply Spotless

Wouter Bornfe42b1d203db
diff --git a/agent/src/test/groovy/org/openremote/agent/protocol/simulator/SimulatorAgentProtocolScheduleTest.groovy b/agent/src/test/groovy/org/openremote/agent/protocol/simulator/SimulatorAgentProtocolScheduleTest.groovy
index 82b6bb2de..c47799ba3 100644
--- a/agent/src/test/groovy/org/openremote/agent/protocol/simulator/SimulatorAgentProtocolScheduleTest.groovy
+++ b/agent/src/test/groovy/org/openremote/agent/protocol/simulator/SimulatorAgentProtocolScheduleTest.groovy
@@ -106,7 +106,7 @@ class SimulatorAgentProtocolScheduleTest extends Specification {
schedule.tryAdvanceActive(
instant("1999-01-01T00:00:00.000Z") + DAY - 1,
0
- ) == start + 17 * HOUR + 30 * MINUTE
+ ) == start + 17 * HOUR + 30 * MINUTE
}
def "a minutely recurrence returns its last occurrence after UNTIL"() {
@@ -160,7 +160,7 @@ class SimulatorAgentProtocolScheduleTest extends Specification {
instant("2000-01-02T00:00:00.000Z"),
null,
"FREQ=HOURLY"
- )
+ )
expect:
delays(schedule, [
@@ -176,7 +176,7 @@ class SimulatorAgentProtocolScheduleTest extends Specification {
instant("2000-01-01T00:00:00.000Z"),
null,
"FREQ=HOURLY;UNTIL=20000101T020000"
- )
+ )
expect:
delays(schedule, recurringDelayExpectations())
@@ -191,7 +191,7 @@ class SimulatorAgentProtocolScheduleTest extends Specification {
instant("2000-01-01T00:00:00.000Z"),
null,
"FREQ=HOURLY;COUNT=3"
- )
+ )
expect:
delays(schedule, recurringDelayExpectations())
@@ -231,7 +231,7 @@ class SimulatorAgentProtocolScheduleTest extends Specification {
LocalDateTime.ofInstant(Instant.ofEpochMilli(start), ZoneOffset.UTC),
end == null ? null : LocalDateTime.ofInstant(Instant.ofEpochMilli(end), ZoneOffset.UTC),
recurrence
- )
+ )
}
private static long instant(String value) {
diff --git a/model/src/test/groovy/org/openremote/model/value/ValueUtilTest.groovy b/model/src/test/groovy/org/openremote/model/value/ValueUtilTest.groovy
index 35891812a..6eb9a8691 100644
--- a/model/src/test/groovy/org/openremote/model/value/ValueUtilTest.groovy
+++ b/model/src/test/groovy/org/openremote/model/value/ValueUtilTest.groovy
@@ -56,11 +56,11 @@ class ValueUtilTest extends Specification {
}
ValueUtil.ConstraintViolationPathProvider pathProvider = { constraintViolationBuilder ->
constraintViolationBuilder
- .addPropertyNode("attributes")
- .addPropertyNode("value")
- .inContainer(Map, 1)
- .inIterable()
- .atKey(attribute.name)
+ .addPropertyNode("attributes")
+ .addPropertyNode("value")
+ .inContainer(Map, 1)
+ .inIterable()
+ .atKey(attribute.name)
}
expect:
@@ -72,7 +72,7 @@ class ValueUtilTest extends Specification {
context,
pathProvider,
attribute.value.orElse(null)
- ) == expected
+ ) == expected
where:
description | attributeName | valueType | value || expected
diff --git a/settings.gradle b/settings.gradle
index b7697a02b..16f8eca80 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -47,7 +47,7 @@ fileTree(
.filter { !new File(it.parentFile, ".buildignore").exists() }
.each {
include it.parentFile.canonicalPath
- .replace(rootDir.canonicalPath, "")
- .replace("\\", ":")
- .replace("/", ":")
+ .replace(rootDir.canonicalPath, "")
+ .replace("\\", ":")
+ .replace("/", ":")
}
diff --git a/spotless.gradle b/spotless.gradle
index a2d4cff3a..5244c9a38 100644
--- a/spotless.gradle
+++ b/spotless.gradle
@@ -16,10 +16,10 @@ Map<String, String> devDependencies =
}
Map<String, String> eslintDependencies = devDependencies.findAll { String name, String ignored ->
name == 'eslint' ||
- name == 'typescript' ||
- name.startsWith('@typescript-eslint/') ||
- name.startsWith('eslint-config-') ||
- name.startsWith('eslint-plugin-')
+ name == 'typescript' ||
+ name.startsWith('@typescript-eslint/') ||
+ name.startsWith('eslint-config-') ||
+ name.startsWith('eslint-plugin-')
}
['eslint', 'prettier', 'typescript'].each { String dependency ->
if (!devDependencies.containsKey(dependency)) {
@@ -32,9 +32,9 @@ String prettierVersion = devDependencies.prettier
def readIgnorePatterns = { File ignoreFile ->
List<String> patterns = ignoreFile
- .readLines('UTF-8')
- .collect { it.trim() }
- .findAll { it && !it.startsWith('#') }
+ .readLines('UTF-8')
+ .collect { it.trim() }
+ .findAll { it && !it.startsWith('#') }
List<String> unsupported = patterns.findAll {
it.startsWith('!') || it.startsWith('/') || it.contains('\\')
}
@@ -175,7 +175,7 @@ spotless {
int end = source.indexOf(
prettierIgnoreEnd,
prettierIgnoreStart.length()
- )
+ )
if (end >= 0) {
candidateEnd = end + prettierIgnoreEnd.length()
candidate = source.substring(0, candidateEnd)
diff --git a/test/src/main/groovy/org/openremote/test/ContainerTrait.groovy b/test/src/main/groovy/org/openremote/test/ContainerTrait.groovy
index 95e6f942c..2db3cc988 100644
--- a/test/src/main/groovy/org/openremote/test/ContainerTrait.groovy
+++ b/test/src/main/groovy/org/openremote/test/ContainerTrait.groovy
@@ -537,8 +537,8 @@ trait ContainerTrait {
ResteasyClient createClient(String accessToken) {
testClient.updateAndGet {
it != null ? it :
- // Use a long timeout to make debugging a bit easier
- WebTargetBuilder.createClient(Container.EXECUTOR, 1, 120000, null)
+ // Use a long timeout to make debugging a bit easier
+ WebTargetBuilder.createClient(Container.EXECUTOR, 1, 120000, null)
}
}
diff --git a/test/src/main/groovy/org/openremote/test/TestUtil.groovy b/test/src/main/groovy/org/openremote/test/TestUtil.groovy
index 3818f0b65..9ed2b30d5 100644
--- a/test/src/main/groovy/org/openremote/test/TestUtil.groovy
+++ b/test/src/main/groovy/org/openremote/test/TestUtil.groovy
@@ -72,17 +72,17 @@ class TestUtil {
def threads = []
taskExecution.threadsPerInterval.times {
threads << new Thread(new Runnable() {
- @Override
- void run() {
- try {
- taskExecution.task()
- } catch (Throwable t) {
+ @Override
+ void run() {
+ try {
+ taskExecution.task()
+ } catch (Throwable t) {
- report.lastError = t
- report.errorCount++
- }
- }
- })
+ report.lastError = t
+ report.errorCount++
+ }
+ }
+ })
}
threads*.start()
threads*.join()
diff --git a/test/src/test/groovy/org/openremote/test/alarm/AlarmResourceTest.groovy b/test/src/test/groovy/org/openremote/test/alarm/AlarmResourceTest.groovy
index 51468bdaf..bcabf1646 100644
--- a/test/src/test/groovy/org/openremote/test/alarm/AlarmResourceTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/alarm/AlarmResourceTest.groovy
@@ -95,7 +95,7 @@ class AlarmResourceTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
regularUserResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM).proxy(AlarmResource.class)
adminResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, adminAccessToken).proxy(AlarmResource.class)
@@ -116,7 +116,7 @@ class AlarmResourceTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
"testuser4",
"testuser4",
- )
+ )
superAdminResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, superAdminAccessToken).proxy(AlarmResource.class)
@@ -126,7 +126,7 @@ class AlarmResourceTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
- )
+ )
buildingUserResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.realmBuilding.name, buildingUserAccessToken).proxy(AlarmResource.class)
diff --git a/test/src/test/groovy/org/openremote/test/assets/ApplyPredictedDataPointsServiceTest.groovy b/test/src/test/groovy/org/openremote/test/assets/ApplyPredictedDataPointsServiceTest.groovy
index f3a585d20..33797ecdb 100644
--- a/test/src/test/groovy/org/openremote/test/assets/ApplyPredictedDataPointsServiceTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/ApplyPredictedDataPointsServiceTest.groovy
@@ -93,7 +93,7 @@ class ApplyPredictedDataPointsServiceTest extends Specification implements Manag
attributeRef.getId(),
attributeRef.getName(),
predictedDatapoints
- )
+ )
and: "time advances to the first datapoint"
awaitScheduled(applyService, attributeRef, conditions)
@@ -142,7 +142,7 @@ class ApplyPredictedDataPointsServiceTest extends Specification implements Manag
def attributeRef = createTestAttribute(assetStorageService, managerTestSetup.thingId, "predictedValue2")
assetProcessingService.sendAttributeEvent(
new AttributeEvent(attributeRef, 1d, now)
- )
+ )
conditions.eventually {
def asset = assetStorageService.find(attributeRef.getId(), true)
def attribute = asset.getAttribute(attributeRef.getName()).get()
@@ -170,7 +170,7 @@ class ApplyPredictedDataPointsServiceTest extends Specification implements Manag
new ValueDatapoint<>(now - TimeUnit.MINUTES.toMillis(1), 5d),
new ValueDatapoint<>(now - TimeUnit.SECONDS.toMillis(10), 7d)
]
- )
+ )
then: "the last predicted value should be applied immediately"
conditions.eventually {
@@ -202,7 +202,7 @@ class ApplyPredictedDataPointsServiceTest extends Specification implements Manag
def attributeRef = createTestAttribute(assetStorageService, managerTestSetup.thingId, "predictedValue3")
assetProcessingService.sendAttributeEvent(
new AttributeEvent(attributeRef, 99d, now)
- )
+ )
conditions.eventually {
def asset = assetStorageService.find(attributeRef.getId(), true)
def attribute = asset.getAttribute(attributeRef.getName()).get()
@@ -226,7 +226,7 @@ class ApplyPredictedDataPointsServiceTest extends Specification implements Manag
new ValueDatapoint<>(now - TimeUnit.MINUTES.toMillis(1), 5d),
new ValueDatapoint<>(now - TimeUnit.SECONDS.toMillis(10), 7d)
]
- )
+ )
then: "the current attribute value should remain unchanged"
conditions.eventually {
@@ -264,7 +264,7 @@ class ApplyPredictedDataPointsServiceTest extends Specification implements Manag
new ValueDatapoint<>(now + TimeUnit.MINUTES.toMillis(1), 10d),
new ValueDatapoint<>(now + TimeUnit.MINUTES.toMillis(2), 20d)
]
- )
+ )
and: "time advances beyond the datapoints"
advancePseudoClock(3, TimeUnit.MINUTES, container)
@@ -308,7 +308,7 @@ class ApplyPredictedDataPointsServiceTest extends Specification implements Manag
new ValueDatapoint<>(now + TimeUnit.MINUTES.toMillis(1), 10d),
new ValueDatapoint<>(now + TimeUnit.MINUTES.toMillis(2), 20d)
]
- )
+ )
and: "time advances beyond the datapoints"
advancePseudoClock(3, TimeUnit.MINUTES, container)
@@ -352,7 +352,7 @@ class ApplyPredictedDataPointsServiceTest extends Specification implements Manag
new ValueDatapoint<>(now + TimeUnit.MINUTES.toMillis(1), 10d),
new ValueDatapoint<>(now + TimeUnit.MINUTES.toMillis(2), 20d)
]
- )
+ )
and: "time advances beyond the datapoints"
advancePseudoClock(3, TimeUnit.MINUTES, container)
@@ -408,7 +408,7 @@ class ApplyPredictedDataPointsServiceTest extends Specification implements Manag
new ValueDatapoint<>(now + TimeUnit.MINUTES.toMillis(1), 10d),
new ValueDatapoint<>(now + TimeUnit.MINUTES.toMillis(2), 20d)
]
- )
+ )
when: "time advances to the first datapoint"
advancePseudoClock(1, TimeUnit.MINUTES, container)
@@ -460,7 +460,7 @@ class ApplyPredictedDataPointsServiceTest extends Specification implements Manag
new ValueDatapoint<>(now + TimeUnit.MINUTES.toMillis(1), 10d),
new ValueDatapoint<>(now + TimeUnit.MINUTES.toMillis(2), 20d)
]
- )
+ )
and: "the first datapoint is scheduled"
awaitScheduled(applyService, attributeRef, conditions)
@@ -468,7 +468,7 @@ class ApplyPredictedDataPointsServiceTest extends Specification implements Manag
when: "an event without the required meta is delivered, as can happen when events arrive out of order"
applyService.onAttributeEvent(
new AttributeEvent(attributeRef, 0d, now).setMeta(new MetaMap())
- )
+ )
then: "the schedule should be kept because the stored attribute still has the required meta"
assert isScheduled(applyService, attributeRef)
@@ -513,7 +513,7 @@ class ApplyPredictedDataPointsServiceTest extends Specification implements Manag
new ValueDatapoint<>(now + TimeUnit.MINUTES.toMillis(1), 10d),
new ValueDatapoint<>(now + TimeUnit.MINUTES.toMillis(2), 20d)
]
- )
+ )
when: "time advances to the first datapoint"
awaitScheduled(applyService, attributeRef, conditions)
@@ -588,7 +588,7 @@ class ApplyPredictedDataPointsServiceTest extends Specification implements Manag
new ValueDatapoint<>(now + TimeUnit.MINUTES.toMillis(2), 20d),
new ValueDatapoint<>(now + TimeUnit.MINUTES.toMillis(3), 30d)
]
- )
+ )
when: "time advances to the middle of the predicted datapoints"
advancePseudoClock(1, TimeUnit.MINUTES, container)
@@ -669,7 +669,7 @@ class ApplyPredictedDataPointsServiceTest extends Specification implements Manag
new ValueDatapoint<>(now + TimeUnit.MINUTES.toMillis(2), 20d),
new ValueDatapoint<>(now + TimeUnit.MINUTES.toMillis(3), 30d)
]
- )
+ )
when: "time advances to the middle of the predicted datapoints"
advancePseudoClock(1, TimeUnit.MINUTES, container)
@@ -712,7 +712,7 @@ class ApplyPredictedDataPointsServiceTest extends Specification implements Manag
attribute.addOrReplaceMeta(
new MetaItem<>(HAS_PREDICTED_DATA_POINTS, true),
new MetaItem<>(APPLY_PREDICTED_DATA_POINTS, true)
- )
+ )
assetStorageService.merge(asset)
}
@@ -720,7 +720,7 @@ class ApplyPredictedDataPointsServiceTest extends Specification implements Manag
def asset = assetStorageService.find(assetId)
asset.getAttributes().addOrReplace(
new org.openremote.model.attribute.Attribute<>(attributeName, ValueType.NUMBER, 0d)
- )
+ )
assetStorageService.merge(asset)
return new AttributeRef(assetId, attributeName)
}
@@ -731,7 +731,7 @@ class ApplyPredictedDataPointsServiceTest extends Specification implements Manag
attribute.addOrReplaceMeta(
new MetaItem<>(HAS_PREDICTED_DATA_POINTS, true),
new MetaItem<>(APPLY_PREDICTED_DATA_POINTS, true)
- )
+ )
asset.getAttributes().addOrReplace(attribute)
assetStorageService.merge(asset)
return new AttributeRef(assetId, attributeName)
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetDatapointExportTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetDatapointExportTest.groovy
index 878a99813..0d06b1561 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetDatapointExportTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetDatapointExportTest.groovy
@@ -79,7 +79,7 @@ class AssetDatapointExportTest extends Specification implements ManagerContainer
.types(LightAsset.class)
.realm(new RealmPredicate(keycloakTestSetup.realmCity.name))
.names("Light 1")
- )
+ )
then: "asset should exist and be correct"
def assetName = "Light 1"
@@ -106,14 +106,14 @@ class AssetDatapointExportTest extends Specification implements ManagerContainer
new ValueDatapoint<>(dateTime.minusMinutes(10).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 20d),
new ValueDatapoint<>(dateTime.minusMinutes(5).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 10d),
]
- )
+ )
then: "the default CSV export should return a stream"
def inputStream1 = assetDatapointService.exportDatapoints(
[new AttributeRef(asset.id, attributeName)] as AttributeRef[],
dateTime.minusMinutes(30).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(),
dateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()
- )
+ )
and: "the CSV export should contain all 5 data points"
def csvExport1Lines = inputStream1.readLines()
@@ -132,7 +132,7 @@ class AssetDatapointExportTest extends Specification implements ManagerContainer
dateTime.minusMinutes(30).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(),
dateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(),
DatapointExportFormat.CSV_CROSSTAB
- )
+ )
then: "the crosstab CSV export should contain all 5 data points in columnar format"
def csvExport2Lines = inputStream2.readLines()
@@ -148,7 +148,7 @@ class AssetDatapointExportTest extends Specification implements ManagerContainer
dateTime.minusMinutes(30).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(),
dateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(),
DatapointExportFormat.CSV_CROSSTAB_MINUTE
- )
+ )
then: "the time-bucketed CSV export should contain aggregated data with correct values"
def csvExport3Lines = inputStream3.readLines()
@@ -185,7 +185,7 @@ class AssetDatapointExportTest extends Specification implements ManagerContainer
[new AttributeRef(asset.id, attributeName)] as AttributeRef[],
dateTime.minusMinutes(30).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(),
dateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()
- )
+ )
then: "the CSV export should throw an exception"
thrown(DatapointQueryTooLargeException)
@@ -221,7 +221,7 @@ class AssetDatapointExportTest extends Specification implements ManagerContainer
.types(LightAsset.class)
.realm(new RealmPredicate(keycloakTestSetup.realmCity.name))
.names("Light 1")
- )
+ )
then: "asset should exist and be correct"
assert asset != null
@@ -232,7 +232,7 @@ class AssetDatapointExportTest extends Specification implements ManagerContainer
[new AttributeRef(asset.id, injectedAttributeName)] as AttributeRef[],
LocalDateTime.now().minusMinutes(30).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(),
LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()
- )
+ )
then: "the CSV export should not contain injected rows"
assert csvExport != null
@@ -258,7 +258,7 @@ class AssetDatapointExportTest extends Specification implements ManagerContainer
.types(LightAsset.class)
.realm(new RealmPredicate(keycloakTestSetup.realmCity.name))
.names("Light 1")
- )
+ )
assert asset != null
def originalName = asset.name
def maliciousAssetName = 'SQL "delimiter" $cat$ -- label'
@@ -274,15 +274,15 @@ class AssetDatapointExportTest extends Specification implements ManagerContainer
[
new ValueDatapoint<>(dateTime.minusMinutes(1).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 42d)
]
- )
+ )
expect: "both crosstab formats export the datapoint without treating the asset name as SQL"
[DatapointExportFormat.CSV_CROSSTAB, DatapointExportFormat.CSV_CROSSTAB_MINUTE].each { format ->
def csvExport = assetDatapointService.exportDatapoints(
- [new AttributeRef(asset.id, attributeName)] as AttributeRef[],
- dateTime.minusMinutes(5).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(),
- dateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(),
- format
+ [new AttributeRef(asset.id, attributeName)] as AttributeRef[],
+ dateTime.minusMinutes(5).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(),
+ dateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(),
+ format
).getText(StandardCharsets.UTF_8.name())
def csvExportLines = csvExport.readLines()
@@ -323,7 +323,7 @@ class AssetDatapointExportTest extends Specification implements ManagerContainer
KEYCLOAK_CLIENT_ID,
"smartcity",
"smartcity"
- )
+ )
def response = null
when: "exporting with a malicious attribute name via REST API"
@@ -332,7 +332,7 @@ class AssetDatapointExportTest extends Specification implements ManagerContainer
.types(LightAsset.class)
.realm(new RealmPredicate(keycloakTestSetup.realmCity.name))
.names("Light 1")
- )
+ )
assert asset != null
def injectedAttributeName = "x')) UNION ((SELECT now()::timestamp, table_name::text, 'injected'::text, NULL::jsonb FROM information_schema.tables WHERE table_schema='public"
def attributeRefsJson = "[{\"id\":\"${asset.id}\",\"name\":\"${injectedAttributeName}\"}]"
@@ -386,7 +386,7 @@ class AssetDatapointExportTest extends Specification implements ManagerContainer
[
new ValueDatapoint<>(dateTime.minusMinutes(1).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 42d)
]
- )
+ )
and: "a restricted user is authenticated in the asset realm"
def accessToken = authenticate(
@@ -395,7 +395,7 @@ class AssetDatapointExportTest extends Specification implements ManagerContainer
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
- )
+ )
when: "the restricted user exports the historical datapoints"
def response = null
def attributeRefsJson = "[{\"id\":\"${asset.id}\",\"name\":\"${attributeName}\"}]"
@@ -448,7 +448,7 @@ class AssetDatapointExportTest extends Specification implements ManagerContainer
[
new ValueDatapoint<>(dateTime.minusMinutes(1).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 42d)
]
- )
+ )
and: "a restricted user is authenticated in the asset realm"
def accessToken = authenticate(
@@ -457,7 +457,7 @@ class AssetDatapointExportTest extends Specification implements ManagerContainer
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
- )
+ )
when: "the restricted user requests the historical datapoint period"
def response = null
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetDatapointPurgeTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetDatapointPurgeTest.groovy
index fc1956340..a9a9f06ac 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetDatapointPurgeTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetDatapointPurgeTest.groovy
@@ -121,7 +121,7 @@ class AssetDatapointPurgeTest extends Specification implements ManagerContainerT
when: "ten assets for segment delete verification are created with the same attributes"
def segmentDeleteAssets = (1..10).collect { index ->
def asset = new ThingAsset("Hypercore Segment Delete Asset ${index}")
- .setRealm(keycloakTestSetup.realmMaster.name)
+ .setRealm(keycloakTestSetup.realmMaster.name)
asset.addOrReplaceAttributes(numberAttributes(attributeNames))
assetStorageService.merge(asset)
}
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetDatapointQueryTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetDatapointQueryTest.groovy
index c798caeca..79cd81f6e 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetDatapointQueryTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetDatapointQueryTest.groovy
@@ -69,7 +69,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
.types(LightAsset.class)
.realm(new RealmPredicate(keycloakTestSetup.realmCity.name))
.names("Light 1")
- )
+ )
then: "asset should exist and be correct"
def assetName = "Light 1"
@@ -97,7 +97,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
new ValueDatapoint<>(dateTime.minusMinutes(10).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 20d),
new ValueDatapoint<>(dateTime.minusMinutes(5).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 10d),
]
- )
+ )
then: "datapoints should exist"
def allDatapoints = new ArrayList<ValueDatapoint>()
@@ -115,7 +115,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
new RuntimeException("Missing attribute")
}),
new AssetDatapointLTTBQuery(dateTime.minusMinutes(30), dateTime, 5)
- )
+ )
assert lttbDatapoints1.size() == 5
and: "the 5 values are equal to 5 values in 'allDatapoints'"
@@ -135,7 +135,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
new RuntimeException("Missing attribute")
}),
new AssetDatapointLTTBQuery(dateTime.minusMinutes(30), dateTime, 3)
- )
+ )
assert lttbDatapoints2.size() == 3
assert lttbDatapoints2[0].value == 50d
assert lttbDatapoints2[1].value == 40d
@@ -158,7 +158,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
new ValueDatapoint<>(dateTime.minusMinutes(25).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 15d),
new ValueDatapoint<>(dateTime.minusMinutes(15).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 20d),
]
- )
+ )
then: "the spike should be present as the 2nd value"
def lttbDatapoints3 = assetDatapointService.queryDatapoints(
@@ -167,7 +167,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
new RuntimeException("Missing attribute")
}),
new AssetDatapointLTTBQuery(dateTime.minusMinutes(60), dateTime, 4)
- )
+ )
assert lttbDatapoints3.size() == 4
assert lttbDatapoints3[0].value == 10d
assert lttbDatapoints3[1].value == 90d
@@ -208,7 +208,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
.addAttributes(
new Attribute<>("status", ValueType.BOOLEAN, null).addMeta(new MetaItem<>(MetaItemType.STORE_DATA_POINTS)),
new Attribute<>("deviceId", ValueType.TEXT, null).addMeta(new MetaItem<>(MetaItemType.STORE_DATA_POINTS)),
- )
+ )
thingAsset = assetStorageService.merge(thingAsset)
and: "add datapoints to the attributes"
@@ -227,11 +227,11 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
and: "lttbQuery with boolean should not throw exception"
conditions.eventually {
def lttbDatapoints = assetDatapointService.queryDatapoints(
- thingAsset.getId(),
- thingAsset.getAttribute("status").orElseThrow({
- new RuntimeException("Missing attribute")
- }),
- new AssetDatapointLTTBQuery(LocalDateTime.now().minusMinutes(5), LocalDateTime.now(), 3)
+ thingAsset.getId(),
+ thingAsset.getAttribute("status").orElseThrow({
+ new RuntimeException("Missing attribute")
+ }),
+ new AssetDatapointLTTBQuery(LocalDateTime.now().minusMinutes(5), LocalDateTime.now(), 3)
)
assert lttbDatapoints.size() == 1
assert lttbDatapoints[0].value == 1.0 // Aka true as boolean
@@ -244,7 +244,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
new RuntimeException("Missing attribute")
}),
new AssetDatapointLTTBQuery(LocalDateTime.now().minusMinutes(5), LocalDateTime.now(), 3)
- )
+ )
then: "exception to be thrown"
IllegalStateException ex = thrown(IllegalStateException)
@@ -272,7 +272,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
.types(LightAsset.class)
.realm(new RealmPredicate(keycloakTestSetup.realmCity.name))
.names("Light 1")
- )
+ )
then: "asset should exist and be correct"
def assetName = "Light 1"
@@ -321,7 +321,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
new RuntimeException("Missing attribute")
}),
new AssetDatapointIntervalQuery(queryTime60, queryTimeNow, "1 minute", AssetDatapointIntervalQuery.Formula.AVG, false)
- )
+ )
assert intervalDatapoints1.size() == 6
def index = 0
intervalDatapoints1.toList().stream().forEach { dp -> {
@@ -339,7 +339,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
new RuntimeException("Missing attribute")
}),
new AssetDatapointIntervalQuery(queryTime60, queryTimeNow, "1 minute", AssetDatapointIntervalQuery.Formula.AVG, true)
- )
+ )
assert intervalDatapoints2.size() == 61 // because 60/1=60, plus an extra datapoint for the spare milliseconds of time
def index2 = 0
intervalDatapoints2.toList().stream().forEach { dp -> {
@@ -357,7 +357,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
new RuntimeException("Missing attribute")
}),
new AssetDatapointIntervalQuery(queryTime30, queryTimeNow, "5 minutes", AssetDatapointIntervalQuery.Formula.DIFFERENCE, true)
- )
+ )
then: "DIFFERENCE datapoints should be correct"
assert diffDatapoints1.size() == 7 // Because 30/5=6, plus an extra datapoint for the spare milliseconds of time.
@@ -383,7 +383,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
new RuntimeException("Missing attribute")
}),
new AssetDatapointIntervalQuery(queryTime60, queryTimeNow, "5 minutes", AssetDatapointIntervalQuery.Formula.COUNT, true)
- )
+ )
then: "COUNT datapoints should be correct"
assert countDatapoints1.size() == 13 // Because 60/5=12, plus an extra datapoint for the spare milliseconds of time.
@@ -421,7 +421,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
new RuntimeException("Missing attribute")
}),
new AssetDatapointIntervalQuery(queryTime30, queryTimeNow, "10 minutes", AssetDatapointIntervalQuery.Formula.SUM, true)
- )
+ )
then: "SUM datapoints should be correct"
assert sumDatapoints1.size() == 4 // Because 30/10=3, plus an extra datapoint for the spare milliseconds of time.
@@ -441,7 +441,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
new RuntimeException("Missing attribute")
}),
new AssetDatapointIntervalQuery(queryTime30, queryTimeNow, "5 minutes", AssetDatapointIntervalQuery.Formula.MODE, true)
- )
+ )
then: "MODE datapoints should be correct"
assert modeDatapoints1.size() == 6
@@ -465,7 +465,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
new RuntimeException("Missing attribute")
}),
new AssetDatapointIntervalQuery(queryTime30, queryTimeNow, "15 minutes", AssetDatapointIntervalQuery.Formula.MEDIAN, true)
- )
+ )
then: "MEDIAN datapoints should be correct"
assert medianDatapoints1.size() == 3 // Because 30/15=2, plus an extra datapoint for the spare milliseconds of time.
@@ -486,7 +486,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
new RuntimeException("Missing attribute")
}),
new AssetDatapointIntervalQuery(queryTime30, queryTimeNow, "60 minutes", AssetDatapointIntervalQuery.Formula.MODE, true)
- )
+ )
then: "MODE datapoints should return 90, because it is most common within the interval"
assert modeDatapoints2.size() == 1
@@ -512,7 +512,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
.types(LightAsset.class)
.realm(new RealmPredicate(keycloakTestSetup.realmCity.name))
.names("Light 1")
- )
+ )
then: "asset should exist and be correct"
def assetName = "Light 1"
@@ -540,7 +540,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
new ValueDatapoint<>(dateTime.minusMinutes(10).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 20d),
new ValueDatapoint<>(dateTime.minusMinutes(5).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 10d),
]
- )
+ )
then: "datapoints should exist"
def allDatapoints = new ArrayList<ValueDatapoint>()
@@ -558,7 +558,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
new RuntimeException("Missing attribute")
}),
new AssetDatapointAllQuery(dateTime.minusMinutes(30), dateTime)
- )
+ )
assert allDatapoints1.size() == 5
/* ------------------------- */
@@ -573,7 +573,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
new RuntimeException("Missing attribute")
}),
new AssetDatapointAllQuery(dateTime.minusMinutes(30), dateTime)
- )
+ )
then: "no points should be returned"
thrown(DatapointQueryTooLargeException)
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 8314b7b63..8fd49153f 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovy
@@ -113,7 +113,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
username,
password
)
- )
+ )
client.setEncoderDecoderProvider({
[
new StringEncoder(CharsetUtil.UTF_8),
@@ -149,7 +149,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
"testuser1",
"testuser1"
- )
+ )
// Resteasy client has issues with @Suspended annotation so not used for now
//def datapointResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AssetDatapointResource.class)
def predictedDatapointResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AssetPredictedDatapointResource.class)
@@ -259,7 +259,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
AssetDatapointIntervalQuery.Formula.AVG,
true
)
- )
+ )
assert aggregatedDatapoints.size() == 61
assert aggregatedDatapoints[54].value == 13.3
assert aggregatedDatapoints[55].value == null
@@ -284,7 +284,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
AssetDatapointIntervalQuery.Formula.AVG,
true
)
- )
+ )
assert aggregatedDatapoints.size() == 13
assert aggregatedDatapoints[11].value, closeTo(13.36666, 0.0001)
assert aggregatedDatapoints[12].value == 14.95
@@ -368,7 +368,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
AssetDatapointIntervalQuery.Formula.AVG,
true
)
- )
+ )
assert aggregatedDatapoints.size() == 61
assert aggregatedDatapoints[58].value == 0
assert aggregatedDatapoints[59].value == 1d
@@ -417,7 +417,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
new ValueDatapoint<>(getClockTimeOf(container)+240000, 40d),
new ValueDatapoint<>(getClockTimeOf(container)+300000, 50d)
] as ValueDatapoint<?>[]
- )
+ )
predictedDatapointResource.writePredictedDatapoints(null, managerTestSetup.thingId, thingLightToggleAttributeName,
[
new ValueDatapoint<>(getClockTimeOf(container)+60000, true),
@@ -426,7 +426,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
new ValueDatapoint<>(getClockTimeOf(container)+240000, false),
new ValueDatapoint<>(getClockTimeOf(container)+300000, false)
] as ValueDatapoint<?>[]
- )
+ )
then: "the predicted data should be available"
def predictedData = assetPredictedDatapointService.getDatapoints(new AttributeRef(managerTestSetup.thingId, "light1PowerConsumption"))
@@ -437,11 +437,11 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
conditions.eventually {
assert predictedEvents.any {
it.ref.id == managerTestSetup.thingId &&
- it.ref.name == "light1PowerConsumption"
+ it.ref.name == "light1PowerConsumption"
}
assert predictedEvents.any {
it.ref.id == managerTestSetup.thingId &&
- it.ref.name == thingLightToggleAttributeName
+ it.ref.name == thingLightToggleAttributeName
}
}
@@ -456,7 +456,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
conditions.eventually {
assert predictedEvents.any {
it.ref.id == managerTestSetup.thingId &&
- it.ref.name == "light1PowerConsumption"
+ it.ref.name == "light1PowerConsumption"
}
}
@@ -485,7 +485,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
apartment1.getAttributes().addOrReplace(
new Attribute<>(attributeName, ValueType.NUMBER, 0d)
.addMeta(new MetaItem<>(ACCESS_PUBLIC_WRITE, true))
- )
+ )
assetStorageService.merge(apartment1)
and: "an anonymous predicted datapoint API client"
@@ -497,7 +497,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
managerTestSetup.apartment1Id,
attributeName,
[new ValueDatapoint<>(getClockTimeOf(container) + 60000, 12d)] as ValueDatapoint<?>[]
- )
+ )
then: "the predicted datapoint should be stored"
conditions.eventually {
@@ -520,7 +520,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
"testuser2",
"testuser2"
- )
+ )
def predictedDatapointResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.realmBuilding.name, accessToken).proxy(AssetPredictedDatapointResource.class)
when: "the user writes predicted datapoints"
@@ -529,7 +529,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
managerTestSetup.apartment1LivingroomId,
"targetTemperature",
[new ValueDatapoint<>(getClockTimeOf(container) + 60000, 19d)] as ValueDatapoint<?>[]
- )
+ )
then: "access should be forbidden"
WebApplicationException ex = thrown()
@@ -552,7 +552,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
- )
+ )
def predictedDatapointResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.realmBuilding.name, accessToken).proxy(AssetPredictedDatapointResource.class)
when: "the restricted user writes a predicted datapoint for an attribute without restricted write access"
@@ -561,7 +561,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
managerTestSetup.apartment1Id,
BuildingAsset.STREET.name,
[new ValueDatapoint<>(getClockTimeOf(container) + 60000, "should fail")] as ValueDatapoint<?>[]
- )
+ )
then: "access should be forbidden"
WebApplicationException ex = thrown()
@@ -587,7 +587,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
"testuser1",
"testuser1"
- )
+ )
def predictedDatapointResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AssetPredictedDatapointResource.class)
and: "a websocket client authenticated in the same realm"
@@ -602,7 +602,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
"testuser1",
"testuser1"
)
- )
+ )
client.setEncoderDecoderProvider({
[
new StringEncoder(CharsetUtil.UTF_8),
@@ -630,13 +630,13 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
client.sendMessage(messageToString(
EventSubscription.SUBSCRIBE_MESSAGE_PREFIX,
new EventSubscription(AssetPredictedDatapointEvent.class, null, "predicted-datapoints")
- ))
+ ))
then: "the server should confirm subscription"
conditions.eventually {
assert receivedMessages.any {
it instanceof EventSubscription &&
- it.subscriptionId == "predicted-datapoints"
+ it.subscriptionId == "predicted-datapoints"
}
}
@@ -647,18 +647,18 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
managerTestSetup.thingId,
"light1PowerConsumption",
[new ValueDatapoint<>(getClockTimeOf(container) + 60000, 42d)] as ValueDatapoint<?>[]
- )
+ )
then: "the websocket subscription should receive the corresponding triggered event"
conditions.eventually {
assert receivedMessages.any {
it instanceof TriggeredEventSubscription &&
- it.subscriptionId == "predicted-datapoints" &&
- it.events.any { event ->
- event instanceof AssetPredictedDatapointEvent &&
- event.ref.id == managerTestSetup.thingId &&
- event.ref.name == "light1PowerConsumption"
- }
+ it.subscriptionId == "predicted-datapoints" &&
+ it.events.any { event ->
+ event instanceof AssetPredictedDatapointEvent &&
+ event.ref.id == managerTestSetup.thingId &&
+ event.ref.name == "light1PowerConsumption"
+ }
}
}
@@ -685,7 +685,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
ClientRole.WRITE_USER.value,
ClientRole.READ_MAP.value
- )
+ )
and: "a websocket client authenticated as that user"
def client = createPredictedDatapointWebsocketClient(serverPort, "building", "building", "testuser2", "testuser2")
@@ -701,13 +701,13 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
client.sendMessage(messageToString(
EventSubscription.SUBSCRIBE_MESSAGE_PREFIX,
new EventSubscription(AssetPredictedDatapointEvent.class, null, "predicted-no-read-assets")
- ))
+ ))
then: "the server should reject subscription"
conditions.eventually {
assert receivedMessages.any {
it instanceof UnauthorizedEventSubscription &&
- it.subscription.subscriptionId == "predicted-no-read-assets"
+ it.subscription.subscriptionId == "predicted-no-read-assets"
}
}
@@ -719,7 +719,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
ClientRole.WRITE_USER.value,
ClientRole.READ_MAP.value,
ClientRole.READ_ASSETS.value
- )
+ )
if (client != null) {
client.disconnect()
}
@@ -771,7 +771,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
ClientRole.READ_MAP.value,
ClientRole.READ_ASSETS.value,
ClientRole.WRITE_ATTRIBUTES.value
- )
+ )
and: "a limited building realm predicted datapoint API client"
def accessToken = authenticate(
@@ -780,7 +780,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
"testuser2",
"testuser2"
- )
+ )
def predictedDatapointResource = getClientApiTarget(serverUri(serverPort), "building", accessToken).proxy(AssetPredictedDatapointResource.class)
and: "a restricted websocket client in the same realm"
@@ -797,7 +797,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
client.sendMessage(messageToString(
EventSubscription.SUBSCRIBE_MESSAGE_PREFIX,
new EventSubscription(AssetPredictedDatapointEvent.class, null, "predicted-restricted-unlinked")
- ))
+ ))
and: "a predicted datapoint update is written on a linked and restricted attribute"
receivedMessages.clear()
@@ -806,18 +806,18 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
managerTestSetup.apartment1LivingroomId,
"targetTemperature",
[new ValueDatapoint<>(getClockTimeOf(container) + 60000, 22d)] as ValueDatapoint<?>[]
- )
+ )
then: "the restricted user should receive the linked attribute event"
conditions.eventually {
assert receivedMessages.any {
it instanceof TriggeredEventSubscription &&
- it.subscriptionId == "predicted-restricted-unlinked" &&
- it.events.any { event ->
- event instanceof AssetPredictedDatapointEvent &&
- event.ref.id == managerTestSetup.apartment1LivingroomId &&
- event.ref.name == "targetTemperature"
- }
+ it.subscriptionId == "predicted-restricted-unlinked" &&
+ it.events.any { event ->
+ event instanceof AssetPredictedDatapointEvent &&
+ event.ref.id == managerTestSetup.apartment1LivingroomId &&
+ event.ref.name == "targetTemperature"
+ }
}
}
@@ -828,7 +828,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
managerTestSetup.apartment2LivingroomId,
"targetTemperature",
[new ValueDatapoint<>(getClockTimeOf(container) + 60000, 21d)] as ValueDatapoint<?>[]
- )
+ )
then: "no triggered event should be received by the restricted user"
assert receivedMessages.every {
@@ -843,7 +843,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
ClientRole.WRITE_USER.value,
ClientRole.READ_MAP.value,
ClientRole.READ_ASSETS.value
- )
+ )
if (client != null) {
client.disconnect()
}
@@ -875,7 +875,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
ClientRole.READ_MAP.value,
ClientRole.READ_ASSETS.value,
ClientRole.WRITE_ATTRIBUTES.value
- )
+ )
and: "a limited building realm predicted datapoint API client"
def accessToken = authenticate(
@@ -884,7 +884,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
"testuser2",
"testuser2"
- )
+ )
def predictedDatapointResource = getClientApiTarget(serverUri(serverPort), "building", accessToken).proxy(AssetPredictedDatapointResource.class)
and: "a restricted websocket client in the same realm"
@@ -901,7 +901,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
client.sendMessage(messageToString(
EventSubscription.SUBSCRIBE_MESSAGE_PREFIX,
new EventSubscription(AssetPredictedDatapointEvent.class, null, "predicted-restricted-attr")
- ))
+ ))
and: "a predicted datapoint update is written on a linked restricted attribute"
receivedMessages.clear()
@@ -910,18 +910,18 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
managerTestSetup.apartment1LivingroomId,
"targetTemperature",
[new ValueDatapoint<>(getClockTimeOf(container) + 60000, 19d)] as ValueDatapoint<?>[]
- )
+ )
then: "the restricted user should receive the restricted attribute event"
conditions.eventually {
assert receivedMessages.any {
it instanceof TriggeredEventSubscription &&
- it.subscriptionId == "predicted-restricted-attr" &&
- it.events.any { event ->
- event instanceof AssetPredictedDatapointEvent &&
- event.ref.id == managerTestSetup.apartment1LivingroomId &&
- event.ref.name == "targetTemperature"
- }
+ it.subscriptionId == "predicted-restricted-attr" &&
+ it.events.any { event ->
+ event instanceof AssetPredictedDatapointEvent &&
+ event.ref.id == managerTestSetup.apartment1LivingroomId &&
+ event.ref.name == "targetTemperature"
+ }
}
}
@@ -932,7 +932,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
managerTestSetup.apartment1Id,
"predictedNonRestricted",
[new ValueDatapoint<>(getClockTimeOf(container) + 60000, 10d)] as ValueDatapoint<?>[]
- )
+ )
then: "no triggered event should be received by the restricted user"
assert receivedMessages.every {
@@ -947,7 +947,7 @@ class AssetDatapointTest extends Specification implements ManagerContainerTrait
ClientRole.WRITE_USER.value,
ClientRole.READ_MAP.value,
ClientRole.READ_ASSETS.value
- )
+ )
if (client != null) {
client.disconnect()
}
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 d03b0f8d3..87e03736d 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovy
@@ -65,7 +65,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "the asset resource"
def serverUri = serverUri(serverPort)
@@ -86,7 +86,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
testAsset = assetResource.get(null, testAsset.getId())
testAsset.addOrReplaceAttributes(
new Attribute<>("illegal- Attribute:name&&&", ValueType.TEXT)
- )
+ )
assetResource.update(null, testAsset.getId(), testAsset)
then: "the request should fail validation and return a validation report indicating the failure(s)"
@@ -104,7 +104,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
testAsset = assetResource.get(null, testAsset.getId())
testAsset.addOrReplaceAttributes(
new Attribute<>("foo", ValueType.TEXT, "bar")
- )
+ )
assetResource.update(null, testAsset.id, testAsset)
testAsset = assetResource.get(null, testAsset.getId())
@@ -230,7 +230,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "there's an asset in the master realm"
def assetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AssetResource.class)
@@ -258,7 +258,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "there's an asset in the master realm"
def assetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AssetResource.class)
@@ -286,7 +286,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "there's an asset in the master realm"
def assetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AssetResource.class)
@@ -314,7 +314,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "there are assets in the master and building realms"
def assetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AssetResource.class)
@@ -344,7 +344,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "there's an asset in the master realm"
def assetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AssetResource.class)
@@ -379,7 +379,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "there is an asset hierarchy in the master realm"
def assetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AssetResource.class)
@@ -410,7 +410,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "there is a group parent that only accepts room assets"
def assetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AssetResource.class)
@@ -441,7 +441,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "there is a locally registered gateway asset in the building realm"
GatewayAsset gateway = assetStorageService.merge(new GatewayAsset("Test gateway")
@@ -478,7 +478,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "there is a locally registered gateway asset and a gateway descendant in the building realm"
GatewayAsset gateway = assetStorageService.merge(new GatewayAsset("Test gateway")
@@ -494,7 +494,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
false,
gateway,
null
- )
+ )
when: "an updateNoneParent call tries to clear the parent of the gateway descendant"
def assetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AssetResource.class)
@@ -597,7 +597,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "the asset resource"
def serverUri = serverUri(serverPort)
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 fee96cad6..bcf0af636 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy
@@ -59,7 +59,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "the asset resource"
def assetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AssetResource.class)
@@ -77,7 +77,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
new AssetQuery()
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
.parents(new ParentPredicate(null))
- )
+ )
then: "result should match"
assets.length == 1
@@ -87,7 +87,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
assets = assetResource.queryAssets(null,
new AssetQuery()
.parents(new ParentPredicate(assets[0].id))
- )
+ )
then: "result should match"
assets.length == 1
@@ -98,7 +98,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
new AssetQuery()
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
.parents(new ParentPredicate(null))
- )
+ )
then: "result should match"
assets.length == 1
@@ -109,7 +109,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
new AssetQuery()
.realm(new RealmPredicate(keycloakTestSetup.realmBuilding.name))
.parents(new ParentPredicate(null))
- )
+ )
then: "result should match"
assets.length == 1
@@ -119,7 +119,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
assets = assetResource.queryAssets(null,
new AssetQuery()
.parents(new ParentPredicate(assets[0].id))
- )
+ )
then: "result should match"
assets.length == 3
@@ -258,7 +258,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
KEYCLOAK_CLIENT_ID,
"testuser1",
"testuser1"
- )
+ )
and: "the asset resource"
def assetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AssetResource.class)
@@ -276,7 +276,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
new AssetQuery()
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
.parents(new ParentPredicate(null))
- )
+ )
then: "result should match"
assets.length == 1
@@ -286,7 +286,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
assets = assetResource.queryAssets(null,
new AssetQuery()
.parents(new ParentPredicate(assets[0].id))
- )
+ )
then: "result should match"
assets.length == 1
@@ -296,7 +296,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
assets = assetResource.queryAssets(null,
new AssetQuery()
.parents(new ParentPredicate(null))
- )
+ )
then: "result should match"
assets.length == 1
@@ -308,7 +308,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
new AssetQuery()
.realm(new RealmPredicate(keycloakTestSetup.realmBuilding.name))
.parents(new ParentPredicate(null))
- )
+ )
then: "a not authorized exception should be thrown"
WebApplicationException ex = thrown()
@@ -318,7 +318,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
assets = assetResource.queryAssets(null,
new AssetQuery()
.parents(new ParentPredicate(managerTestSetup.smartBuildingId))
- )
+ )
then: "result should be empty"
assets.length == 0
@@ -437,7 +437,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
KEYCLOAK_CLIENT_ID,
"testuser2",
"testuser2"
- )
+ )
and: "the asset resource"
def assetResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.realmBuilding.name, accessToken).proxy(AssetResource.class)
@@ -455,7 +455,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
new AssetQuery()
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
.parents(new ParentPredicate(null))
- )
+ )
then: "a not authorized exception should be thrown"
thrown(ForbiddenException)
@@ -464,7 +464,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
assets = assetResource.queryAssets(null,
new AssetQuery()
.parents(new ParentPredicate(null))
- )
+ )
then: "result should match"
assets.length == 1
@@ -476,7 +476,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
new AssetQuery()
.realm(new RealmPredicate(keycloakTestSetup.realmCity.name))
.parents(new ParentPredicate(null))
- )
+ )
then: "a forbidden exception should be thrown"
thrown(ForbiddenException)
@@ -485,7 +485,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
assets = assetResource.queryAssets(null,
new AssetQuery()
.parents(new ParentPredicate(managerTestSetup.thingId))
- )
+ )
then: "result should be empty"
assets.length == 0
@@ -599,7 +599,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
- )
+ )
and: "the asset resource"
def assetResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.realmBuilding.name, accessToken).proxy(AssetResource.class)
@@ -647,7 +647,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
new AssetQuery()
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
.parents(new ParentPredicate(null))
- )
+ )
then: "a forbidden exception should be thrown"
thrown(ForbiddenException)
@@ -656,7 +656,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
assets = assetResource.queryAssets(null,
new AssetQuery()
.parents(new ParentPredicate(null))
- )
+ )
then: "result should match"
assets.length == 0
@@ -666,7 +666,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
new AssetQuery()
.realm(new RealmPredicate(keycloakTestSetup.realmCity.name))
.parents(new ParentPredicate(null))
- )
+ )
then: "a forbidden exception should be thrown"
thrown(ForbiddenException)
@@ -675,7 +675,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
assets = assetResource.queryAssets(null,
new AssetQuery()
.parents(new ParentPredicate(managerTestSetup.apartment1Id))
- )
+ )
then: "result should match"
assets.length == 5
@@ -684,7 +684,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
assets = assetResource.queryAssets(null,
new AssetQuery()
.parents(new ParentPredicate(managerTestSetup.smartBuildingId))
- )
+ )
then: "result should match"
assets.length == 1
@@ -693,7 +693,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
assets = assetResource.queryAssets(null,
new AssetQuery()
.parents(new ParentPredicate(managerTestSetup.thingId))
- )
+ )
then: "result should be empty"
assets.length == 0
@@ -946,7 +946,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
KEYCLOAK_CLIENT_ID,
"testuser1",
"testuser1"
- )
+ )
and: "there are assets in the authenticated realm"
def assetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AssetResource.class)
@@ -981,7 +981,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "there are child assets with parents in different accessible realms"
def assetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AssetResource.class)
@@ -1009,7 +1009,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
KEYCLOAK_CLIENT_ID,
"testuser1",
"testuser1"
- )
+ )
and: "there is an asset in the authenticated realm"
def assetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AssetResource.class)
@@ -1037,7 +1037,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
KEYCLOAK_CLIENT_ID,
"testuser1",
"testuser1"
- )
+ )
and: "there's an asset in the authenticated realm"
def assetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AssetResource.class)
@@ -1065,7 +1065,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
- )
+ )
when: "a restricted user tries to move a linked asset"
def assetResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.realmBuilding.name, accessToken).proxy(AssetResource.class)
@@ -1090,7 +1090,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
- )
+ )
when: "a restricted user tries to clear the parent of a linked asset"
def assetResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.realmBuilding.name, accessToken).proxy(AssetResource.class)
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 5c176068b..4183a26c4 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy
@@ -94,7 +94,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new AssetQuery()
.types(Agent.class)
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
- )
+ )
then: "agent assets should be retrieved"
assets.size() == 1
@@ -209,7 +209,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new AssetQuery()
.select(new Select().excludeAttributes())
.ids(managerTestSetup.smartOfficeId)
- )
+ )
then: "result should match"
asset.id == managerTestSetup.smartOfficeId
@@ -224,7 +224,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
asset = assetStorageService.find(
new AssetQuery()
.ids(managerTestSetup.smartOfficeId)
- )
+ )
then: "result should match"
asset.id == managerTestSetup.smartOfficeId
@@ -243,7 +243,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.select(new Select().excludeAttributes())
.parents(new ParentPredicate(null))
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
- )
+ )
then: "result should match"
assets.size() == 1
@@ -260,7 +260,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new AssetQuery()
.parents(new ParentPredicate(null))
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
- )
+ )
then: "result should match"
assets.size() == 1
@@ -314,7 +314,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.parents(new ParentPredicate(managerTestSetup.smartBuildingId))
.realm(new RealmPredicate(keycloakTestSetup.realmBuilding.name))
.orderBy(new OrderBy(NAME, true))
- )
+ )
then: "result should match"
assets.size() == 3
@@ -328,7 +328,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.select(new Select().excludeAttributes())
.parents(new ParentPredicate(managerTestSetup.smartBuildingId))
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
- )
+ )
then: "result should match"
assets.size() == 0
@@ -338,7 +338,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new AssetQuery()
.select(new Select().excludeAttributes())
.paths(new PathPredicate(assetStorageService.find(managerTestSetup.apartment1Id, true).getPath()))
- )
+ )
then: "result should match"
assets.size() == 7
@@ -356,7 +356,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.select(new Select().excludeAttributes())
.paths(new PathPredicate(assetStorageService.find(managerTestSetup.apartment1Id, true).getPath()))
.types(RoomAsset.class)
- )
+ )
then: "result should match"
assets.size() == 5
@@ -371,7 +371,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new AssetQuery()
.userIds(keycloakTestSetup.testuser3Id)
.access(PROTECTED)
- )
+ )
then: "result should match"
assets.size() == 6
@@ -393,7 +393,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new AssetQuery()
.userIds(keycloakTestSetup.testuser2Id)
.access(PROTECTED)
- )
+ )
then: "result should match"
assets.size() == 0
@@ -418,7 +418,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new AssetQuery()
.select(new Select().excludeAttributes())
.types(Agent.class)
- )
+ )
then: "result should match"
assets.size() == 3
@@ -432,7 +432,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.select(new Select().excludeAttributes())
.types(ThingAsset.class)
.parents(new ParentPredicate(managerTestSetup.agentId))
- )
+ )
then: "result should match"
assets.size() == 1
@@ -444,7 +444,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.select(new Select().excludeAttributes())
.types(ThingAsset)
.parents(new ParentPredicate(managerTestSetup.agentId))
- )
+ )
then: "result should match"
assets.size() == 1
@@ -461,7 +461,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new NameValuePredicate(READ_ONLY, new BooleanPredicate(true))
)
)
- )
+ )
then: "result should match"
assets.size() == 2
@@ -477,7 +477,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new NameValuePredicate(UNITS.name, new ArrayPredicate(Constants.UNITS_KILO, 0, 3, null, null, false))
)
)
- )
+ )
then: "result should match"
assets.size() == 1
@@ -488,7 +488,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new AssetQuery()
.select(new Select().excludeAttributes())
.attributes(new AttributePredicate().meta(new NameValuePredicate(AGENT_LINK, new StringPredicate(managerTestSetup.agentId), false, new NameValuePredicate.Path("id"))))
- )
+ )
then: "result should match"
assets.size() == 1
@@ -500,7 +500,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.select(new Select().excludeAttributes())
.attributes(new AttributePredicate().meta(new NameValuePredicate(AGENT_LINK, new StringPredicate(managerTestSetup.agentId), false, new NameValuePredicate.Path("id"))))
.names(new StringPredicate(Match.CONTAINS, false, "thing"))
- )
+ )
then: "result should match"
assets.size() == 1
@@ -512,7 +512,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.select(new Select().excludeAttributes())
.attributes(new AttributePredicate().meta(new NameValuePredicate(AGENT_LINK, new StringPredicate(managerTestSetup.agentId), false, new NameValuePredicate.Path("id"))))
.names(new StringPredicate(Match.CONTAINS, true, "thing"))
- )
+ )
then: "result should match"
assets.size() == 0
@@ -523,7 +523,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.select(new Select().excludeAttributes())
.attributes(new AttributePredicate().meta(new NameValuePredicate(AGENT_LINK, new StringPredicate(managerTestSetup.agentId), false, new NameValuePredicate.Path("id"))))
.parents(new ParentPredicate(managerTestSetup.agentId))
- )
+ )
then: "result should match"
assets.size() == 1
@@ -535,7 +535,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.select(new Select().excludeAttributes())
.attributes(new AttributePredicate().meta(new NameValuePredicate(AGENT_LINK, new StringPredicate(managerTestSetup.agentId), false, new NameValuePredicate.Path("id"))))
.parents(new ParentPredicate(managerTestSetup.apartment1LivingroomId))
- )
+ )
then: "result should match"
assets.size() == 0
@@ -546,7 +546,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.select(new Select().excludeAttributes())
.attributes(new AttributePredicate().meta(new NameValuePredicate(AGENT_LINK, new StringPredicate(managerTestSetup.agentId), false, new NameValuePredicate.Path("id"))))
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
- )
+ )
then: "result should match"
assets.size() == 1
@@ -558,7 +558,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.ids(managerTestSetup.apartment1LivingroomId)
.select(new Select().attributes("co2Level", "lastPresenceDetected", "motionSensor"))
.access(PRIVATE)
- )
+ )
then: "result should match"
asset.id == managerTestSetup.apartment1LivingroomId
@@ -582,7 +582,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.ids(managerTestSetup.apartment1LivingroomId)
.select(new Select().attributes("co2Level", "lastPresenceDetected", "motionSensor"))
.access(PROTECTED)
- )
+ )
then: "result should contain only matches that are protected"
asset.id == managerTestSetup.apartment1LivingroomId
@@ -608,7 +608,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new StringPredicate("co2Level"), new NumberPredicate(340, Operator.GREATER_THAN)
)
)
- )
+ )
then: "result should contain an Asset with the expected values"
assert asset != null
@@ -627,7 +627,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new StringPredicate("co2Level"), new NumberPredicate(360, Operator.GREATER_THAN)
)
)
- )
+ )
then: "no assets should match"
assert asset == null
@@ -645,7 +645,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new StringPredicate("co2Level"), new NumberPredicate(50, Operator.GREATER_THAN)
)
)
- )
+ )
then: "result should contain an Asset with the expected values"
assert asset != null
@@ -672,7 +672,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
)
])
)
- )
+ )
then: "result should contain an Asset with the expected values"
assert asset != null
@@ -699,7 +699,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
)
])
)
- )
+ )
then: "no assets should match"
assert asset == null
@@ -722,7 +722,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
)
])
)
- )
+ )
then: "no assets should match"
assert asset == null
@@ -740,7 +740,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.attributes(new LocationAttributePredicate(new RadialGeofencePredicate(10, 51.44541688237109d, 5.460315214821094d)))
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
.orderBy(new OrderBy(NAME))
- )
+ )
then: "assets in the queried region should be retrieved"
assets.size() == 5
@@ -767,7 +767,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.attributes(new LocationAttributePredicate(new RadialGeofencePredicate(10, 51.44541688237109d, 5.460315214821094d)))
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
.orderBy(new OrderBy(NAME))
- )
+ )
then: "the moved asset should not be included"
assets.size() == 4
@@ -780,7 +780,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.attributes(new LocationAttributePredicate(new RectangularGeofencePredicate(51.44540d, 5.46031d, 51.44594d, 5.46110d)))
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
.orderBy(new OrderBy(NAME))
- )
+ )
then: "all 5 assets should be returned"
assets.size() == 5
@@ -797,7 +797,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.attributes(new LocationAttributePredicate(new RectangularGeofencePredicate(51.44542d, 5.46032d, 51.44590d, 5.46100d)))
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
.orderBy(new OrderBy(NAME))
- )
+ )
then: "no assets should be returned"
assets.size() == 0
@@ -809,7 +809,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.attributes(new LocationAttributePredicate(new RectangularGeofencePredicate(51.44542d, 5.46032d, 51.44590d, 5.46100d).negate()))
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
.orderBy(new OrderBy(NAME))
- )
+ )
then: "all 5 realm assets should be returned"
assets.size() == 5
@@ -838,7 +838,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
lobby.addAttributes(
new Attribute<>("test", CALENDAR_EVENT, new CalendarEvent(start, end, recur))
- )
+ )
lobby = assetStorageService.merge(lobby)
recur = new Recur(Frequency.DAILY, 3)
@@ -846,11 +846,11 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
floor.addAttributes(
new Attribute<>("test", CALENDAR_EVENT, new CalendarEvent(start, end, recur))
- )
+ )
floor = assetStorageService.merge(floor)
office.addAttributes(
new Attribute<>("test", CALENDAR_EVENT, new CalendarEvent(start, end))
- )
+ )
office = assetStorageService.merge(office)
then: "the system should settle down"
@@ -864,7 +864,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
.attributes(new AttributePredicate(new StringPredicate("test"), new CalendarEventPredicate(new Date(1517155200000)))) // 28/01/2018 @ 4:00pm (UTC)
.orderBy(new OrderBy(NAME))
- )
+ )
then: "all 3 assets should be returned"
assets.size() == 3
@@ -881,7 +881,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
.attributes(new AttributePredicate(new StringPredicate("test"), new CalendarEventPredicate(new Date(1517335200000)))) // 30/01/2018 @ 6:00pm (UTC)
.orderBy(new OrderBy(NAME))
- )
+ )
then: "no assets should be returned"
assets.size() == 0
@@ -892,7 +892,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
.attributes(new AttributePredicate(new StringPredicate("test"), new CalendarEventPredicate(new Date(1517238600000)))) // 29/01/2018 @ 3:10pm (UTC)
.orderBy(new OrderBy(NAME))
- )
+ )
then: "no assets should be returned"
assets.size() == 0
@@ -903,7 +903,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
.attributes(new AttributePredicate(new StringPredicate("test"), new CalendarEventPredicate(new Date(1517503800000)))) // 01/02/2018 @ 4:50pm (UTC))
.orderBy(new OrderBy(NAME))
- )
+ )
then: "the lobby and ground floor assets should be returned"
assets.size() == 2
@@ -918,7 +918,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
.attributes(new AttributePredicate(new StringPredicate("test"), new CalendarEventPredicate(new Date(1517849400000)))) // 05/02/2018 @ 4:50pm (UTC))
.orderBy(new OrderBy(NAME))
- )
+ )
then: "the lobby and ground floor assets should be returned"
assets.size() == 1
@@ -931,7 +931,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.realm(new RealmPredicate(keycloakTestSetup.realmMaster.name))
.attributes(new AttributePredicate(new StringPredicate("test"), new CalendarEventPredicate(new Date(1518017520000)))) // 02/07/2018 @ 3:32pm (UTC)
.orderBy(new OrderBy(NAME))
- )
+ )
then: "no assets should be returned"
assets.size() == 0
@@ -942,7 +942,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
def lobby = assetStorageService.find(managerTestSetup.lobbyId, true)
lobby.addAttributes(
new Attribute<>("openingDate", TIMESTAMP_ISO8601, Instant.ofEpochMilli(1517151600000).atZone(ZoneId.systemDefault()).format(ISO_OFFSET_DATE_TIME)) // 28/01/2018 @ 2:00pm (UTC)
- )
+ )
lobby = assetStorageService.merge(lobby)
def rangeStart = Instant.ofEpochMilli(1517151600000).atZone(ZoneId.systemDefault()).minusHours(2) // 28/01/2018 @ 1:00pm (UTC)
@@ -956,7 +956,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
"openingDate",
new DateTimePredicate(rangeStart.format(ISO_OFFSET_DATE_TIME), rangeEnd.format(ISO_OFFSET_DATE_TIME))
.operator(Operator.BETWEEN))
- )
+ )
then: "the lobby asset should be retrieved"
@@ -971,7 +971,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.attributeValue(
"openingDate",
new DateTimePredicate(Operator.GREATER_THAN, rangeStart.format(ISO_OFFSET_DATE_TIME)))
- )
+ )
then: "the lobby asset should be retrieved"
@@ -986,7 +986,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.attributeValue(
"openingDate",
new DateTimePredicate(Operator.LESS_THAN, rangeEnd.format(ISO_OFFSET_DATE_TIME)))
- )
+ )
then: "the lobby asset should be retrieved"
@@ -1003,7 +1003,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.attributeValue(
"openingDate",
new DateTimePredicate(Operator.EQUALS, rangeStart.format(ISO_OFFSET_DATE_TIME)))
- )
+ )
then: "the lobby asset should be retrieved"
@@ -1020,7 +1020,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.ids(managerTestSetup.smartBuildingId)
.recursive(true)
.orderBy(new OrderBy(NAME))
- )
+ )
then: "all assets should be returned"
allAssets.size() > 0
@@ -1034,7 +1034,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.recursive(true)
.orderBy(new OrderBy(NAME))
.limit(0)
- )
+ )
then: "all assets should be returned"
zeroLimitAssets.size() == allAssetsSize
@@ -1048,7 +1048,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.recursive(true)
.orderBy(new OrderBy(NAME))
.limit(3)
- )
+ )
then: "only 3 assets should be returned"
limitedAssets.size() == 3
@@ -1062,7 +1062,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.recursive(true)
.orderBy(new OrderBy(NAME))
.limit(5)
- )
+ )
then: "then 5 assets should be returned"
higherLimitAssets.size() == 5
@@ -1075,7 +1075,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.recursive(true)
.orderBy(new OrderBy(NAME))
.offset(2)
- )
+ )
then: "all assets after the offset should be returned"
offsetAssets.size() == allAssetsSize - 2
@@ -1093,7 +1093,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.orderBy(new OrderBy(NAME))
.limit(2)
.offset(3)
- )
+ )
then: "the assets from the offset should be returned"
offsetLimitAssets.collect { it.id } == allAssets.drop(3).take(2).collect { it.id }
@@ -1112,7 +1112,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.recursive(true)
.orderBy(new OrderBy(NAME))
.offset(allAssets.size() + 1)
- )
+ )
then: "no assets should be returned"
offsetHigherThanAssets.size() == 0
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetTreeTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetTreeTest.groovy
index 8d19afd02..09007d774 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetTreeTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetTreeTest.groovy
@@ -55,7 +55,7 @@ class AssetTreeTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "the asset resource is available"
def assetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AssetResource.class)
@@ -66,7 +66,7 @@ class AssetTreeTest extends Specification implements ManagerContainerTrait {
.realm(new RealmPredicate(managerTestSetup.realmBuildingName))
.limit(10)
.offset(0)
- )
+ )
then: "the asset tree should be returned"
assert assetTree != null
@@ -83,7 +83,7 @@ class AssetTreeTest extends Specification implements ManagerContainerTrait {
.realm(new RealmPredicate(managerTestSetup.realmBuildingName))
.limit(10)
.offset(10)
- )
+ )
then: "the asset tree should be returned"
assert assetTree != null
@@ -98,7 +98,7 @@ class AssetTreeTest extends Specification implements ManagerContainerTrait {
assetTree = assetResource.queryAssetTree(null,
new AssetQuery()
.realm(new RealmPredicate(managerTestSetup.realmBuildingName))
- )
+ )
then: "the asset tree should be returned"
assert assetTree != null
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 0e627912f..22d21ccde 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetUserLinkingTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetUserLinkingTest.groovy
@@ -51,7 +51,7 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "the asset resource"
def assetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessTokenString).proxy(AssetResource.class)
@@ -79,51 +79,51 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
userAssetLinks.length == 13
userAssetLinks.any {
it.id.realm == keycloakTestSetup.realmBuilding.name &&
- it.id.userId == keycloakTestSetup.testuser3Id &&
- it.id.assetId == managerTestSetup.apartment1Id &&
- it.assetName == "Apartment 1" &&
- it.parentAssetName == "Smart building" &&
- it.userFullName == "testuser3 (DemoA3 DemoLast)"
+ it.id.userId == keycloakTestSetup.testuser3Id &&
+ it.id.assetId == managerTestSetup.apartment1Id &&
+ it.assetName == "Apartment 1" &&
+ it.parentAssetName == "Smart building" &&
+ it.userFullName == "testuser3 (DemoA3 DemoLast)"
}
userAssetLinks.any {
it.id.realm == keycloakTestSetup.realmBuilding.name &&
- it.id.userId == keycloakTestSetup.testuser3Id &&
- it.id.assetId == managerTestSetup.apartment1LivingroomId &&
- it.assetName == "Living Room 1" &&
- it.parentAssetName == "Apartment 1" &&
- it.userFullName == "testuser3 (DemoA3 DemoLast)"
+ it.id.userId == keycloakTestSetup.testuser3Id &&
+ it.id.assetId == managerTestSetup.apartment1LivingroomId &&
+ it.assetName == "Living Room 1" &&
+ it.parentAssetName == "Apartment 1" &&
+ it.userFullName == "testuser3 (DemoA3 DemoLast)"
}
userAssetLinks.any {
it.id.realm == keycloakTestSetup.realmBuilding.name &&
- it.id.userId == keycloakTestSetup.testuser3Id &&
- it.id.assetId == managerTestSetup.apartment1KitchenId &&
- it.assetName == "Kitchen 1" &&
- it.parentAssetName == "Apartment 1" &&
- it.userFullName == "testuser3 (DemoA3 DemoLast)"
+ it.id.userId == keycloakTestSetup.testuser3Id &&
+ it.id.assetId == managerTestSetup.apartment1KitchenId &&
+ it.assetName == "Kitchen 1" &&
+ it.parentAssetName == "Apartment 1" &&
+ it.userFullName == "testuser3 (DemoA3 DemoLast)"
}
userAssetLinks.any {
it.id.realm == keycloakTestSetup.realmBuilding.name &&
- it.id.userId == keycloakTestSetup.testuser3Id &&
- it.id.assetId == managerTestSetup.apartment1HallwayId &&
- it.assetName == "Hallway 1" &&
- it.parentAssetName == "Apartment 1" &&
- it.userFullName == "testuser3 (DemoA3 DemoLast)"
+ it.id.userId == keycloakTestSetup.testuser3Id &&
+ it.id.assetId == managerTestSetup.apartment1HallwayId &&
+ it.assetName == "Hallway 1" &&
+ it.parentAssetName == "Apartment 1" &&
+ it.userFullName == "testuser3 (DemoA3 DemoLast)"
}
userAssetLinks.any {
it.id.realm == keycloakTestSetup.realmBuilding.name &&
- it.id.userId == keycloakTestSetup.testuser3Id &&
- it.id.assetId == managerTestSetup.apartment1Bedroom1Id &&
- it.assetName == "Bedroom 1" &&
- it.parentAssetName == "Apartment 1" &&
- it.userFullName == "testuser3 (DemoA3 DemoLast)"
+ it.id.userId == keycloakTestSetup.testuser3Id &&
+ it.id.assetId == managerTestSetup.apartment1Bedroom1Id &&
+ it.assetName == "Bedroom 1" &&
+ it.parentAssetName == "Apartment 1" &&
+ it.userFullName == "testuser3 (DemoA3 DemoLast)"
}
userAssetLinks.any {
it.id.realm == keycloakTestSetup.realmBuilding.name &&
- it.id.userId == keycloakTestSetup.testuser3Id &&
- it.id.assetId == managerTestSetup.apartment1BathroomId &&
- it.assetName == "Bathroom 1" &&
- it.parentAssetName == "Apartment 1" &&
- it.userFullName == "testuser3 (DemoA3 DemoLast)"
+ 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"
@@ -159,11 +159,11 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
userAssetLinks.length == 1
userAssetLinks.any {
it.id.realm == keycloakTestSetup.realmBuilding.name &&
- it.id.userId == keycloakTestSetup.testuser3Id &&
- it.id.assetId == managerTestSetup.apartment1Id &&
- it.assetName == "Apartment 1" &&
- it.parentAssetName == "Smart building" &&
- it.userFullName == "testuser3 (DemoA3 DemoLast)"
+ 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"
@@ -173,11 +173,11 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
userAssetLinks.length == 1
userAssetLinks.any {
it.id.realm == keycloakTestSetup.realmBuilding.name &&
- it.id.userId == keycloakTestSetup.testuser3Id &&
- it.id.assetId == managerTestSetup.apartment1Id &&
- it.assetName == "Apartment 1" &&
- it.parentAssetName == "Smart building" &&
- it.userFullName == "testuser3 (DemoA3 DemoLast)"
+ 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"
@@ -197,12 +197,12 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
userAssetLinks.length == 1
userAssetLinks.any {
it.id.realm == keycloakTestSetup.realmBuilding.name &&
- it.id.userId == keycloakTestSetup.testuser2Id &&
- it.id.assetId == managerTestSetup.apartment2Id &&
- it.assetName == "Apartment 2" &&
- it.parentAssetName == "Smart building" &&
- it.userFullName == "testuser2 (DemoA2 DemoLast)" &&
- it.createdOn.toEpochMilli() <= timerService.currentTimeMillis
+ it.id.userId == keycloakTestSetup.testuser2Id &&
+ it.id.assetId == managerTestSetup.apartment2Id &&
+ it.assetName == "Apartment 2" &&
+ it.parentAssetName == "Smart building" &&
+ it.userFullName == "testuser2 (DemoA2 DemoLast)" &&
+ it.createdOn.toEpochMilli() <= timerService.currentTimeMillis
}
when: "an asset link is deleted"
diff --git a/test/src/test/groovy/org/openremote/test/assets/AttributeLinkingTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AttributeLinkingTest.groovy
index 80bb82b6b..6454f5d14 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AttributeLinkingTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AttributeLinkingTest.groovy
@@ -63,7 +63,7 @@ class AttributeLinkingTest extends Specification implements ManagerContainerTrai
new Attribute<>("button", TEXT, "RELEASED"),
new Attribute<>("array", null, null),
new Attribute<>("crossRealm", TEXT, null)
- )
+ )
asset1 = assetStorageService.merge(asset1)
def asset2 = new ThingAsset("Asset 2")
@@ -72,7 +72,7 @@ class AttributeLinkingTest extends Specification implements ManagerContainerTrai
new Attribute<>("lightOnOff", BOOLEAN, false),
new Attribute<>("counter", NUMBER, 0d),
new Attribute<>("item2Prop1", BOOLEAN, null)
- )
+ )
asset2 = assetStorageService.merge(asset2)
then: "the assets should be saved to the DB"
@@ -84,14 +84,14 @@ class AttributeLinkingTest extends Specification implements ManagerContainerTrai
"PRESSED", "@TOGGLE",
"RELEASED", "@IGNORE",
"LONG_PRESSED", "@IGNORE"
- )
+ )
def attributeLinkOnOff = new AttributeLink(new AttributeRef(asset2.id, "lightOnOff"), converterOnOff, null)
def converterCounter = Map.of(
"PRESSED", "@INCREMENT",
"RELEASED", "@DECREMENT",
"LONG_PRESSED", "@IGNORE"
- )
+ )
def attributeLinkCounter = new AttributeLink(new AttributeRef(asset2.id, "counter"), converterCounter, null)
def attributeLinkProp = new AttributeLink(new AttributeRef(asset2.id, "item2Prop1"), null, [new JsonPathFilter("\$[1].prop1", true, false)] as ValueFilter[])
@@ -106,13 +106,13 @@ class AttributeLinkingTest extends Specification implements ManagerContainerTrai
and: "the button is pressed for a short period"
def buttonPressed = new AttributeEvent(
new AttributeState(new AttributeRef(asset1.id, "button"), "PRESSED")
- )
+ )
assetProcessingService.sendAttributeEvent(buttonPressed)
Thread.sleep(200)
advancePseudoClock(1, TimeUnit.SECONDS, container)
def buttonReleased = new AttributeEvent(
new AttributeState(new AttributeRef(asset1.id, "button"), "RELEASED")
- )
+ )
assetProcessingService.sendAttributeEvent(buttonReleased)
then: "the linked attribute value should be toggled on"
@@ -124,13 +124,13 @@ class AttributeLinkingTest extends Specification implements ManagerContainerTrai
when: "the button is pressed again for a short period"
buttonPressed = new AttributeEvent(
new AttributeState(new AttributeRef(asset1.id, "button"), "PRESSED")
- )
+ )
assetProcessingService.sendAttributeEvent(buttonPressed)
Thread.sleep(200)
advancePseudoClock(1, TimeUnit.SECONDS, container)
buttonReleased = new AttributeEvent(
new AttributeState(new AttributeRef(asset1.id, "button"), "RELEASED")
- )
+ )
assetProcessingService.sendAttributeEvent(buttonReleased)
then: "the linked attribute value should be toggled off"
@@ -141,12 +141,12 @@ class AttributeLinkingTest extends Specification implements ManagerContainerTrai
when: "a long button press occurs"
def buttonLongPressed = new AttributeEvent(
new AttributeState(new AttributeRef(asset1.id, "button"), "LONG_PRESSED")
- )
+ )
assetProcessingService.sendAttributeEvent(buttonLongPressed)
advancePseudoClock(1, TimeUnit.SECONDS, container)
buttonReleased = new AttributeEvent(
new AttributeState(new AttributeRef(asset1.id, "button"), "RELEASED")
- )
+ )
assetProcessingService.sendAttributeEvent(buttonReleased)
then: "the linked attribute value should not have changed and the system has settled down"
@@ -167,7 +167,7 @@ class AttributeLinkingTest extends Specification implements ManagerContainerTrai
and: "A button press event occurs without a release event"
buttonPressed = new AttributeEvent(
new AttributeState(new AttributeRef(asset1.id, "button"), "PRESSED")
- )
+ )
assetProcessingService.sendAttributeEvent(buttonPressed)
then: "the counter should increment"
@@ -179,7 +179,7 @@ class AttributeLinkingTest extends Specification implements ManagerContainerTrai
when: "A button release event occur"
buttonReleased = new AttributeEvent(
new AttributeState(new AttributeRef(asset1.id, "button"), "RELEASED")
- )
+ )
assetProcessingService.sendAttributeEvent(buttonReleased)
then: "the counter should decrement"
diff --git a/test/src/test/groovy/org/openremote/test/assets/ForecastServiceTest.groovy b/test/src/test/groovy/org/openremote/test/assets/ForecastServiceTest.groovy
index 454e0db28..06cd273df 100644
--- a/test/src/test/groovy/org/openremote/test/assets/ForecastServiceTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/ForecastServiceTest.groovy
@@ -123,8 +123,8 @@ class ForecastServiceTest extends Specification implements ManagerContainerTrait
and: "initial forecast values have been calculated"
conditions.eventually {
List<AssetPredictedDatapoint> predictedDatapoints = assetPredictedDatapointService
- .getDatapoints(attributeRef)
- .sort {it.timestamp}
+ .getDatapoints(attributeRef)
+ .sort {it.timestamp}
assert predictedDatapoints.size() == config.forecastCount
for (int i = 0; i <predictedDatapoints.size(); i++) {
assert predictedDatapoints[i].value == calculateForecast(managerTestSetup.forecastTestHistoryData[i][0..config.pastCount - 1]).get()
@@ -157,8 +157,8 @@ class ForecastServiceTest extends Specification implements ManagerContainerTrait
and: "partially existing forecast values should have have been completed and updated"
conditions.eventually {
List<AssetPredictedDatapoint> predictedDatapoints = assetPredictedDatapointService
- .getDatapoints(attributeRef)
- .sort {it.timestamp}
+ .getDatapoints(attributeRef)
+ .sort {it.timestamp}
assert predictedDatapoints.size() == config.forecastCount
Long offset = ((config.forecastPeriod.toMillis() * 2) / 3) * (-1)
for (int i = 0; i <predictedDatapoints.size(); i++) {
@@ -204,7 +204,7 @@ class ForecastServiceTest extends Specification implements ManagerContainerTrait
and: "time has passed"
advancePseudoClock(
forecastConfig.forecastPeriod.toMillis(), MILLISECONDS, container
- )
+ )
and: "the forecast service is started again"
forecastService.forecastTaskManager.start(timerService.currentTimeMillis)
@@ -212,8 +212,8 @@ class ForecastServiceTest extends Specification implements ManagerContainerTrait
then: "initial forecast values should be calculated"
conditions.eventually {
List<AssetPredictedDatapoint> predictedDatapoints = assetPredictedDatapointService
- .getDatapoints(attributeRef)
- .sort {it.timestamp}
+ .getDatapoints(attributeRef)
+ .sort {it.timestamp}
assert predictedDatapoints.size() == forecastConfig.forecastCount
for (int i = 0; i <predictedDatapoints.size(); i++) {
assert predictedDatapoints[i].value == calculateForecast(forecastHistoricalData[i][0..forecastConfig.pastCount - 1]).get()
@@ -231,7 +231,7 @@ class ForecastServiceTest extends Specification implements ManagerContainerTrait
forecastConfig
)
)
- )
+ )
forecastThing1 = assetStorageService.merge(forecastThing1)
def newAttributeRef = new AttributeRef(forecastThing1.id, "newForecastAttribute")
@@ -245,7 +245,7 @@ class ForecastServiceTest extends Specification implements ManagerContainerTrait
def updatedPastCount = forecastConfig.pastCount + 1
def updatedConfig = new ForecastConfigurationWeightedExponentialAverage(
forecastConfig.pastPeriod, updatedPastCount, forecastConfig.forecastPeriod, forecastConfig.forecastCount
- )
+ )
forecastThing1.getAttributes().addOrReplace(
new Attribute<>("newForecastAttribute", NUMBER)
.addOrReplaceMeta(
@@ -254,7 +254,7 @@ class ForecastServiceTest extends Specification implements ManagerContainerTrait
updatedConfig
)
)
- )
+ )
forecastThing1 = assetStorageService.merge(forecastThing1)
then: "forecast service should contain updated forecast configuration"
@@ -268,7 +268,7 @@ class ForecastServiceTest extends Specification implements ManagerContainerTrait
forecastThing1 = assetStorageService.find(forecastThing1.id)
forecastThing1.getAttributes().addOrReplace(
new Attribute<>("newForecastAttribute", NUMBER)
- )
+ )
forecastThing1 = assetStorageService.merge(forecastThing1)
then: "attribute should be unregistered from forecast service"
@@ -302,7 +302,7 @@ class ForecastServiceTest extends Specification implements ManagerContainerTrait
config
)
)
- )
+ )
thing = assetStorageService.merge(thing)
return thing
}
diff --git a/test/src/test/groovy/org/openremote/test/benchmark/AttributeEventBenchmarkTest.groovy b/test/src/test/groovy/org/openremote/test/benchmark/AttributeEventBenchmarkTest.groovy
index 817786242..0208ee2ce 100644
--- a/test/src/test/groovy/org/openremote/test/benchmark/AttributeEventBenchmarkTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/benchmark/AttributeEventBenchmarkTest.groovy
@@ -85,7 +85,7 @@ class AttributeEventBenchmarkTest extends Specification implements ManagerContai
for (i in 1..eventCount) {
def asset = assetStorageService.merge(new ThingAsset("TestThing$i").setRealm(keycloakTestSetup.realmBuilding.name).addAttributes(
new Attribute<Object>("counter", ValueType.NUMBER)
- ))
+ ))
assetIDs.add(asset.id)
}
and: "one asset is added with many attributes"
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 d90e27cba..26b2706d6 100644
--- a/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy
@@ -237,14 +237,14 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
- )
+ )
def testUser2AccessToken = authenticate(
container,
keycloakTestSetup.realmBuilding.name,
KEYCLOAK_CLIENT_ID,
"testuser2",
"testuser2"
- )
+ )
def testUser3ConsoleResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.realmBuilding.name, testUser3AccessToken).proxy(ConsoleResource.class)
def testUser2ConsoleResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.realmBuilding.name, testUser2AccessToken).proxy(ConsoleResource.class)
def anonymousConsoleResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.realmBuilding.name).proxy(ConsoleResource.class)
@@ -310,7 +310,7 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
- )
+ )
def authenticatedConsoleResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.realmBuilding.name, accessToken).proxy(ConsoleResource.class)
when: "a client tries to create a console with its own unused ID"
@@ -395,7 +395,7 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
- )
+ )
and: "authenticated and anonymous console, rules and asset resources"
def authenticatedConsoleResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.realmBuilding.name, accessToken).proxy(ConsoleResource.class)
@@ -472,7 +472,7 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
false,
true,
null,
- ))
+ ))
returnedConsoleRegistration = authenticatedConsoleResource.register(null, returnedConsoleRegistration)
console = assetStorageService.find(consoleId, true)
testUser3Console1 = console
@@ -635,25 +635,25 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
when: "the location of each console is marked as RULE_STATE"
testUser3Console1.getAttribute(Asset.LOCATION).ifPresent {it ->
it.addMeta(
- new MetaItem<>(MetaItemType.RULE_STATE),
- new MetaItem<>(MetaItemType.ACCESS_RESTRICTED_WRITE),
- new MetaItem<>(MetaItemType.ACCESS_RESTRICTED_READ)
+ new MetaItem<>(MetaItemType.RULE_STATE),
+ new MetaItem<>(MetaItemType.ACCESS_RESTRICTED_WRITE),
+ new MetaItem<>(MetaItemType.ACCESS_RESTRICTED_READ)
)
}
testUser3Console1 = assetStorageService.merge(testUser3Console1)
testUser3Console2.getAttribute(Asset.LOCATION).ifPresent {it ->
it.addMeta(
- new MetaItem<>(MetaItemType.RULE_STATE),
- new MetaItem<>(MetaItemType.ACCESS_RESTRICTED_WRITE),
- new MetaItem<>(MetaItemType.ACCESS_RESTRICTED_READ)
+ new MetaItem<>(MetaItemType.RULE_STATE),
+ new MetaItem<>(MetaItemType.ACCESS_RESTRICTED_WRITE),
+ new MetaItem<>(MetaItemType.ACCESS_RESTRICTED_READ)
)
}
testUser3Console2 = assetStorageService.merge(testUser3Console2)
anonymousConsole1.getAttribute(Asset.LOCATION).ifPresent {it ->
it.addMeta(
- new MetaItem<>(MetaItemType.RULE_STATE),
- new MetaItem<>(MetaItemType.ACCESS_RESTRICTED_WRITE),
- new MetaItem<>(MetaItemType.ACCESS_RESTRICTED_READ)
+ new MetaItem<>(MetaItemType.RULE_STATE),
+ new MetaItem<>(MetaItemType.ACCESS_RESTRICTED_WRITE),
+ new MetaItem<>(MetaItemType.ACCESS_RESTRICTED_READ)
)
}
anonymousConsole1 = assetStorageService.merge(anonymousConsole1)
@@ -877,11 +877,11 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
assert geofences.size() == 2
def geofence1 = geofences.find {
it.id == testUser3Console1.id + "_" + Integer.toString(
- expectedLocationPredicate.hashCode())
+ expectedLocationPredicate.hashCode())
}
def geofence2 = geofences.find {
it.id == testUser3Console1.id + "_" + Integer.toString(
- newLocationPredicate.hashCode())
+ newLocationPredicate.hashCode())
}
assert geofence1 != null && geofence2 != null
assert geofence1.lat == expectedLocationPredicate.lat
@@ -917,11 +917,11 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
assert geofences.size() == 2
def geofence1 = geofences.find {
it.id == testUser3Console1.id + "_" + Integer.toString(
- expectedLocationPredicate.hashCode())
+ expectedLocationPredicate.hashCode())
}
def geofence2 = geofences.find {
it.id == testUser3Console1.id + "_" + Integer.toString(
- newLocationPredicate.hashCode())
+ newLocationPredicate.hashCode())
}
assert geofence1 != null && geofence2 != null
assert geofence1.lat == expectedLocationPredicate.lat
@@ -1058,7 +1058,7 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
),
"",
["manager"] as String[]
- )
+ )
}
protected static String getPushToken(ConsoleAsset console) {
diff --git a/test/src/test/groovy/org/openremote/test/dashboard/DashboardTest.groovy b/test/src/test/groovy/org/openremote/test/dashboard/DashboardTest.groovy
index fa0f3ea35..d8cf65678 100644
--- a/test/src/test/groovy/org/openremote/test/dashboard/DashboardTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/dashboard/DashboardTest.groovy
@@ -58,21 +58,21 @@ class DashboardTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
def privateUser1AccessToken = authenticate(
container,
MASTER_REALM,
KEYCLOAK_CLIENT_ID,
"testuser1",
"testuser1"
- )
+ )
def smartcityUserAccessToken = authenticate(
container,
keycloakTestSetup.realmCity.name,
KEYCLOAK_CLIENT_ID,
"smartcity",
"smartcity"
- )
+ )
and: "the admin user has been retrieved"
def serverUri = serverUri(serverPort)
@@ -340,7 +340,7 @@ class DashboardTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
- )
+ )
def restrictedUserDashboardResource = getClientApiTarget(serverUri, keycloakTestSetup.realmBuilding.name, restrictedUser1AccessToken).proxy(DashboardResource.class)
and: "a restricted user tries to query a dashboard without access to the assets shown"
@@ -353,7 +353,7 @@ class DashboardTest extends Specification implements ManagerContainerTrait {
def assetStorageService = container.getService(AssetStorageService.class)
assetStorageService.storeUserAssetLinks(Arrays.asList(
new UserAssetLink(keycloakTestSetup.realmBuilding.getName(), keycloakTestSetup.testuser3Id, adminLightAsset.getId())
- ))
+ ))
then: "the user is able to request the dashboard"
def restrictedDashboards2 = restrictedUserDashboardResource.getAllRealmDashboards(null, keycloakTestSetup.realmBuilding.name)
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 fe5c3a9a0..b007b01be 100644
--- a/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy
@@ -152,7 +152,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
managerTestSetup.realmBuildingName,
gateway.getClientId().orElse(""),
gateway.getClientSecret().orElse("")
- )
+ )
def assetResource = getClientApiTarget(serverUri(serverPort), managerTestSetup.realmBuildingName, accessToken).proxy(AssetResource.class)
and: "the realm assets are requested"
@@ -258,7 +258,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
.setPath("")),
new MetaItem<>(UNITS, Constants.units(UNITS_CELSIUS))
)
- )
+ )
assets.add(roomAsset)
}
@@ -274,7 +274,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
new Attribute<>(Asset.LOCATION, new GeoJSONPoint(10, 11)).addMeta(
new MetaItem<>(ACCESS_PUBLIC_READ)
)
- )
+ )
assets.add(buildingAsset)
}
@@ -577,7 +577,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
.setPath("")),
new MetaItem<>(UNITS, Constants.units(UNITS_CELSIUS))
)
- )
+ )
gatewayClient.sendMessage(SharedEvent.MESSAGE_PREFIX + ValueUtil.asJSON(new AssetEvent(AssetEvent.Cause.CREATE, building1Room5Asset, null)).get())
@@ -602,7 +602,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
new MetaItem<>(UNITS, Constants.units(UNITS_PART_PER_MILLION)),
new MetaItem<>(AGENT_LINK, new HTTPAgentLink(agentAssetIds[0]).setPath(""))
)
- )
+ )
gatewayClient.sendMessage(SharedEvent.MESSAGE_PREFIX + ValueUtil.asJSON(new AssetEvent(AssetEvent.Cause.UPDATE, building1Room5Asset, (String[]) ["name", "attributes"].toArray(new String[0]))).get())
then: "the asset should also be updated in the local manager"
@@ -738,7 +738,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
new Attribute<>(Asset.LOCATION, new GeoJSONPoint(10, 11)).addMeta(
new MetaItem<>(ACCESS_PUBLIC_READ)
)
- )
+ )
assetStorageService.merge(failedAsset)
then: "an error should occur"
@@ -883,7 +883,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
.setPath("")),
new MetaItem<>(UNITS, Constants.units(UNITS_CELSIUS))
)
- )
+ )
gatewayClient.sendMessage(SharedEvent.MESSAGE_PREFIX + ValueUtil.asJSON(new AssetEvent(AssetEvent.Cause.CREATE, building2Room5Asset, null)).get())
@@ -1020,7 +1020,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "the gateway client resource"
@@ -1060,7 +1060,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
null,
Map.of("test", new GatewayAssetSyncRule()),
false
- )
+ )
gatewayClientResource.setConnection(null, managerTestSetup.realmCityName, gatewayConnection)
then: "the gateway client should become connected"
@@ -1106,7 +1106,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
microphone1.setName("Microphone 1 Updated")
microphone1.addAttributes(
new Attribute<>("test", NUMBER, 100d)
- )
+ )
microphone1 = assetStorageService.merge(microphone1)
then: "the mirrored asset under the gateway should have also been updated"
@@ -1130,7 +1130,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
.setParentId(managerTestSetup.area1Id)
.addAttributes(
new Attribute<>("test", TEXT, "testValue")
- )
+ )
microphone2 = assetStorageService.merge(microphone2)
then: "the new asset should have been created in the gateway and also mirrored under the gateway asset"
@@ -1162,7 +1162,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
new BuildingAsset("UnknownAssetType")
.setId(UniqueIdentifierGenerator.generateId()),
null
- )
+ )
msgEvent.asset.type = "CustomBuildingAsset"
gatewayClientService.connectionRealmMap.get(gatewayConnection.getLocalRealm()).sendCentralManagerMessage(msgEvent)
@@ -1405,7 +1405,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "the gateway client resource"
def gatewayClientResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(GatewayClientResource.class)
@@ -1463,7 +1463,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
]).setExcludeAttributes([LightAsset.COLOUR_RGB.name]).setAccessPublicRead(false)
] as Map<String, GatewayAssetSyncRule>,
false
- )
+ )
gatewayClientResource.setConnection(null, managerTestSetup.realmCityName, gatewayConnection)
then: "the gateway client should become connected"
@@ -1541,13 +1541,13 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
new User().setUsername("gatewayrealmtunnelreader").setEnabled(true),
"gatewayrealmtunnelreader",
true
- )
+ )
identityProvider.updateUserClientRoles(
managerTestSetup.realmBuildingName,
tunnelReader.id,
KEYCLOAK_CLIENT_ID,
READ_TUNNELS_ROLE
- )
+ )
and: "an authenticated session for that user"
def accessToken = authenticate(
@@ -1556,7 +1556,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
"gatewayrealmtunnelreader",
"gatewayrealmtunnelreader"
- )
+ )
and: "the gateway service resource"
def gatewayResource = getClientApiTarget(serverUri(serverPort), managerTestSetup.realmBuildingName, accessToken).proxy(GatewayServiceResource.class)
@@ -1564,7 +1564,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
when: "a fake tunnel for a fake gateway ID in the smart city realm is injected into the gateway service"
[email protected]("fake-tunnel-id",
new GatewayTunnelInfo(managerTestSetup.realmCityName, "fake-gateway-id", GatewayTunnelInfo.Type.HTTPS, "127.0.0.1", 443)
- )
+ )
and: "the building user then retrieves the list of tunnels for the fake gateway ID"
def activeTunnels = gatewayResource.getGatewayActiveTunnelInfos(null, managerTestSetup.realmBuildingName, "fake-gateway-id")
@@ -1624,7 +1624,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
null,
Map.of("test", new GatewayAssetSyncRule()),
false
- )
+ )
gatewayClientService.setConnection(gatewayConnection)
then: "the gateway client connector should be created"
@@ -1801,7 +1801,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "the gateway client resource"
def gatewayResource = getClientApiTarget(serverUri((isCentralInstanceSecure), centralInstanceHostname, centralInstancePort), MASTER_REALM, accessToken).proxy(GatewayServiceResource.class)
@@ -1819,7 +1819,7 @@ class GatewayTest extends Specification implements ManagerContainerTrait {
null,
Map.of("test", new GatewayAssetSyncRule()),
false
- )
+ )
gatewayClientService.setConnection(gatewayConnection)
diff --git a/test/src/test/groovy/org/openremote/test/map/MapResourceTest.groovy b/test/src/test/groovy/org/openremote/test/map/MapResourceTest.groovy
index 7afcf1192..681f3c7be 100644
--- a/test/src/test/groovy/org/openremote/test/map/MapResourceTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/map/MapResourceTest.groovy
@@ -59,7 +59,7 @@ class MapResourceTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "a test client target set"
clientTarget = getClientApiTarget(serverUri(serverPort), realm, accessToken)
diff --git a/test/src/test/groovy/org/openremote/test/model/AssetModelTest.groovy b/test/src/test/groovy/org/openremote/test/model/AssetModelTest.groovy
index 1c2797ab7..25f6e9246 100644
--- a/test/src/test/groovy/org/openremote/test/model/AssetModelTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/model/AssetModelTest.groovy
@@ -128,7 +128,7 @@ class AssetModelTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
stopPseudoClock()
and: "the asset resource"
@@ -202,7 +202,7 @@ class AssetModelTest extends Specification implements ManagerContainerTrait {
new Attribute<>("custom2", ValueType.GEO_JSON_POINT, new GeoJSONPoint(1.234, 5.678)).addMeta(
new MetaItem<>(MetaItemType.CONSTRAINTS, ValueConstraint.constraints(new ValueConstraint.NotNull()))
)
- )
+ )
def updatedModelTestAsset = assetResource.update(null, modelTestAsset.id, modelTestAsset)
then: "the save should succeed and correct values should be stored"
@@ -527,7 +527,7 @@ class AssetModelTest extends Specification implements ManagerContainerTrait {
.addAttributes(
new Attribute<>("attr1", ValueType.TIMESTAMP, getClockTimeOf(container)),
new Attribute<>("attr2", ValueType.POSITIVE_INTEGER, 3)
- )
+ )
customAsset.type = CUSTOM_ASSET_TYPE
customAsset = assetResource.create(null, customAsset)
@@ -552,7 +552,7 @@ class AssetModelTest extends Specification implements ManagerContainerTrait {
when: "the issue is resolved"
customAsset.addAttributes(
new Attribute<>("dynamic1", dynamicValueDescriptors[0], "value1")
- )
+ )
customAsset = assetResource.create(null, customAsset)
then: "it should have been persisted"
@@ -704,15 +704,15 @@ class AssetModelTest extends Specification implements ManagerContainerTrait {
.setPath("test_path")
.setPagingMode(true))
)
- )
+ )
asset.getAttribute(LightAsset.COLOUR_RGB).ifPresent({
it.addOrReplaceMeta(
- new MetaItem<>(MetaItemType.AGENT_LINK, new DefaultAgentLink("agent_id")
- .setValueFilters(
- [new SubStringValueFilter(0,10)] as ValueFilter[]
+ new MetaItem<>(MetaItemType.AGENT_LINK, new DefaultAgentLink("agent_id")
+ .setValueFilters(
+ [new SubStringValueFilter(0,10)] as ValueFilter[]
+ )
)
)
- )
})
// Inject properties which are normally done by the backend on retrieval
asset.path = [asset.id, parentId]
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 605ab9f69..31db45e2a 100644
--- a/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy
@@ -110,21 +110,21 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
"testuser1",
"testuser1"
- )
+ )
def testuser2AccessToken = authenticate(
container,
realm,
KEYCLOAK_CLIENT_ID,
"testuser2",
"testuser2"
- )
+ )
def testuser3AccessToken = authenticate(
container,
realm,
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
- )
+ )
and: "an authenticated superuser"
def adminAccessToken = authenticate(
@@ -133,7 +133,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
def notification = new Notification("TestAction",
new PushNotificationMessage("Test Action",
@@ -855,7 +855,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
def notification = new Notification(
"MultiLanguageAction",
@@ -950,7 +950,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
"testuser1",
"testuser1"
- )
+ )
and: "their language is updated to dutch"
def testuser1 = identityService.getIdentityProvider().getUserByUsername(MASTER_REALM, "testuser1")
@@ -1202,8 +1202,8 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
// realm is selected via the realmId query param (the consolidated endpoint has no realm path segment)
def requestNotificationsByRealm = { String authRealm, String token, String realmId ->
getClientApiTarget(serverUri(serverPort), authRealm, token)
- .path("notification").queryParam("realmId", realmId)
- .request().get()
+ .path("notification").queryParam("realmId", realmId)
+ .request().get()
}
and: "a helper that reads the notifications of a realm with a given name as the superuser"
@@ -1222,8 +1222,8 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
}
def deleteNotificationById = { String authRealm, String token, Long notificationId ->
getClientApiTarget(serverUri(serverPort), authRealm, token)
- .path("notification").path(notificationId.toString())
- .request().delete()
+ .path("notification").path(notificationId.toString())
+ .request().delete()
}
when: "an email notification is sent to the entire building realm"
diff --git a/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy
index ca1ae7679..c011ab7bd 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy
@@ -263,7 +263,7 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait {
)
)
)
- )
+ )
mockThing = assetStorageService.merge(mockThing)
@@ -527,7 +527,7 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait {
"${username}@openremote.local",
true,
[ClientRole.READ_ASSETS] as ClientRole[]
- )
+ )
def accessToken = authenticate(container, MASTER_REALM, KEYCLOAK_CLIENT_ID, username, username)
and: "a running mock protocol agent"
@@ -583,7 +583,7 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait {
"${username}@openremote.local",
true,
[ClientRole.WRITE_ASSETS] as ClientRole[]
- )
+ )
def accessToken = authenticate(container, MASTER_REALM, KEYCLOAK_CLIENT_ID, username, username)
and: "a running mock protocol agent"
diff --git a/test/src/test/groovy/org/openremote/test/protocol/KNXImportTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/KNXImportTest.groovy
index ea47758bb..131bba918 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/KNXImportTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/KNXImportTest.groovy
@@ -71,7 +71,7 @@ class KNXImportTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "the agent resource"
def agentResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AgentResource.class)
@@ -85,7 +85,7 @@ class KNXImportTest extends Specification implements ManagerContainerTrait {
when: "discovery is requested with a ETS project file"
def knxProjectFileResource = getClass().getResourceAsStream(
"/org/openremote/test/protocol/knx/knx-import-testproject.knxproj"
- )
+ )
String base64Content = Base64.getEncoder().encodeToString(knxProjectFileResource.bytes)
def fileInfo = new FileInfo("knx-import-testproject.knxproj", base64Content, true)
def assets = agentResource.doProtocolAssetImport(null, knxAgent.getId(), null, fileInfo)
@@ -96,14 +96,14 @@ class KNXImportTest extends Specification implements ManagerContainerTrait {
assert assets.length == 12
assert assets.each {
!TextUtil.isNullOrEmpty(it.asset.id) &&
- !TextUtil.isNullOrEmpty(it.asset.getName()) &&
- !it.asset.attributes().isEmpty() &&
- it.asset.getAttributes().stream().allMatch({attr ->
- attr.getMetaValue(AGENT_LINK).map({agentLink ->
- agentLink.id == knxAgent.id
- })
- .orElse(false)
- })
+ !TextUtil.isNullOrEmpty(it.asset.getName()) &&
+ !it.asset.attributes().isEmpty() &&
+ it.asset.getAttributes().stream().allMatch({attr ->
+ attr.getMetaValue(AGENT_LINK).map({agentLink ->
+ agentLink.id == knxAgent.id
+ })
+ .orElse(false)
+ })
}
}
diff --git a/test/src/test/groovy/org/openremote/test/protocol/KNXImportXXETest.groovy b/test/src/test/groovy/org/openremote/test/protocol/KNXImportXXETest.groovy
index 629088aee..92df70c56 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/KNXImportXXETest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/KNXImportXXETest.groovy
@@ -52,7 +52,7 @@ class KNXImportXXETest extends Specification {
assets.size() == 12
assets.every {
it.asset.name != null &&
- !it.asset.attributes.isEmpty()
+ !it.asset.attributes.isEmpty()
}
cleanup:
diff --git a/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy
index 66c23e592..cfc9718a4 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy
@@ -130,7 +130,7 @@ class KNXProtocolTest extends Specification implements ManagerContainerTrait {
new MetaItem<>(LABEL, "Light 1 Toggle On/Off"),
new MetaItem<>(AGENT_LINK, new KNXAgentLink(knxAgent1.id, "1.001", "1/0/17", "0/4/14"))
)
- )
+ )
knxThing = assetStorageService.merge(knxThing)
then: "the living room thing to be fully deployed"
diff --git a/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy
index 3075d719d..53aa21891 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy
@@ -120,7 +120,7 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
requestContext.abortWith(
Response.ok(response, MediaType.APPLICATION_JSON_TYPE).build()
- )
+ )
return
} else if (grant.getFirst(OAuthGrant.VALUE_KEY_GRANT_TYPE) == "refresh_token"
&& grant.getFirst(OAuthGrant.VALUE_KEY_CLIENT_ID) == "TestClient"
@@ -138,7 +138,7 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
requestContext.abortWith(
Response.ok(response, MediaType.APPLICATION_JSON_TYPE).build()
- )
+ )
return
}
break
@@ -197,7 +197,7 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
Response
.ok("This is an example response where the value of 100% is in the body of the message.", MediaType.TEXT_PLAIN)
.build()
- )
+ )
return
case "https://mockapi/get_poll_fast":
pollCountFast++
@@ -205,7 +205,7 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
Response
.ok("This is an example response where there are multiple values of 100% 60% in the body of the message.", MediaType.TEXT_PLAIN)
.build()
- )
+ )
return
case "https://mockapi/get_success_200":
case "https://redirected.mockapi/get_success_200":
@@ -222,11 +222,11 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
return
case "https://mockapi/binary":
requestContext.abortWith(
- Response.ok(
- new byte[] {
- (byte)0x1F & 0xFF, (byte)0x56 & 0xFF, (byte)0x01 & 0xFF, (byte)0xAE & 0xFF, (byte)0x12 & 0xFF
- }, MediaType.APPLICATION_OCTET_STREAM_TYPE
- ).build()
+ Response.ok(
+ new byte[] {
+ (byte)0x1F & 0xFF, (byte)0x56 & 0xFF, (byte)0x01 & 0xFF, (byte)0xAE & 0xFF, (byte)0x12 & 0xFF
+ }, MediaType.APPLICATION_OCTET_STREAM_TYPE
+ ).build()
)
return
case "https://mockapi/dynamic_time_1":
@@ -262,7 +262,7 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
Response
.ok(requestContext.getEntity() as String, MediaType.APPLICATION_JSON_TYPE)
.build()
- )
+ )
return
}
}
@@ -317,7 +317,7 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
)
.setRequestQueryParameters(
ValueUtil.parse(/{"param1": ["param1Value1"], "param2": ["param2Value1","param2Value2"]}/, MultivaluedStringMap.class).orElseThrow()
- )
+ )
and: "the agent is added to the asset service"
agent = assetStorageService.merge(agent)
@@ -427,7 +427,7 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
)
)
)
- )
+ )
and: "the asset is merged into the asset service"
asset = assetStorageService.merge(asset)
@@ -561,7 +561,7 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
.setPath("redirect")
)
)
- )
+ )
and: "the asset is merged into the asset service"
asset2 = assetStorageService.merge(asset2)
@@ -660,7 +660,7 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
))
)
)
- )
+ )
and: "the clock is stopped"
stopPseudoClock()
diff --git a/test/src/test/groovy/org/openremote/test/protocol/http/HttpServerProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/http/HttpServerProtocolTest.groovy
index a86d6378b..ab2083ecd 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/http/HttpServerProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/http/HttpServerProtocolTest.groovy
@@ -86,7 +86,7 @@ class HttpServerProtocolTest extends Specification implements ManagerContainerTr
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
when: "a test HTTP server agent with a test deployment is created"
def agent = new HTTPServerTestAgent("Test agent")
@@ -193,7 +193,7 @@ class HttpServerProtocolTest extends Specification implements ManagerContainerTr
testAsset.setId(UniqueIdentifierGenerator.generateId())
testAsset.addOrReplaceAttributes(
new Attribute<>("attribute2", TEXT, "Test")
- )
+ )
testAsset.setLocation(new GeoJSONPoint(3d, 4d))
testResource2.postAsset(testAsset)
diff --git a/test/src/test/groovy/org/openremote/test/protocol/http/WebTargetTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/http/WebTargetTest.groovy
index 3ca817abe..95645be51 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/http/WebTargetTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/http/WebTargetTest.groovy
@@ -90,7 +90,7 @@ class WebTargetTest extends Specification {
requestContext.abortWith(
Response.ok(response, MediaType.APPLICATION_JSON_TYPE).build()
- )
+ )
return
} else if (grant.getFirst(OAuthGrant.VALUE_KEY_GRANT_TYPE) == "client_credentials"
&& grant.getFirst(OAuthGrant.VALUE_KEY_CLIENT_ID) == "client1"
@@ -104,7 +104,7 @@ class WebTargetTest extends Specification {
requestContext.abortWith(
Response.ok(response, MediaType.APPLICATION_JSON_TYPE).build()
- )
+ )
return
} else if (supportsRefresh && grant.getFirst(OAuthGrant.VALUE_KEY_GRANT_TYPE) == "refresh_token"
&& grant.getFirst(OAuthGrant.VALUE_KEY_CLIENT_ID) == "client1"
@@ -122,7 +122,7 @@ class WebTargetTest extends Specification {
requestContext.abortWith(
Response.ok(response, MediaType.APPLICATION_JSON_TYPE).build()
- )
+ )
return
}
break
@@ -140,19 +140,19 @@ class WebTargetTest extends Specification {
accessTokenCount++
requestContext.abortWith(
Response.status(Response.Status.FORBIDDEN).build()
- )
+ )
return
case "https://headerserver":
if (requestContext.getHeaderString("MyHeader") == "MyHeaderValue"
- && requestContext.getHeaderString("MyMultiHeader") == "MyMultiHeaderValue1,MyMultiHeaderValue2") {
+ && requestContext.getHeaderString("MyMultiHeader") == "MyMultiHeaderValue1,MyMultiHeaderValue2") {
requestContext.abortWith(Response.ok().build())
return
}
break
case "https://headerserver/get":
if (requestContext.getHeaderString("MyHeader") == "MyHeaderValue"
- && requestContext.getHeaderString("MyHeaderNew") == "MyHeaderNewValue"
- && requestContext.getHeaderString("MyMultiHeader") == "MyMultiHeaderValue1,MyMultiHeaderValue2,MyMultiHeaderValue3") {
+ && requestContext.getHeaderString("MyHeaderNew") == "MyHeaderNewValue"
+ && requestContext.getHeaderString("MyMultiHeader") == "MyMultiHeaderValue1,MyMultiHeaderValue2,MyMultiHeaderValue3") {
requestContext.abortWith(Response.ok().build())
return
}
diff --git a/test/src/test/groovy/org/openremote/test/protocol/lorawan/chirpstack/ChirpStackTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/lorawan/chirpstack/ChirpStackTest.groovy
index ca4930c34..b06803e6d 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/lorawan/chirpstack/ChirpStackTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/lorawan/chirpstack/ChirpStackTest.groovy
@@ -179,7 +179,7 @@ class ChirpStackTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "the agent resource"
def agentResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AgentResource.class)
@@ -308,7 +308,7 @@ class ChirpStackTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "the agent resource"
def agentResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AgentResource.class)
@@ -464,7 +464,7 @@ class ChirpStackTest extends Specification implements ManagerContainerTrait {
Status.NOT_FOUND
.withDescription("Device profile not found: ${request.id}")
.asRuntimeException()
- )
+ )
return
}
diff --git a/test/src/test/groovy/org/openremote/test/protocol/lorawan/tts/TheThingsStackTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/lorawan/tts/TheThingsStackTest.groovy
index 4826554ae..399681c56 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/lorawan/tts/TheThingsStackTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/lorawan/tts/TheThingsStackTest.groovy
@@ -202,7 +202,7 @@ class TheThingsStackTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "the agent resource"
def agentResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AgentResource.class)
diff --git a/test/src/test/groovy/org/openremote/test/protocol/mail/MailClientProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/mail/MailClientProtocolTest.groovy
index 134605ec8..b291b92a4 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/mail/MailClientProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/mail/MailClientProtocolTest.groovy
@@ -166,7 +166,7 @@ class MailClientProtocolTest extends Specification implements ManagerContainerTr
.setUseSubject(true)
)
)
- )
+ )
and: "the asset is merged into the asset service"
asset = assetStorageService.merge(asset)
diff --git a/test/src/test/groovy/org/openremote/test/protocol/modbus/ModbusSerialTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/modbus/ModbusSerialTest.groovy
index 14b67a6a5..9405c9549 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/modbus/ModbusSerialTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/modbus/ModbusSerialTest.groovy
@@ -68,7 +68,7 @@ class ModbusSerialTest extends Specification implements ManagerContainerTrait {
.type(ElementMatchers.is(SerialIOClient.class))
.transform { builder, typeDescription, classLoader, module, protectionDomain ->
builder.visit(Advice.to(MockSerialChannel.GetChannelClassAdvice.class)
- .on(ElementMatchers.named("getChannelClass")))
+ .on(ElementMatchers.named("getChannelClass")))
}
.installOn(instrumentation)
@@ -137,7 +137,7 @@ class ModbusSerialTest extends Specification implements ManagerContainerTrait {
new Attribute<>(ModbusAgent.DEVICE_CONFIG, [
"default": new ModbusAgent.ModbusDeviceConfig(ModbusAgent.EndianFormat.BIG_ENDIAN, "101,151-161", 30)
] as ModbusAgent.DeviceConfigMap)
- )
+ )
agent = assetStorageService.merge(agent)
@@ -169,7 +169,7 @@ class ModbusSerialTest extends Specification implements ManagerContainerTrait {
// Missing: readValueType
}
))
- )
+ )
device0 = assetStorageService.merge(device0)
then: "the attribute should be linked without creating read polling tasks"
@@ -245,7 +245,7 @@ class ModbusSerialTest extends Specification implements ManagerContainerTrait {
it.setWriteAddress(6)
}
))
- )
+ )
device = assetStorageService.merge(device)
@@ -304,7 +304,7 @@ class ModbusSerialTest extends Specification implements ManagerContainerTrait {
new Attribute<>(ModbusAgent.DEVICE_CONFIG, [
"default": new ModbusAgent.ModbusDeviceConfig(ModbusAgent.EndianFormat.BIG_ENDIAN, "6-11,21-26", 30)
] as ModbusAgent.DeviceConfigMap)
- )
+ )
agent = assetStorageService.merge(agent)
@@ -349,7 +349,7 @@ class ModbusSerialTest extends Specification implements ManagerContainerTrait {
it.setRegistersAmount(2)
}
))
- )
+ )
device = assetStorageService.merge(device)
@@ -392,7 +392,7 @@ class ModbusSerialTest extends Specification implements ManagerContainerTrait {
new Attribute<>(ModbusAgent.DEVICE_CONFIG, [
"default": new ModbusAgent.ModbusDeviceConfig(ModbusAgent.EndianFormat.BIG_ENDIAN, "", 30)
] as ModbusAgent.DeviceConfigMap)
- )
+ )
agent = assetStorageService.merge(agent)
@@ -420,7 +420,7 @@ class ModbusSerialTest extends Specification implements ManagerContainerTrait {
it.setRegistersAmount(1)
}
))
- )
+ )
ThingAsset device2 = new ThingAsset("Device on Unit 2")
device2.setRealm(MASTER_REALM)
@@ -437,7 +437,7 @@ class ModbusSerialTest extends Specification implements ManagerContainerTrait {
it.setRegistersAmount(1)
}
))
- )
+ )
device1 = assetStorageService.merge(device1)
device2 = assetStorageService.merge(device2)
@@ -594,7 +594,7 @@ class ModbusSerialTest extends Specification implements ManagerContainerTrait {
new Attribute<>(ModbusAgent.DEVICE_CONFIG, [
"default": new ModbusAgent.ModbusDeviceConfig(ModbusAgent.EndianFormat.BIG_ENDIAN, "", 50)
] as ModbusAgent.DeviceConfigMap)
- )
+ )
agent = assetStorageService.merge(agent)
@@ -639,7 +639,7 @@ class ModbusSerialTest extends Specification implements ManagerContainerTrait {
}
)
)
- )
+ )
device = assetStorageService.merge(device)
@@ -705,7 +705,7 @@ class ModbusSerialTest extends Specification implements ManagerContainerTrait {
new Attribute<>(ModbusSerialAgent.DATA_BITS, 8),
new Attribute<>(ModbusSerialAgent.STOP_BITS, Stopbits.STOPBITS_1),
new Attribute<>(ModbusSerialAgent.PARITY, Paritybit.EVEN)
- )
+ )
agent = assetStorageService.merge(agent)
then: "the agent should connect successfully"
@@ -733,7 +733,7 @@ class ModbusSerialTest extends Specification implements ManagerContainerTrait {
it.setWriteAddress(51)
}
))
- )
+ )
device = assetStorageService.merge(device)
then: "device should be linked"
@@ -778,7 +778,7 @@ class ModbusSerialTest extends Specification implements ManagerContainerTrait {
new Attribute<>(ModbusSerialAgent.DATA_BITS, 8),
new Attribute<>(ModbusSerialAgent.STOP_BITS, Stopbits.STOPBITS_1),
new Attribute<>(ModbusSerialAgent.PARITY, Paritybit.EVEN)
- )
+ )
agent = assetStorageService.merge(agent)
then: "the agent should connect successfully"
@@ -805,7 +805,7 @@ class ModbusSerialTest extends Specification implements ManagerContainerTrait {
),
new MetaItem<>(STORE_DATA_POINTS)
)
- )
+ )
device = assetStorageService.merge(device)
then: "write request task should be created"
@@ -861,7 +861,7 @@ class ModbusSerialTest extends Specification implements ManagerContainerTrait {
new Attribute<>(ModbusAgent.DEVICE_CONFIG, [
"default": new ModbusAgent.ModbusDeviceConfig(endianFormat, "", 50)
] as ModbusAgent.DeviceConfigMap)
- )
+ )
return assetStorageService.merge(agent)
}
@@ -884,7 +884,7 @@ class ModbusSerialTest extends Specification implements ManagerContainerTrait {
}
)
)
- )
+ )
return assetStorageService.merge(device)
}
@@ -907,7 +907,7 @@ class ModbusSerialTest extends Specification implements ManagerContainerTrait {
}
)
)
- )
+ )
return assetStorageService.merge(device)
}
diff --git a/test/src/test/groovy/org/openremote/test/protocol/modbus/ModbusTcpTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/modbus/ModbusTcpTest.groovy
index aae00122d..59fbe11d3 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/modbus/ModbusTcpTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/modbus/ModbusTcpTest.groovy
@@ -81,47 +81,47 @@ class ModbusTcpTest extends Specification implements ManagerContainerTrait {
server.setMessageHandler((msg, sender) -> {
ModbusMessage modbusMessage = null
switch (msg.getFunction().blockType()) {
- case ModbusBlockType.Coil -> {
- BitsModbusMessage tcpRequest = msg.unwrap(BitsModbusMessage.class)
- if (msg.getFunction().isReadFunction()) {
- modbusMessage = readCoilsResponse(tcpRequest.getUnitId(), tcpRequest.getAddress(), tcpRequest.getCount(), BigInteger.valueOf(0xFFFF))
- } else {
- if (tcpRequest.getFunction().getCode() == WRITE_COILS) {
- modbusMessage = writeCoilsResponse(tcpRequest.getUnitId(), tcpRequest.getAddress(), tcpRequest.getCount())
- } else if (tcpRequest.getFunction().getCode() == WRITE_COIL) {
- modbusMessage = writeCoilResponse(tcpRequest.getUnitId(), tcpRequest.getAddress(), true)
- }
- }
- }
- case ModbusBlockType.Discrete -> {
- BitsModbusMessage tcpRequest = msg.unwrap(BitsModbusMessage.class)
- modbusMessage = readDiscretesResponse(tcpRequest.getUnitId(), tcpRequest.getAddress(), tcpRequest.getCount(), BigInteger.valueOf(0xFFFF))
- }
- case ModbusBlockType.Holding -> {
- RegistersModbusMessage registerRequest = msg.unwrap(RegistersModbusMessage.class)
- if (msg.getFunction().isReadFunction()) {
- // Generate mock data based on address and count
- short[] mockData = generateMockHoldingData(registerRequest.getAddress(), registerRequest.getCount())
- println("TCP Mock: address=${registerRequest.getAddress()}, count=${registerRequest.getCount()}, data=${mockData.collect{String.format('0x%04X', it & 0xFFFF)}}")
- modbusMessage = readHoldingsResponse(registerRequest.getUnitId(), registerRequest.getAddress(), mockData)
- } else {
- if (registerRequest.getFunction().getCode() == WRITE_HOLDING_REGISTERS) {
- modbusMessage = writeHoldingsResponse(registerRequest.getUnitId(), registerRequest.getAddress(), registerRequest.getCount())
- } else if (registerRequest.getFunction().getCode() == WRITE_HOLDING_REGISTER) {
- modbusMessage = writeHoldingResponse(registerRequest.getUnitId(), registerRequest.getAddress(), 21)
- }
- }
- }
- case ModbusBlockType.Input -> {
- RegistersModbusMessage registerRequest = msg.unwrap(RegistersModbusMessage.class)
- modbusMessage = readInputsResponse(registerRequest.getUnitId(), registerRequest.getAddress(), new short[]{
- 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
- })
- }
- case ModbusBlockType.Diagnostic -> {
- modbusMessage = new BaseModbusMessage(msg.getUnitId(), msg.getFunction(), ModbusErrorCode.Acknowledge)
- }
- }
+ case ModbusBlockType.Coil -> {
+ BitsModbusMessage tcpRequest = msg.unwrap(BitsModbusMessage.class)
+ if (msg.getFunction().isReadFunction()) {
+ modbusMessage = readCoilsResponse(tcpRequest.getUnitId(), tcpRequest.getAddress(), tcpRequest.getCount(), BigInteger.valueOf(0xFFFF))
+ } else {
+ if (tcpRequest.getFunction().getCode() == WRITE_COILS) {
+ modbusMessage = writeCoilsResponse(tcpRequest.getUnitId(), tcpRequest.getAddress(), tcpRequest.getCount())
+ } else if (tcpRequest.getFunction().getCode() == WRITE_COIL) {
+ modbusMessage = writeCoilResponse(tcpRequest.getUnitId(), tcpRequest.getAddress(), true)
+ }
+ }
+ }
+ case ModbusBlockType.Discrete -> {
+ BitsModbusMessage tcpRequest = msg.unwrap(BitsModbusMessage.class)
+ modbusMessage = readDiscretesResponse(tcpRequest.getUnitId(), tcpRequest.getAddress(), tcpRequest.getCount(), BigInteger.valueOf(0xFFFF))
+ }
+ case ModbusBlockType.Holding -> {
+ RegistersModbusMessage registerRequest = msg.unwrap(RegistersModbusMessage.class)
+ if (msg.getFunction().isReadFunction()) {
+ // Generate mock data based on address and count
+ short[] mockData = generateMockHoldingData(registerRequest.getAddress(), registerRequest.getCount())
+ println("TCP Mock: address=${registerRequest.getAddress()}, count=${registerRequest.getCount()}, data=${mockData.collect{String.format('0x%04X', it & 0xFFFF)}}")
+ modbusMessage = readHoldingsResponse(registerRequest.getUnitId(), registerRequest.getAddress(), mockData)
+ } else {
+ if (registerRequest.getFunction().getCode() == WRITE_HOLDING_REGISTERS) {
+ modbusMessage = writeHoldingsResponse(registerRequest.getUnitId(), registerRequest.getAddress(), registerRequest.getCount())
+ } else if (registerRequest.getFunction().getCode() == WRITE_HOLDING_REGISTER) {
+ modbusMessage = writeHoldingResponse(registerRequest.getUnitId(), registerRequest.getAddress(), 21)
+ }
+ }
+ }
+ case ModbusBlockType.Input -> {
+ RegistersModbusMessage registerRequest = msg.unwrap(RegistersModbusMessage.class)
+ modbusMessage = readInputsResponse(registerRequest.getUnitId(), registerRequest.getAddress(), new short[]{
+ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
+ })
+ }
+ case ModbusBlockType.Diagnostic -> {
+ modbusMessage = new BaseModbusMessage(msg.getUnitId(), msg.getFunction(), ModbusErrorCode.Acknowledge)
+ }
+ }
if (msg.getFunction().isReadFunction()) {
latestReadMessage.set(msg)
@@ -252,7 +252,7 @@ class ModbusTcpTest extends Specification implements ManagerContainerTrait {
}
)
)
- )
+ )
device = assetStorageService.merge(device)
then: "the attribute should be linked without creating read polling tasks"
@@ -278,7 +278,7 @@ class ModbusTcpTest extends Specification implements ManagerContainerTrait {
writeMemoryArea: ModbusAgentLink.WriteMemoryArea.HOLDING,
writeAddress: 3
)
- )))
+ )))
ship = assetStorageService.merge(ship)
ModbusAgentLink agentLink
@@ -328,7 +328,7 @@ class ModbusTcpTest extends Specification implements ManagerContainerTrait {
writeMemoryArea: ModbusAgentLink.WriteMemoryArea.COIL,
writeAddress: 6
)
- )))
+ )))
ship.addOrReplaceAttributes(new Attribute<Object>(ShipAsset.SPEED).setMeta(Map.of() as MetaMap))
latestReadMessage.set(null)
latestWriteMessage.set(null)
@@ -389,7 +389,7 @@ class ModbusTcpTest extends Specification implements ManagerContainerTrait {
new Attribute<>(ModbusAgent.DEVICE_CONFIG, [
"default": new ModbusAgent.ModbusDeviceConfig(ModbusAgent.EndianFormat.BIG_ENDIAN, "", 50)
] as ModbusAgent.DeviceConfigMap) // Enable batching
- )
+ )
agent = assetStorageService.merge(agent)
then: "the protocol instance should be created and connected"
@@ -436,7 +436,7 @@ class ModbusTcpTest extends Specification implements ManagerContainerTrait {
}
)
)
- )
+ )
device = assetStorageService.merge(device)
then: "batch groups should be created and attributes should receive values"
@@ -479,7 +479,7 @@ class ModbusTcpTest extends Specification implements ManagerContainerTrait {
new Attribute<>(ModbusAgent.DEVICE_CONFIG, [
"default": new ModbusAgent.ModbusDeviceConfig(ModbusAgent.EndianFormat.BIG_ENDIAN, "", 50)
] as ModbusAgent.DeviceConfigMap)
- )
+ )
agent = assetStorageService.merge(agent)
then: "the agent should connect successfully"
@@ -531,7 +531,7 @@ class ModbusTcpTest extends Specification implements ManagerContainerTrait {
}
)
)
- )
+ )
device = assetStorageService.merge(device)
then: "all 64-bit attributes should receive values"
@@ -581,7 +581,7 @@ class ModbusTcpTest extends Specification implements ManagerContainerTrait {
new Attribute<>(ModbusAgent.DEVICE_CONFIG, [
"default": new ModbusAgent.ModbusDeviceConfig(ModbusAgent.EndianFormat.BIG_ENDIAN, "", 1)
] as ModbusAgent.DeviceConfigMap)
- )
+ )
agent = assetStorageService.merge(agent)
then: "the agent should connect successfully"
@@ -618,7 +618,7 @@ class ModbusTcpTest extends Specification implements ManagerContainerTrait {
}
)
)
- )
+ )
device = assetStorageService.merge(device)
then: "the values should be read correctly with BIG-BIG order"
@@ -697,7 +697,7 @@ class ModbusTcpTest extends Specification implements ManagerContainerTrait {
}
)
)
- )
+ )
device = assetStorageService.merge(device)
then: "device should be linked"
@@ -784,7 +784,7 @@ class ModbusTcpTest extends Specification implements ManagerContainerTrait {
}
)
)
- )
+ )
device = assetStorageService.merge(device)
then: "write polling task should be created"
@@ -877,7 +877,7 @@ class ModbusTcpTest extends Specification implements ManagerContainerTrait {
}
)
)
- )
+ )
device = assetStorageService.merge(device)
then: "the attribute should be linked without errors"
diff --git a/test/src/test/groovy/org/openremote/test/protocol/mqtt/MQTTClientProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/mqtt/MQTTClientProtocolTest.groovy
index 80a66518e..a341dd33c 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/mqtt/MQTTClientProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/mqtt/MQTTClientProtocolTest.groovy
@@ -133,7 +133,7 @@ class MQTTClientProtocolTest extends Specification implements ManagerContainerTr
new MQTTLastWill("${keycloakTestSetup.realmBuilding.name}/${clientId}/$DefaultMQTTHandler.ATTRIBUTE_VALUE_WRITE_TOPIC/notes/${managerTestSetup.apartment1HallwayId}".toString(), "\"LAST WILL\"".toString(), false),
null,
null
- )
+ )
client.setResubscribeIfSessionPresent(false)
client.setTopicSubscribeFailureConsumer {
LOG.info("Subscription failed: $it")
@@ -201,7 +201,7 @@ class MQTTClientProtocolTest extends Specification implements ManagerContainerTr
new UserAssetLink(keycloakTestSetup.realmBuilding.getName(),
keycloakTestSetup.serviceUser2.getId(),
managerTestSetup.apartment1BathroomId)
- ))
+ ))
then: "the client should have disconnected and reconnected"
conditions.eventually {
@@ -362,7 +362,7 @@ class MQTTClientProtocolTest extends Specification implements ManagerContainerTr
.setPublishTopic("${keycloakTestSetup.realmBuilding.name}/$clientId/${DefaultMQTTHandler.ATTRIBUTE_VALUE_WRITE_TOPIC}/targetTemperature/${managerTestSetup.apartment1LivingroomId}")
.setWriteValue("%VALUE%")
))
- )
+ )
and: "the asset is merged into the asset service"
asset = assetStorageService.merge(asset)
@@ -414,7 +414,7 @@ class MQTTClientProtocolTest extends Specification implements ManagerContainerTr
.setPublishTopic("${keycloakTestSetup.realmBuilding.name}/$clientId/${DefaultMQTTHandler.ATTRIBUTE_VALUE_WRITE_TOPIC}/targetTemperature/${managerTestSetup.apartment1LivingroomId}")
.setQos(2)
.setWriteValue("%VALUE%")
- ))
+ ))
and: "the asset is merged into the asset service"
asset = assetStorageService.merge(asset)
@@ -460,7 +460,7 @@ class MQTTClientProtocolTest extends Specification implements ManagerContainerTr
.setRealm(keycloakTestSetup.realmBuilding.name)
.addOrReplaceAttributes(
new Attribute<Object>("test", JSON)
- )
+ )
and: "the test asset is added to the asset service"
testThing = assetStorageService.merge(testThing)
@@ -507,7 +507,7 @@ class MQTTClientProtocolTest extends Specification implements ManagerContainerTr
SWITCH_OFF: false
])
))
- )
+ )
and: "the asset is merged into the asset service"
asset = assetStorageService.merge(asset)
@@ -629,17 +629,17 @@ class MQTTClientProtocolTest extends Specification implements ManagerContainerTr
)
.addOrReplaceAttributes(
new Attribute<Object>("humidity", NUMBER)
- )
+ )
def testThing2 = new ThingAsset("Test thing 2")
.setRealm(keycloakTestSetup.realmBuilding.name)
.addOrReplaceAttributes(
new Attribute<Object>("pressure", NUMBER)
- )
+ )
def testThing3 = new ThingAsset("Test thing 3")
.setRealm(keycloakTestSetup.realmBuilding.name)
.addOrReplaceAttributes(
new Attribute<Object>("uvIndex", NUMBER)
- )
+ )
and: "the test assets are added to the asset service"
testThing1 = assetStorageService.merge(testThing1)
@@ -707,7 +707,7 @@ class MQTTClientProtocolTest extends Specification implements ManagerContainerTr
new MetaItem<>(AGENT_LINK, new MQTTAgentLink(agent.id)
.setSubscriptionTopic(uvIndexTopic)
))
- )
+ )
and: "the asset is merged into the asset service"
asset = assetStorageService.merge(asset)
@@ -982,7 +982,7 @@ class MQTTClientProtocolTest extends Specification implements ManagerContainerTr
endDate,
subject,
keyPair.getPublic()
- )
+ )
ContentSigner contentSigner = new JcaContentSignerBuilder("SHA256WithRSA").build(keyPair.getPrivate())
diff --git a/test/src/test/groovy/org/openremote/test/protocol/openweathermap/OpenWeatherMapProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/openweathermap/OpenWeatherMapProtocolTest.groovy
index 61a1825f2..c7691f9ee 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/openweathermap/OpenWeatherMapProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/openweathermap/OpenWeatherMapProtocolTest.groovy
@@ -222,7 +222,7 @@ class OpenWeatherMapProtocolTest extends Specification implements ManagerContain
def responseBody = ValueUtil.JSON.readValue(content, OpenWeatherMapResponse.class)
requestContext.abortWith(
Response.ok(responseBody, MediaType.APPLICATION_JSON_TYPE).build()
- )
+ )
return
}
break
diff --git a/test/src/test/groovy/org/openremote/test/protocol/simulator/SimulatorProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/simulator/SimulatorProtocolTest.groovy
index e2e72ce81..3f31dc7bd 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/simulator/SimulatorProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/simulator/SimulatorProtocolTest.groovy
@@ -151,11 +151,11 @@ class SimulatorProtocolTest extends Specification implements ManagerContainerTra
private getDataPoints = {
def now = Instant
- .ofEpochMilli(getClockTimeOf(container)).atZone(ZoneId.of("UTC")).toLocalDateTime()
+ .ofEpochMilli(getClockTimeOf(container)).atZone(ZoneId.of("UTC")).toLocalDateTime()
new AssetDatapointAllQuery(
now.minus(1, ChronoUnit.HOURS),
now.plus(1, ChronoUnit.HOURS),
- )
+ )
}
/**
@@ -173,7 +173,7 @@ class SimulatorProtocolTest extends Specification implements ManagerContainerTra
asset.getId(),
attribute.getName(),
getDataPoints.call()
- )
+ )
assert !datapoints.isEmpty()
return datapoints.get(0).getTimestamp()
}
@@ -182,7 +182,7 @@ class SimulatorProtocolTest extends Specification implements ManagerContainerTra
when: "nothing is configured"
asset.addOrReplaceAttributes(new Attribute<>("test1", ValueType.TEXT)
.addMeta(new MetaItem<>(AGENT_LINK, new SimulatorAgentLink(agent.getId())))
- )
+ )
asset = assetStorageService.merge(asset)
def attribute = asset.getAttribute("test1").get()
def attributeRef = new AttributeRef(asset.getId(), attribute.getName())
@@ -214,7 +214,7 @@ class SimulatorProtocolTest extends Specification implements ManagerContainerTra
}
asset.addOrReplaceAttributes(new Attribute<>("test1", ValueType.TEXT).addMeta(
new MetaItem<>(AGENT_LINK, new SimulatorAgentLink(agent.getId(), replayData, null, null))
- ))
+ ))
asset = assetStorageService.merge(asset)
def attribute = asset.getAttribute("test1").get()
def attributeRef = new AttributeRef(asset.getId(), attribute.getName())
@@ -245,7 +245,7 @@ class SimulatorProtocolTest extends Specification implements ManagerContainerTra
// We manually set the schedule so it starts when we want, as AgentLinks don't have access to the timer service
LocalDateTime.ofInstant(Instant.parse("1970-01-01T00:00:00.000Z"), ZoneOffset.UTC), null, "FREQ=DAILY"
))))
- )
+ )
asset = assetStorageService.merge(asset)
def attribute = asset.getAttribute("test2").get()
def attributeRef = new AttributeRef(asset.getId(), attribute.getName())
@@ -323,7 +323,7 @@ class SimulatorProtocolTest extends Specification implements ManagerContainerTra
LocalDateTime.ofInstant(Instant.parse("1970-01-02T00:00:00.000Z"), ZoneOffset.UTC), null, null
)))
)
- )
+ )
asset = assetStorageService.merge(asset)
def attribute1 = asset.getAttribute("test8").get()
def attribute2 = asset.getAttribute("test9").get()
@@ -383,7 +383,7 @@ class SimulatorProtocolTest extends Specification implements ManagerContainerTra
).setSchedule(new SimulatorProtocol.Schedule(
LocalDateTime.ofInstant(Instant.parse("1970-01-02T00:00:00.000Z"), ZoneOffset.UTC), null, null
))
- )))
+ )))
asset = assetStorageService.merge(asset)
def attribute = asset.getAttribute("test3").get()
def attributeRef = new AttributeRef(asset.getId(), attribute.getName())
@@ -447,7 +447,7 @@ class SimulatorProtocolTest extends Specification implements ManagerContainerTra
// Recur every Monday until 1970-01-31
"FREQ=WEEKLY;UNTIL=19700131T000000;BYDAY=MO"
))
- )))
+ )))
asset = assetStorageService.merge(asset)
def attribute = asset.getAttribute("test5").get()
def attributeRef = new AttributeRef(asset.getId(), attribute.getName())
@@ -542,7 +542,7 @@ class SimulatorProtocolTest extends Specification implements ManagerContainerTra
LocalDateTime.ofInstant(Instant.parse("1970-01-01T00:00:00.000Z"), ZoneOffset.UTC), null, "FREQ=DAILY"
))),
new MetaItem<>(HAS_PREDICTED_DATA_POINTS, true))
- )
+ )
asset = assetStorageService.merge(asset)
def attribute = asset.getAttribute("test6").get()
def attributeRef = new AttributeRef(asset.getId(), attribute.getName())
@@ -610,7 +610,7 @@ class SimulatorProtocolTest extends Specification implements ManagerContainerTra
when: "reset agentLink"
attribute.addOrReplaceMeta(
new MetaItem<>(AGENT_LINK, new SimulatorAgentLink(agent.getId())),
- )
+ )
assetStorageService.merge(asset)
then: "purge datapoints"
@@ -629,7 +629,7 @@ class SimulatorProtocolTest extends Specification implements ManagerContainerTra
LocalDateTime.ofInstant(Instant.parse("1970-01-01T00:00:00.000Z"), ZoneOffset.UTC), null, null
))),
new MetaItem<>(HAS_PREDICTED_DATA_POINTS, true))
- )
+ )
asset = assetStorageService.merge(asset)
def attribute = asset.getAttribute("test7").get()
def attributeRef = new AttributeRef(asset.getId(), attribute.getName())
@@ -678,7 +678,7 @@ class SimulatorProtocolTest extends Specification implements ManagerContainerTra
"FREQ=DAILY;UNTIL=19700101T030000"
))),
new MetaItem<>(HAS_PREDICTED_DATA_POINTS, true))
- )
+ )
asset = assetStorageService.merge(asset)
def attribute = asset.getAttribute("test7").get()
def attributeRef = new AttributeRef(asset.getId(), attribute.getName())
@@ -717,7 +717,7 @@ class SimulatorProtocolTest extends Specification implements ManagerContainerTra
"FREQ=DAILY;UNTIL=19700102T010000"
)).setTimezone(TimeZone.getTimeZone("Europe/Amsterdam"))),
new MetaItem<>(HAS_PREDICTED_DATA_POINTS, true))
- )
+ )
asset = assetStorageService.merge(asset)
def attribute = asset.getAttribute("test7").get()
def attributeRef = new AttributeRef(asset.getId(), attribute.getName())
diff --git a/test/src/test/groovy/org/openremote/test/protocol/udp/UdpClientProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/udp/UdpClientProtocolTest.groovy
index 03c5f8de7..f4e8dac7c 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/udp/UdpClientProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/udp/UdpClientProtocolTest.groovy
@@ -157,7 +157,7 @@ class UdpClientProtocolTest extends Specification implements ManagerContainerTra
new ValueAnyPredicate())
)
)
- )
+ )
and: "the asset is merged into the asset service"
asset = assetStorageService.merge(asset)
diff --git a/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusProtocolTest.groovy
index e1a2c287a..60f75eced 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusProtocolTest.groovy
@@ -111,7 +111,7 @@ class VelbusProtocolTest extends Specification implements ManagerContainerTrait
new VelbusAgentLink(agent.id, 48, "CH1")
)
)
- )
+ )
and: "the device asset is added to the asset service"
device = assetStorageService.merge(device)
@@ -145,7 +145,7 @@ class VelbusProtocolTest extends Specification implements ManagerContainerTrait
and: "a VELBUS project file"
def velbusProjectFileResource = getClass().getResourceAsStream(
"/org/openremote/test/protocol/velbus/VelbusProject.vlp"
- )
+ )
def velbusProjectFile = IOUtils.toString(velbusProjectFileResource, "UTF-8")
and: "an authenticated admin user"
@@ -155,7 +155,7 @@ class VelbusProtocolTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "the agent resource"
def agentResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AgentResource.class)
@@ -185,17 +185,17 @@ class VelbusProtocolTest extends Specification implements ManagerContainerTrait
assert assets.length == 13
assert assets.each {
!TextUtil.isNullOrEmpty(it.asset.id) &&
- !TextUtil.isNullOrEmpty(it.asset.getName()) &&
- !it.asset.getAttributes().isEmpty() &&
- it.asset.getAttributes().values().every {attr ->
- attr.getMetaValue(AGENT_LINK).map{
- ValueUtil.getValue(it, VelbusAgentLink.class)
- .map({agentLink ->
- agentLink.id == agent.id && agentLink.deviceAddress.isPresent() && agentLink.deviceValueLink.isPresent()
- })
- .orElse(false)
- }.orElse(true)
- }
+ !TextUtil.isNullOrEmpty(it.asset.getName()) &&
+ !it.asset.getAttributes().isEmpty() &&
+ it.asset.getAttributes().values().every {attr ->
+ attr.getMetaValue(AGENT_LINK).map{
+ ValueUtil.getValue(it, VelbusAgentLink.class)
+ .map({agentLink ->
+ agentLink.id == agent.id && agentLink.deviceAddress.isPresent() && agentLink.deviceValueLink.isPresent()
+ })
+ .orElse(false)
+ }.orElse(true)
+ }
}
and: "a given asset should have the correct attributes (VMBGPOD)"
@@ -255,7 +255,7 @@ class VelbusProtocolTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "the agent resource"
def agentResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AgentResource.class)
@@ -313,7 +313,7 @@ class VelbusProtocolTest extends Specification implements ManagerContainerTrait
and: "a VELBUS project file"
def velbusProjectFileResource = getClass().getResourceAsStream(
"/org/openremote/test/protocol/velbus/VelbusProject.vlp"
- )
+ )
def velbusProjectFile = IOUtils.toString(velbusProjectFileResource, "UTF-8")
and: "a master realm user with read-only asset permission"
@@ -326,14 +326,14 @@ class VelbusProtocolTest extends Specification implements ManagerContainerTrait
true,
[ClientRole.READ_ASSETS] as ClientRole[]
- )
+ )
def accessToken = authenticate(
container,
MASTER_REALM,
KEYCLOAK_CLIENT_ID,
"agentimportreadonly",
"agentimportreadonly"
- )
+ )
and: "the agent resource"
def agentResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AgentResource.class)
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 9e92b0d68..db8f0ec71 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
@@ -97,9 +97,9 @@ class WebsocketClientProtocolTest extends Specification implements ManagerContai
case "https://mockapi/assets":
if (requestContext.method == HttpMethod.POST
- && requestContext.getHeaderString("header1") == "header1Value1"
- && requestContext.getHeaderString("header2") == "header2Value1,header2Value2"
- && requestContext.getHeaderString("Content-type") == MediaType.APPLICATION_JSON) {
+ && requestContext.getHeaderString("header1") == "header1Value1"
+ && requestContext.getHeaderString("header2") == "header2Value1,header2Value2"
+ && requestContext.getHeaderString("Content-type") == MediaType.APPLICATION_JSON) {
String bodyStr = (String)requestContext.getEntity()
AssetQuery assetQuery = ValueUtil.JSON.readValue(bodyStr, AssetQuery.class)
@@ -169,7 +169,7 @@ class WebsocketClientProtocolTest extends Specification implements ManagerContai
ValueUtil.asJSON(new AssetQuery().ids(managerTestSetup.apartment1LivingroomId)).orElse(null)
)
] as WebsocketSubscription[]
- )
+ )
when: "the agent is added to the asset service"
agent = assetStorageService.merge(agent)
@@ -258,7 +258,7 @@ class WebsocketClientProtocolTest extends Specification implements ManagerContai
] as WebsocketSubscription[]
))
)
- )
+ )
and: "the asset is merged into the asset service"
asset = assetStorageService.merge(asset)
@@ -305,7 +305,7 @@ class WebsocketClientProtocolTest extends Specification implements ManagerContai
when: "the co2level changes"
def co2LevelIncrement = new AttributeEvent(
managerTestSetup.apartment1LivingroomId, "co2Level", 600
- )
+ )
((SimulatorProtocol)agentService.getProtocolInstance(managerTestSetup.apartment1ServiceAgentId)).updateSensor(co2LevelIncrement)
then: "the linked co2Level attribute should get the new value"
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 23c0b382b..c5252e3e0 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
@@ -310,10 +310,10 @@ class WebsocketClientTest extends Specification implements ManagerContainerTrait
new MetaItem<>(MetaItemType.ACCESS_RESTRICTED_READ, false),
new MetaItem<>(MetaItemType.ACCESS_PUBLIC_READ, false)
)
- )
+ )
apartment1Livingroom.getAttribute(Asset.NOTES).get().addOrReplaceMeta(
new MetaItem<>(MetaItemType.ACCESS_PUBLIC_READ)
- )
+ )
apartment1Livingroom = assetStorageService.merge(apartment1Livingroom)
then: "the testuser3 client should be notified with only accessible attributes"
@@ -465,7 +465,7 @@ class WebsocketClientTest extends Specification implements ManagerContainerTrait
List<String> receivedMessages = new CopyOnWriteArrayList<>()
client.addMessageConsumer(
message -> receivedMessages.add(messageFromString(message))
- )
+ )
client.addConnectionStatusConsumer({ status ->
connectionStatus = status
})
diff --git a/test/src/test/groovy/org/openremote/test/provisioning/UserAndAssetProvisioningTest.groovy b/test/src/test/groovy/org/openremote/test/provisioning/UserAndAssetProvisioningTest.groovy
index 2f33b51ac..7ea38cbaa 100644
--- a/test/src/test/groovy/org/openremote/test/provisioning/UserAndAssetProvisioningTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/provisioning/UserAndAssetProvisioningTest.groovy
@@ -242,7 +242,7 @@ class UserAndAssetProvisioningTest extends Specification implements ManagerConta
new MQTTMessage<String>(device1RequestTopic, ValueUtil.asJSON(
new X509ProvisioningMessage(getClass().getResource("/org/openremote/test/provisioning/device1.pem").text)
).orElse(null))
- )
+ )
then: "the broker should have published to the response topic a success message containing the provisioned asset"
String weatherAssetID
@@ -290,7 +290,7 @@ class UserAndAssetProvisioningTest extends Specification implements ManagerConta
new MQTTMessage<String>(device1RequestTopic, ValueUtil.asJSON(
new X509ProvisioningMessage(getClass().getResource("/org/openremote/test/provisioning/device1.pem").text)
).orElse(null))
- )
+ )
then: "the broker should have published to the response topic a success message containing the provisioned asset"
conditions.eventually {
@@ -370,7 +370,7 @@ class UserAndAssetProvisioningTest extends Specification implements ManagerConta
"$provisioningConfig.realm/$mqttDevice1ClientId/$DefaultMQTTHandler.ATTRIBUTE_VALUE_WRITE_TOPIC/customAttribute/${asset.id}",
"99"
)
- )
+ )
then: "the attribute should have been updated"
conditions.eventually {
@@ -459,7 +459,7 @@ class UserAndAssetProvisioningTest extends Specification implements ManagerConta
new MQTTMessage<String>(device1RequestTopic, ValueUtil.asJSON(
new X509ProvisioningMessage(getClass().getResource("/org/openremote/test/provisioning/device1.pem").text)
).orElse(null))
- )
+ )
then: "the broker should have published to the response topic a success message containing the provisioned asset"
conditions.eventually {
@@ -531,7 +531,7 @@ class UserAndAssetProvisioningTest extends Specification implements ManagerConta
new MQTTMessage<String>(deviceNRequestTopic, ValueUtil.asJSON(
new X509ProvisioningMessage(getClass().getResource("/org/openremote/test/provisioning/device2_expired.pem").text)
).orElse(null))
- )
+ )
then: "the broker should have published to the response topic an error message"
conditions.eventually {
@@ -581,7 +581,7 @@ class UserAndAssetProvisioningTest extends Specification implements ManagerConta
new MQTTMessage<String>(deviceNRequestTopic, ValueUtil.asJSON(
new X509ProvisioningMessage(getClass().getResource("/org/openremote/test/provisioning/device4_forged.pem").text)
).orElse(null))
- )
+ )
then: "the broker should have published to the response topic an error message"
conditions.eventually {
@@ -631,7 +631,7 @@ class UserAndAssetProvisioningTest extends Specification implements ManagerConta
new MQTTMessage<String>(deviceNRequestTopic, ValueUtil.asJSON(
new X509ProvisioningMessage(getClass().getResource("/org/openremote/test/provisioning/device3_caexpired.pem").text)
).orElse(null))
- )
+ )
then: "the broker should have published to the response topic a success message containing the provisioned asset"
conditions.eventually {
@@ -682,7 +682,7 @@ class UserAndAssetProvisioningTest extends Specification implements ManagerConta
new MQTTMessage<String>(device1RequestTopic, ValueUtil.asJSON(
new X509ProvisioningMessage(getClass().getResource("/org/openremote/test/provisioning/device1.pem").text)
).orElse(null))
- )
+ )
then: "the broker should have published to the response topic an error message"
conditions.eventually {
@@ -719,7 +719,7 @@ class UserAndAssetProvisioningTest extends Specification implements ManagerConta
new MQTTMessage<String>(deviceNRequestTopic, ValueUtil.asJSON(
new X509ProvisioningMessage(getClass().getResource("/org/openremote/test/provisioning/device3_caexpired.pem").text)
).orElse(null))
- )
+ )
then: "the broker should have published to the response topic an error message"
conditions.eventually {
@@ -751,7 +751,7 @@ class UserAndAssetProvisioningTest extends Specification implements ManagerConta
new MQTTMessage<String>(device1RequestTopic, ValueUtil.asJSON(
new X509ProvisioningMessage(getClass().getResource("/org/openremote/test/provisioning/device1.pem").text)
).orElse(null))
- )
+ )
then: "the broker should have published to the response topic a success message containing the provisioned asset"
conditions.eventually {
@@ -789,7 +789,7 @@ class UserAndAssetProvisioningTest extends Specification implements ManagerConta
new MQTTMessage<String>(device1RequestTopic, ValueUtil.asJSON(
new X509ProvisioningMessage(getClass().getResource("/org/openremote/test/provisioning/device1.pem").text)
).orElse(null))
- )
+ )
then: "the broker should have published to the response topic an error message"
conditions.eventually {
@@ -826,7 +826,7 @@ class UserAndAssetProvisioningTest extends Specification implements ManagerConta
new MQTTMessage<String>(deviceNRequestTopic, ValueUtil.asJSON(
new X509ProvisioningMessage(getClass().getResource("/org/openremote/test/provisioning/device3_caexpired.pem").text)
).orElse(null))
- )
+ )
then: "the broker should have published to the response topic an error message"
conditions.eventually {
@@ -847,7 +847,7 @@ class UserAndAssetProvisioningTest extends Specification implements ManagerConta
new MQTTMessage<String>(device1RequestTopic, ValueUtil.asJSON(
new X509ProvisioningMessage(getClass().getResource("/org/openremote/test/provisioning/device1.pem").text)
).orElse(null))
- )
+ )
then: "the broker should have published to the response topic a success message containing the provisioned asset"
conditions.eventually {
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 1afab8827..95478f030 100644
--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovy
@@ -74,7 +74,7 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
def realmResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(RealmResource.class)
expect: "the rules engines to be ready"
@@ -86,7 +86,7 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
def ruleset = new GlobalRuleset(
"Some more global rules", GROOVY,
getClass().getResource("/org/openremote/test/rules/BasicMatchAllAssetStates2.groovy").text
- )
+ )
rulesetStorageService.merge(ruleset)
then: "the global rules engine should load this definition and restart successfully"
@@ -198,7 +198,7 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
ruleset = new GlobalRuleset(
"Some broken global rules", GROOVY,
getClass().getResource("/org/openremote/test/rules/BasicBrokenRules.groovy").text
- )
+ )
ruleset = rulesetStorageService.merge(ruleset)
then: "the global rules engine should still run and the rule engine status should indicate the issue"
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 b7ed72f2b..cce0200c0 100644
--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy
@@ -114,7 +114,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
rulesImport.resetRulesFired(smartHomeEngine)
def apartment2LivingRoomPresenceDetectedChange = new AttributeEvent(
managerTestSetup.apartment2LivingroomId, "presenceDetected", true
- )
+ )
assetProcessingService.sendAttributeEvent(apartment2LivingRoomPresenceDetectedChange)
then: "the engines in scope should have fired"
@@ -169,7 +169,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
.addOrReplaceMeta(
new MetaItem<>(MetaItemType.RULE_STATE, true)
)
- )
+ )
asset = assetStorageService.merge(asset)
then: "the rules engines should have executed at least once"
@@ -215,7 +215,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
new MetaItem<>(MetaItemType.RULE_STATE, true)
),
new Attribute<>("testInteger", ValueType.NUMBER, 0d)
- )
+ )
asset = assetStorageService.merge(asset)
then: "the rules engines should have executed at least one more time"
@@ -250,7 +250,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
new MetaItem<>(MetaItemType.RULE_STATE, false)
),
new Attribute<>("testInteger", ValueType.NUMBER, 0d)
- )
+ )
asset = assetStorageService.merge(asset)
then: "the facts should be removed from the rule engines and rules should have fired"
@@ -281,7 +281,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
.addOrReplaceMeta(
new MetaItem<>(MetaItemType.RULE_STATE, true)
)
- )
+ )
asset = assetStorageService.merge(asset)
then: "the facts should be added to the rule engines and rules should have fired"
@@ -373,7 +373,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
def apartment3LastFireTimestamp = rulesImport.apartment3Engine.lastFireTimestamp
def apartment2LivingRoomPresenceDetectedChange = new AttributeEvent(
managerTestSetup.apartment2LivingroomId, "presenceDetected", true
- )
+ )
assetProcessingService.sendAttributeEvent(apartment2LivingRoomPresenceDetectedChange)
then: "the rules engines should have executed at least one more time"
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 a0678d212..cd7e6ab04 100644
--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesTimedExecutionTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesTimedExecutionTest.groovy
@@ -65,7 +65,7 @@ class BasicRulesTimedExecutionTest extends Specification implements ManagerConta
Ruleset ruleset = new GlobalRuleset(
"Some timer rules",
getClass().getResource("/org/openremote/test/rules/BasicTimedExecutionRules.drl").text
- )
+ )
rulesetStorageService.merge(ruleset)
expect: "the rule engines to become available and be running"
@@ -103,7 +103,7 @@ class BasicRulesTimedExecutionTest extends Specification implements ManagerConta
Ruleset ruleset = new GlobalRuleset(
"Some timer rules",
getClass().getResource("/org/openremote/test/rules/BasicTimedExecutionRules.drl").text
- )
+ )
rulesetStorageService.merge(ruleset)
expect: "the rule engines to become available and be running"
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 1e8ae2bd1..abf2b635d 100644
--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy
@@ -59,7 +59,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "the ruleset resource"
def rulesetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(RulesResource.class)
@@ -435,7 +435,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
KEYCLOAK_CLIENT_ID,
"testuser1",
"testuser1"
- )
+ )
and: "the ruleset resource"
def rulesetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(RulesResource.class)
@@ -760,7 +760,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
KEYCLOAK_CLIENT_ID,
"testuser2",
"testuser2"
- )
+ )
and: "the ruleset resource"
def rulesetResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.realmBuilding.name, accessToken).proxy(RulesResource.class)
@@ -942,7 +942,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
- )
+ )
and: "the ruleset resource"
def rulesetResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.realmBuilding.name, accessToken).proxy(RulesResource.class)
@@ -1213,7 +1213,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "the ruleset resource"
def rulesetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(RulesResource.class)
@@ -1254,7 +1254,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "the ruleset resource"
def rulesetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(RulesResource.class)
@@ -1309,7 +1309,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
and: "the ruleset resource"
def rulesetResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(RulesResource.class)
diff --git a/test/src/test/groovy/org/openremote/test/rules/ChildAssetControlRulesTest.groovy b/test/src/test/groovy/org/openremote/test/rules/ChildAssetControlRulesTest.groovy
index e71fb78fd..6dc242d30 100644
--- a/test/src/test/groovy/org/openremote/test/rules/ChildAssetControlRulesTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/ChildAssetControlRulesTest.groovy
@@ -58,7 +58,7 @@ class ChildAssetControlRulesTest extends Specification implements ManagerContain
new Attribute<>(LightAsset.BRIGHTNESS).addMeta(new MetaItem<>(MetaItemType.RULE_STATE)),
new Attribute<>(LightAsset.COLOUR_RGB).addMeta(new MetaItem<>(MetaItemType.RULE_STATE)),
new Attribute<>(LightAsset.COLOUR_TEMPERATURE).addMeta(new MetaItem<>(MetaItemType.RULE_STATE))
- )
+ )
parentAsset = assetStorageService.merge(parentAsset)
for (int i = 1; i <= 100; i++) {
@@ -102,7 +102,7 @@ class ChildAssetControlRulesTest extends Specification implements ManagerContain
when: "The on/off attribute of the parent asset is written to"
assetProcessingService.sendAttributeEvent(
new AttributeEvent(parentAsset.id, LightAsset.ON_OFF, true)
- )
+ )
then: "the parent asset attribute should be updated"
conditions.eventually {
@@ -162,7 +162,7 @@ class ChildAssetControlRulesTest extends Specification implements ManagerContain
when: "The on/off attribute of the parent asset is written to"
assetProcessingService.sendAttributeEvent(
new AttributeEvent(parentAsset.id, LightAsset.ON_OFF, false)
- )
+ )
then: "the parent asset attribute should be updated"
conditions.eventually {
diff --git a/test/src/test/groovy/org/openremote/test/rules/GroupSummationRuleTest.groovy b/test/src/test/groovy/org/openremote/test/rules/GroupSummationRuleTest.groovy
index 86615df64..0e94a2a28 100644
--- a/test/src/test/groovy/org/openremote/test/rules/GroupSummationRuleTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/GroupSummationRuleTest.groovy
@@ -58,7 +58,7 @@ class GroupSummationRuleTest extends Specification implements ManagerContainerTr
new Attribute<>("boolean", ValueType.BOOLEAN, null).addMeta(new MetaItem<>(MetaItemType.RULE_STATE)),
new Attribute<>("integer", ValueType.INTEGER, null).addMeta(new MetaItem<>(MetaItemType.RULE_STATE)),
new Attribute<>("number", ValueType.NUMBER, null).addMeta(new MetaItem<>(MetaItemType.RULE_STATE))
- )
+ )
parentAsset = assetStorageService.merge(parentAsset)
def childAsset1 = new ThingAsset("childAsset1")
@@ -68,7 +68,7 @@ class GroupSummationRuleTest extends Specification implements ManagerContainerTr
new Attribute<>("boolean", ValueType.BOOLEAN, null).addMeta(new MetaItem<>(MetaItemType.RULE_STATE)),
new Attribute<>("integer", ValueType.INTEGER, null).addMeta(new MetaItem<>(MetaItemType.RULE_STATE)),
new Attribute<>("number", ValueType.NUMBER, null).addMeta(new MetaItem<>(MetaItemType.RULE_STATE))
- )
+ )
childAsset1 = assetStorageService.merge(childAsset1)
def childAsset2 = new ThingAsset("childAsset2")
@@ -78,7 +78,7 @@ class GroupSummationRuleTest extends Specification implements ManagerContainerTr
new Attribute<>("boolean", ValueType.BOOLEAN, null).addMeta(new MetaItem<>(MetaItemType.RULE_STATE)),
new Attribute<>("integer", ValueType.INTEGER, null).addMeta(new MetaItem<>(MetaItemType.RULE_STATE)),
new Attribute<>("number", ValueType.NUMBER, null).addMeta(new MetaItem<>(MetaItemType.RULE_STATE))
- )
+ )
childAsset2 = assetStorageService.merge(childAsset2)
and: "the group summation ruleset is added"
diff --git a/test/src/test/groovy/org/openremote/test/rules/RulesEngineFiringTest.groovy b/test/src/test/groovy/org/openremote/test/rules/RulesEngineFiringTest.groovy
index 5568f435d..a42e5e82a 100644
--- a/test/src/test/groovy/org/openremote/test/rules/RulesEngineFiringTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/RulesEngineFiringTest.groovy
@@ -76,7 +76,7 @@ class RulesEngineFiringTest extends Specification implements ManagerContainerTra
.setRealm(Constants.MASTER_REALM)
.addAttributes(
new Attribute<>("count", ValueType.INTEGER, null).addMeta(new MetaItem<>(MetaItemType.RULE_STATE)),
- )
+ )
counterAsset = assetStorageService.merge(counterAsset)
expect: "the rule engines to become available and be running"
@@ -198,7 +198,7 @@ class RulesEngineFiringTest extends Specification implements ManagerContainerTra
.setRealm(Constants.MASTER_REALM)
.addAttributes(
new Attribute<>("count", ValueType.INTEGER, null).addMeta(new MetaItem<>(MetaItemType.RULE_STATE)),
- )
+ )
counterAsset = assetStorageService.merge(counterAsset)
expect: "the rule engines to become available and be running"
@@ -283,7 +283,7 @@ class RulesEngineFiringTest extends Specification implements ManagerContainerTra
.setRealm(Constants.MASTER_REALM)
.addAttributes(
new Attribute<>("count", ValueType.INTEGER, null).addMeta(new MetaItem<>(MetaItemType.RULE_STATE)),
- )
+ )
counterAsset = assetStorageService.merge(counterAsset)
expect: "the rule engines to become available and be running"
diff --git a/test/src/test/groovy/org/openremote/test/rules/RulesServiceStateOrderingTest.groovy b/test/src/test/groovy/org/openremote/test/rules/RulesServiceStateOrderingTest.groovy
index 32bb5f5fc..d30c1a655 100644
--- a/test/src/test/groovy/org/openremote/test/rules/RulesServiceStateOrderingTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/RulesServiceStateOrderingTest.groovy
@@ -109,7 +109,7 @@ class RulesServiceStateOrderingTest extends Specification implements ManagerCont
.addAttributes(
new Attribute<>("count", ValueType.INTEGER, 0)
.addMeta(new MetaItem<>(MetaItemType.RULE_STATE))
- )
+ )
asset = assetStorageService.merge(asset)
expect: "the rule-state cache contains the asset attribute"
@@ -127,7 +127,7 @@ class RulesServiceStateOrderingTest extends Specification implements ManagerCont
"Rule state ordering",
Ruleset.Lang.GROOVY,
getClass().getResource("/org/openremote/test/rules/BasicMatchAllAssetStates.groovy").text
- )
+ )
rulesetStorageService.merge(ruleset)
RulesEngine engine = null
@@ -157,7 +157,7 @@ class RulesServiceStateOrderingTest extends Specification implements ManagerCont
newerTimestamp,
storedAttribute.getValue().orElse(null),
initialTimestamp
- )
+ )
def olderEvent = new AttributeEvent(
storedAsset,
storedAttribute,
@@ -166,7 +166,7 @@ class RulesServiceStateOrderingTest extends Specification implements ManagerCont
olderTimestamp,
storedAttribute.getValue().orElse(null),
initialTimestamp
- )
+ )
rulesService.onAttributeEvent(newerEvent)
rulesService.onAttributeEvent(olderEvent)
@@ -209,7 +209,7 @@ class RulesServiceStateOrderingTest extends Specification implements ManagerCont
.addAttributes(
new Attribute<>("count", ValueType.INTEGER, 0)
.addMeta(new MetaItem<>(MetaItemType.RULE_STATE))
- )
+ )
asset = assetStorageService.merge(asset)
expect: "the initial rule state is cached"
@@ -227,7 +227,7 @@ class RulesServiceStateOrderingTest extends Specification implements ManagerCont
"Rule state retract ordering",
Ruleset.Lang.GROOVY,
getClass().getResource("/org/openremote/test/rules/BasicMatchAllAssetStates.groovy").text
- )
+ )
rulesetStorageService.merge(ruleset)
RulesEngine engine = null
@@ -257,7 +257,7 @@ class RulesServiceStateOrderingTest extends Specification implements ManagerCont
newerTimestamp,
storedAttribute.getValue().orElse(null),
initialTimestamp
- )
+ )
rulesService.onAttributeEvent(newerEvent)
and: "a delete for the same rule state arrives afterwards carrying an older value timestamp"
@@ -269,7 +269,7 @@ class RulesServiceStateOrderingTest extends Specification implements ManagerCont
olderTimestamp,
storedAttribute.getValue().orElse(null),
initialTimestamp
- ).setDeleted(true)
+ ).setDeleted(true)
rulesService.onAttributeEvent(olderRetractEvent)
then: "the cached rule state should be removed"
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 a4fd1afbf..753d8be55 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
@@ -66,13 +66,13 @@ class FlowRulesTest extends Specification implements ManagerContainerTrait {
managerTestSetup.apartment1LivingroomId,
"targetTemperature",
startTemperature
- ))
+ ))
assetProcessingService.sendAttributeEvent(new AttributeEvent(
managerTestSetup.apartment1Bedroom1Id,
"targetTemperature",
0
- ))
+ ))
when: "a valid node collection is added"
String json = getClass().getResource("/org/openremote/test/rules/BasicFlowRules.json").text
@@ -83,7 +83,7 @@ class FlowRulesTest extends Specification implements ManagerContainerTrait {
realCollection.name,
Ruleset.Lang.FLOW,
json
- ))
+ ))
rulesetStorageService.merge(ruleset)
then: "the flow should be deployed"
@@ -98,8 +98,8 @@ class FlowRulesTest extends Specification implements ManagerContainerTrait {
and: "the flow should be executed correctly"
conditions.eventually {
def bedroomTargetTemp = assetStorageService.
- find(managerTestSetup.apartment1Bedroom1Id).
- getAttribute("targetTemperature").flatMap{it.value}.orElse(0d)
+ find(managerTestSetup.apartment1Bedroom1Id).
+ getAttribute("targetTemperature").flatMap{it.value}.orElse(0d)
assert bedroomTargetTemp.intValue() == (startTemperature.intValue() + 10) : ("it was actually " + bedroomTargetTemp.intValue())//convert to int considering floating point inaccuracy
}
}
@@ -130,7 +130,7 @@ class FlowRulesTest extends Specification implements ManagerContainerTrait {
new Attribute<Object>("maxOutput", null).addMeta(new MetaItem<>(MetaItemType.STORE_DATA_POINTS, true),new MetaItem<>(MetaItemType.RULE_STATE, true)),
new Attribute<Object>("derOutput", null).addMeta(new MetaItem<>(MetaItemType.STORE_DATA_POINTS, true),new MetaItem<>(MetaItemType.RULE_STATE, true)),
new Attribute<Object>("intOutput", null).addMeta(new MetaItem<>(MetaItemType.STORE_DATA_POINTS, true),new MetaItem<>(MetaItemType.RULE_STATE, true))
- )
+ )
asset = assetStorageService.merge(asset)
and: "Some datapoints are added to the living room"
@@ -171,7 +171,7 @@ class FlowRulesTest extends Specification implements ManagerContainerTrait {
"HistoricValueAndProcessorsTest",
Ruleset.Lang.FLOW,
json
- ))
+ ))
rulesetStorageService.merge(ruleset)
and: "the integral and derivative values are calculated"
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 7ed4a68e7..b28a17b9a 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
@@ -222,7 +222,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
- )
+ )
and: "another user authenticates"
def accessToken2 = authenticate(
@@ -231,7 +231,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
"building",
"building"
- )
+ )
and: "a console is registered by the first user"
def authenticatedConsoleResource = getClientApiTarget(serverUri(serverPort), keycloakTestSetup.realmBuilding.name, accessToken).proxy(ConsoleResource.class)
@@ -317,7 +317,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
new UserAssetLink(keycloakTestSetup.realmBuilding.getName(), keycloakTestSetup.testuser2Id, consoleRegistration.id),
new UserAssetLink(keycloakTestSetup.realmBuilding.getName(), keycloakTestSetup.buildingUserId, consoleRegistration.id)
]
- )
+ )
and: "the console location is set to the apartment"
assetProcessingService.sendAttributeEvent(new AttributeEvent(consoleRegistration.id, Asset.LOCATION.name, ManagerTestSetup.SMART_BUILDING_LOCATION))
@@ -409,8 +409,8 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
conditions.eventually {
assert emailMessages.any {
it.getRecipients(jakarta.mail.Message.RecipientType.TO).length == 1
- && (it.getRecipients(jakarta.mail.Message.RecipientType.TO)[0] as InternetAddress).address == "[email protected]"
- && MailUtil.toMailMessage(it, true).content == "<table cellpadding=\"30\"><tr><th>Asset ID</th><th>Asset Name</th><th>Attribute</th><th>Value</th></tr><tr><td>${consoleRegistration.id}</td><td>Test Console</td><td>location</td><td>" + ValueUtil.asJSON(outsideLocation).orElse("") + "</td></tr></table>"
+ && (it.getRecipients(jakarta.mail.Message.RecipientType.TO)[0] as InternetAddress).address == "[email protected]"
+ && MailUtil.toMailMessage(it, true).content == "<table cellpadding=\"30\"><tr><th>Asset ID</th><th>Asset Name</th><th>Attribute</th><th>Value</th></tr><tr><td>${consoleRegistration.id}</td><td>Test Console</td><td>location</td><td>" + ValueUtil.asJSON(outsideLocation).orElse("") + "</td></tr></table>"
}
}
@@ -418,8 +418,8 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
conditions.eventually {
assert emailMessages.any {
it.getRecipients(jakarta.mail.Message.RecipientType.TO).length == 1
- && (it.getRecipients(jakarta.mail.Message.RecipientType.TO)[0] as InternetAddress).address == "[email protected]"
- && MailUtil.toMailMessage(it, true).content == "<table cellpadding=\"30\"><tr><th>Asset ID</th><th>Asset Name</th><th>Attribute</th><th>Value</th></tr><tr><td>${consoleRegistration.id}</td><td>Test Console</td><td>location</td><td>" + ValueUtil.asJSON(outsideLocation).orElse("") + "</td></tr></table>"
+ && (it.getRecipients(jakarta.mail.Message.RecipientType.TO)[0] as InternetAddress).address == "[email protected]"
+ && MailUtil.toMailMessage(it, true).content == "<table cellpadding=\"30\"><tr><th>Asset ID</th><th>Asset Name</th><th>Attribute</th><th>Value</th></tr><tr><td>${consoleRegistration.id}</td><td>Test Console</td><td>location</td><td>" + ValueUtil.asJSON(outsideLocation).orElse("") + "</td></tr></table>"
}
}
@@ -463,7 +463,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
// Verify push notifications
def assetIdPushNotification = pushMessages.find { localizedMsg ->
localizedMsg.getMessages().get("en") instanceof PushNotificationMessage &&
- ((PushNotificationMessage) localizedMsg.getMessages().get("en")).getBody()?.contains(consoleRegistration.id)
+ ((PushNotificationMessage) localizedMsg.getMessages().get("en")).getBody()?.contains(consoleRegistration.id)
}
assert assetIdPushNotification != null
@@ -483,7 +483,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
// Count notifications for users with test-realm-role
def linkedNotifications = pushTargetsAndMessages.findAll {
it.v2.title == "Linked Asset ID Test" &&
- it.v2.body == "This notification is about asset: ${consoleRegistration.id}"
+ it.v2.body == "This notification is about asset: ${consoleRegistration.id}"
}
assert linkedNotifications.size() == 2 // should be sent to both linked users
}
@@ -511,8 +511,8 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
assert pushTargetsAndMessages.any {
it.v1.type == Notification.TargetType.ASSET &&
- it.v2.title == "Asset ID Test" &&
- it.v2.body == "Your asset ID is: ${consoleRegistration.id}"
+ it.v2.title == "Asset ID Test" &&
+ it.v2.body == "Your asset ID is: ${consoleRegistration.id}"
}
}
@@ -546,8 +546,8 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
conditions.eventually {
assert emailMessages.any {
it.getRecipients(jakarta.mail.Message.RecipientType.TO).length == 1
- && (it.getRecipients(jakarta.mail.Message.RecipientType.TO)[0] as InternetAddress).address == "[email protected]"
- && MailUtil.toMailMessage(it, true).content == "<table cellpadding=\"30\"><tr><th>Asset ID</th><th>Asset Name</th><th>Attribute</th><th>Value</th></tr><tr><td>${consoleRegistration.id}</td><td>Test Console</td><td>location</td><td>" + ValueUtil.asJSON(new GeoJSONPoint(-10d, -4d)).orElse("") + "</td></tr></table>"
+ && (it.getRecipients(jakarta.mail.Message.RecipientType.TO)[0] as InternetAddress).address == "[email protected]"
+ && MailUtil.toMailMessage(it, true).content == "<table cellpadding=\"30\"><tr><th>Asset ID</th><th>Asset Name</th><th>Attribute</th><th>Value</th></tr><tr><td>${consoleRegistration.id}</td><td>Test Console</td><td>location</td><td>" + ValueUtil.asJSON(new GeoJSONPoint(-10d, -4d)).orElse("") + "</td></tr></table>"
}
}
@@ -1525,7 +1525,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
new Attribute<>("sunset", ValueType.INTEGER, null),
new Attribute<>("sunriseWithOffset", ValueType.INTEGER, null),
new Attribute<>("twilightHorizon", ValueType.INTEGER, null),
- )
+ )
thingAsset = assetStorageService.merge(thingAsset)
and: "the pseudo clock is stopped"
@@ -1792,7 +1792,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
new Attribute<>("webhookAttribute", TEXT).addMeta(
new MetaItem<>(MetaItemType.RULE_STATE)
)
- )
+ )
thingAsset = assetStorageService.merge(thingAsset)
and: "a ruleset with 'has value' condition is added whose action triggers the webhook"
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 4382aa38c..2fc493a2e 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
@@ -82,7 +82,7 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerConta
when: "auto ventilation is turned on"
assetProcessingService.sendAttributeEvent(
new AttributeEvent(managerTestSetup.apartment1Id, "ventilationAuto", true)
- )
+ )
then: "auto ventilation should be on"
conditions.eventually {
@@ -97,7 +97,7 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerConta
def co2LevelIncrement = new AttributeEvent(
managerTestSetup.apartment1LivingroomId, "co2Level", 700 + i
- )
+ )
simulatorProtocol.putValue(co2LevelIncrement)
// Wait for event to be processed
@@ -120,7 +120,7 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerConta
when: "CO2 is decreasing in a room"
def co2LevelDecrement = new AttributeEvent(
managerTestSetup.apartment1LivingroomId, "co2Level", 500
- )
+ )
simulatorProtocol.putValue(co2LevelDecrement)
then: "the decreasing CO2 should have been detected in rules"
@@ -146,7 +146,7 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerConta
def co2LevelIncrement = new AttributeEvent(
managerTestSetup.apartment1LivingroomId, "co2Level", 1000 + i
- )
+ )
simulatorProtocol.putValue(co2LevelIncrement)
// Wait for event to be processed
@@ -169,7 +169,7 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerConta
when: "CO2 is decreasing in a room"
def co2LevelDecrement2 = new AttributeEvent(
managerTestSetup.apartment1LivingroomId, "co2Level", 800
- )
+ )
simulatorProtocol.putValue(co2LevelDecrement2)
conditions.eventually {
assert apartment1Engine.facts.assetEvents.any() {
@@ -190,7 +190,7 @@ class ResidenceAutoVentilationTest extends Specification implements ManagerConta
when: "CO2 is decreasing in a room"
def co2LevelDecrement3 = new AttributeEvent(
managerTestSetup.apartment1LivingroomId, "co2Level", 500
- )
+ )
simulatorProtocol.putValue(co2LevelDecrement3)
conditions.eventually {
assert apartment1Engine.facts.assetEvents.any() {
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 293847b50..e3cd2b459 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
@@ -146,7 +146,7 @@ class ResidenceNotifyAlarmTriggerTest extends Specification implements ManagerCo
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
- )
+ )
and: "the notification and console resources"
def authenticatedConsoleResource = getClientApiTarget(serverUri(serverPort), realm, accessToken).proxy(ConsoleResource.class)
@@ -186,7 +186,7 @@ class ResidenceNotifyAlarmTriggerTest extends Specification implements ManagerCo
when: "the alarm is enabled"
assetProcessingService.sendAttributeEvent(new AttributeEvent(
managerTestSetup.apartment1Id, "alarmEnabled", true
- ))
+ ))
then: "that value should be stored"
conditions.eventually {
@@ -197,7 +197,7 @@ class ResidenceNotifyAlarmTriggerTest extends Specification implements ManagerCo
when: "the presence is detected in Living room of apartment 1"
((SimulatorProtocol)agentService.getProtocolInstance(managerTestSetup.apartment1ServiceAgentId)).updateSensor(
new AttributeEvent(managerTestSetup.apartment1LivingroomId, "presenceDetected", true)
- )
+ )
then: "that value should be stored"
conditions.eventually {
@@ -232,7 +232,7 @@ class ResidenceNotifyAlarmTriggerTest extends Specification implements ManagerCo
advancePseudoClock(20, TimeUnit.MINUTES, container)
((SimulatorProtocol)agentService.getProtocolInstance(managerTestSetup.apartment1ServiceAgentId)).updateSensor(
new AttributeEvent(managerTestSetup.apartment1LivingroomId, "co2Level", 444)
- )
+ )
then: "still only one notification should have been sent"
conditions.eventually {
@@ -253,7 +253,7 @@ class ResidenceNotifyAlarmTriggerTest extends Specification implements ManagerCo
advancePseudoClock(5, TimeUnit.SECONDS, container)
((SimulatorProtocol)agentService.getProtocolInstance(managerTestSetup.apartment1ServiceAgentId)).updateSensor(
new AttributeEvent(managerTestSetup.apartment1LivingroomId, "presenceDetected", false)
- )
+ )
then: "that value should be stored"
conditions.eventually {
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 a762ef069..0b648ee43 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
@@ -86,11 +86,11 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
double expectedLastPresenceDetected = getClockTimeOf(container)
def kitchenMotionSensorEvent = new AttributeEvent(
managerTestSetup.apartment1KitchenId, "motionSensor", 1
- )
+ )
simulatorProtocol.updateSensor(kitchenMotionSensorEvent)
def hallwayMotionSensorEvent = new AttributeEvent(
managerTestSetup.apartment1HallwayId, "motionSensor", 1
- )
+ )
simulatorProtocol.updateSensor(hallwayMotionSensorEvent)
then: "presence should be detected in all rooms"
@@ -116,7 +116,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
double expectedLastPresenceDetected2 = getClockTimeOf(container)
kitchenMotionSensorEvent = new AttributeEvent(
managerTestSetup.apartment1KitchenId, "motionSensor", 1
- )
+ )
simulatorProtocol.updateSensor(kitchenMotionSensorEvent)
then: "presence should be detected in all rooms and timestamp should be updated of one room"
@@ -141,7 +141,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
and: "motion sensor is not triggered in a room"
kitchenMotionSensorEvent = new AttributeEvent(
managerTestSetup.apartment1KitchenId, "motionSensor", 0
- )
+ )
simulatorProtocol.updateSensor(kitchenMotionSensorEvent)
then: "some presence should still be detected and timestamps are still available"
@@ -166,7 +166,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
and: "motion sensor is not triggered in another room"
hallwayMotionSensorEvent = new AttributeEvent(
managerTestSetup.apartment1HallwayId, "motionSensor", 0
- )
+ )
simulatorProtocol.updateSensor(hallwayMotionSensorEvent)
then: "no presence should be detected but the last timestamp still available"
@@ -226,7 +226,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
double expectedLastPresenceDetected = getClockTimeOf(container)
def motionSensorTrigger = new AttributeEvent(
managerTestSetup.apartment1LivingroomId, "motionSensor", 1
- )
+ )
simulatorProtocol.updateSensor(motionSensorTrigger)
/* See rules, this leads to many false negatives when windows are open in the room
@@ -268,7 +268,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
when: "motion sensor is not triggered (someone might be resting in the room)"
def motionSensorNoTrigger = new AttributeEvent(
managerTestSetup.apartment1LivingroomId, "motionSensor", 0
- )
+ )
simulatorProtocol.updateSensor(motionSensorNoTrigger)
and: "the CO2 level increases (someone breathing in the room)"
@@ -277,7 +277,7 @@ class ResidencePresenceDetectionTest extends Specification implements ManagerCon
def co2LevelIncrement = new AttributeEvent(
managerTestSetup.apartment1LivingroomId, "co2Level", 400 + i
- )
+ )
simulatorProtocol.updateSensor(co2LevelIncrement)
// Wait for event to be processed
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 13a4ffba9..7964387b9 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
@@ -92,7 +92,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
when: "mode is set to ON_AT"
assetProcessingService.sendAttributeEvent(
new AttributeEvent(managerTestSetup.apartment1KitchenId, "smartSwitchModeA", "ON_AT")
- )
+ )
noEventProcessedIn(assetProcessingService, 500)
then: "mode should be ON_AT but actuator not enabled"
@@ -119,7 +119,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
long oneMinuteInFutureMillis = getClockTimeOf(container) + 60000
assetProcessingService.sendAttributeEvent(
new AttributeEvent(managerTestSetup.apartment1KitchenId, "smartSwitchBeginEndA", oneMinuteInFutureMillis)
- )
+ )
noEventProcessedIn(assetProcessingService, 500)
then: "mode should be ON_AT and actuator enabled with correct start/stop time"
@@ -220,7 +220,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
when: "mode is set to ON_AT"
assetProcessingService.sendAttributeEvent(
new AttributeEvent(managerTestSetup.apartment1KitchenId, "smartSwitchModeA", "ON_AT")
- )
+ )
noEventProcessedIn(assetProcessingService, 500)
then: "mode should be ON_AT but actuator not enabled"
@@ -244,7 +244,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
long fiveMinutesInPastMillis = getClockTimeOf(container) - (5 * 60 * 1000)
assetProcessingService.sendAttributeEvent(
new AttributeEvent(managerTestSetup.apartment1KitchenId, "smartSwitchBeginEndA", fiveMinutesInPastMillis)
- )
+ )
noEventProcessedIn(assetProcessingService, 500)
then: "mode should be ON_AT and actuator not enabled"
@@ -313,7 +313,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
when: "mode is set to READY_AT"
assetProcessingService.sendAttributeEvent(
new AttributeEvent(managerTestSetup.apartment1KitchenId, "smartSwitchModeA", "READY_AT")
- )
+ )
noEventProcessedIn(assetProcessingService, 500)
then: "mode should be READY_AT but actuator not enabled"
@@ -337,7 +337,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
long threeHoursInFutureMillis = getClockTimeOf(container) + (3 * 60 * 60 * 1000)
assetProcessingService.sendAttributeEvent(
new AttributeEvent(managerTestSetup.apartment1KitchenId, "smartSwitchBeginEndA", threeHoursInFutureMillis)
- )
+ )
noEventProcessedIn(assetProcessingService, 500)
then: "mode should be READY_AT and actuator enabled with correct start/stop time"
@@ -436,7 +436,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
when: "mode is set to READY_AT"
assetProcessingService.sendAttributeEvent(
new AttributeEvent(managerTestSetup.apartment1KitchenId, "smartSwitchModeA", "READY_AT")
- )
+ )
noEventProcessedIn(assetProcessingService, 500)
then: "mode should be READY_AT but actuator not enabled"
@@ -460,7 +460,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
long fiveMinutesInPastMillis = getClockTimeOf(container) - (5 * 60 * 1000)
assetProcessingService.sendAttributeEvent(
new AttributeEvent(managerTestSetup.apartment1KitchenId, "smartSwitchBeginEndA", fiveMinutesInPastMillis)
- )
+ )
noEventProcessedIn(assetProcessingService, 500)
then: "mode should be READY_AT but actuator not enabled"
@@ -532,7 +532,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
when: "mode is set to READY_AT"
assetProcessingService.sendAttributeEvent(
new AttributeEvent(managerTestSetup.apartment1KitchenId, "smartSwitchModeA", "READY_AT")
- )
+ )
noEventProcessedIn(assetProcessingService, 500)
then: "mode should be READY_AT but actuator not enabled"
@@ -556,7 +556,7 @@ class ResidenceSmartSwitchTest extends Specification implements ManagerContainer
long fiveMinutesInFuture = getClockTimeOf(container) + (5 * 60 * 1000)
assetProcessingService.sendAttributeEvent(
new AttributeEvent(managerTestSetup.apartment1KitchenId, "smartSwitchBeginEndA", fiveMinutesInFuture)
- )
+ )
noEventProcessedIn(assetProcessingService, 500)
then: "mode should be READY_AT but actuator not enabled"
diff --git a/test/src/test/groovy/org/openremote/test/services/ExternalServiceTest.groovy b/test/src/test/groovy/org/openremote/test/services/ExternalServiceTest.groovy
index 56791e3c1..9ab6e0a94 100644
--- a/test/src/test/groovy/org/openremote/test/services/ExternalServiceTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/services/ExternalServiceTest.groovy
@@ -55,7 +55,7 @@ class ExternalServiceTest extends Specification implements ManagerContainerTrait
KEYCLOAK_CLIENT_ID,
"testuser1",
"testuser1"
- )
+ )
// building service user for single tenant logic
def buildingServiceUserAccessToken = authenticate(
@@ -63,14 +63,14 @@ class ExternalServiceTest extends Specification implements ManagerContainerTrait
keycloakTestSetup.realmBuilding.getName(),
keycloakTestSetup.serviceUser.username,
keycloakTestSetup.serviceUser.secret
- )
+ )
def buildingServiceUser2AccessToken = authenticate(
container,
keycloakTestSetup.realmBuilding.getName(),
keycloakTestSetup.serviceUser2.username,
keycloakTestSetup.serviceUser2.secret
- )
+ )
// master service user for multi-tenant logic
def superServiceUserAccessToken = authenticate(
@@ -78,7 +78,7 @@ class ExternalServiceTest extends Specification implements ManagerContainerTrait
MASTER_REALM,
keycloakTestSetup.superServiceUser.username,
keycloakTestSetup.superServiceUser.secret
- )
+ )
then: "the users have been authenticated and the tokens are retrieved"
conditions.eventually {
@@ -108,7 +108,7 @@ class ExternalServiceTest extends Specification implements ManagerContainerTrait
label: "Building Energy Management Service",
homepageUrl: "https://local.test/services/building-energy-management/ui",
status: ExternalServiceStatus.AVAILABLE,
- )
+ )
def registeredBuildingExternalService = buildingExternalServiceResource.registerService(null, buildingExternalService)
then: "the building external service should be registered and the registered external service should have an instanceId assigned"
@@ -194,7 +194,7 @@ class ExternalServiceTest extends Specification implements ManagerContainerTrait
label: "Forecasting Service",
homepageUrl: "https://local.test/services/forecasting-service/ui",
status: ExternalServiceStatus.AVAILABLE,
- )
+ )
def registeredGlobalExternalService = superServiceUserExternalServiceResource.registerGlobalService(null, globalExternalService)
then: "the global external service should be registered and the registered external service should have an instanceId assigned"
@@ -238,7 +238,7 @@ class ExternalServiceTest extends Specification implements ManagerContainerTrait
label: "Building Energy Management Service 2",
homepageUrl: "https://local.test/services/building-energy-management-2/ui",
status: ExternalServiceStatus.AVAILABLE,
- )
+ )
def registeredBuildingExternalService2 = buildingExternalServiceResource.registerService(null, buildingExternalService2)
then: "the building service user should receive the new realm-bound external service"
@@ -335,7 +335,7 @@ class ExternalServiceTest extends Specification implements ManagerContainerTrait
label: "Regular User New Service",
homepageUrl: "https://local.test/services/regular-user-new-service/ui",
status: ExternalServiceStatus.AVAILABLE,
- )
+ )
regularUserExternalServiceResource.registerService(null, regularUserNewService)
then: "the regular user should receive a 401 unauthorized response"
diff --git a/test/src/test/groovy/org/openremote/test/syslog/SyslogResourceTest.groovy b/test/src/test/groovy/org/openremote/test/syslog/SyslogResourceTest.groovy
index 3e539a7bf..d45af4c0a 100644
--- a/test/src/test/groovy/org/openremote/test/syslog/SyslogResourceTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/syslog/SyslogResourceTest.groovy
@@ -93,7 +93,7 @@ class SyslogResourceTest extends Specification implements ManagerContainerTrait
"${username}@openremote.local",
true,
[role] as ClientRole[]
- )
+ )
userId = user.id
authenticate(container, MASTER_REALM, KEYCLOAK_CLIENT_ID, username, username)
diff --git a/test/src/test/groovy/org/openremote/test/users/UserResourceTest.groovy b/test/src/test/groovy/org/openremote/test/users/UserResourceTest.groovy
index 14241d833..451f3d922 100644
--- a/test/src/test/groovy/org/openremote/test/users/UserResourceTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/users/UserResourceTest.groovy
@@ -77,7 +77,7 @@ class UserResourceTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
MASTER_REALM_ADMIN_USER,
getString(container.getConfig(), OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT)
- )
+ )
def regularMasterAccessToken = authenticate(
container,
@@ -85,7 +85,7 @@ class UserResourceTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
"testuser1",
"testuser1"
- )
+ )
def regularBuildingAccessToken = authenticate(
container,
@@ -93,19 +93,19 @@ class UserResourceTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
- )
+ )
def adminBuildingRoles = identityProvider.getUserClientRoles(
keycloakTestSetup.realmBuilding.name,
keycloakTestSetup.testuser4Id,
KEYCLOAK_CLIENT_ID
- )
+ )
identityProvider.updateUserClientRoles(
keycloakTestSetup.realmBuilding.name,
keycloakTestSetup.testuser4Id,
KEYCLOAK_CLIENT_ID,
((adminBuildingRoles as List) + ClientRole.READ_ADMIN.value).unique() as String[]
- )
+ )
def adminBuildingAccessToken = authenticate(
container,
@@ -113,7 +113,7 @@ class UserResourceTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
"testuser4",
"testuser4"
- )
+ )
adminUserResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(UserResource.class)
regularUserMasterResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, regularMasterAccessToken).proxy(UserResource.class)
@@ -228,7 +228,7 @@ class UserResourceTest extends Specification implements ManagerContainerTrait {
.attributes(
new UserQuery.AttributeValuePredicate(true, new StringPredicate(User.SYSTEM_ACCOUNT_ATTRIBUTE)),
new UserQuery.AttributeValuePredicate(true, new StringPredicate(EMAIL_NOTIFICATIONS_DISABLED_ATTRIBUTE), new StringPredicate("true"))
- ).orderBy(new UserQuery.OrderBy(UserQuery.OrderBy.Property.USERNAME, false)))
+ ).orderBy(new UserQuery.OrderBy(UserQuery.OrderBy.Property.USERNAME, false)))
then: "only matching users of this realm should be returned"
users.size() == 5
@@ -296,7 +296,7 @@ class UserResourceTest extends Specification implements ManagerContainerTrait {
roles.find {it.name == ClientRole.READ_LOGS.value}.id,
roles.find {it.name == ClientRole.READ_MAP.value}.id
] as String[]
- ).setDescription("This is a test"))
+ ).setDescription("This is a test"))
adminUserResource.updateRoles(null, keycloakTestSetup.realmBuilding.name, updatedRoles as Role[])
roles = adminUserResource.getClientRoles(null, keycloakTestSetup.realmBuilding.name, KEYCLOAK_CLIENT_ID)
def testRole = roles.find {it.name == "test"}
@@ -393,7 +393,7 @@ class UserResourceTest extends Specification implements ManagerContainerTrait {
KEYCLOAK_CLIENT_ID,
"testuser2",
"newPassword"
- )
+ )
testUser2BuildingAccessToken != null
}
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 57f0de880..8e6b78b5b 100644
--- a/test/src/test/resources/org/openremote/test/rules/BasicLocationPredicates.groovy
+++ b/test/src/test/resources/org/openremote/test/rules/BasicLocationPredicates.groovy
@@ -31,7 +31,7 @@ rules.add()
.name("Another radial location predicate")
.when({ facts ->
facts.matchFirstAssetState(new AssetQuery().attributes(new LocationAttributePredicate((new RadialGeofencePredicate(50, 0, -60))))).isPresent() &&
- !facts.matchFirst("RadialLocation2").isPresent()
+ !facts.matchFirst("RadialLocation2").isPresent()
})
.then({ facts ->
facts.put("RadialLocation2", "fired")
@@ -41,7 +41,7 @@ rules.add()
.name("Duplicate radial location predicate")
.when({ facts ->
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()
+ !facts.matchFirst("DuplicateLocation").isPresent()
})
.then({ facts ->
facts.put("DuplicateLocation", "fired")
@@ -51,7 +51,7 @@ rules.add()
.name("Rectangular location predicate")
.when({ facts ->
facts.matchFirstAssetState(new AssetQuery().attributes(new LocationAttributePredicate(new RectangularGeofencePredicate(0, 50, 50, 100)))).isPresent() &&
- !facts.matchFirst("RectLocation").isPresent()
+ !facts.matchFirst("RectLocation").isPresent()
})
.then({ facts ->
facts.put("RectLocation", "fired")
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 cc46f289f..abac48a46 100644
--- a/test/src/test/resources/org/openremote/test/rules/BasicLocationPredicates2.groovy
+++ b/test/src/test/resources/org/openremote/test/rules/BasicLocationPredicates2.groovy
@@ -31,7 +31,7 @@ rules.add()
.name("Another radial location predicate")
.when({ facts ->
facts.matchFirstAssetState(new AssetQuery().attributes(new LocationAttributePredicate(new RadialGeofencePredicate(150, 10, 40)))).isPresent() &&
- !facts.matchFirst("RadialLocation2").isPresent()
+ !facts.matchFirst("RadialLocation2").isPresent()
})
.then({ facts ->
facts.put("RadialLocation2", "fired")
@@ -41,7 +41,7 @@ rules.add()
.name("Duplicate radial location predicate")
.when({ facts ->
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()
+ !facts.matchFirst("Location").isPresent()
})
.then({ facts ->
facts.put("DuplicateLocation", "fired")
@@ -51,7 +51,7 @@ rules.add()
.name("Rectangular location predicate")
.when({ facts ->
facts.matchFirstAssetState(new AssetQuery().attributes(new LocationAttributePredicate(new RectangularGeofencePredicate(0, 50, 50, 100)))).isPresent() &&
- !facts.matchFirst("RectLocation").isPresent()
+ !facts.matchFirst("RectLocation").isPresent()
})
.then({ facts ->
facts.put("RectLocation", "fired")
diff --git a/test/src/test/resources/org/openremote/test/rules/BasicMatchAllAssetStates.groovy b/test/src/test/resources/org/openremote/test/rules/BasicMatchAllAssetStates.groovy
index 1b47f96e3..6eb8ef427 100644
--- a/test/src/test/resources/org/openremote/test/rules/BasicMatchAllAssetStates.groovy
+++ b/test/src/test/resources/org/openremote/test/rules/BasicMatchAllAssetStates.groovy
@@ -27,7 +27,7 @@ rules.add()
.name("All")
.when({ facts ->
!facts.matchFirst("All").isPresent() &&
- facts.matchFirstAssetState(new AssetQuery()).isPresent()
+ facts.matchFirstAssetState(new AssetQuery()).isPresent()
})
.then({ facts ->
facts.put("All", "fired")
diff --git a/test/src/test/resources/org/openremote/test/rules/BasicMatchAllAssetStates2.groovy b/test/src/test/resources/org/openremote/test/rules/BasicMatchAllAssetStates2.groovy
index 10092fbb2..716dffff5 100644
--- a/test/src/test/resources/org/openremote/test/rules/BasicMatchAllAssetStates2.groovy
+++ b/test/src/test/resources/org/openremote/test/rules/BasicMatchAllAssetStates2.groovy
@@ -29,7 +29,7 @@ rules.add()
.name("All")
.when({ facts ->
!facts.matchFirst("All").isPresent() &&
- facts.matchFirstAssetState(new AssetQuery()).isPresent()
+ facts.matchFirstAssetState(new AssetQuery()).isPresent()
})
.then({ facts ->
facts.put("All", "fired")
diff --git a/test/src/test/resources/org/openremote/test/rules/BasicSmartHomeMatchAllAssetStates.groovy b/test/src/test/resources/org/openremote/test/rules/BasicSmartHomeMatchAllAssetStates.groovy
index c84fe663e..e184ea864 100644
--- a/test/src/test/resources/org/openremote/test/rules/BasicSmartHomeMatchAllAssetStates.groovy
+++ b/test/src/test/resources/org/openremote/test/rules/BasicSmartHomeMatchAllAssetStates.groovy
@@ -29,7 +29,7 @@ rules.add()
.name("Living Room All")
.when({ facts ->
!facts.matchFirst("Living Room All").isPresent() &&
- facts.matchFirstAssetState(new AssetQuery().names("Living Room 1")).isPresent()
+ facts.matchFirstAssetState(new AssetQuery().names("Living Room 1")).isPresent()
})
.then({ facts ->
facts.put("Living Room All", "fired")
@@ -39,7 +39,7 @@ rules.add()
.name("Kitchen All")
.when({ facts ->
!facts.matchFirst("Kitchen All").isPresent() &&
- facts.matchFirstAssetState(new AssetQuery().names("Kitchen 1")).isPresent()
+ facts.matchFirstAssetState(new AssetQuery().names("Kitchen 1")).isPresent()
})
.then({ facts ->
facts.put("Kitchen All", "fired")
@@ -49,9 +49,9 @@ rules.add()
.name("Kitchen Number Attributes")
.when({ facts ->
!facts.matchFirst("Kitchen Number Attributes").isPresent() &&
- facts.matchAssetState(new AssetQuery().names("Kitchen 1"))
- .filter({ assetState -> assetState.type == NUMBER })
- .findFirst().isPresent()
+ facts.matchAssetState(new AssetQuery().names("Kitchen 1"))
+ .filter({ assetState -> assetState.type == NUMBER })
+ .findFirst().isPresent()
})
.then({ facts ->
facts.put("Kitchen Number Attributes", "fired")
@@ -61,9 +61,9 @@ rules.add()
.name("Boolean attributes")
.when({ facts ->
!facts.matchFirst("Boolean attributes").isPresent() &&
- facts.matchAssetState(new AssetQuery())
- .filter({ assetState -> assetState.type == BOOLEAN })
- .findFirst().isPresent()
+ facts.matchAssetState(new AssetQuery())
+ .filter({ assetState -> assetState.type == BOOLEAN })
+ .findFirst().isPresent()
})
.then({ facts ->
facts.put("Boolean attributes", "fired")
@@ -73,9 +73,9 @@ rules.add()
.name("String attributes")
.when({ facts ->
!facts.matchFirst("String Attributes").isPresent() &&
- facts.matchAssetState(new AssetQuery())
- .filter({ assetState -> assetState.type == TEXT })
- .findFirst().isPresent()
+ facts.matchAssetState(new AssetQuery())
+ .filter({ assetState -> assetState.type == TEXT })
+ .findFirst().isPresent()
})
.then({ facts ->
facts.put("String Attributes", "fired")
@@ -85,9 +85,9 @@ rules.add()
.name("Number value types")
.when({ facts ->
!facts.matchFirst("Number value types").isPresent() &&
- facts.matchAssetState(new AssetQuery())
- .filter({ assetState -> assetState.value.isPresent() })
- .findFirst().isPresent()
+ facts.matchAssetState(new AssetQuery())
+ .filter({ assetState -> assetState.value.isPresent() })
+ .findFirst().isPresent()
})
.then({ facts ->
facts.put("Number value types", "fired")
@@ -97,8 +97,8 @@ rules.add()
.name("Asset Type Room")
.when({ facts ->
!facts.matchFirst("Asset Type Room").isPresent() &&
- facts.matchAssetState(new AssetQuery().types(RoomAsset))
- .findFirst().isPresent()
+ facts.matchAssetState(new AssetQuery().types(RoomAsset))
+ .findFirst().isPresent()
})
.then({ facts ->
facts.put("Asset Type Room", "fired")
@@ -110,14 +110,14 @@ rules.add()
.when({ facts ->
facts.matchAssetState(new AssetQuery().names("Living Room")).findFirst()
- .map{livingRoomState ->
- !facts.matchFirst("Living Room as Parent").isPresent() &&
- facts.matchAssetState(new AssetQuery())
- .filter({ assetState ->
- assetState.parentId == livingRoomState.id
- })
- .findFirst().isPresent()
- }.orElse(false)
+ .map{livingRoomState ->
+ !facts.matchFirst("Living Room as Parent").isPresent() &&
+ facts.matchAssetState(new AssetQuery())
+ .filter({ assetState ->
+ assetState.parentId == livingRoomState.id
+ })
+ .findFirst().isPresent()
+ }.orElse(false)
})
.then({ facts ->
facts.put("Living Room as Parent", "fired")
diff --git a/test/src/test/resources/org/openremote/test/rules/ConsoleLocation.groovy b/test/src/test/resources/org/openremote/test/rules/ConsoleLocation.groovy
index afa14f45f..a157f048e 100644
--- a/test/src/test/resources/org/openremote/test/rules/ConsoleLocation.groovy
+++ b/test/src/test/resources/org/openremote/test/rules/ConsoleLocation.groovy
@@ -43,12 +43,12 @@ rules.add()
.when({ facts ->
def consoleIds = facts.matchAssetState(new AssetQuery()
- .types(ConsoleAsset.class)
- .attributes(new LocationAttributePredicate(
- new RadialGeofencePredicate(100, ManagerTestSetup.SMART_BUILDING_LOCATION.y, ManagerTestSetup.SMART_BUILDING_LOCATION.x))))
- .filter({ !facts.getOptional("welcomeHome" + "_${it.id}").isPresent() })
- .map({ it.id })
- .collect()
+ .types(ConsoleAsset.class)
+ .attributes(new LocationAttributePredicate(
+ new RadialGeofencePredicate(100, ManagerTestSetup.SMART_BUILDING_LOCATION.y, ManagerTestSetup.SMART_BUILDING_LOCATION.x))))
+ .filter({ !facts.getOptional("welcomeHome" + "_${it.id}").isPresent() })
+ .map({ it.id })
+ .collect()
if (consoleIds.size() > 0) {
facts.bind("consoleIds", consoleIds)
@@ -82,11 +82,11 @@ rules.add()
.when({ facts ->
def consoleIds = facts.matchAssetState(new AssetQuery()
- .types(ConsoleAsset.class)
- .attributeValue(Asset.LOCATION.name, new ValueEmptyPredicate()))
- .filter({ facts.getOptional("welcomeHome" + "_${it.id}").isPresent() })
- .map({ it.id })
- .collect()
+ .types(ConsoleAsset.class)
+ .attributeValue(Asset.LOCATION.name, new ValueEmptyPredicate()))
+ .filter({ facts.getOptional("welcomeHome" + "_${it.id}").isPresent() })
+ .map({ it.id })
+ .collect()
if (consoleIds.size() > 0) {
facts.bind("consoleIds", consoleIds)
diff --git a/test/src/test/resources/org/openremote/test/rules/ResidenceAutoVentilation.groovy b/test/src/test/resources/org/openremote/test/rules/ResidenceAutoVentilation.groovy
index 3c79239f2..3f1492fce 100644
--- a/test/src/test/resources/org/openremote/test/rules/ResidenceAutoVentilation.groovy
+++ b/test/src/test/resources/org/openremote/test/rules/ResidenceAutoVentilation.groovy
@@ -55,36 +55,36 @@ final VENTILATION_THRESHOLD_HIGH_TIME_WINDOW = "PT15M"
Closure<Stream<AssetState<?>>> residenceWithVentilationAutoMatch = { RulesFacts facts, Operator operator, double ventilationLevelThreshold ->
// Any residence where auto ventilation is on
facts.matchAssetState(
- new AssetQuery().types(BuildingAsset).attributeValue("ventilationAuto", true)
- ).filter { residenceWithVentilationAuto ->
-
- // and ventilation level is above/below/equal/etc. threshold
- if (operator == LESS_THAN) {
- // Used to have an implicit "OR NULL" which has now been removed
- def isNull = facts.matchFirstAssetState(
- new AssetQuery().ids(residenceWithVentilationAuto.id).attributeName("ventilationLevel")
+ new AssetQuery().types(BuildingAsset).attributeValue("ventilationAuto", true)
+ ).filter { residenceWithVentilationAuto ->
+
+ // and ventilation level is above/below/equal/etc. threshold
+ if (operator == LESS_THAN) {
+ // Used to have an implicit "OR NULL" which has now been removed
+ def isNull = facts.matchFirstAssetState(
+ new AssetQuery().ids(residenceWithVentilationAuto.id).attributeName("ventilationLevel")
).map {!it.value.isPresent()}.orElse(false)
- if (isNull) {
- return true
- }
- }
+ if (isNull) {
+ return true
+ }
+ }
- return facts.matchFirstAssetState(
- new AssetQuery().ids(residenceWithVentilationAuto.id)
- .attributeValue("ventilationLevel", operator, ventilationLevelThreshold)
+ return facts.matchFirstAssetState(
+ new AssetQuery().ids(residenceWithVentilationAuto.id)
+ .attributeValue("ventilationLevel", operator, ventilationLevelThreshold)
).isPresent()
- }
+ }
}
Closure<Boolean> roomThresholdMatch = { RulesFacts facts, AssetState residence, String attribute, boolean above, double threshold, String timeWindow ->
// Any room of the residence which has a level greater than zero
def roomWithMaxLevel = facts.matchAssetState(
- new AssetQuery().types(RoomAsset).parents(residence.id).attributeValue(attribute, GREATER_THAN, 0)
- ).max { roomA, roomB ->
- // get the room with the highest level
- Double.compare(roomA.value.orElse(0))
- }
+ new AssetQuery().types(RoomAsset).parents(residence.id).attributeValue(attribute, GREATER_THAN, 0)
+ ).max { roomA, roomB ->
+ // get the room with the highest level
+ Double.compare(roomA.value.orElse(0))
+ }
if (roomWithMaxLevel.isPresent()) {
// if we have a room with max level
@@ -94,12 +94,12 @@ Closure<Boolean> roomThresholdMatch = { RulesFacts facts, AssetState residence,
}.filter { roomAboveBelowThreshold ->
// and no level above/below threshold in the time window
facts.matchAssetEvent(
- new AssetQuery()
- .ids(roomAboveBelowThreshold.id)
- .attributeValue(attribute, above ? LESS_EQUALS : GREATER_THAN, threshold)
- ).filter{
- facts.clock.now.minus(12, ChronoUnit.MINUTES).toEpochMilli() <it.timestamp
- }.count() == 0
+ new AssetQuery()
+ .ids(roomAboveBelowThreshold.id)
+ .attributeValue(attribute, above ? LESS_EQUALS : GREATER_THAN, threshold)
+ ).filter{
+ facts.clock.now.minus(12, ChronoUnit.MINUTES).toEpochMilli() <it.timestamp
+ }.count() == 0
}.isPresent()
} else {
// if we don't have a room with max level (empty attribute?), it's always "below threshold"
@@ -111,19 +111,19 @@ rules.add()
.name("Auto ventilation is on, level is below MEDIUM, CO2 or humidity above MEDIUM, set level MEDIUM")
.when({ facts ->
residenceWithVentilationAutoMatch(
- facts, LESS_THAN, VENTILATION_LEVEL_MEDIUM
- ).filter { residence ->
- def roomAboveThresholdCO2 = roomThresholdMatch(
- facts, residence, "co2Level", true, VENTILATION_THRESHOLD_MEDIUM_CO2_LEVEL, VENTILATION_THRESHOLD_MEDIUM_CO2_TIME_WINDOW
- )
- def roomAboveThresholdHumidity = roomThresholdMatch(
- facts, residence, "humidity", true, VENTILATION_THRESHOLD_MEDIUM_HUMIDITY, VENTILATION_THRESHOLD_MEDIUM_HUMIDITY_TIME_WINDOW
+ facts, LESS_THAN, VENTILATION_LEVEL_MEDIUM
+ ).filter { residence ->
+ def roomAboveThresholdCO2 = roomThresholdMatch(
+ facts, residence, "co2Level", true, VENTILATION_THRESHOLD_MEDIUM_CO2_LEVEL, VENTILATION_THRESHOLD_MEDIUM_CO2_TIME_WINDOW
+ )
+ def roomAboveThresholdHumidity = roomThresholdMatch(
+ facts, residence, "humidity", true, VENTILATION_THRESHOLD_MEDIUM_HUMIDITY, VENTILATION_THRESHOLD_MEDIUM_HUMIDITY_TIME_WINDOW
)
- roomAboveThresholdCO2 || roomAboveThresholdHumidity
- }.findFirst().map { residence ->
- facts.bind("residence", residence)
- true
- }.orElse(false)
+ roomAboveThresholdCO2 || roomAboveThresholdHumidity
+ }.findFirst().map { residence ->
+ facts.bind("residence", residence)
+ true
+ }.orElse(false)
})
.then({ facts ->
AssetState residence = facts.bound("residence")
@@ -135,19 +135,19 @@ rules.add()
.name("Auto ventilation is on, level is above LOW, CO2 or humidity below MEDIUM, set level LOW")
.when({ facts ->
residenceWithVentilationAutoMatch(
- facts, GREATER_THAN, VENTILATION_LEVEL_LOW
- ).filter { residence ->
- def roomBelowThresholdCO2 = roomThresholdMatch(
- facts, residence, "co2Level", false, VENTILATION_THRESHOLD_MEDIUM_CO2_LEVEL, VENTILATION_THRESHOLD_MEDIUM_TIME_WINDOW
- )
- def roomBelowThresholdHumidity = roomThresholdMatch(
- facts, residence, "humidity", false, VENTILATION_THRESHOLD_MEDIUM_HUMIDITY, VENTILATION_THRESHOLD_MEDIUM_TIME_WINDOW
+ facts, GREATER_THAN, VENTILATION_LEVEL_LOW
+ ).filter { residence ->
+ def roomBelowThresholdCO2 = roomThresholdMatch(
+ facts, residence, "co2Level", false, VENTILATION_THRESHOLD_MEDIUM_CO2_LEVEL, VENTILATION_THRESHOLD_MEDIUM_TIME_WINDOW
)
- roomBelowThresholdCO2 && roomBelowThresholdHumidity
- }.findFirst().map { residence ->
- facts.bind("residence", residence)
- true
- }.orElse(false)
+ def roomBelowThresholdHumidity = roomThresholdMatch(
+ facts, residence, "humidity", false, VENTILATION_THRESHOLD_MEDIUM_HUMIDITY, VENTILATION_THRESHOLD_MEDIUM_TIME_WINDOW
+ )
+ roomBelowThresholdCO2 && roomBelowThresholdHumidity
+ }.findFirst().map { residence ->
+ facts.bind("residence", residence)
+ true
+ }.orElse(false)
})
.then({ facts ->
AssetState residence = facts.bound("residence")
@@ -159,19 +159,19 @@ rules.add()
.name("Auto ventilation is on, level is below HIGH, CO2 or humidity above HIGH, set level HIGH")
.when({ facts ->
residenceWithVentilationAutoMatch(
- facts, LESS_THAN, VENTILATION_LEVEL_HIGH
- ).filter { residence ->
- def roomAboveThresholdCO2 = roomThresholdMatch(
- facts, residence, "co2Level", true, VENTILATION_THRESHOLD_HIGH_CO2_LEVEL, VENTILATION_THRESHOLD_HIGH_CO2_TIME_WINDOW
- )
- def roomAboveThresholdHumidity = roomThresholdMatch(
- facts, residence, "humidity", true, VENTILATION_THRESHOLD_HIGH_HUMIDITY, VENTILATION_THRESHOLD_HIGH_HUMIDITY_TIME_WINDOW
+ facts, LESS_THAN, VENTILATION_LEVEL_HIGH
+ ).filter { residence ->
+ def roomAboveThresholdCO2 = roomThresholdMatch(
+ facts, residence, "co2Level", true, VENTILATION_THRESHOLD_HIGH_CO2_LEVEL, VENTILATION_THRESHOLD_HIGH_CO2_TIME_WINDOW
+ )
+ def roomAboveThresholdHumidity = roomThresholdMatch(
+ facts, residence, "humidity", true, VENTILATION_THRESHOLD_HIGH_HUMIDITY, VENTILATION_THRESHOLD_HIGH_HUMIDITY_TIME_WINDOW
)
- roomAboveThresholdCO2 || roomAboveThresholdHumidity
- }.findFirst().map { residence ->
- facts.bind("residence", residence)
- true
- }.orElse(false)
+ roomAboveThresholdCO2 || roomAboveThresholdHumidity
+ }.findFirst().map { residence ->
+ facts.bind("residence", residence)
+ true
+ }.orElse(false)
})
.then({ facts ->
AssetState residence = facts.bound("residence")
@@ -183,19 +183,19 @@ rules.add()
.name("Auto ventilation is on, level is above MEDIUM, CO2 or humidity below HIGH, set level MEDIUM")
.when({ facts ->
residenceWithVentilationAutoMatch(
- facts, GREATER_THAN, VENTILATION_LEVEL_MEDIUM
- ).filter { residence ->
- def roomBelowThresholdCO2 = roomThresholdMatch(
- facts, residence, "co2Level", false, VENTILATION_THRESHOLD_HIGH_CO2_LEVEL, VENTILATION_THRESHOLD_HIGH_TIME_WINDOW
- )
- def roomBelowThresholdHumidity = roomThresholdMatch(
- facts, residence, "humidity", false, VENTILATION_THRESHOLD_HIGH_HUMIDITY, VENTILATION_THRESHOLD_HIGH_TIME_WINDOW
+ facts, GREATER_THAN, VENTILATION_LEVEL_MEDIUM
+ ).filter { residence ->
+ def roomBelowThresholdCO2 = roomThresholdMatch(
+ facts, residence, "co2Level", false, VENTILATION_THRESHOLD_HIGH_CO2_LEVEL, VENTILATION_THRESHOLD_HIGH_TIME_WINDOW
+ )
+ def roomBelowThresholdHumidity = roomThresholdMatch(
+ facts, residence, "humidity", false, VENTILATION_THRESHOLD_HIGH_HUMIDITY, VENTILATION_THRESHOLD_HIGH_TIME_WINDOW
)
- roomBelowThresholdCO2 && roomBelowThresholdHumidity
- }.findFirst().map { residence ->
- facts.bind("residence", residence)
- true
- }.orElse(false)
+ roomBelowThresholdCO2 && roomBelowThresholdHumidity
+ }.findFirst().map { residence ->
+ facts.bind("residence", residence)
+ true
+ }.orElse(false)
})
.then({ facts ->
AssetState residence = facts.bound("residence")
diff --git a/test/src/test/resources/org/openremote/test/rules/ResidenceNotifyAlarmTrigger.groovy b/test/src/test/resources/org/openremote/test/rules/ResidenceNotifyAlarmTrigger.groovy
index a2f5a3323..e3984c66e 100644
--- a/test/src/test/resources/org/openremote/test/rules/ResidenceNotifyAlarmTrigger.groovy
+++ b/test/src/test/resources/org/openremote/test/rules/ResidenceNotifyAlarmTrigger.groovy
@@ -59,32 +59,32 @@ rules.add()
.name("Create alarm trigger when residence alarm is enabled and presence is detected in any room")
.when({ facts ->
facts.matchAssetState(
- new AssetQuery().types(BuildingAsset).attributeValue("alarmEnabled", true)
- ).filter { residenceWithAlarmEnabled ->
- !facts.matchFirst(AlarmTrigger) { alarmTrigger ->
- alarmTrigger.residenceId == residenceWithAlarmEnabled.id
- }.isPresent()
- }.map { residenceWithoutAlarmTrigger ->
- // Map to Optional<AssetState<?>> of the "first" room in the residence with presence detected
- facts.matchFirstAssetState(
- new AssetQuery().types(RoomAsset)
- .parents(residenceWithoutAlarmTrigger.id)
- .attributeValue("presenceDetected", true)
- )
- }.filter {
- it.isPresent()
- }.map {
- it.get()
- }.findFirst().map { roomWithPresence ->
- facts.bind("residenceId", roomWithPresence.parentId)
- .bind("roomName", roomWithPresence.assetName)
- true
- }.orElse(false)
+ new AssetQuery().types(BuildingAsset).attributeValue("alarmEnabled", true)
+ ).filter { residenceWithAlarmEnabled ->
+ !facts.matchFirst(AlarmTrigger) { alarmTrigger ->
+ alarmTrigger.residenceId == residenceWithAlarmEnabled.id
+ }.isPresent()
+ }.map { residenceWithoutAlarmTrigger ->
+ // Map to Optional<AssetState<?>> of the "first" room in the residence with presence detected
+ facts.matchFirstAssetState(
+ new AssetQuery().types(RoomAsset)
+ .parents(residenceWithoutAlarmTrigger.id)
+ .attributeValue("presenceDetected", true)
+ )
+ }.filter {
+ it.isPresent()
+ }.map {
+ it.get()
+ }.findFirst().map { roomWithPresence ->
+ facts.bind("residenceId", roomWithPresence.parentId)
+ .bind("roomName", roomWithPresence.assetName)
+ true
+ }.orElse(false)
})
.then({ facts ->
AlarmTrigger alarmTrigger = new AlarmTrigger(
- residenceId: facts.bound("residenceId"),
- roomName: facts.bound("roomName")
+ residenceId: facts.bound("residenceId"),
+ roomName: facts.bound("roomName")
)
LOG.info("Alarm enabled and presence detected in residence, creating: $alarmTrigger")
facts.put(alarmTrigger)
@@ -95,9 +95,9 @@ rules.add()
.when({ facts ->
facts.matchFirst(AlarmTrigger) { alarmTrigger ->
!facts.matchFirstAssetState(
- new AssetQuery().types(RoomAsset)
- .parents(alarmTrigger.residenceId)
- .attributeValue("presenceDetected", true)
+ new AssetQuery().types(RoomAsset)
+ .parents(alarmTrigger.residenceId)
+ .attributeValue("presenceDetected", true)
).isPresent()
}.map { alarmTrigger ->
facts.bind("alarmTrigger", alarmTrigger)
@@ -115,9 +115,9 @@ rules.add()
.when({ facts ->
facts.matchFirst(AlarmTrigger) { alarmTrigger ->
facts.matchFirstAssetState(
- new AssetQuery().types(BuildingAsset)
- .ids(alarmTrigger.residenceId)
- .attributeValue("alarmEnabled", false)
+ new AssetQuery().types(BuildingAsset)
+ .ids(alarmTrigger.residenceId)
+ .attributeValue("alarmEnabled", false)
).isPresent()
}.map { alarmTrigger ->
facts.bind("alarmTrigger", alarmTrigger)
@@ -133,23 +133,23 @@ rules.add()
.name("Alert user when alarm has been triggered and not done so already")
.when({ facts ->
facts.matchAssetState(
- new AssetQuery().types(BuildingAsset).attributeValue("alarmEnabled", true)
- ).map { residenceWithAlarmEnabled ->
- facts.matchFirst(AlarmTrigger, { alarmTrigger ->
- alarmTrigger.residenceId == residenceWithAlarmEnabled.id
- })
- }.filter { alarmTrigger ->
- // there is an alarm trigger and alerts are not silenced for this residence
- alarmTrigger.isPresent() &&
- !facts.matchFirst(AlertSilence, { alertSilence ->
- alertSilence.residenceId == alarmTrigger.get().residenceId
- }).isPresent()
- }.map {
- it.get()
- }.findFirst().map { alarmTrigger ->
- facts.bind("alarmTrigger", alarmTrigger)
- true
- }.orElse(false)
+ new AssetQuery().types(BuildingAsset).attributeValue("alarmEnabled", true)
+ ).map { residenceWithAlarmEnabled ->
+ facts.matchFirst(AlarmTrigger, { alarmTrigger ->
+ alarmTrigger.residenceId == residenceWithAlarmEnabled.id
+ })
+ }.filter { alarmTrigger ->
+ // there is an alarm trigger and alerts are not silenced for this residence
+ alarmTrigger.isPresent() &&
+ !facts.matchFirst(AlertSilence, { alertSilence ->
+ alertSilence.residenceId == alarmTrigger.get().residenceId
+ }).isPresent()
+ }.map {
+ it.get()
+ }.findFirst().map { alarmTrigger ->
+ facts.bind("alarmTrigger", alarmTrigger)
+ true
+ }.orElse(false)
}).then({ facts ->
AlarmTrigger alarmTrigger = facts.bound("alarmTrigger")
@@ -174,14 +174,14 @@ rules.add()
new PushNotificationButton("Alarm uit", PushNotificationAction.writeAttributeValueAction(new AttributeRef(alarmTrigger.residenceId, "alarmEnabled"), false))
]),
targets, null, null
- )
+ )
// Send the notification to all matched users
notifications.send(notification)
AlertSilence alertSilence = new AlertSilence(
residenceId: alarmTrigger.residenceId
- )
+ )
facts.putTemporary(AlertSilence.DURATION, alertSilence)
})
@@ -189,19 +189,19 @@ rules.add()
.name("Remove alert silence when residence alarm is disabled")
.when({ facts ->
facts.matchAssetState(
- new AssetQuery().types(BuildingAsset).attributeValue("alarmEnabled", false)
- ).map { residenceWithAlarmEnabled ->
- facts.matchFirst(AlertSilence) { alertSilence ->
- alertSilence.residenceId == residenceWithAlarmEnabled.id
- }
- }.filter {
- it.isPresent()
- }.map {
- it.get()
- }.findFirst().map { alertSilence ->
- facts.bind("alertSilence", alertSilence)
- true
- }.orElse(false)
+ new AssetQuery().types(BuildingAsset).attributeValue("alarmEnabled", false)
+ ).map { residenceWithAlarmEnabled ->
+ facts.matchFirst(AlertSilence) { alertSilence ->
+ alertSilence.residenceId == residenceWithAlarmEnabled.id
+ }
+ }.filter {
+ it.isPresent()
+ }.map {
+ it.get()
+ }.findFirst().map { alertSilence ->
+ facts.bind("alertSilence", alertSilence)
+ true
+ }.orElse(false)
}).then({ facts ->
AlertSilence alertSilence = facts.bound("alertSilence")
LOG.info("Alarm disabled, removing: " + alertSilence)
diff --git a/test/src/test/resources/org/openremote/test/rules/ResidencePresenceDetection.groovy b/test/src/test/resources/org/openremote/test/rules/ResidencePresenceDetection.groovy
index a43a44103..52d32296f 100644
--- a/test/src/test/resources/org/openremote/test/rules/ResidencePresenceDetection.groovy
+++ b/test/src/test/resources/org/openremote/test/rules/ResidencePresenceDetection.groovy
@@ -49,18 +49,18 @@ rules.add()
.when({ facts ->
// Any room where the presence detected flag is not set
facts.matchAssetState(
- new AssetQuery().types(RoomAsset).attributeValue("presenceDetected", false)
- ).flatMap { roomWithoutPresence ->
- // and the motion sensor has been triggered
- facts.matchAssetState(
- new AssetQuery().ids(roomWithoutPresence.id).attributeValue("motionSensor", GREATER_THAN, 0)
- )
- }.findFirst().map { roomWithMotionSensorTriggered ->
+ new AssetQuery().types(RoomAsset).attributeValue("presenceDetected", false)
+ ).flatMap { roomWithoutPresence ->
+ // and the motion sensor has been triggered
+ facts.matchAssetState(
+ new AssetQuery().ids(roomWithoutPresence.id).attributeValue("motionSensor", GREATER_THAN, 0)
+ )
+ }.findFirst().map { roomWithMotionSensorTriggered ->
- facts.bind("room", roomWithMotionSensorTriggered)
- true
+ facts.bind("room", roomWithMotionSensorTriggered)
+ true
- /* Results in many false negatives when somebody is moving in the room but
+ /* Results in many false negatives when somebody is moving in the room but
windows are open, and therefore CO2 is not increasing
// and there is a CO2 sensor in the room
facts.matchFirstAssetState(
@@ -81,7 +81,7 @@ rules.add()
}).count() >= 2 // at least 2
}).orElse(true) // or we don't have a CO2 sensor
*/
- }.orElse(false)
+ }.orElse(false)
})
.then({ facts ->
AssetState room = facts.bound("room")
@@ -94,32 +94,32 @@ rules.add()
.when({ facts ->
// Any room where the presence detected flag is set
facts.matchAssetState(
- new AssetQuery().types(RoomAsset).attributeValue("presenceDetected", true)
- ).flatMap { roomWithPresence ->
- // and the motion sensor has not been triggered
- facts.matchAssetState(
- new AssetQuery().ids(roomWithPresence.id).attributeValue("motionSensor", LESS_THAN, 1)
- )
- }.findFirst().map { roomWithoutMotionSensorTriggered ->
+ new AssetQuery().types(RoomAsset).attributeValue("presenceDetected", true)
+ ).flatMap { roomWithPresence ->
+ // and the motion sensor has not been triggered
+ facts.matchAssetState(
+ new AssetQuery().ids(roomWithPresence.id).attributeValue("motionSensor", LESS_THAN, 1)
+ )
+ }.findFirst().map { roomWithoutMotionSensorTriggered ->
- facts.bind("room", roomWithoutMotionSensorTriggered)
+ facts.bind("room", roomWithoutMotionSensorTriggered)
- // and there is a CO2 sensor in the room
- facts.matchFirstAssetState(
- new AssetQuery().ids(roomWithoutMotionSensorTriggered.id).attributeName("co2Level")
- ).map { co2Level ->
- // and there are no sensor events
- facts.matchAssetEvent(
- new AssetQuery().ids(roomWithoutMotionSensorTriggered.id).attributeName("co2Level")
- ).filter { coLevelFact ->
- // with increasing values
- coLevelFact.getFact().isValueGreaterThanOldValue()
- // in the last 12 minutes
- }.filter{
- facts.clock.now.minus(12, ChronoUnit.MINUTES).toEpochMilli() <it.timestamp
- }.count() == 0
- }.orElse(true) // or we don't have a CO2 sensor
- }.orElse(false)
+ // and there is a CO2 sensor in the room
+ facts.matchFirstAssetState(
+ new AssetQuery().ids(roomWithoutMotionSensorTriggered.id).attributeName("co2Level")
+ ).map { co2Level ->
+ // and there are no sensor events
+ facts.matchAssetEvent(
+ new AssetQuery().ids(roomWithoutMotionSensorTriggered.id).attributeName("co2Level")
+ ).filter { coLevelFact ->
+ // with increasing values
+ coLevelFact.getFact().isValueGreaterThanOldValue()
+ // in the last 12 minutes
+ }.filter{
+ facts.clock.now.minus(12, ChronoUnit.MINUTES).toEpochMilli() <it.timestamp
+ }.count() == 0
+ }.orElse(true) // or we don't have a CO2 sensor
+ }.orElse(false)
})
.then({ facts ->
AssetState room = facts.bound("room")
@@ -132,28 +132,28 @@ rules.add()
.when({ facts ->
// Any room where the presence detected flag is set
facts.matchAssetState(
- new AssetQuery().types(RoomAsset).attributeValue("presenceDetected", true)
- ).flatMap { roomWithPresence ->
- // and the motion sensor has been triggered
- facts.matchAssetState(
- new AssetQuery().ids(roomWithPresence.id)
- .attributeValue("motionSensor", GREATER_THAN, 0)
- ).flatMap { roomWithMotionSensorTriggered ->
- // and the last presence detection timestamp is not set or is older than the motion sensor timestamp
- facts.matchAssetState(
- new AssetQuery().ids(roomWithMotionSensorTriggered.id)
- .attributeName("lastPresenceDetected")
- ).filter({
- !it.value.isPresent() || it.value.timestamp
- }).map { outdatedLastPresenceDetected ->
- // keep the room and the new timestamp
- new Pair<AttributeInfo, Double>(outdatedLastPresenceDetected, roomWithMotionSensorTriggered.timestamp)
- }
- }
- }.findFirst().map { pair ->
- facts.bind("room", pair.key).bind("lastPresenceTimestamp", pair.value)
- true
- }.orElse(false)
+ new AssetQuery().types(RoomAsset).attributeValue("presenceDetected", true)
+ ).flatMap { roomWithPresence ->
+ // and the motion sensor has been triggered
+ facts.matchAssetState(
+ new AssetQuery().ids(roomWithPresence.id)
+ .attributeValue("motionSensor", GREATER_THAN, 0)
+ ).flatMap { roomWithMotionSensorTriggered ->
+ // and the last presence detection timestamp is not set or is older than the motion sensor timestamp
+ facts.matchAssetState(
+ new AssetQuery().ids(roomWithMotionSensorTriggered.id)
+ .attributeName("lastPresenceDetected")
+ ).filter({
+ !it.value.isPresent() || it.value.timestamp
+ }).map { outdatedLastPresenceDetected ->
+ // keep the room and the new timestamp
+ new Pair<AttributeInfo, Double>(outdatedLastPresenceDetected, roomWithMotionSensorTriggered.timestamp)
+ }
+ }
+ }.findFirst().map { pair ->
+ facts.bind("room", pair.key).bind("lastPresenceTimestamp", pair.value)
+ true
+ }.orElse(false)
})
.then({ facts ->
AssetState room = facts.bound("room")
@@ -166,18 +166,18 @@ rules.add()
.when({ facts ->
// A room where the presence detected flag is set
facts.matchAssetState(
- new AssetQuery().types(RoomAsset).attributeValue("presenceDetected", true)
- ).flatMap { roomWithPresence ->
- // and a residence parent where the presence detected flag is not set
- facts.matchAssetState(
- new AssetQuery()
- .ids(roomWithPresence.parentId)
- .attributeValue("presenceDetected", false)
- )
- }.findFirst().map { residenceWithoutPresence ->
- facts.bind("residence", residenceWithoutPresence)
- true
- }.orElse(false)
+ new AssetQuery().types(RoomAsset).attributeValue("presenceDetected", true)
+ ).flatMap { roomWithPresence ->
+ // and a residence parent where the presence detected flag is not set
+ facts.matchAssetState(
+ new AssetQuery()
+ .ids(roomWithPresence.parentId)
+ .attributeValue("presenceDetected", false)
+ )
+ }.findFirst().map { residenceWithoutPresence ->
+ facts.bind("residence", residenceWithoutPresence)
+ true
+ }.orElse(false)
})
.then({ facts ->
AssetState residence = facts.bound("residence")
@@ -190,17 +190,17 @@ rules.add()
.when({ facts ->
// A residence where the presence detected flag is set
facts.matchAssetState(
- new AssetQuery().types(BuildingAsset).attributeValue("presenceDetected", true)
- ).filter { residenceWithPresence ->
- // and no room child of that residence has presence
- facts.matchAssetState(
- new AssetQuery().types(RoomAsset).parents(residenceWithPresence.id)
- .attributeValue("presenceDetected", true)
- ).count() == 0
- }.findFirst().map { residenceWithPresence ->
- facts.bind("residence", residenceWithPresence)
- true
- }.orElse(false)
+ new AssetQuery().types(BuildingAsset).attributeValue("presenceDetected", true)
+ ).filter { residenceWithPresence ->
+ // and no room child of that residence has presence
+ facts.matchAssetState(
+ new AssetQuery().types(RoomAsset).parents(residenceWithPresence.id)
+ .attributeValue("presenceDetected", true)
+ ).count() == 0
+ }.findFirst().map { residenceWithPresence ->
+ facts.bind("residence", residenceWithPresence)
+ true
+ }.orElse(false)
})
.then({ facts ->
AssetState residence = facts.bound("residence")
diff --git a/test/src/test/resources/org/openremote/test/rules/ResidenceSmartSwitch.groovy b/test/src/test/resources/org/openremote/test/rules/ResidenceSmartSwitch.groovy
index 9f62a0e58..ff6703d5a 100644
--- a/test/src/test/resources/org/openremote/test/rules/ResidenceSmartSwitch.groovy
+++ b/test/src/test/resources/org/openremote/test/rules/ResidenceSmartSwitch.groovy
@@ -53,7 +53,7 @@ enum SmartSwitchMode {
Closure<Stream<AssetState<?>>> smartSwitchAttributesMatch = { RulesFacts facts, SmartSwitchAttribute attribute ->
facts.matchAssetState(
- new AssetQuery().types(RoomAsset).attributes(new AttributePredicate(new StringPredicate(BEGIN, "smartSwitch" + attribute.name()), null))
+ new AssetQuery().types(RoomAsset).attributes(new AttributePredicate(new StringPredicate(BEGIN, "smartSwitch" + attribute.name()), null))
)
}
@@ -63,7 +63,7 @@ Closure<Character> getSmartSwitchName = { AssetState attribute ->
Closure<Optional<AssetState<?>>> smartSwitchAttributeMatch = { RulesFacts facts, AssetState smartSwitch, SmartSwitchAttribute attribute ->
facts.matchFirstAssetState(
- new AssetQuery().types(RoomAsset).attributeName("smartSwitch" + attribute.name() + getSmartSwitchName(smartSwitch))
+ new AssetQuery().types(RoomAsset).attributeName("smartSwitch" + attribute.name() + getSmartSwitchName(smartSwitch))
)
}
@@ -71,21 +71,21 @@ rules.add()
.name("Clear start/stop time and disable actuator when begin/end of cycle is empty")
.when({ facts ->
smartSwitchAttributesMatch(
- facts, SmartSwitchAttribute.BeginEnd
- ).filter { beginEnd ->
- !beginEnd.value.isPresent()
- }.filter { emptyBeginEnd ->
- // Any of start time, stop time, or enabled is greater than zero
- def startTime = smartSwitchAttributeMatch(facts, emptyBeginEnd, SmartSwitchAttribute.StartTime)
- def stopTime = smartSwitchAttributeMatch(facts, emptyBeginEnd, SmartSwitchAttribute.StopTime)
- def enabled = smartSwitchAttributeMatch(facts, emptyBeginEnd, SmartSwitchAttribute.Enabled)
- (startTime.isPresent() && startTime.get().value.orElse(0l) > 0l) ||
- (stopTime.isPresent() && stopTime.get().value.orElse(0l) > 0l) ||
- (enabled.isPresent() && enabled.get().value.orElse(0l) > 0l)
- }.findFirst().map { emptyBeginEnd ->
- facts.bind("beginEnd", emptyBeginEnd)
- true
- }.orElse(false)
+ facts, SmartSwitchAttribute.BeginEnd
+ ).filter { beginEnd ->
+ !beginEnd.value.isPresent()
+ }.filter { emptyBeginEnd ->
+ // Any of start time, stop time, or enabled is greater than zero
+ def startTime = smartSwitchAttributeMatch(facts, emptyBeginEnd, SmartSwitchAttribute.StartTime)
+ def stopTime = smartSwitchAttributeMatch(facts, emptyBeginEnd, SmartSwitchAttribute.StopTime)
+ def enabled = smartSwitchAttributeMatch(facts, emptyBeginEnd, SmartSwitchAttribute.Enabled)
+ (startTime.isPresent() && startTime.get().value.orElse(0l) > 0l) ||
+ (stopTime.isPresent() && stopTime.get().value.orElse(0l) > 0l) ||
+ (enabled.isPresent() && enabled.get().value.orElse(0l) > 0l)
+ }.findFirst().map { emptyBeginEnd ->
+ facts.bind("beginEnd", emptyBeginEnd)
+ true
+ }.orElse(false)
})
.then({ facts ->
AssetState beginEnd = facts.bound("beginEnd")
@@ -100,19 +100,19 @@ rules.add()
.name("Clear begin/end of cycle when mode is NOW_ON")
.when({ facts ->
smartSwitchAttributesMatch(
- facts, SmartSwitchAttribute.Mode
- ).filter { mode ->
- SmartSwitchMode.matches(mode, SmartSwitchMode.NOW_ON)
- }.filter { modeNowOn ->
- // Begin/end time of cycle is greater than zero
- smartSwitchAttributeMatch(facts, modeNowOn, SmartSwitchAttribute.BeginEnd)
- .flatMap { it.getValue(Long.class) }
- .map { it> 0 }
- .orElse(false)
- }.findFirst().map { modeNowOn ->
- facts.bind("mode", modeNowOn)
- true
- }.orElse(false)
+ facts, SmartSwitchAttribute.Mode
+ ).filter { mode ->
+ SmartSwitchMode.matches(mode, SmartSwitchMode.NOW_ON)
+ }.filter { modeNowOn ->
+ // Begin/end time of cycle is greater than zero
+ smartSwitchAttributeMatch(facts, modeNowOn, SmartSwitchAttribute.BeginEnd)
+ .flatMap { it.getValue(Long.class) }
+ .map { it> 0 }
+ .orElse(false)
+ }.findFirst().map { modeNowOn ->
+ facts.bind("mode", modeNowOn)
+ true
+ }.orElse(false)
})
.then({ facts ->
AssetState mode = facts.bound("mode")
@@ -125,34 +125,34 @@ rules.add()
.name("Enable actuator when mode is ON_AT and begin/end of cycle is now or in future and different than actuator start time")
.when({ facts ->
smartSwitchAttributesMatch(
- facts, SmartSwitchAttribute.Mode
- ).filter { mode ->
- SmartSwitchMode.matches(mode, SmartSwitchMode.ON_AT)
- }.map { modeOnAt ->
- smartSwitchAttributeMatch(facts, modeOnAt, SmartSwitchAttribute.BeginEnd)
- }.filter { beginEnd ->
- // User-provided begin/end time of cycle
- beginEnd.flatMap { it.value}.filter {
- // is now or in future
- it >= facts.clock.currentTimeMillis
- }.map { expectedStartTime ->
- // and actuator start time attribute
- def startTime = beginEnd.flatMap {
- smartSwitchAttributeMatch(facts, it, SmartSwitchAttribute.StartTime)
- }
- // is present
- startTime.isPresent() &&
- // the value is not the same as the expected start time
- startTime.map {
- it.value.map {
- it != expectedStartTime
- }.orElse(true) // or actuator start time is empty
+ facts, SmartSwitchAttribute.Mode
+ ).filter { mode ->
+ SmartSwitchMode.matches(mode, SmartSwitchMode.ON_AT)
+ }.map { modeOnAt ->
+ smartSwitchAttributeMatch(facts, modeOnAt, SmartSwitchAttribute.BeginEnd)
+ }.filter { beginEnd ->
+ // User-provided begin/end time of cycle
+ beginEnd.flatMap { it.value}.filter {
+ // is now or in future
+ it >= facts.clock.currentTimeMillis
+ }.map { expectedStartTime ->
+ // and actuator start time attribute
+ def startTime = beginEnd.flatMap {
+ smartSwitchAttributeMatch(facts, it, SmartSwitchAttribute.StartTime)
}
- }.orElse(false)
- }.findFirst().map {beginEnd ->
- facts.bind("beginEnd", beginEnd.get())
- true
- }.orElse(false)
+ // is present
+ startTime.isPresent() &&
+ // the value is not the same as the expected start time
+ startTime.map {
+ it.value.map {
+ it != expectedStartTime
+ }.orElse(true) // or actuator start time is empty
+ }
+ }.orElse(false)
+ }.findFirst().map {beginEnd ->
+ facts.bind("beginEnd", beginEnd.get())
+ true
+ }.orElse(false)
})
.then({ facts ->
AssetState<Long> beginEnd = facts.bound("beginEnd")
@@ -175,32 +175,32 @@ rules.add()
.name("Enable actuator when mode is READY_AT and cycle will complete in future and different than actuator stop time")
.when({ facts ->
smartSwitchAttributesMatch(
- facts, SmartSwitchAttribute.Mode
- ).filter { mode ->
- SmartSwitchMode.matches(mode, SmartSwitchMode.READY_AT)
- }.map { modeReadyAt ->
- smartSwitchAttributeMatch(facts, modeReadyAt, SmartSwitchAttribute.BeginEnd)
- }.filter { beginEnd ->
- // User-provided begin/end time of cycle
- beginEnd.flatMap { it.value}.filter {
- // allows the cycle to complete in future
- (it - CYCLE_TIME_MILLISECONDS) >= facts.clock.currentTimeMillis
- }.map { expectedStopTime ->
- // and actuator stop time attribute
- def stopTime = beginEnd.flatMap {
- smartSwitchAttributeMatch(facts, it, SmartSwitchAttribute.StopTime)
- }
- // is present
- stopTime.isPresent() &&
- // the value is not the same as the expected stop time
- stopTime.flatMap { it.value}.map {
- it != expectedStopTime
- }.orElse(true) // or actuator stop time is empty
- }.orElse(false)
- }.findFirst().map { beginEnd ->
- facts.bind("beginEnd", beginEnd.get())
- true
- }.orElse(false)
+ facts, SmartSwitchAttribute.Mode
+ ).filter { mode ->
+ SmartSwitchMode.matches(mode, SmartSwitchMode.READY_AT)
+ }.map { modeReadyAt ->
+ smartSwitchAttributeMatch(facts, modeReadyAt, SmartSwitchAttribute.BeginEnd)
+ }.filter { beginEnd ->
+ // User-provided begin/end time of cycle
+ beginEnd.flatMap { it.value}.filter {
+ // allows the cycle to complete in future
+ (it - CYCLE_TIME_MILLISECONDS) >= facts.clock.currentTimeMillis
+ }.map { expectedStopTime ->
+ // and actuator stop time attribute
+ def stopTime = beginEnd.flatMap {
+ smartSwitchAttributeMatch(facts, it, SmartSwitchAttribute.StopTime)
+ }
+ // is present
+ stopTime.isPresent() &&
+ // the value is not the same as the expected stop time
+ stopTime.flatMap { it.value}.map {
+ it != expectedStopTime
+ }.orElse(true) // or actuator stop time is empty
+ }.orElse(false)
+ }.findFirst().map { beginEnd ->
+ facts.bind("beginEnd", beginEnd.get())
+ true
+ }.orElse(false)
})
.then({ facts ->
AssetState<Long> beginEnd = facts.bound("beginEnd")
@@ -223,20 +223,20 @@ rules.add()
.name("Set mode NOW_ON when mode is ON_AT or READY_AT and actuator stop time is in the past")
.when({ facts ->
smartSwitchAttributesMatch(
- facts, SmartSwitchAttribute.Mode
- ).filter { mode ->
- SmartSwitchMode.matches(mode, SmartSwitchMode.ON_AT) || SmartSwitchMode.matches(mode, SmartSwitchMode.READY_AT)
- }.map { modeOnAtOrReadyAt ->
- smartSwitchAttributeMatch(facts, modeOnAtOrReadyAt, SmartSwitchAttribute.StopTime)
- }.filter { stopTime ->
- // Actuator stop time attribute is present and value (in seconds) is not zero and in the past
- stopTime.flatMap { it.value}.map {
- it> 0 && it <facts.clock.currentTimeMillis
- }.orElse(false)
- }.findFirst().map { stopTime ->
- facts.bind("stopTime", stopTime.get())
- true
- }.orElse(false)
+ facts, SmartSwitchAttribute.Mode
+ ).filter { mode ->
+ SmartSwitchMode.matches(mode, SmartSwitchMode.ON_AT) || SmartSwitchMode.matches(mode, SmartSwitchMode.READY_AT)
+ }.map { modeOnAtOrReadyAt ->
+ smartSwitchAttributeMatch(facts, modeOnAtOrReadyAt, SmartSwitchAttribute.StopTime)
+ }.filter { stopTime ->
+ // Actuator stop time attribute is present and value (in seconds) is not zero and in the past
+ stopTime.flatMap { it.value}.map {
+ it> 0 && it <facts.clock.currentTimeMillis
+ }.orElse(false)
+ }.findFirst().map { stopTime ->
+ facts.bind("stopTime", stopTime.get())
+ true
+ }.orElse(false)
})
.then({ facts ->
AssetState stopTime = facts.bound("stopTime")
@@ -246,5 +246,5 @@ rules.add()
stopTime.id,
"smartSwitch" + SmartSwitchAttribute.Mode + smartSwitchName,
SmartSwitchMode.NOW_ON.name()
- )
+ )
})
diff --git a/test/src/test/resources/org/openremote/test/rules/ResidenceVacationMode.groovy b/test/src/test/resources/org/openremote/test/rules/ResidenceVacationMode.groovy
index 162079495..118cd11b9 100644
--- a/test/src/test/resources/org/openremote/test/rules/ResidenceVacationMode.groovy
+++ b/test/src/test/resources/org/openremote/test/rules/ResidenceVacationMode.groovy
@@ -48,22 +48,22 @@ rules.add()
.name("When residence has vacation until in future, add vacation mode, execute DAY scene and disable scene timers")
.when({ facts ->
facts.matchAssetState(
- new AssetQuery().types(BuildingAsset)
- .attributeValue("vacationUntil", GREATER_THAN, facts.clock.currentTimeMillis)
- ).filter { residenceWithVacationUntil ->
- facts.match(VacationMode).noneMatch { vacationMode ->
- vacationMode.residenceId == residenceWithVacationUntil.id
- }
- }.findFirst().map { residenceWithoutVacationMode ->
- facts.bind("residenceId", residenceWithoutVacationMode.id)
- .bind("vacationUntil", residenceWithoutVacationMode.value.get())
- true
- }.orElse(false)
+ new AssetQuery().types(BuildingAsset)
+ .attributeValue("vacationUntil", GREATER_THAN, facts.clock.currentTimeMillis)
+ ).filter { residenceWithVacationUntil ->
+ facts.match(VacationMode).noneMatch { vacationMode ->
+ vacationMode.residenceId == residenceWithVacationUntil.id
+ }
+ }.findFirst().map { residenceWithoutVacationMode ->
+ facts.bind("residenceId", residenceWithoutVacationMode.id)
+ .bind("vacationUntil", residenceWithoutVacationMode.value.get())
+ true
+ }.orElse(false)
})
.then({ facts ->
VacationMode vacationMode = new VacationMode(
- residenceId: facts.bound("residenceId"),
- until: facts.bound("vacationUntil")
+ residenceId: facts.bound("residenceId"),
+ until: facts.bound("vacationUntil")
)
LOG.info("Vacation mode enabled: " + vacationMode)
@@ -78,18 +78,18 @@ rules.add()
.name("When residence has vacation until in past, clear it and enable scene timers")
.when({ facts ->
facts.matchAssetState(
- new AssetQuery().types(BuildingAsset)
- .attributeValue("vacationUntil", LESS_EQUALS, facts.clock.currentTimeMillis)
- ).filter { residenceWithVacationUntilInPast ->
- residenceWithVacationUntilInPast.getValue(Double.class).isPresent()
- }.filter { residenceWithVacationUntilInPast ->
- facts.match(VacationMode).noneMatch { vacationMode ->
- vacationMode.residenceId == residenceWithVacationUntilInPast.id
- }
- }.findFirst().map { residenceWithVacationUntilInPastWithoutVacationMode ->
- facts.bind("residence", residenceWithVacationUntilInPastWithoutVacationMode)
- true
- }.orElse(false)
+ new AssetQuery().types(BuildingAsset)
+ .attributeValue("vacationUntil", LESS_EQUALS, facts.clock.currentTimeMillis)
+ ).filter { residenceWithVacationUntilInPast ->
+ residenceWithVacationUntilInPast.getValue(Double.class).isPresent()
+ }.filter { residenceWithVacationUntilInPast ->
+ facts.match(VacationMode).noneMatch { vacationMode ->
+ vacationMode.residenceId == residenceWithVacationUntilInPast.id
+ }
+ }.findFirst().map { residenceWithVacationUntilInPastWithoutVacationMode ->
+ facts.bind("residence", residenceWithVacationUntilInPastWithoutVacationMode)
+ true
+ }.orElse(false)
})
.then({ facts ->
AssetState residence = facts.bound("residence")
@@ -103,12 +103,12 @@ rules.add()
.when({ facts ->
facts.matchFirst(VacationMode) { vacationMode ->
facts.matchFirstAssetState(
- new AssetQuery().types(BuildingAsset)
- .ids(vacationMode.residenceId)
- .attributes(new AttributePredicate(new StringPredicate("vacationUntil"), new ValueEmptyPredicate().negate(true)))
- ).map { residence ->
- vacationMode.until != residence.value.get()
- }.orElse(false)
+ new AssetQuery().types(BuildingAsset)
+ .ids(vacationMode.residenceId)
+ .attributes(new AttributePredicate(new StringPredicate("vacationUntil"), new ValueEmptyPredicate().negate(true)))
+ ).map { residence ->
+ vacationMode.until != residence.value.get()
+ }.orElse(false)
}.map { vacationMode ->
facts.bind("vacationMode", vacationMode)
true
@@ -125,9 +125,9 @@ rules.add()
.when({ facts ->
facts.matchFirst(VacationMode) { vacationMode ->
!facts.matchFirstAssetState(
- new AssetQuery().types(BuildingAsset)
- .ids(vacationMode.residenceId)
- .attributes(new AttributePredicate(new StringPredicate("vacationUntil"), new ValueEmptyPredicate().negate(true)))).isPresent()
+ new AssetQuery().types(BuildingAsset)
+ .ids(vacationMode.residenceId)
+ .attributes(new AttributePredicate(new StringPredicate("vacationUntil"), new ValueEmptyPredicate().negate(true)))).isPresent()
}.map { vacationMode ->
facts.bind("vacationMode", vacationMode)
true
diff --git a/test/src/test/resources/org/openremote/test/rules/SmartCityCamera.groovy b/test/src/test/resources/org/openremote/test/rules/SmartCityCamera.groovy
index 5f120739e..a164fc644 100644
--- a/test/src/test/resources/org/openremote/test/rules/SmartCityCamera.groovy
+++ b/test/src/test/resources/org/openremote/test/rules/SmartCityCamera.groovy
@@ -40,22 +40,22 @@ rules.add()
.when({ facts ->
def totals = facts.matchAssetState(new AssetQuery()
- .names(new StringPredicate(AssetQuery.Match.BEGIN, "Camera"))
- .attributeName("cameraCountIn"))
- .map({
- new Tuple(it.id, it.getValue(Double.class).orElse(0d) - facts.matchFirstAssetState(new AssetQuery()
- .names(new StringPredicate(AssetQuery.Match.BEGIN, "Camera"))
- .attributeName("cameraCountOut"))
- .map({ it.getValue(Double.class).orElse(0d)}).orElse(0d))
- })
- .filter({
- cameraTotals.getOrDefault(it.get(0), new Integer(0)) != it.get(1)
- })
- .collect(Collectors.toMap({ Tuple tuple ->
- tuple.get(0) as String
- }, { Tuple tuple ->
- tuple.get(1) as Integer
- }))
+ .names(new StringPredicate(AssetQuery.Match.BEGIN, "Camera"))
+ .attributeName("cameraCountIn"))
+ .map({
+ new Tuple(it.id, it.getValue(Double.class).orElse(0d) - facts.matchFirstAssetState(new AssetQuery()
+ .names(new StringPredicate(AssetQuery.Match.BEGIN, "Camera"))
+ .attributeName("cameraCountOut"))
+ .map({ it.getValue(Double.class).orElse(0d)}).orElse(0d))
+ })
+ .filter({
+ cameraTotals.getOrDefault(it.get(0), new Integer(0)) != it.get(1)
+ })
+ .collect(Collectors.toMap({ Tuple tuple ->
+ tuple.get(0) as String
+ }, { Tuple tuple ->
+ tuple.get(1) as Integer
+ }))
if (!totals.isEmpty()) {
facts.bind("totals", totals)
@@ -78,23 +78,23 @@ rules.add()
.when({ facts ->
def cameraIds = facts.matchAssetState(new AssetQuery()
- .names(new StringPredicate(AssetQuery.Match.BEGIN, "Camera"))
- .attributeName("cameraCountTotalAlert"))
- .filter({
- !it.value.orElse(false) &&
- facts.matchFirstAssetState(new AssetQuery()
- .ids(it.id)
- .attributeName("cameraCountTotal"))
- .map({ it.value.orElse(-1) })
- .orElse(-1) >
- facts.matchFirstAssetState(new AssetQuery()
- .ids(it.id)
- .attributeName("cameraCountTotalAlertLevel"))
- .map({ it.value.orElse(-1) })
- .orElse(-1)
- })
- .map({ it.id })
- .collect()
+ .names(new StringPredicate(AssetQuery.Match.BEGIN, "Camera"))
+ .attributeName("cameraCountTotalAlert"))
+ .filter({
+ !it.value.orElse(false) &&
+ facts.matchFirstAssetState(new AssetQuery()
+ .ids(it.id)
+ .attributeName("cameraCountTotal"))
+ .map({ it.value.orElse(-1) })
+ .orElse(-1) >
+ facts.matchFirstAssetState(new AssetQuery()
+ .ids(it.id)
+ .attributeName("cameraCountTotalAlertLevel"))
+ .map({ it.value.orElse(-1) })
+ .orElse(-1)
+ })
+ .map({ it.id })
+ .collect()
if (cameraIds.size() > 0) {
facts.bind("cameraIds", cameraIds)
diff --git a/ui/component/rest/build.gradle b/ui/component/rest/build.gradle
index a50d4294d..c98cd9d1a 100644
--- a/ui/component/rest/build.gradle
+++ b/ui/component/rest/build.gradle
@@ -26,7 +26,7 @@ dependencies {
generateTypeScript createTSGeneratorConfigForClient(
"src/restclient.ts",
new File("${project(":ui:component:model").projectDir}/src/typescript-generator-info.json")
- )
+)
def generateTypeScriptTask = tasks.named("generateTypeScript") {
// Work around typescript-generator exposing non-serializable configuration objects as Gradle task inputs.