use of org.eclipse.smarthome.core.thing.ChannelUID in project smarthome by eclipse.
the class FSInternetRadioHandlerJavaTest method playInfoNameChannelUpdated.
/**
* Verify the playInfoName channel is updated.
*/
@Test
public void playInfoNameChannelUpdated() {
String playInfoNameChannelID = FSInternetRadioBindingConstants.CHANNEL_PLAY_INFO_NAME;
String acceptedItemType = acceptedItemTypes.get(playInfoNameChannelID);
createChannel(DEFAULT_THING_UID, playInfoNameChannelID, acceptedItemType);
Thing radioThing = initializeRadioThingWithMockedHandler(DEFAULT_COMPLETE_CONFIGURATION);
testRadioThingConsideringConfiguration(radioThing);
turnTheRadioOn(radioThing);
ChannelUID playInfoNameChannelUID = getChannelUID(radioThing, FSInternetRadioBindingConstants.CHANNEL_PLAY_INFO_NAME);
initializeItem(playInfoNameChannelUID, DEFAULT_TEST_ITEM_NAME, acceptedItemType);
waitForAssert(() -> {
verifyOnlineStatusIsSet();
});
}
use of org.eclipse.smarthome.core.thing.ChannelUID in project smarthome by eclipse.
the class FSInternetRadioHandlerJavaTest method validInvalidPercVolume.
/**
* Verify the valid and invalid values when updating CHANNEL_VOLUME_PERCENT are handled correctly.
*/
@Test
public void validInvalidPercVolume() {
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);
initializeItem(absoluteVolumeChannelUID, DEFAULT_TEST_ITEM_NAME, absoluteAcceptedItemType);
ChannelUID percentVolumeChannelUID = getChannelUID(radioThing, percentVolumeChannelID);
/*
* Giving the handler a valid percent value. According to the FrontierSiliconRadio's
* documentation 100 percents correspond to 32 absolute value
*/
radioHandler.handleCommand(percentVolumeChannelUID, PercentType.valueOf("50"));
waitForAssert(() -> {
assertTrue("We should be able to set the volume correctly using percentages.", radioServiceDummy.containsRequestParameter(16, VOLUME));
radioServiceDummy.clearRequestParameters();
});
radioHandler.handleCommand(percentVolumeChannelUID, PercentType.valueOf("15"));
waitForAssert(() -> {
assertTrue("We should be able to set the volume correctly using percentages.", radioServiceDummy.containsRequestParameter(4, VOLUME));
radioServiceDummy.clearRequestParameters();
});
}
use of org.eclipse.smarthome.core.thing.ChannelUID 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.ChannelUID 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.ChannelUID 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();
});
}
Aggregations