[automation] conditions related to the ThingStatus (#5231)

Signed-off-by: Jörg Sautter <joerg.sautter@gmx.net>
This commit is contained in:
joerg1985
2026-02-28 18:10:58 +01:00
committed by GitHub
parent 01c20d59ad
commit 0c2db221b0
14 changed files with 467 additions and 19 deletions
@@ -63,6 +63,7 @@ import org.openhab.core.service.StartLevelService;
import org.openhab.core.storage.StorageService;
import org.openhab.core.test.java.JavaOSGiTest;
import org.openhab.core.test.storage.VolatileStorageService;
import org.openhab.core.thing.ThingRegistry;
import org.openhab.core.types.UnDefType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -80,6 +81,7 @@ public class AutomationIntegrationJsonTest extends JavaOSGiTest {
private final Logger logger = LoggerFactory.getLogger(AutomationIntegrationJsonTest.class);
private @NonNullByDefault({}) EventPublisher eventPublisher;
private @NonNullByDefault({}) ThingRegistry thingRegistry;
private @NonNullByDefault({}) ItemRegistry itemRegistry;
private @NonNullByDefault({}) StartLevelService startLevelService;
private @NonNullByDefault({}) RuleRegistry ruleRegistry;
@@ -97,13 +99,14 @@ public class AutomationIntegrationJsonTest extends JavaOSGiTest {
logger.info("@Before.begin");
eventPublisher = getService(EventPublisher.class);
thingRegistry = getService(ThingRegistry.class);
itemRegistry = getService(ItemRegistry.class);
startLevelService = mock(StartLevelService.class);
when(startLevelService.getStartLevel()).thenReturn(100);
registerService(startLevelService, StartLevelService.class.getName());
CoreModuleHandlerFactory coreModuleHandlerFactory = new CoreModuleHandlerFactory(getBundleContext(),
eventPublisher, itemRegistry, mock(TimeZoneProvider.class), startLevelService);
eventPublisher, thingRegistry, itemRegistry, mock(TimeZoneProvider.class), startLevelService);
mock(CoreModuleHandlerFactory.class);
registerService(coreModuleHandlerFactory);
@@ -82,6 +82,7 @@ import org.openhab.core.service.ReadyMarker;
import org.openhab.core.service.StartLevelService;
import org.openhab.core.storage.StorageService;
import org.openhab.core.test.java.JavaOSGiTest;
import org.openhab.core.thing.ThingRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -96,6 +97,7 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
private final Logger logger = LoggerFactory.getLogger(AutomationIntegrationTest.class);
private @Nullable EventPublisher eventPublisher;
private @Nullable ThingRegistry thingRegistry;
private @Nullable ItemRegistry itemRegistry;
private @NonNullByDefault({}) StartLevelService startLevelService;
private @Nullable RuleRegistry ruleRegistry;
@@ -112,14 +114,15 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
logger.info("@Before.begin");
eventPublisher = getService(EventPublisher.class);
thingRegistry = getService(ThingRegistry.class);
itemRegistry = getService(ItemRegistry.class);
startLevelService = mock(StartLevelService.class);
when(startLevelService.getStartLevel()).thenReturn(100);
registerService(startLevelService, StartLevelService.class.getName());
CoreModuleHandlerFactory coreModuleHandlerFactory = new CoreModuleHandlerFactory(getBundleContext(),
Objects.requireNonNull(eventPublisher), Objects.requireNonNull(itemRegistry),
mock(TimeZoneProvider.class), startLevelService);
Objects.requireNonNull(eventPublisher), Objects.requireNonNull(thingRegistry),
Objects.requireNonNull(itemRegistry), mock(TimeZoneProvider.class), startLevelService);
mock(CoreModuleHandlerFactory.class);
registerService(coreModuleHandlerFactory);
@@ -54,6 +54,7 @@ import org.openhab.core.service.ReadyMarker;
import org.openhab.core.service.StartLevelService;
import org.openhab.core.test.java.JavaOSGiTest;
import org.openhab.core.test.storage.VolatileStorageService;
import org.openhab.core.thing.ThingRegistry;
import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -77,9 +78,11 @@ public class RunRuleModuleTest extends JavaOSGiTest {
when(startLevelService.getStartLevel()).thenReturn(100);
registerService(startLevelService, StartLevelService.class.getName());
EventPublisher eventPublisher = Objects.requireNonNull(getService(EventPublisher.class));
ThingRegistry thingRegistry = Objects.requireNonNull(getService(ThingRegistry.class));
ItemRegistry itemRegistry = Objects.requireNonNull(getService(ItemRegistry.class));
CoreModuleHandlerFactory coreModuleHandlerFactory = new CoreModuleHandlerFactory(getBundleContext(),
eventPublisher, itemRegistry, mock(TimeZoneProvider.class), mock(StartLevelService.class));
eventPublisher, thingRegistry, itemRegistry, mock(TimeZoneProvider.class),
mock(StartLevelService.class));
mock(CoreModuleHandlerFactory.class);
registerService(coreModuleHandlerFactory);
@@ -63,6 +63,7 @@ import org.openhab.core.service.ReadyMarker;
import org.openhab.core.service.StartLevelService;
import org.openhab.core.test.java.JavaOSGiTest;
import org.openhab.core.test.storage.VolatileStorageService;
import org.openhab.core.thing.ThingRegistry;
import org.openhab.core.types.Command;
import org.openhab.core.types.TypeParser;
import org.osgi.framework.ServiceReference;
@@ -88,9 +89,11 @@ public class RuntimeRuleTest extends JavaOSGiTest {
when(startLevelService.getStartLevel()).thenReturn(100);
registerService(startLevelService, StartLevelService.class.getName());
EventPublisher eventPublisher = Objects.requireNonNull(getService(EventPublisher.class));
ThingRegistry thingRegistry = Objects.requireNonNull(getService(ThingRegistry.class));
ItemRegistry itemRegistry = Objects.requireNonNull(getService(ItemRegistry.class));
CoreModuleHandlerFactory coreModuleHandlerFactory = new CoreModuleHandlerFactory(getBundleContext(),
eventPublisher, itemRegistry, mock(TimeZoneProvider.class), mock(StartLevelService.class));
eventPublisher, thingRegistry, itemRegistry, mock(TimeZoneProvider.class),
mock(StartLevelService.class));
mock(CoreModuleHandlerFactory.class);
registerService(coreModuleHandlerFactory);
@@ -62,6 +62,7 @@ import org.openhab.core.service.ReadyMarker;
import org.openhab.core.service.StartLevelService;
import org.openhab.core.test.java.JavaOSGiTest;
import org.openhab.core.test.storage.VolatileStorageService;
import org.openhab.core.thing.ThingRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -91,9 +92,11 @@ public abstract class BasicConditionHandlerTest extends JavaOSGiTest {
when(startLevelService.getStartLevel()).thenReturn(100);
registerService(startLevelService, StartLevelService.class.getName());
EventPublisher eventPublisher = Objects.requireNonNull(getService(EventPublisher.class));
ThingRegistry thingRegistry = Objects.requireNonNull(getService(ThingRegistry.class));
ItemRegistry itemRegistry = Objects.requireNonNull(getService(ItemRegistry.class));
CoreModuleHandlerFactory coreModuleHandlerFactory = new CoreModuleHandlerFactory(getBundleContext(),
eventPublisher, itemRegistry, mock(TimeZoneProvider.class), mock(StartLevelService.class));
eventPublisher, thingRegistry, itemRegistry, mock(TimeZoneProvider.class),
mock(StartLevelService.class));
mock(CoreModuleHandlerFactory.class);
registerService(coreModuleHandlerFactory);
@@ -36,6 +36,7 @@ import org.openhab.core.events.EventPublisher;
import org.openhab.core.i18n.TimeZoneProvider;
import org.openhab.core.items.ItemRegistry;
import org.openhab.core.service.StartLevelService;
import org.openhab.core.thing.ThingRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,9 +61,11 @@ public class DayOfWeekConditionHandlerTest extends BasicConditionHandlerTest {
@BeforeEach
public void before() {
EventPublisher eventPublisher = Objects.requireNonNull(getService(EventPublisher.class));
ThingRegistry thingRegistry = Objects.requireNonNull(getService(ThingRegistry.class));
ItemRegistry itemRegistry = Objects.requireNonNull(getService(ItemRegistry.class));
CoreModuleHandlerFactory coreModuleHandlerFactory = new CoreModuleHandlerFactory(getBundleContext(),
eventPublisher, itemRegistry, mock(TimeZoneProvider.class), mock(StartLevelService.class));
eventPublisher, thingRegistry, itemRegistry, mock(TimeZoneProvider.class),
mock(StartLevelService.class));
mock(CoreModuleHandlerFactory.class);
registerService(coreModuleHandlerFactory);
}
@@ -59,6 +59,7 @@ import org.openhab.core.service.ReadyMarker;
import org.openhab.core.service.StartLevelService;
import org.openhab.core.test.java.JavaOSGiTest;
import org.openhab.core.test.storage.VolatileStorageService;
import org.openhab.core.thing.ThingRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -84,9 +85,11 @@ public class RuntimeRuleTest extends JavaOSGiTest {
when(startLevelService.getStartLevel()).thenReturn(100);
registerService(startLevelService, StartLevelService.class.getName());
EventPublisher eventPublisher = Objects.requireNonNull(getService(EventPublisher.class));
ThingRegistry thingRegistry = Objects.requireNonNull(getService(ThingRegistry.class));
ItemRegistry itemRegistry = Objects.requireNonNull(getService(ItemRegistry.class));
CoreModuleHandlerFactory coreModuleHandlerFactory = new CoreModuleHandlerFactory(getBundleContext(),
eventPublisher, itemRegistry, mock(TimeZoneProvider.class), mock(StartLevelService.class));
eventPublisher, thingRegistry, itemRegistry, mock(TimeZoneProvider.class),
mock(StartLevelService.class));
mock(CoreModuleHandlerFactory.class);
registerService(coreModuleHandlerFactory);
@@ -62,6 +62,7 @@ import org.openhab.core.library.types.OnOffType;
import org.openhab.core.service.ReadyMarker;
import org.openhab.core.service.StartLevelService;
import org.openhab.core.test.java.JavaOSGiTest;
import org.openhab.core.thing.ThingRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -89,9 +90,11 @@ public class RuleEventTest extends JavaOSGiTest {
when(startLevelService.getStartLevel()).thenReturn(100);
registerService(startLevelService, StartLevelService.class.getName());
EventPublisher eventPublisher = Objects.requireNonNull(getService(EventPublisher.class));
ThingRegistry thingRegistry = Objects.requireNonNull(getService(ThingRegistry.class));
ItemRegistry itemRegistry = Objects.requireNonNull(getService(ItemRegistry.class));
CoreModuleHandlerFactory coreModuleHandlerFactory = new CoreModuleHandlerFactory(getBundleContext(),
eventPublisher, itemRegistry, mock(TimeZoneProvider.class), mock(StartLevelService.class));
eventPublisher, thingRegistry, itemRegistry, mock(TimeZoneProvider.class),
mock(StartLevelService.class));
mock(CoreModuleHandlerFactory.class);
registerService(coreModuleHandlerFactory);