Search in sources :

Example 26 with ChannelUID

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();
    });
}
Also used : ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID) Thing(org.eclipse.smarthome.core.thing.Thing) Test(org.junit.Test) JavaTest(org.eclipse.smarthome.test.java.JavaTest)

Example 27 with ChannelUID

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();
    });
}
Also used : ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID) Thing(org.eclipse.smarthome.core.thing.Thing) Test(org.junit.Test) JavaTest(org.eclipse.smarthome.test.java.JavaTest)

Example 28 with ChannelUID

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
         */
}
Also used : ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID) Thing(org.eclipse.smarthome.core.thing.Thing) Test(org.junit.Test) JavaTest(org.eclipse.smarthome.test.java.JavaTest)

Example 29 with ChannelUID

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);
}
Also used : SwitchItem(org.eclipse.smarthome.core.library.items.SwitchItem) NumberItem(org.eclipse.smarthome.core.library.items.NumberItem) Item(org.eclipse.smarthome.core.items.Item) StringItem(org.eclipse.smarthome.core.library.items.StringItem) DimmerItem(org.eclipse.smarthome.core.library.items.DimmerItem) ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID) Thing(org.eclipse.smarthome.core.thing.Thing) Test(org.junit.Test) JavaTest(org.eclipse.smarthome.test.java.JavaTest)

Example 30 with ChannelUID

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();
    });
}
Also used : ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID) Thing(org.eclipse.smarthome.core.thing.Thing) Test(org.junit.Test) JavaTest(org.eclipse.smarthome.test.java.JavaTest)

Aggregations

ChannelUID (org.eclipse.smarthome.core.thing.ChannelUID)69 Test (org.junit.Test)31 Thing (org.eclipse.smarthome.core.thing.Thing)24 Channel (org.eclipse.smarthome.core.thing.Channel)16 JavaTest (org.eclipse.smarthome.test.java.JavaTest)14 Configuration (org.eclipse.smarthome.config.core.Configuration)10 Bridge (org.eclipse.smarthome.core.thing.Bridge)9 ThingBuilder (org.eclipse.smarthome.core.thing.binding.builder.ThingBuilder)9 Item (org.eclipse.smarthome.core.items.Item)7 Command (org.eclipse.smarthome.core.types.Command)7 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)7 DmxBridgeHandler (org.eclipse.smarthome.binding.dmx.internal.DmxBridgeHandler)6 StringItem (org.eclipse.smarthome.core.library.items.StringItem)6 ThingUID (org.eclipse.smarthome.core.thing.ThingUID)6 BaseThingHandler (org.eclipse.smarthome.core.thing.binding.BaseThingHandler)6 ThingHandler (org.eclipse.smarthome.core.thing.binding.ThingHandler)6 ItemChannelLink (org.eclipse.smarthome.core.thing.link.ItemChannelLink)6 NonNull (org.eclipse.jdt.annotation.NonNull)5 DimmerItem (org.eclipse.smarthome.core.library.items.DimmerItem)5 NumberItem (org.eclipse.smarthome.core.library.items.NumberItem)5