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