From 3b6dfbeddb78fea4d9c4111011e7ec796fa03f5e Mon Sep 17 00:00:00 2001 From: Kai Kreuzer Date: Wed, 30 Jan 2019 11:37:51 +0100 Subject: [PATCH] Keep persisted disabled status when thing is removed (#493) Also-By: Florian Stolte Signed-off-by: Kai Kreuzer --- .../smarthome/core/thing/internal/ThingManagerImpl.java | 1 - .../core/thing/internal/ThingManagerOSGiJavaTest.java | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/internal/ThingManagerImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/internal/ThingManagerImpl.java index 82b7c30c1..2c336c02c 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/internal/ThingManagerImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/internal/ThingManagerImpl.java @@ -484,7 +484,6 @@ public class ThingManagerImpl } } - storage.remove(thing.getUID().getAsString()); this.things.remove(thing); } diff --git a/itests/org.openhab.core.thing.tests/src/test/java/org/eclipse/smarthome/core/thing/internal/ThingManagerOSGiJavaTest.java b/itests/org.openhab.core.thing.tests/src/test/java/org/eclipse/smarthome/core/thing/internal/ThingManagerOSGiJavaTest.java index 5c90117fe..337ad3ffa 100644 --- a/itests/org.openhab.core.thing.tests/src/test/java/org/eclipse/smarthome/core/thing/internal/ThingManagerOSGiJavaTest.java +++ b/itests/org.openhab.core.thing.tests/src/test/java/org/eclipse/smarthome/core/thing/internal/ThingManagerOSGiJavaTest.java @@ -913,7 +913,7 @@ public class ThingManagerOSGiJavaTest extends JavaOSGiTest { } @Test - public void testStorageEntryRemovedOnThingRemoval() throws Exception { + public void testStorageEntryRetainedOnThingRemoval() throws Exception { registerThingTypeProvider(); AtomicReference thingHandlerCallback = new AtomicReference<>(); @@ -981,8 +981,10 @@ public class ThingManagerOSGiJavaTest extends JavaOSGiTest { new Thread((Runnable) () -> managedThingProvider.remove(THING.getUID())).start(); waitForAssert(() -> { - assertThat(storage.containsKey(THING_UID.getAsString()), is(false)); + assertThat(thingRegistry.get(THING.getUID()), is(equalTo(null))); }, SafeCaller.DEFAULT_TIMEOUT - 100, 50); + + assertThat(storage.containsKey(THING_UID.getAsString()), is(true)); } private void assertThingStatus(Map propsThing, Map propsChannel, ThingStatus status,