use of org.openhab.core.thing.link.ItemChannelLink in project openhab-addons by openhab.
the class AbstractModbusOSGiTest method tearDownAbstractModbusOSGiTest.
@AfterEach
public void tearDownAbstractModbusOSGiTest() throws Exception {
logger.debug("tearDownAbstractModbusOSGiTest BEGIN");
swapModbusManagerToReal();
for (Item item : addedItems) {
assertNotNull(itemProvider.remove(item.getName()));
}
for (Thing thing : addedThings) {
disposeThing(thing);
}
for (ItemChannelLink link : addedLinks) {
logger.debug("Unlinking {} <-> {}", link.getItemName(), link.getLinkedUID());
assertNotNull(itemChannelLinkProvider.remove(link.getUID()));
}
logger.debug("tearDownAbstractModbusOSGiTest END");
}
use of org.openhab.core.thing.link.ItemChannelLink in project openhab-addons by openhab.
the class AbstractMieleThingHandlerTest method linkChannelsToItems.
private void linkChannelsToItems(Thing thing) {
ItemChannelLinkRegistry itemChannelLinkRegistry = getService(ItemChannelLinkRegistry.class, ItemChannelLinkRegistry.class);
assertNotNull(itemChannelLinkRegistry);
for (Channel channel : thing.getChannels()) {
String itemName = channel.getUID().getId();
assertNotNull(itemName);
ChannelUID channelUid = channel.getUID();
assertNotNull(channelUid);
ItemChannelLink link = itemChannelLinkRegistry.add(new ItemChannelLink(itemName, channelUid));
assertNotNull(link);
}
}
use of org.openhab.core.thing.link.ItemChannelLink in project openhab-addons by openhab.
the class WWNThingHandlerOSGiTest method createAndLinkItems.
protected void createAndLinkItems() {
thing.getChannels().forEach(c -> {
String itemName = getItemName(c.getUID().getId());
Item item = itemFactory.createItem(c.getAcceptedItemType(), itemName);
if (item != null) {
itemRegistry.add(item);
}
managedItemChannelLinkProvider.add(new ItemChannelLink(itemName, c.getUID()));
});
}
use of org.openhab.core.thing.link.ItemChannelLink in project openhab-addons by openhab.
the class SysteminfoOSGiTest method intializeItem.
private void intializeItem(ChannelUID channelUID, String itemName, String acceptedItemType) {
if (acceptedItemType.equals("Number")) {
testItem = new NumberItem(itemName);
} else if (acceptedItemType.equals("String")) {
testItem = new StringItem(itemName);
}
itemRegistry.add(testItem);
ManagedItemChannelLinkProvider itemChannelLinkProvider = getService(ManagedItemChannelLinkProvider.class);
assertThat(itemChannelLinkProvider, is(notNullValue()));
itemChannelLinkProvider.add(new ItemChannelLink(itemName, channelUID));
}
use of org.openhab.core.thing.link.ItemChannelLink in project openhab-core by openhab.
the class ItemChannelLinkResourceOSGiTest method beforeEach.
@BeforeEach
public void beforeEach() {
registerVolatileStorageService();
itemChannelLinkResource = getService(RESTResource.class, ItemChannelLinkResource.class);
assertNotNull(itemChannelLinkResource);
itemChannelLinkRegistry = getService(ItemChannelLinkRegistry.class);
assertNotNull(itemChannelLinkRegistry);
managedItemChannelLinkProvider = getService(ManagedItemChannelLinkProvider.class);
assertNotNull(managedItemChannelLinkProvider);
link1 = new ItemChannelLink(ITEM_NAME1, new ChannelUID(CHANNEL_UID1));
link2 = new ItemChannelLink(ITEM_NAME2, new ChannelUID(CHANNEL_UID2));
link3 = new ItemChannelLink(ITEM_NAME3, new ChannelUID(THING_TYPE_UID + ":" + UID + ":3"));
when(itemChannelLinkProviderMock.getAll()).thenReturn(List.of(link1, link2, link3));
registerService(itemChannelLinkProviderMock);
waitForAssert(() -> {
assertThat(itemChannelLinkRegistry.getAll(), hasSize(3));
});
when(uriBuilderMock.build(any())).thenReturn(URI.create(""));
when(uriInfoMock.getAbsolutePathBuilder()).thenReturn(uriBuilderMock);
when(uriInfoMock.getPath()).thenReturn("");
when(httpHeadersMock.getHeaderString(anyString())).thenReturn(null);
}
Aggregations