Skip to content

armgit / core

Public Imported from GitHub
0

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

Minor updates for console registration

Rich Turnere5f598983066
diff --git a/manager/src/main/java/org/openremote/manager/asset/console/ConsoleResourceImpl.java b/manager/src/main/java/org/openremote/manager/asset/console/ConsoleResourceImpl.java
index 325e6fa5a..05fdeae0b 100644
--- a/manager/src/main/java/org/openremote/manager/asset/console/ConsoleResourceImpl.java
+++ b/manager/src/main/java/org/openremote/manager/asset/console/ConsoleResourceImpl.java
@@ -78,6 +78,9 @@ public class ConsoleResourceImpl extends ManagerWebResource implements ConsoleRe
if (!ConsoleConfigration.getConsoleName(console).orElse("").equals(ConsoleConfigration.getConsoleName(existingConsole).orElse(null))) {
throw new BadRequestException(Response.status(Response.Status.BAD_REQUEST).entity(new ValidationFailure[] {new ValidationFailure(ConsoleConfigration.ValidationFailureReason.NAME_MISSING_OR_INVALID)}).build());
}
+
+ // Use the same parent as the existing asset
+ console.setParentId(existingConsole.getParentId());
}
}
diff --git a/test/src/test/groovy/org/openremote/test/console/ConsoleAssetTest.groovy b/test/src/test/groovy/org/openremote/test/console/ConsoleAssetTest.groovy
index e1fe05df7..50ded9ade 100644
--- a/test/src/test/groovy/org/openremote/test/console/ConsoleAssetTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/console/ConsoleAssetTest.groovy
@@ -2,6 +2,7 @@ package org.openremote.test.console
import org.openremote.container.util.UniqueIdentifierGenerator
import org.openremote.manager.asset.AssetStorageService
+import org.openremote.manager.asset.console.ConsoleResourceImpl
import org.openremote.manager.rules.geofence.ORConsoleGeofenceAssetAdapter
import org.openremote.manager.setup.SetupService
import org.openremote.manager.setup.builtin.KeycloakDemoSetup
@@ -93,6 +94,7 @@ class ConsoleAssetTest extends Specification implements ManagerContainerTrait {
assert consolePushProvider.data.get("token").flatMap{Values.getString(it)}.orElse(null) == "23123213ad2313b0897efd"
assert !TextUtil.isNullOrEmpty(returnedConsole.getId())
+ assert returnedConsole.getParentId() == ConsoleResourceImpl.consoleParentAssetIdGenerator(MASTER_REALM)
assert returnedConsole.name == console.name
assert ConsoleConfigration.getConsoleName(returnedConsole).orElse(null) == ConsoleConfigration.getConsoleName(console).orElse(null)
assert ConsoleConfigration.getConsoleVersion(returnedConsole).orElse(null) == ConsoleConfigration.getConsoleVersion(console).orElse(null)
@@ -112,6 +114,11 @@ class ConsoleAssetTest extends Specification implements ManagerContainerTrait {
assert !returnedConsolePushProvider.disabled
assert returnedConsolePushProvider.data.get("token").flatMap{Values.getString(it)}.orElse(null) == "23123213ad2313b0897efd"
+ and: "the console should have been linked to the authenticated user"
+ def userAssets = assetStorageService.findUserAssets(MASTER_REALM, keycloakDemoSetup.testuser1Id, consoleId)
+ assert userAssets.size() == 1
+ assert userAssets.get(0).assetName == "Test Android Console"
+
when: "the console is modified and registration is updated"
returnedConsoleGeofenceProvider.hasPermission = true
ConsoleConfigration.addOrReplaceConsoleProvider(returnedConsole, "geofence", returnedConsoleGeofenceProvider)