Java Code Examples for org.eclipse.smarthome.core.thing.binding.ThingHandler#initialize()

The following examples show how to use org.eclipse.smarthome.core.thing.binding.ThingHandler#initialize() . 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: AstroValidConfigurationTest.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
private void assertThingStatus(Configuration configuration, ThingStatus expectedStatus) {
    ThingUID thingUID = new ThingUID(THING_TYPE_SUN, TEST_SUN_THING_ID);

    Thing thing = mock(Thing.class);
    when(thing.getConfiguration()).thenReturn(configuration);
    when(thing.getUID()).thenReturn(thingUID);

    ThingHandlerCallback callback = mock(ThingHandlerCallback.class);
    CronScheduler cronScheduler = mock(CronScheduler.class);
    ThingHandler sunHandler = new SunHandler(thing, cronScheduler);
    sunHandler.setCallback(callback);

    sunHandler.initialize();

    ThingStatusInfo expectedThingStatus = new ThingStatusInfo(expectedStatus, ThingStatusDetail.NONE, null);
    verify(callback, times(1)).statusUpdated(thing, expectedThingStatus);
}
 
Example 2
Source File: AbstractDmxThingTest.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
protected void assertThingStatusWithoutBridge(ThingHandler handler) {
    handler.setCallback(mockCallback);
    handler.initialize();
    waitForAssert(() -> {
        assertEquals(ThingStatus.OFFLINE, handler.getThing().getStatus());
        assertEquals(ThingStatusDetail.CONFIGURATION_ERROR, handler.getThing().getStatusInfo().getStatusDetail());
    });
}
 
Example 3
Source File: AbstractDmxThingTest.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
protected void initializeHandler(ThingHandler handler) {
    handler.getThing().setHandler(handler);
    handler.setCallback(mockCallback);
    handler.initialize();
}