use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class FSInternetRadioHandlerJavaTest method muteChhannelUpdated.
/**
* Verify the mute channel is updated.
*/
@Test
public void muteChhannelUpdated() {
String muteChannelID = FSInternetRadioBindingConstants.CHANNEL_MUTE;
String acceptedItemType = acceptedItemTypes.get(muteChannelID);
createChannel(DEFAULT_THING_UID, muteChannelID, acceptedItemType);
Thing radioThing = initializeRadioThing(DEFAULT_COMPLETE_CONFIGURATION);
testRadioThingConsideringConfiguration(radioThing);
turnTheRadioOn(radioThing);
ChannelUID muteChannelUID = getChannelUID(radioThing, FSInternetRadioBindingConstants.CHANNEL_MUTE);
initializeItem(muteChannelUID, DEFAULT_TEST_ITEM_NAME, acceptedItemType);
radioHandler.handleCommand(muteChannelUID, OnOffType.ON);
waitForAssert(() -> {
assertTrue("We should be able to mute the radio", radioServiceDummy.containsRequestParameter(1, CHANNEL_MUTE));
radioServiceDummy.clearRequestParameters();
});
radioHandler.handleCommand(muteChannelUID, OnOffType.OFF);
waitForAssert(() -> {
assertTrue("We should be able to unmute the radio", radioServiceDummy.containsRequestParameter(0, CHANNEL_MUTE));
radioServiceDummy.clearRequestParameters();
});
/*
* Setting the needed boolean variable to true, so we can be sure
* that an invalid value will be returned in the XML response
*/
}
use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class FSInternetRadioHandlerJavaTest method volumechannelUpdatedAbsIncDec.
/**
* Verify the volume is updated through the CHANNEL_VOLUME_ABSOLUTE using INCREASE and DECREASE commands.
*/
@Test
public void volumechannelUpdatedAbsIncDec() {
String absoluteVolumeChannelID = FSInternetRadioBindingConstants.CHANNEL_VOLUME_ABSOLUTE;
String absoluteAcceptedItemType = acceptedItemTypes.get(absoluteVolumeChannelID);
createChannel(DEFAULT_THING_UID, absoluteVolumeChannelID, absoluteAcceptedItemType);
Thing radioThing = initializeRadioThing(DEFAULT_COMPLETE_CONFIGURATION);
testRadioThingConsideringConfiguration(radioThing);
turnTheRadioOn(radioThing);
ChannelUID absoluteVolumeChannelUID = getChannelUID(radioThing, absoluteVolumeChannelID);
Item volumeTestItem = initializeItem(absoluteVolumeChannelUID, DEFAULT_TEST_ITEM_NAME, absoluteAcceptedItemType);
testChannelWithINCREASEAndDECREASECommands(absoluteVolumeChannelUID, volumeTestItem);
}
use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class FSInternetRadioHandlerJavaTest method invalidAbsVolumeValues.
/**
* Verify the invalid values when updating CHANNEL_VOLUME_ABSOLUTE are handled correctly.
*/
@Test
public void invalidAbsVolumeValues() {
String absoluteVolumeChannelID = FSInternetRadioBindingConstants.CHANNEL_VOLUME_ABSOLUTE;
String absoluteAcceptedItemType = acceptedItemTypes.get(absoluteVolumeChannelID);
createChannel(DEFAULT_THING_UID, absoluteVolumeChannelID, absoluteAcceptedItemType);
Thing radioThing = initializeRadioThing(DEFAULT_COMPLETE_CONFIGURATION);
testRadioThingConsideringConfiguration(radioThing);
turnTheRadioOn(radioThing);
ChannelUID absoluteVolumeChannelUID = getChannelUID(radioThing, absoluteVolumeChannelID);
initializeItem(absoluteVolumeChannelUID, DEFAULT_TEST_ITEM_NAME, absoluteAcceptedItemType);
// Trying to set a value that is greater than the maximum volume
radioHandler.handleCommand(absoluteVolumeChannelUID, DecimalType.valueOf("36"));
waitForAssert(() -> {
assertTrue("The volume should not exceed the maximum value", radioServiceDummy.containsRequestParameter(32, VOLUME));
radioServiceDummy.clearRequestParameters();
});
// Trying to increase the volume more than its maximum value using the INCREASE command
radioHandler.handleCommand(absoluteVolumeChannelUID, IncreaseDecreaseType.INCREASE);
waitForAssert(() -> {
assertTrue("The volume should not be increased above the maximum value", radioServiceDummy.areRequestParametersEmpty());
radioServiceDummy.clearRequestParameters();
});
// Trying to increase the volume more than its maximum value using the UP command
radioHandler.handleCommand(absoluteVolumeChannelUID, UpDownType.UP);
waitForAssert(() -> {
assertTrue("The volume should not be increased above the maximum value", radioServiceDummy.areRequestParametersEmpty());
radioServiceDummy.clearRequestParameters();
});
// Trying to set a value that is lower than the minimum volume value
radioHandler.handleCommand(absoluteVolumeChannelUID, DecimalType.valueOf("-10"));
waitForAssert(() -> {
assertTrue("The volume should not be decreased below 0", radioServiceDummy.containsRequestParameter(0, VOLUME));
radioServiceDummy.clearRequestParameters();
});
/*
* Setting the needed boolean variable to true, so we can be sure
* that an invalid value will be returned in the XML response
*/
// trying to set the volume
radioHandler.handleCommand(absoluteVolumeChannelUID, DecimalType.valueOf("15"));
waitForAssert(() -> {
assertTrue("We should be able to set the volume correctly", radioServiceDummy.containsRequestParameter(15, VOLUME));
radioServiceDummy.clearRequestParameters();
});
}
use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class FSInternetRadioHandlerJavaTest method offlineIfEmptyPIN.
/**
* Verify OFFLINE Thing status when the PIN is empty String.
*/
@Test
public void offlineIfEmptyPIN() {
Configuration config = createConfiguration(DEFAULT_CONFIG_PROPERTY_IP, "", String.valueOf(DEFAULT_CONFIG_PROPERTY_PORT), DEFAULT_CONFIG_PROPERTY_REFRESH);
Thing radioThingWithEmptyPIN = initializeRadioThing(config);
testRadioThingConsideringConfiguration(radioThingWithEmptyPIN);
}
use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class FSInternetRadioHandlerJavaTest method volumeChannelUpdatedPercUpDown.
/**
* Verify the volume is updated through the CHANNEL_VOLUME_PERCENT using UP and DOWN commands.
*/
@Test
public void volumeChannelUpdatedPercUpDown() {
/*
* The volume is set through the CHANNEL_VOLUME_PERCENT in order to check if
* the absolute volume will be updated properly.
*/
String absoluteVolumeChannelID = FSInternetRadioBindingConstants.CHANNEL_VOLUME_ABSOLUTE;
String absoluteAcceptedItemType = acceptedItemTypes.get(absoluteVolumeChannelID);
createChannel(DEFAULT_THING_UID, absoluteVolumeChannelID, absoluteAcceptedItemType);
String percentVolumeChannelID = FSInternetRadioBindingConstants.CHANNEL_VOLUME_PERCENT;
String percentAcceptedItemType = acceptedItemTypes.get(percentVolumeChannelID);
createChannel(DEFAULT_THING_UID, percentVolumeChannelID, percentAcceptedItemType);
Thing radioThing = initializeRadioThing(DEFAULT_COMPLETE_CONFIGURATION);
testRadioThingConsideringConfiguration(radioThing);
turnTheRadioOn(radioThing);
ChannelUID absoluteVolumeChannelUID = getChannelUID(radioThing, absoluteVolumeChannelID);
Item volumeTestItem = initializeItem(absoluteVolumeChannelUID, DEFAULT_TEST_ITEM_NAME, absoluteAcceptedItemType);
ChannelUID percentVolumeChannelUID = getChannelUID(radioThing, percentVolumeChannelID);
testChannelWithUPAndDOWNCommands(percentVolumeChannelUID, volumeTestItem);
}
Aggregations