Search in sources :

Example 1 with ThingLinkManager

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);
}
Also used : Locale(java.util.Locale) ManagedItemChannelLinkProvider(org.eclipse.smarthome.core.thing.link.ManagedItemChannelLinkProvider) EventPublisher(org.eclipse.smarthome.core.events.EventPublisher) Bundle(org.osgi.framework.Bundle) ReadyService(org.eclipse.smarthome.core.service.ReadyService) ThingLinkManager(org.eclipse.smarthome.core.thing.link.ThingLinkManager) ItemRegistry(org.eclipse.smarthome.core.items.ItemRegistry) BundleResolver(org.eclipse.smarthome.core.util.BundleResolver) ChannelTypeUID(org.eclipse.smarthome.core.thing.type.ChannelTypeUID) ThingTypeMigrationService(org.eclipse.smarthome.core.thing.ThingTypeMigrationService) ChannelTypeProvider(org.eclipse.smarthome.core.thing.type.ChannelTypeProvider) ManagedThingProvider(org.eclipse.smarthome.core.thing.ManagedThingProvider) ItemChannelLinkRegistry(org.eclipse.smarthome.core.thing.link.ItemChannelLinkRegistry) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) ReadyMarker(org.eclipse.smarthome.core.service.ReadyMarker) Before(org.junit.Before)

Aggregations

Locale (java.util.Locale)1 EventPublisher (org.eclipse.smarthome.core.events.EventPublisher)1 ItemRegistry (org.eclipse.smarthome.core.items.ItemRegistry)1 ReadyMarker (org.eclipse.smarthome.core.service.ReadyMarker)1 ReadyService (org.eclipse.smarthome.core.service.ReadyService)1 ManagedThingProvider (org.eclipse.smarthome.core.thing.ManagedThingProvider)1 ThingTypeMigrationService (org.eclipse.smarthome.core.thing.ThingTypeMigrationService)1 ItemChannelLinkRegistry (org.eclipse.smarthome.core.thing.link.ItemChannelLinkRegistry)1 ManagedItemChannelLinkProvider (org.eclipse.smarthome.core.thing.link.ManagedItemChannelLinkProvider)1 ThingLinkManager (org.eclipse.smarthome.core.thing.link.ThingLinkManager)1 ChannelTypeProvider (org.eclipse.smarthome.core.thing.type.ChannelTypeProvider)1 ChannelTypeUID (org.eclipse.smarthome.core.thing.type.ChannelTypeUID)1 BundleResolver (org.eclipse.smarthome.core.util.BundleResolver)1 Before (org.junit.Before)1 Bundle (org.osgi.framework.Bundle)1 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)1