use of org.eclipse.smarthome.core.thing.link.ThingLinkManager in project smarthome by eclipse.
the class ThingManagerOSGiTest method setUp.
@Before
@SuppressWarnings("null")
public void setUp() {
thing = ThingBuilder.create(THING_TYPE_UID, THING_UID).withChannels(ChannelBuilder.create(CHANNEL_UID, "Switch").withKind(ChannelKind.STATE).withType(CHANNEL_TYPE_UID).build()).build();
registerVolatileStorageService();
channelTypeProvider = mock(ChannelTypeProvider.class);
when(channelTypeProvider.getChannelType(any(ChannelTypeUID.class), nullable(Locale.class))).thenReturn(ChannelTypeBuilder.state(CHANNEL_TYPE_UID, "label", "Switch").build());
registerService(channelTypeProvider);
thingLinkManager = getService(ThingLinkManager.class);
thingLinkManager.deactivate();
managedItemChannelLinkProvider = getService(ManagedItemChannelLinkProvider.class);
managedThingProvider = getService(ManagedThingProvider.class);
eventPublisher = getService(EventPublisher.class);
itemRegistry = getService(ItemRegistry.class);
assertNotNull(itemRegistry);
itemChannelLinkRegistry = getService(ItemChannelLinkRegistry.class);
assertNotNull(itemChannelLinkRegistry);
readyService = getService(ReadyService.class);
assertNotNull(readyService);
waitForAssert(() -> {
try {
assertThat(bundleContext.getServiceReferences(ReadyMarker.class, "(" + ThingManagerImpl.XML_THING_TYPE + "=" + bundleContext.getBundle().getSymbolicName() + ")"), is(notNullValue()));
} catch (InvalidSyntaxException e) {
fail("Failed to get service reference: " + e.getMessage());
}
});
waitForAssert(() -> {
try {
assertThat(bundleContext.getServiceReferences(ChannelItemProvider.class, null), is(notNullValue()));
} catch (InvalidSyntaxException e) {
fail("Failed to get service reference: " + e.getMessage());
}
});
Bundle bundle = mock(Bundle.class);
when(bundle.getSymbolicName()).thenReturn("org.eclipse.smarthome.core.thing");
BundleResolver bundleResolver = mock(BundleResolver.class);
when(bundleResolver.resolveBundle(any())).thenReturn(bundle);
ThingManagerImpl thingManager = (ThingManagerImpl) getService(ThingTypeMigrationService.class);
thingManager.setBundleResolver(bundleResolver);
}
Aggregations