use of org.openhab.core.items.ItemProvider in project openhab-core by openhab.
the class RunRuleModuleTest method before.
@BeforeEach
public void before() {
registerService(new ItemProvider() {
@Override
public void addProviderChangeListener(final ProviderChangeListener<Item> listener) {
}
@Override
public void removeProviderChangeListener(final ProviderChangeListener<Item> listener) {
}
@Override
public Collection<Item> getAll() {
return List.of(new SwitchItem("switch1"), new SwitchItem("switch2"), new SwitchItem("switch3"), new SwitchItem("ruleTrigger"));
}
});
registerService(volatileStorageService);
// start rule engine
RuleEngineImpl ruleEngine = requireNonNull((RuleEngineImpl) getService(RuleManager.class));
ruleEngine.onReadyMarkerAdded(new ReadyMarker("", ""));
waitForAssert(() -> assertTrue(ruleEngine.isStarted()));
}
use of org.openhab.core.items.ItemProvider in project openhab-core by openhab.
the class ScriptRuleOSGiTest method before.
@BeforeEach
public void before() {
ItemProvider itemProvider = new ItemProvider() {
@Override
public void addProviderChangeListener(ProviderChangeListener<Item> listener) {
}
@Override
public Collection<Item> getAll() {
return List.of(new SwitchItem("MyTrigger"), new SwitchItem("ScriptItem"));
}
@Override
public void removeProviderChangeListener(ProviderChangeListener<Item> listener) {
}
};
registerService(itemProvider);
registerService(volatileStorageService);
EventSubscriber eventSubscriber = new EventSubscriber() {
@Override
public void receive(Event event) {
receivedEvent = (ItemCommandEvent) event;
logger.info("received event from item {}, command {}", receivedEvent.getItemName(), receivedEvent.getItemCommand());
}
@Override
public Set<String> getSubscribedEventTypes() {
return Set.of(ItemCommandEvent.TYPE);
}
@Override
@Nullable
public EventFilter getEventFilter() {
return null;
}
};
registerService(eventSubscriber);
}
use of org.openhab.core.items.ItemProvider in project openhab-core by openhab.
the class BasicConditionHandlerTest method beforeBase.
/**
* This executes before every test and before the
*
* @Before-annotated methods in sub-classes.
*/
@BeforeEach
public void beforeBase() {
ItemProvider itemProvider = new ItemProvider() {
@Override
public void addProviderChangeListener(ProviderChangeListener<Item> listener) {
}
@Override
public Collection<Item> getAll() {
List<Item> items = new ArrayList<>();
items.add(new SwitchItem("TriggeredItem"));
items.add(new SwitchItem("SwitchedItem"));
return items;
}
@Override
public void removeProviderChangeListener(ProviderChangeListener<Item> listener) {
}
};
registerService(itemProvider);
registerService(volatileStorageService);
waitForAssert(() -> {
ruleRegistry = getService(RuleRegistry.class);
assertThat(ruleRegistry, is(notNullValue()));
}, 3000, 100);
waitForAssert(() -> {
ruleEngine = getService(RuleManager.class);
assertThat(ruleEngine, is(notNullValue()));
}, 3000, 100);
// start rule engine
RuleEngineImpl ruleEngine = requireNonNull((RuleEngineImpl) getService(RuleManager.class));
ruleEngine.onReadyMarkerAdded(new ReadyMarker("", ""));
waitForAssert(() -> assertTrue(ruleEngine.isStarted()));
}
use of org.openhab.core.items.ItemProvider in project openhab-core by openhab.
the class RuntimeRuleTest method before.
@BeforeEach
public void before() {
ItemProvider itemProvider = new TestItemProvider(Set.of(new SwitchItem("myLampItem")));
registerService(itemProvider);
registerService(volatileStorageService);
waitForAssert(() -> {
ruleRegistry = getService(RuleRegistry.class);
assertThat("RuleRegistry service not found", ruleRegistry, is(notNullValue()));
}, 3000, 100);
waitForAssert(() -> {
ruleEngine = getService(RuleManager.class);
assertThat("RuleManager service not found", ruleEngine, is(notNullValue()));
}, 3000, 100);
// start rule engine
RuleEngineImpl ruleEngine = requireNonNull((RuleEngineImpl) getService(RuleManager.class));
ruleEngine.onReadyMarkerAdded(new ReadyMarker("", ""));
waitForAssert(() -> assertTrue(ruleEngine.isStarted()));
}
use of org.openhab.core.items.ItemProvider in project openhab-addons by openhab.
the class AbstractModbusOSGiTest method setUpAbstractModbusOSGiTest.
/**
* Before each test, configure mocked services
*/
@BeforeEach
public void setUpAbstractModbusOSGiTest() {
logger.debug("setUpAbstractModbusOSGiTest BEGIN");
registerVolatileStorageService();
registerService(mockedModbusManager);
registerService(stateSubscriber);
swapModbusManagerToMocked();
thingProvider = getService(ThingProvider.class, ManagedThingProvider.class);
assertThat("Could not get ManagedThingProvider", thingProvider, is(notNullValue()));
itemProvider = getService(ItemProvider.class, ManagedItemProvider.class);
assertThat("Could not get ManagedItemProvider", itemProvider, is(notNullValue()));
itemChannelLinkProvider = getService(ItemChannelLinkProvider.class, ManagedItemChannelLinkProvider.class);
assertThat("Could not get ManagedItemChannelLinkProvider", itemChannelLinkProvider, is(notNullValue()));
itemRegistry = getService(ItemRegistry.class);
assertThat("Could not get ItemRegistry", itemRegistry, is(notNullValue()));
coreItemFactory = new CoreItemFactory();
// Clean slate for all tests
reset(mockedModbusManager);
stateSubscriber.stateUpdates.clear();
logger.debug("setUpAbstractModbusOSGiTest END");
}
Aggregations