org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory Java Examples
The following examples show how to use
org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DynamicThingUpdateOSGITest.java From smarthome with Eclipse Public License 2.0 | 6 votes |
private ThingHandlerFactory createThingHandlerFactory() { ThingHandlerFactory thingHandlerFactory = new BaseThingHandlerFactory() { @Override public boolean supportsThingType(@NonNull ThingTypeUID thingTypeUID) { return THING_TYPE_UID.equals(thingTypeUID); } @Override protected @Nullable ThingHandler createHandler(@NonNull Thing thing) { thingHandler = createThingHandler(thing); return thingHandler; } }; return thingHandlerFactory; }
Example #2
Source File: ThingManagerOSGiJavaTest.java From smarthome with Eclipse Public License 2.0 | 5 votes |
private AtomicReference<ThingHandlerCallback> initializeThingHandlerCallback() throws Exception { registerThingTypeProvider(); registerChannelTypeProvider(); registerChannelGroupTypeProvider(); AtomicReference<ThingHandlerCallback> thc = new AtomicReference<>(); ThingHandlerFactory thingHandlerFactory = new BaseThingHandlerFactory() { @Override public boolean supportsThingType(@NonNull ThingTypeUID thingTypeUID) { return true; } @Override protected @Nullable ThingHandler createHandler(@NonNull Thing thing) { ThingHandler mockHandler = mock(ThingHandler.class); doAnswer(a -> { thc.set((ThingHandlerCallback) a.getArguments()[0]); return null; }).when(mockHandler).setCallback(any(ThingHandlerCallback.class)); when(mockHandler.getThing()).thenReturn(THING); return mockHandler; } }; registerService(thingHandlerFactory, ThingHandlerFactory.class.getName()); new Thread((Runnable) () -> managedThingProvider.add(THING)).start(); waitForAssert(() -> { assertNotNull(thc.get()); }); return thc; }