import org.openhab.binding.mielecloud.internal.auth.OAuthTokenRefresher;
import org.openhab.binding.mielecloud.internal.auth.OpenHabOAuthTokenRefresher;
import org.openhab.binding.mielecloud.internal.util.MieleCloudBindingIntegrationTestConstants;
+import org.openhab.binding.mielecloud.internal.util.ReflectionUtil;
import org.openhab.binding.mielecloud.internal.webservice.MieleWebservice;
import org.openhab.binding.mielecloud.internal.webservice.MieleWebserviceFactory;
import org.openhab.binding.mielecloud.internal.webservice.api.DeviceState;
ThingHandler handler = thing.getHandler();
assertNotNull(handler);
- return (AbstractMieleThingHandler) Objects.requireNonNull(handler);
+ AbstractMieleThingHandler mieleThingHandler = (AbstractMieleThingHandler) Objects.requireNonNull(handler);
+
+ waitForAssert(() -> {
+ try {
+ assertNotNull(ReflectionUtil.invokePrivate(mieleThingHandler, "getBridge"));
+ } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException e) {
+ throw new RuntimeException(e);
+ }
+ assertNotNull(getBridge().getThing(thingUid));
+ });
+
+ return mieleThingHandler;
}
private List<Channel> createChannelsForThingHandler(ThingTypeUID thingTypeUid, ThingUID thingUid) {
setUpThingRegistry();
setUpItemRegistry();
setUpWebservice();
+ }
+
+ protected void setUpBridgeAndThing() throws Exception {
setUpBridge();
thingHandler = setUpThingHandler();
}
@Test
public void testCachedStateIsQueriedOnInitialize() throws Exception {
+ // given:
+ setUpBridgeAndThing();
+
// then:
verify(getWebserviceMock()).dispatchDeviceState(SERIAL_NUMBER);
}
@Test
- public void testThingStatusIsOfflineWithDetailGoneAndDetailMessageWhenDeviceIsRemoved() {
+ public void testThingStatusIsOfflineWithDetailGoneAndDetailMessageWhenDeviceIsRemoved() throws Exception {
+ // given:
+ setUpBridgeAndThing();
+
// when:
getBridgeHandler().onDeviceRemoved(SERIAL_NUMBER);
}
@Test
- public void testStatusIsSetToOnlineWhenDeviceStateIsValid() {
+ public void testStatusIsSetToOnlineWhenDeviceStateIsValid() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = createDeviceStateMock(StateType.ON, "On");
// when:
}
@Test
- public void testStatusIsSetToOfflineWhenDeviceIsNotConnected() {
+ public void testStatusIsSetToOfflineWhenDeviceIsNotConnected() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = createDeviceStateMock(StateType.NOT_CONNECTED, "Not connected");
// when:
}
@Test
- public void testFailingPutProcessActionDoesNotSetTheDeviceToOffline() {
+ public void testFailingPutProcessActionDoesNotSetTheDeviceToOffline() throws Exception {
// given:
+ doThrow(MieleWebserviceException.class).when(getWebserviceMock()).putProcessAction(any(),
+ eq(ProcessAction.STOP));
+
+ setUpBridgeAndThing();
+
DeviceState deviceState = createDeviceStateMock(StateType.ON, "On");
getBridgeHandler().onDeviceStateUpdated(deviceState);
assertThingStatusIs(getThingHandler().getThing(), ThingStatus.ONLINE, ThingStatusDetail.NONE);
- doThrow(MieleWebserviceException.class).when(getWebserviceMock()).putProcessAction(any(),
- eq(ProcessAction.STOP));
-
// when:
getThingHandler().triggerProcessAction(ProcessAction.STOP);
}
@Test
- public void testHandleCommandProgramStartToStartStopChannel() {
+ public void testHandleCommandProgramStartToStartStopChannel() throws Exception {
+ // given:
+ setUpBridgeAndThing();
+
// when:
getThingHandler().handleCommand(channel(PROGRAM_START_STOP),
new StringType(ProgramStatus.PROGRAM_STARTED.getState()));
}
@Test
- public void testHandleCommandProgramStopToStartStopChannel() {
+ public void testHandleCommandProgramStopToStartStopChannel() throws Exception {
+ // given:
+ setUpBridgeAndThing();
+
// when:
getThingHandler().handleCommand(channel(PROGRAM_START_STOP),
new StringType(ProgramStatus.PROGRAM_STOPPED.getState()));
}
@Test
- public void testHandleCommandProgramStartToStartStopPauseChannel() {
+ public void testHandleCommandProgramStartToStartStopPauseChannel() throws Exception {
+ // given:
+ setUpBridgeAndThing();
+
// when:
getThingHandler().handleCommand(channel(PROGRAM_START_STOP_PAUSE),
new StringType(ProgramStatus.PROGRAM_STARTED.getState()));
}
@Test
- public void testHandleCommandProgramStopToStartStopPauseChannel() {
+ public void testHandleCommandProgramStopToStartStopPauseChannel() throws Exception {
+ // given:
+ setUpBridgeAndThing();
+
// when:
getThingHandler().handleCommand(channel(PROGRAM_START_STOP_PAUSE),
new StringType(ProgramStatus.PROGRAM_STOPPED.getState()));
}
@Test
- public void testHandleCommandProgramPauseToStartStopPauseChannel() {
+ public void testHandleCommandProgramPauseToStartStopPauseChannel() throws Exception {
+ // given:
+ setUpBridgeAndThing();
+
// when:
getThingHandler().handleCommand(channel(PROGRAM_START_STOP_PAUSE),
new StringType(ProgramStatus.PROGRAM_PAUSED.getState()));
}
@Test
- public void testFailingPutLightDoesNotSetTheDeviceToOffline() {
+ public void testFailingPutLightDoesNotSetTheDeviceToOffline() throws Exception {
// given:
+ doThrow(MieleWebserviceException.class).when(getWebserviceMock()).putLight(any(), eq(true));
+
+ setUpBridgeAndThing();
+
DeviceState deviceState = createDeviceStateMock(StateType.ON, "On");
getBridgeHandler().onDeviceStateUpdated(deviceState);
assertThingStatusIs(getThingHandler().getThing(), ThingStatus.ONLINE, ThingStatusDetail.NONE);
- doThrow(MieleWebserviceException.class).when(getWebserviceMock()).putLight(any(), eq(true));
-
// when:
getThingHandler().triggerLight(true);
}
@Test
- public void testHandleCommandLightOff() {
+ public void testHandleCommandLightOff() throws Exception {
+ // given:
+ setUpBridgeAndThing();
+
// when:
getThingHandler().handleCommand(channel(LIGHT_SWITCH), OnOffType.OFF);
}
@Test
- public void testHandleCommandLightOn() {
+ public void testHandleCommandLightOn() throws Exception {
+ // given:
+ setUpBridgeAndThing();
+
// when:
getThingHandler().handleCommand(channel(LIGHT_SWITCH), OnOffType.ON);
}
@Test
- public void testHandleCommandDoesNothingWhenCommandIsNotOfOnOffType() {
+ public void testHandleCommandDoesNothingWhenCommandIsNotOfOnOffType() throws Exception {
+ // given:
+ setUpBridgeAndThing();
+
// when:
getThingHandler().handleCommand(channel(LIGHT_SWITCH), new DecimalType(0));
}
@Test
- public void testHandleCommandPowerOn() {
+ public void testHandleCommandPowerOn() throws Exception {
+ // given:
+ setUpBridgeAndThing();
+
// when:
getThingHandler().handleCommand(channel(POWER_ON_OFF), OnOffType.ON);
}
@Test
- public void testHandleCommandPowerOff() {
+ public void testHandleCommandPowerOff() throws Exception {
+ // given:
+ setUpBridgeAndThing();
+
// when:
getThingHandler().handleCommand(channel(POWER_ON_OFF), OnOffType.OFF);
}
@Test
- public void testHandleCommandDoesNothingWhenPowerCommandIsNotOfOnOffType() {
+ public void testHandleCommandDoesNothingWhenPowerCommandIsNotOfOnOffType() throws Exception {
+ // given:
+ setUpBridgeAndThing();
+
// when:
getThingHandler().handleCommand(channel(POWER_ON_OFF), new DecimalType(0));
}
@Test
- public void testMissingPropertiesAreSetWhenAStateUpdateIsReceivedFromTheCloud() {
+ public void testMissingPropertiesAreSetWhenAStateUpdateIsReceivedFromTheCloud() throws Exception {
// given:
+ setUpBridgeAndThing();
+
assertFalse(getThingHandler().getThing().getProperties().containsKey(Thing.PROPERTY_SERIAL_NUMBER));
assertFalse(getThingHandler().getThing().getProperties().containsKey(Thing.PROPERTY_MODEL_ID));
}
@Test
- public void testChannelUpdatesForNullValues() {
+ public void testChannelUpdatesForNullValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.getDeviceIdentifier()).thenReturn(COFFEE_SYSTEM_THING_UID.getId());
when(deviceState.isRemoteControlEnabled()).thenReturn(Optional.empty());
}
@Test
- public void testChannelUpdatesForValidValues() {
+ public void testChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.getDeviceIdentifier()).thenReturn(COFFEE_SYSTEM_THING_UID.getId());
when(deviceState.isRemoteControlEnabled()).thenReturn(Optional.of(true));
}
@Test
- public void testFinishStateChannelIsSetToOnWhenProgramHasFinished() {
+ public void testFinishStateChannelIsSetToOnWhenProgramHasFinished() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceStateBefore = mock(DeviceState.class);
when(deviceStateBefore.getDeviceIdentifier()).thenReturn(COFFEE_SYSTEM_THING_UID.getId());
when(deviceStateBefore.getStateType()).thenReturn(Optional.of(StateType.RUNNING));
}
@Test
- public void testTransitionChannelUpdatesForNullValues() {
+ public void testTransitionChannelUpdatesForNullValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceStateBefore = mock(DeviceState.class);
when(deviceStateBefore.getDeviceIdentifier()).thenReturn(COFFEE_SYSTEM_THING_UID.getId());
when(deviceStateBefore.getStateType()).thenReturn(Optional.of(StateType.RUNNING));
}
@Test
- public void testTransitionChannelUpdatesForValidValues() {
+ public void testTransitionChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceStateBefore = mock(DeviceState.class);
when(deviceStateBefore.getDeviceIdentifier()).thenReturn(COFFEE_SYSTEM_THING_UID.getId());
when(deviceStateBefore.getStateType()).thenReturn(Optional.of(StateType.RUNNING));
}
@Test
- public void testActionsChannelUpdatesForValidValues() {
+ public void testActionsChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
ActionsState actionsState = mock(ActionsState.class);
when(actionsState.getDeviceIdentifier()).thenReturn(COFFEE_SYSTEM_THING_UID.getId());
when(actionsState.canBeSwitchedOn()).thenReturn(true);
}
@Test
- public void testChannelUpdatesForNullValues() {
+ public void testChannelUpdatesForNullValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.getDeviceIdentifier()).thenReturn(FRIDGE_FREEZER_DEVICE_THING_UID.getId());
when(deviceState.getRawType()).thenReturn(DeviceType.FRIDGE_FREEZER_COMBINATION);
}
@Test
- public void testChannelUpdatesForValidValues() {
+ public void testChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.getDeviceIdentifier()).thenReturn(FRIDGE_FREEZER_DEVICE_THING_UID.getId());
when(deviceState.getRawType()).thenReturn(DeviceType.FRIDGE_FREEZER_COMBINATION);
}
@Test
- public void testChannelUpdatesForSuperCooling() {
+ public void testChannelUpdatesForSuperCooling() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.getDeviceIdentifier()).thenReturn(FRIDGE_FREEZER_DEVICE_THING_UID.getId());
when(deviceState.getRawType()).thenReturn(DeviceType.FRIDGE_FREEZER_COMBINATION);
}
@Test
- public void testChannelUpdatesForSuperFreezing() {
+ public void testChannelUpdatesForSuperFreezing() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.getDeviceIdentifier()).thenReturn(FRIDGE_FREEZER_DEVICE_THING_UID.getId());
when(deviceState.getRawType()).thenReturn(DeviceType.FRIDGE_FREEZER_COMBINATION);
}
@Test
- public void testChannelUpdatesForSuperCollingSuperFreezing() {
+ public void testChannelUpdatesForSuperCollingSuperFreezing() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.getDeviceIdentifier()).thenReturn(FRIDGE_FREEZER_DEVICE_THING_UID.getId());
when(deviceState.getRawType()).thenReturn(DeviceType.FRIDGE_FREEZER_COMBINATION);
}
@Test
- public void testActionsChannelUpdatesForValidValues() {
+ public void testActionsChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
ActionsState actionsState = mock(ActionsState.class);
when(actionsState.getDeviceIdentifier()).thenReturn(FRIDGE_FREEZER_DEVICE_THING_UID.getId());
when(actionsState.canContolSupercooling()).thenReturn(true);
@Override
@Test
- public void testHandleCommandDoesNothingWhenCommandIsNotOfOnOffType() {
+ public void testHandleCommandDoesNothingWhenCommandIsNotOfOnOffType() throws Exception {
+ // given:
+ setUpBridgeAndThing();
+
// when:
getThingHandler().handleCommand(channel(FRIDGE_SUPER_COOL), new DecimalType(50));
}
@Test
- public void testHandleCommandStartsSupercoolingWhenRequested() {
+ public void testHandleCommandStartsSupercoolingWhenRequested() throws Exception {
+ // given:
+ setUpBridgeAndThing();
+
// when:
getThingHandler().handleCommand(channel(FRIDGE_SUPER_COOL), OnOffType.ON);
}
@Test
- public void testHandleCommandStopsSupercoolingWhenRequested() {
+ public void testHandleCommandStopsSupercoolingWhenRequested() throws Exception {
+ // given:
+ setUpBridgeAndThing();
+
// when:
getThingHandler().handleCommand(channel(FRIDGE_SUPER_COOL), OnOffType.OFF);
}
@Test
- public void testHandleCommandStartsSuperfreezingWhenRequested() {
+ public void testHandleCommandStartsSuperfreezingWhenRequested() throws Exception {
+ // given:
+ setUpBridgeAndThing();
+
// when:
getThingHandler().handleCommand(channel(FREEZER_SUPER_FREEZE), OnOffType.ON);
}
@Test
- public void testHandleCommandStopsSuperfreezingWhenRequested() {
+ public void testHandleCommandStopsSuperfreezingWhenRequested() throws Exception {
+ // given:
+ setUpBridgeAndThing();
+
// when:
getThingHandler().handleCommand(channel(FREEZER_SUPER_FREEZE), OnOffType.OFF);
}
@Test
- public void testChannelUpdatesForNullValues() {
+ public void testChannelUpdatesForNullValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.getDeviceIdentifier())
.thenReturn(MieleCloudBindingIntegrationTestConstants.DISH_WARMER_DEVICE_THING_UID.getId());
}
@Test
- public void testChannelUpdatesForValidValues() {
+ public void testChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.getDeviceIdentifier())
.thenReturn(MieleCloudBindingIntegrationTestConstants.DISH_WARMER_DEVICE_THING_UID.getId());
}
@Test
- public void testFinishStateChannelIsSetToOnWhenProgramHasFinished() {
+ public void testFinishStateChannelIsSetToOnWhenProgramHasFinished() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceStateBefore = mock(DeviceState.class);
when(deviceStateBefore.getDeviceIdentifier())
.thenReturn(MieleCloudBindingIntegrationTestConstants.DISH_WARMER_DEVICE_THING_UID.getId());
}
@Test
- public void testTransitionChannelUpdatesForNullValues() {
+ public void testTransitionChannelUpdatesForNullValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceStateBefore = mock(DeviceState.class);
when(deviceStateBefore.getDeviceIdentifier())
.thenReturn(MieleCloudBindingIntegrationTestConstants.DISH_WARMER_DEVICE_THING_UID.getId());
}
@Test
- public void testTransitionChannelUpdatesForValidValues() {
+ public void testTransitionChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceStateBefore = mock(DeviceState.class);
when(deviceStateBefore.getDeviceIdentifier())
.thenReturn(MieleCloudBindingIntegrationTestConstants.DISH_WARMER_DEVICE_THING_UID.getId());
}
@Test
- public void testActionsChannelUpdatesForValidValues() {
+ public void testActionsChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
ActionsState actionsState = mock(ActionsState.class);
when(actionsState.getDeviceIdentifier())
.thenReturn(MieleCloudBindingIntegrationTestConstants.DISH_WARMER_DEVICE_THING_UID.getId());
}
@Test
- public void testHandleCommandDishWarmerProgramActive() {
+ public void testHandleCommandDishWarmerProgramActive() throws Exception {
+ // given:
+ setUpBridgeAndThing();
+
// when:
getThingHandler().handleCommand(channel(DISH_WARMER_PROGRAM_ACTIVE), new StringType("3"));
}
@Test
- public void testChannelUpdatesForNullValues() {
+ public void testChannelUpdatesForNullValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.getDeviceIdentifier()).thenReturn(DISHWASHER_DEVICE_THING_UID.getId());
when(deviceState.getStateType()).thenReturn(Optional.empty());
}
@Test
- public void testChannelUpdatesForValidValues() {
+ public void testChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.isInState(any())).thenCallRealMethod();
when(deviceState.getDeviceIdentifier()).thenReturn(DISHWASHER_DEVICE_THING_UID.getId());
}
@Test
- public void testFinishStateChannelIsSetToOnWhenProgramHasFinished() {
+ public void testFinishStateChannelIsSetToOnWhenProgramHasFinished() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceStateBefore = mock(DeviceState.class);
when(deviceStateBefore.getDeviceIdentifier()).thenReturn(DISHWASHER_DEVICE_THING_UID.getId());
when(deviceStateBefore.getStateType()).thenReturn(Optional.of(StateType.RUNNING));
}
@Test
- public void testTransitionChannelUpdatesForNullValues() {
+ public void testTransitionChannelUpdatesForNullValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceStateBefore = mock(DeviceState.class);
when(deviceStateBefore.getDeviceIdentifier()).thenReturn(DISHWASHER_DEVICE_THING_UID.getId());
when(deviceStateBefore.getStateType()).thenReturn(Optional.of(StateType.RUNNING));
}
@Test
- public void testTransitionChannelUpdatesForValidValues() {
+ public void testTransitionChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceStateBefore = mock(DeviceState.class);
when(deviceStateBefore.getDeviceIdentifier()).thenReturn(DISHWASHER_DEVICE_THING_UID.getId());
when(deviceStateBefore.getStateType()).thenReturn(Optional.of(StateType.RUNNING));
}
@Test
- public void testActionsChannelUpdatesForValidValues() {
+ public void testActionsChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
ActionsState actionsState = mock(ActionsState.class);
when(actionsState.getDeviceIdentifier()).thenReturn(DISHWASHER_DEVICE_THING_UID.getId());
when(actionsState.canBeStarted()).thenReturn(true);
}
@Test
- public void testChannelUpdatesForNullValues() {
+ public void testChannelUpdatesForNullValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.getDeviceIdentifier()).thenReturn(DRYER_DEVICE_THING_UID.getId());
when(deviceState.getStateType()).thenReturn(Optional.empty());
}
@Test
- public void testChannelUpdatesForValidValues() {
+ public void testChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.isInState(any())).thenCallRealMethod();
when(deviceState.getDeviceIdentifier()).thenReturn(DRYER_DEVICE_THING_UID.getId());
}
@Test
- public void testFinishStateChannelIsSetToOnWhenProgramHasFinished() {
+ public void testFinishStateChannelIsSetToOnWhenProgramHasFinished() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceStateBefore = mock(DeviceState.class);
when(deviceStateBefore.getDeviceIdentifier()).thenReturn(DRYER_DEVICE_THING_UID.getId());
when(deviceStateBefore.getStateType()).thenReturn(Optional.of(StateType.RUNNING));
}
@Test
- public void testTransitionChannelUpdatesForNullValues() {
+ public void testTransitionChannelUpdatesForNullValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceStateBefore = mock(DeviceState.class);
when(deviceStateBefore.getDeviceIdentifier()).thenReturn(DRYER_DEVICE_THING_UID.getId());
when(deviceStateBefore.getStateType()).thenReturn(Optional.of(StateType.RUNNING));
}
@Test
- public void testTransitionChannelUpdatesForValidValues() {
+ public void testTransitionChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceStateBefore = mock(DeviceState.class);
when(deviceStateBefore.getDeviceIdentifier()).thenReturn(DRYER_DEVICE_THING_UID.getId());
when(deviceStateBefore.getStateType()).thenReturn(Optional.of(StateType.RUNNING));
}
@Test
- public void testActionsChannelUpdatesForValidValues() {
+ public void testActionsChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
ActionsState actionsState = mock(ActionsState.class);
when(actionsState.getDeviceIdentifier()).thenReturn(DRYER_DEVICE_THING_UID.getId());
when(actionsState.canBeStarted()).thenReturn(true);
}
@Test
- public void testChannelUpdatesForNullValues() {
+ public void testChannelUpdatesForNullValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.getDeviceIdentifier()).thenReturn(HOB_DEVICE_THING_UID.getId());
when(deviceState.getStateType()).thenReturn(Optional.empty());
}
@Test
- public void testChannelUpdatesForValidValues() {
+ public void testChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.getDeviceIdentifier()).thenReturn(HOB_DEVICE_THING_UID.getId());
when(deviceState.getStateType()).thenReturn(Optional.of(StateType.RUNNING));
}
@Test
- public void testChannelUpdatesForNullValues() {
+ public void testChannelUpdatesForNullValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.getDeviceIdentifier()).thenReturn(HOOD_DEVICE_THING_UID.getId());
when(deviceState.getStateType()).thenReturn(Optional.empty());
}
@Test
- public void testChannelUpdatesForValidValues() {
+ public void testChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.getDeviceIdentifier()).thenReturn(HOOD_DEVICE_THING_UID.getId());
when(deviceState.getStateType()).thenReturn(Optional.of(StateType.RUNNING));
}
@Test
- public void testActionsChannelUpdatesForValidValues() {
+ public void testActionsChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
ActionsState actionsState = mock(ActionsState.class);
when(actionsState.getDeviceIdentifier()).thenReturn(HOOD_DEVICE_THING_UID.getId());
when(actionsState.canBeSwitchedOn()).thenReturn(true);
}
@Test
- public void testChannelUpdatesForNullValues() {
+ public void testChannelUpdatesForNullValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.getDeviceIdentifier()).thenReturn(OVEN_DEVICE_THING_UID.getId());
when(deviceState.getStateType()).thenReturn(Optional.empty());
}
@Test
- public void testChannelUpdatesForValidValues() {
+ public void testChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.isInState(any())).thenCallRealMethod();
when(deviceState.getDeviceIdentifier()).thenReturn(OVEN_DEVICE_THING_UID.getId());
}
@Test
- public void testFinishStateChannelIsSetToOnWhenProgramHasFinished() {
+ public void testFinishStateChannelIsSetToOnWhenProgramHasFinished() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceStateBefore = mock(DeviceState.class);
when(deviceStateBefore.getDeviceIdentifier()).thenReturn(OVEN_DEVICE_THING_UID.getId());
when(deviceStateBefore.getStateType()).thenReturn(Optional.of(StateType.RUNNING));
}
@Test
- public void testTransitionChannelUpdatesForNullValues() {
+ public void testTransitionChannelUpdatesForNullValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceStateBefore = mock(DeviceState.class);
when(deviceStateBefore.getDeviceIdentifier()).thenReturn(OVEN_DEVICE_THING_UID.getId());
when(deviceStateBefore.getStateType()).thenReturn(Optional.of(StateType.RUNNING));
}
@Test
- public void testTransitionChannelUpdatesForValidValues() {
+ public void testTransitionChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceStateBefore = mock(DeviceState.class);
when(deviceStateBefore.getDeviceIdentifier()).thenReturn(OVEN_DEVICE_THING_UID.getId());
when(deviceStateBefore.getStateType()).thenReturn(Optional.of(StateType.RUNNING));
}
@Test
- public void testActionsChannelUpdatesForValidValues() {
+ public void testActionsChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
ActionsState actionsState = mock(ActionsState.class);
when(actionsState.getDeviceIdentifier()).thenReturn(OVEN_DEVICE_THING_UID.getId());
when(actionsState.canBeStarted()).thenReturn(true);
}
@Test
- public void testChannelUpdatesForNullValues() {
+ public void testChannelUpdatesForNullValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.getDeviceIdentifier())
.thenReturn(MieleCloudBindingIntegrationTestConstants.ROBOTIC_VACUUM_CLEANER_THING_UID.getId());
}
@Test
- public void testChannelUpdatesForValidValues() {
+ public void testChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.isInState(any())).thenCallRealMethod();
when(deviceState.getDeviceIdentifier())
}
@Test
- public void testFinishStateChannelIsSetToOnWhenProgramHasFinished() {
+ public void testFinishStateChannelIsSetToOnWhenProgramHasFinished() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceStateBefore = mock(DeviceState.class);
when(deviceStateBefore.getDeviceIdentifier())
.thenReturn(MieleCloudBindingIntegrationTestConstants.ROBOTIC_VACUUM_CLEANER_THING_UID.getId());
}
@Test
- public void testActionsChannelUpdatesForValidValues() {
+ public void testActionsChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
ActionsState actionsState = mock(ActionsState.class);
when(actionsState.getDeviceIdentifier())
.thenReturn(MieleCloudBindingIntegrationTestConstants.ROBOTIC_VACUUM_CLEANER_THING_UID.getId());
}
@Test
- public void testHandleCommandVacuumCleanerProgramActive() {
+ public void testHandleCommandVacuumCleanerProgramActive() throws Exception {
+ // given:
+ setUpBridgeAndThing();
+
// when:
getThingHandler().handleCommand(channel(VACUUM_CLEANER_PROGRAM_ACTIVE), new StringType("1"));
}
@Test
- public void testChannelUpdatesForNullValues() {
+ public void testChannelUpdatesForNullValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.getDeviceIdentifier()).thenReturn(WASHING_MACHINE_THING_UID.getId());
when(deviceState.getStateType()).thenReturn(Optional.empty());
}
@Test
- public void testChannelUpdatesForValidValues() {
+ public void testChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.isInState(any())).thenCallRealMethod();
when(deviceState.getDeviceIdentifier()).thenReturn(WASHING_MACHINE_THING_UID.getId());
}
@Test
- public void testFinishStateChannelIsSetToOnWhenProgramHasFinished() {
+ public void testFinishStateChannelIsSetToOnWhenProgramHasFinished() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceStateBefore = mock(DeviceState.class);
when(deviceStateBefore.getDeviceIdentifier()).thenReturn(WASHING_MACHINE_THING_UID.getId());
when(deviceStateBefore.getStateType()).thenReturn(Optional.of(StateType.RUNNING));
}
@Test
- public void testTransitionChannelUpdatesForNullValues() {
+ public void testTransitionChannelUpdatesForNullValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceStateBefore = mock(DeviceState.class);
when(deviceStateBefore.getDeviceIdentifier()).thenReturn(WASHING_MACHINE_THING_UID.getId());
when(deviceStateBefore.getStateType()).thenReturn(Optional.of(StateType.RUNNING));
}
@Test
- public void testTransitionChannelUpdatesForValidValues() {
+ public void testTransitionChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceStateBefore = mock(DeviceState.class);
when(deviceStateBefore.getDeviceIdentifier()).thenReturn(WASHING_MACHINE_THING_UID.getId());
when(deviceStateBefore.getStateType()).thenReturn(Optional.of(StateType.RUNNING));
}
@Test
- public void testActionsChannelUpdatesForValidValues() {
+ public void testActionsChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
ActionsState actionsState = mock(ActionsState.class);
when(actionsState.getDeviceIdentifier()).thenReturn(WASHING_MACHINE_THING_UID.getId());
when(actionsState.canBeStarted()).thenReturn(true);
}
@Test
- public void testChannelUpdatesForNullValues() {
+ public void testChannelUpdatesForNullValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.getDeviceIdentifier()).thenReturn(WINE_STORAGE_DEVICE_THING_UID.getId());
when(deviceState.getRawType()).thenReturn(DeviceType.WINE_CONDITIONING_UNIT);
}
@Test
- public void testChannelUpdatesForValidValues() {
+ public void testChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
DeviceState deviceState = mock(DeviceState.class);
when(deviceState.getDeviceIdentifier()).thenReturn(WINE_STORAGE_DEVICE_THING_UID.getId());
when(deviceState.getRawType()).thenReturn(DeviceType.WINE_CONDITIONING_UNIT);
}
@Test
- public void testActionsChannelUpdatesForValidValues() {
+ public void testActionsChannelUpdatesForValidValues() throws Exception {
// given:
+ setUpBridgeAndThing();
+
ActionsState actionsState = mock(ActionsState.class);
when(actionsState.getDeviceIdentifier()).thenReturn(WINE_STORAGE_DEVICE_THING_UID.getId());
when(actionsState.canBeSwitchedOn()).thenReturn(true);