Search in sources :

Example 1 with ModelThing

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

the class GenericThingProviderMultipleBundlesTest method createModelBridge.

private EList<ModelThing> createModelBridge() {
    ModelBridge bridge = mock(ModelBridge.class);
    when(bridge.getId()).thenReturn(BRIDGE_UID.toString());
    when(bridge.getProperties()).thenReturn(new BasicEList<>(0));
    when(bridge.getChannels()).thenReturn(new BasicEList<>(0));
    EList<ModelThing> modelThings = createModelThing();
    when(bridge.getThings()).thenReturn(modelThings);
    BasicEList<ModelThing> result = new BasicEList<ModelThing>();
    result.add(bridge);
    return result;
}
Also used : BasicEList(org.eclipse.emf.common.util.BasicEList) ModelBridge(org.eclipse.smarthome.model.thing.thing.ModelBridge) ModelThing(org.eclipse.smarthome.model.thing.thing.ModelThing)

Example 2 with ModelThing

use of org.eclipse.smarthome.model.thing.thing.ModelThing 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)

Example 3 with ModelThing

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

the class GenericThingProviderMultipleBundlesTest method createModelThing.

private EList<ModelThing> createModelThing() {
    ModelThing thing = mock(ModelThing.class);
    // simulate a nested defined thing model with only type id & id given:
    when(thing.getThingTypeId()).thenReturn("thing");
    when(thing.getThingId()).thenReturn(THING_ID);
    when(thing.getBridgeUID()).thenReturn(BRIDGE_UID.toString());
    when(thing.getProperties()).thenReturn(new BasicEList<>(0));
    when(thing.getChannels()).thenReturn(new BasicEList<>(0));
    BasicEList<ModelThing> result = new BasicEList<ModelThing>();
    result.add(thing);
    return result;
}
Also used : BasicEList(org.eclipse.emf.common.util.BasicEList) ModelThing(org.eclipse.smarthome.model.thing.thing.ModelThing)

Aggregations

ModelThing (org.eclipse.smarthome.model.thing.thing.ModelThing)3 BasicEList (org.eclipse.emf.common.util.BasicEList)2 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 ModelBridge (org.eclipse.smarthome.model.thing.thing.ModelBridge)1 ThingModel (org.eclipse.smarthome.model.thing.thing.ThingModel)1 Before (org.junit.Before)1 Bundle (org.osgi.framework.Bundle)1