diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/util/ThingHandlerHelper.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/util/ThingHandlerHelper.java index 9233a4294..86c438fd5 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/util/ThingHandlerHelper.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/util/ThingHandlerHelper.java @@ -12,6 +12,7 @@ */ package org.openhab.core.thing.util; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.thing.Thing; import org.openhab.core.thing.ThingStatus; import org.openhab.core.thing.binding.ThingHandler; @@ -22,6 +23,7 @@ import org.openhab.core.thing.binding.ThingHandler; * @author Markus Rathgeb - Initial contribution * @author Simon Kaufmann - added UNKNOWN */ +@NonNullByDefault public class ThingHandlerHelper { private ThingHandlerHelper() { diff --git a/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/internal/ChannelLinkNotifierOSGiTest.java b/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/internal/ChannelLinkNotifierOSGiTest.java index a222fccd8..22b7edd5b 100644 --- a/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/internal/ChannelLinkNotifierOSGiTest.java +++ b/itests/org.openhab.core.thing.tests/src/main/java/org/openhab/core/thing/internal/ChannelLinkNotifierOSGiTest.java @@ -18,7 +18,6 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.openMocks; -import static org.openhab.core.thing.util.ThingHandlerHelper.isHandlerInitialized; import java.util.ArrayList; import java.util.HashMap; @@ -58,6 +57,7 @@ import org.openhab.core.thing.link.ItemChannelLinkRegistry; import org.openhab.core.thing.link.ManagedItemChannelLinkProvider; import org.openhab.core.thing.type.ChannelKind; import org.openhab.core.thing.type.ChannelTypeUID; +import org.openhab.core.thing.util.ThingHandlerHelper; import org.openhab.core.types.Command; import org.openhab.core.util.BundleResolver; import org.osgi.framework.Bundle; @@ -96,7 +96,7 @@ public class ChannelLinkNotifierOSGiTest extends JavaOSGiTest { private final @Nullable ThingStatus thingStatus; - private Map> channelLinkEvents = new HashMap<>(); + private final Map> channelLinkEvents = new HashMap<>(); public TestHandler(Thing thing, @Nullable ThingStatus thingStatus) { super(thing); @@ -118,12 +118,12 @@ public class ChannelLinkNotifierOSGiTest extends JavaOSGiTest { @Override public void channelLinked(ChannelUID channelUID) { - channelLinkEvents.get(channelUID).add(Boolean.TRUE); + channelLinkEvents.getOrDefault(channelUID, List.of()).add(Boolean.TRUE); } @Override public void channelUnlinked(ChannelUID channelUID) { - channelLinkEvents.get(channelUID).add(Boolean.FALSE); + channelLinkEvents.getOrDefault(channelUID, List.of()).add(Boolean.FALSE); } public List getChannelLinkEvents(ChannelUID channelUID) { @@ -208,13 +208,13 @@ public class ChannelLinkNotifierOSGiTest extends JavaOSGiTest { private Thing addInitializedThing() { Thing thing = addThing(ThingStatus.ONLINE); - assertThat(isHandlerInitialized(thing.getHandler()), is(true)); + assertThat(ThingHandlerHelper.isHandlerInitialized(getHandler(thing)), is(true)); return thing; } private Thing addUninitializedThing() { Thing thing = addThing(null); - assertThat(isHandlerInitialized(thing.getHandler()), is(false)); + assertThat(ThingHandlerHelper.isHandlerInitialized(getHandler(thing)), is(false)); return thing; }