Search in sources :

Example 1 with ThingModel

use of org.eclipse.smarthome.model.thing.thing.ThingModel in project smarthome by eclipse.

the class GenericThingProviderMultipleBundlesTest method setup.

@Before
public void setup() {
    thingProvider = new GenericThingProvider();
    Bundle bundle = mock(Bundle.class);
    when(bundle.getSymbolicName()).thenReturn(BUNDLE_NAME);
    BundleResolver bundleResolver = mock(BundleResolver.class);
    when(bundleResolver.resolveBundle(any(Class.class))).thenReturn(bundle);
    thingProvider.setBundleResolver(bundleResolver);
    ModelRepository modelRepository = mock(ModelRepository.class);
    ThingModel thingModel = mock(ThingModel.class);
    EList<ModelThing> dslThings = createModelBridge();
    when(thingModel.getThings()).thenReturn(dslThings);
    when(modelRepository.getModel(TEST_MODEL_THINGS)).thenReturn(thingModel);
    thingProvider.setModelRepository(modelRepository);
    // configure bridgeHandlerFactory to accept the bridge type UID and create a bridge:
    bridgeHandlerFactory = mock(ThingHandlerFactory.class);
    when(bridgeHandlerFactory.supportsThingType(BRIDGE_TYPE_UID)).thenReturn(true);
    when(bridgeHandlerFactory.createThing(eq(BRIDGE_TYPE_UID), any(Configuration.class), eq(BRIDGE_UID), eq(null))).thenReturn(BridgeBuilder.create(BRIDGE_TYPE_UID, BRIDGE_ID).build());
    thingProvider.addThingHandlerFactory(bridgeHandlerFactory);
    // configure thingHandlerFactory to accept the thing type UID and create a thing:
    thingHandlerFactory = mock(ThingHandlerFactory.class);
    when(thingHandlerFactory.supportsThingType(THING_TYPE_UID)).thenReturn(true);
    when(thingHandlerFactory.createThing(eq(THING_TYPE_UID), any(Configuration.class), eq(THING_UID), eq(BRIDGE_UID))).thenReturn(ThingBuilder.create(THING_TYPE_UID, THING_ID).build());
    thingProvider.addThingHandlerFactory(thingHandlerFactory);
}
Also used : BundleResolver(org.eclipse.smarthome.core.util.BundleResolver) ModelRepository(org.eclipse.smarthome.model.core.ModelRepository) Configuration(org.eclipse.smarthome.config.core.Configuration) Bundle(org.osgi.framework.Bundle) ThingModel(org.eclipse.smarthome.model.thing.thing.ThingModel) ThingHandlerFactory(org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory) ModelThing(org.eclipse.smarthome.model.thing.thing.ModelThing) Before(org.junit.Before)

Aggregations

Configuration (org.eclipse.smarthome.config.core.Configuration)1 ThingHandlerFactory (org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory)1 BundleResolver (org.eclipse.smarthome.core.util.BundleResolver)1 ModelRepository (org.eclipse.smarthome.model.core.ModelRepository)1 ModelThing (org.eclipse.smarthome.model.thing.thing.ModelThing)1 ThingModel (org.eclipse.smarthome.model.thing.thing.ThingModel)1 Before (org.junit.Before)1 Bundle (org.osgi.framework.Bundle)1