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;
}
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);
}
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;
}
Aggregations