ThingManagerImpl implements ThingManager, ThingTracker, ThingTypeMigrationService, ReadyService.ReadyTracker { @Override public boolean isEnabled(ThingUID thingUID) { Thing thing = getThing(thingUID); if (thing != null) { return thing.isEnabled(); } logger.debug("Thing with UID {} is unknown. Will try to get the enabled status from the persistent storage.", thingUID); return !isDisabledByStorage(thingUID); } @Activate  ThingManagerImpl( //
            final @Reference BundleResolver bundleResolver,
            final @Reference ChannelGroupTypeRegistry channelGroupTypeRegistry,
            final @Reference ChannelTypeRegistry channelTypeRegistry,
            final @Reference CommunicationManager communicationManager,
            final @Reference ConfigDescriptionRegistry configDescriptionRegistry,
            final @Reference ConfigDescriptionValidator configDescriptionValidator,
            final @Reference EventPublisher eventPublisher,
            final @Reference ItemChannelLinkRegistry itemChannelLinkRegistry,
            final @Reference ReadyService readyService, //
            final @Reference SafeCaller safeCaller, //
            final @Reference StorageService storageService, //
            final @Reference ThingRegistry thingRegistry,
            final @Reference ThingStatusInfoI18nLocalizationService thingStatusInfoI18nLocalizationService,
            final @Reference ThingTypeRegistry thingTypeRegistry); @Override void migrateThingType(final Thing thing, final ThingTypeUID thingTypeUID,
            final @Nullable Configuration configuration); @Override void thingAdded(Thing thing, ThingTrackerEvent thingTrackerEvent); @Override void thingRemoving(Thing thing, ThingTrackerEvent thingTrackerEvent); @Override void thingRemoved(final Thing thing, ThingTrackerEvent thingTrackerEvent); @Override void thingUpdated(final Thing thing, ThingTrackerEvent thingTrackerEvent); @Override void onReadyMarkerAdded(ReadyMarker readyMarker); @Override void onReadyMarkerRemoved(ReadyMarker readyMarker); @Override void setEnabled(ThingUID thingUID, boolean enabled); @Override boolean isEnabled(ThingUID thingUID);  }
@Test public void isEnabledWithUnknownThingUIDAndNullStorage() throws Exception { ThingUID unknownUID = new ThingUID("someBundle", "someType", "someID"); when(storageServiceMock.getStorage(eq("thing_status_storage"), any(ClassLoader.class))).thenReturn(storageMock); ThingManagerImpl thingManager = createThingManager(); assertTrue(thingManager.isEnabled(unknownUID)); }
@Test public void isEnabledWithUnknownThingUIDAndNonNullStorage() throws Exception { ThingUID unknownUID = new ThingUID("someBundle", "someType", "someID"); when(storageMock.containsKey(unknownUID.getAsString())).thenReturn(false); when(storageServiceMock.getStorage(eq("thing_status_storage"), any(ClassLoader.class))).thenReturn(storageMock); ThingManagerImpl thingManager = createThingManager(); assertTrue(thingManager.isEnabled(unknownUID)); when(storageMock.containsKey(unknownUID.getAsString())).thenReturn(true); when(storageServiceMock.getStorage(eq("thing_status_storage"), any(ClassLoader.class))).thenReturn(storageMock); assertFalse(thingManager.isEnabled(unknownUID)); }