Search in sources :

Example 31 with ChannelUID

use of org.eclipse.smarthome.core.thing.ChannelUID 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);
}
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 32 with ChannelUID

use of org.eclipse.smarthome.core.thing.ChannelUID in project smarthome by eclipse.

the class FSInternetRadioHandlerJavaTest method presetChannelUpdated.

/**
 * Verify the preset channel is updated.
 */
@Test
public void presetChannelUpdated() {
    String presetChannelID = FSInternetRadioBindingConstants.CHANNEL_PRESET;
    String acceptedItemType = acceptedItemTypes.get(presetChannelID);
    createChannel(DEFAULT_THING_UID, presetChannelID, acceptedItemType);
    Thing radioThing = initializeRadioThing(DEFAULT_COMPLETE_CONFIGURATION);
    testRadioThingConsideringConfiguration(radioThing);
    turnTheRadioOn(radioThing);
    ChannelUID presetChannelUID = getChannelUID(radioThing, FSInternetRadioBindingConstants.CHANNEL_PRESET);
    initializeItem(presetChannelUID, DEFAULT_TEST_ITEM_NAME, acceptedItemType);
    radioHandler.handleCommand(presetChannelUID, DecimalType.valueOf("100"));
    waitForAssert(() -> {
        assertTrue("We should be able to set value to the preset", radioServiceDummy.containsRequestParameter(100, PRESET));
        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 33 with ChannelUID

use of org.eclipse.smarthome.core.thing.ChannelUID in project smarthome by eclipse.

the class FSInternetRadioHandlerJavaTest method volumeChannelUpdatedPercIncDec.

/**
 * Verify the volume is updated through the CHANNEL_VOLUME_PERCENT using INCREASE and DECREASE commands.
 */
@Test
public void volumeChannelUpdatedPercIncDec() {
    /*
         * 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);
    testChannelWithINCREASEAndDECREASECommands(percentVolumeChannelUID, 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 34 with ChannelUID

use of org.eclipse.smarthome.core.thing.ChannelUID in project smarthome by eclipse.

the class ChaserThingHandlerTest method holdInfiniteChaser.

@Test
public void holdInfiniteChaser() {
    initializeTestBridge();
    thingProperties.put(CONFIG_CHASER_STEPS, TEST_STEPS_INFINITE);
    initialize();
    long currentTime = System.currentTimeMillis();
    chaserThingHandler.handleCommand(new ChannelUID(chaserThing.getUID(), CHANNEL_SWITCH), OnOffType.ON);
    // step I
    currentTime = dmxBridgeHandler.calcBuffer(currentTime, 1000);
    waitForAssert(() -> assertThat(dmxBridgeHandler.getDmxChannelValue(100), is(equalTo(100))));
    currentTime = dmxBridgeHandler.calcBuffer(currentTime, 1000);
    waitForAssert(() -> assertThat(dmxBridgeHandler.getDmxChannelValue(100), is(equalTo(100))));
    // step II (holds forever)
    currentTime = dmxBridgeHandler.calcBuffer(currentTime, 1000);
    waitForAssert(() -> assertThat(dmxBridgeHandler.getDmxChannelValue(100), is(equalTo(200))));
    currentTime = dmxBridgeHandler.calcBuffer(currentTime, 2000);
    waitForAssert(() -> assertThat(dmxBridgeHandler.getDmxChannelValue(100), is(equalTo(200))));
}
Also used : ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID) Test(org.junit.Test)

Example 35 with ChannelUID

use of org.eclipse.smarthome.core.thing.ChannelUID in project smarthome by eclipse.

the class ChaserThingHandlerTest method runningChaserWithResume.

@Test
public void runningChaserWithResume() {
    initializeTestBridge();
    thingProperties.put(CONFIG_CHASER_STEPS, TEST_STEPS_REPEAT);
    thingProperties.put(CONFIG_CHASER_RESUME_AFTER, true);
    initialize();
    dmxBridgeHandler.setDmxChannelValue(100, 193);
    long currentTime = System.currentTimeMillis();
    currentTime = dmxBridgeHandler.calcBuffer(currentTime, 0);
    waitForAssert(() -> assertThat(dmxBridgeHandler.getDmxChannelValue(100), is(equalTo(193))));
    chaserThingHandler.handleCommand(new ChannelUID(chaserThing.getUID(), CHANNEL_SWITCH), OnOffType.ON);
    // step I
    currentTime = dmxBridgeHandler.calcBuffer(currentTime, 1000);
    waitForAssert(() -> assertThat(dmxBridgeHandler.getDmxChannelValue(100), is(equalTo(115))));
    currentTime = dmxBridgeHandler.calcBuffer(currentTime, 1000);
    waitForAssert(() -> assertThat(dmxBridgeHandler.getDmxChannelValue(100), is(equalTo(115))));
    // step II
    currentTime = dmxBridgeHandler.calcBuffer(currentTime, 1000);
    waitForAssert(() -> assertThat(dmxBridgeHandler.getDmxChannelValue(100), is(equalTo(210))));
    currentTime = dmxBridgeHandler.calcBuffer(currentTime, 1000);
    waitForAssert(() -> assertThat(dmxBridgeHandler.getDmxChannelValue(100), is(equalTo(210))));
    // resume old state
    currentTime = dmxBridgeHandler.calcBuffer(currentTime, 1000);
    waitForAssert(() -> assertThat(dmxBridgeHandler.getDmxChannelValue(100), is(equalTo(193))));
}
Also used : ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID) Test(org.junit.Test)

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