Search in sources :

Example 96 with Thing

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

the class FSInternetRadioHandlerJavaTest method volumeChannelUpdatedAbsUpDown.

/**
 * Verify the volume is updated through the CHANNEL_VOLUME_ABSOLUTE using UP and DOWN commands.
 */
@Test
public void volumeChannelUpdatedAbsUpDown() {
    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);
    testChannelWithUPAndDOWNCommands(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 97 with Thing

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

the class FSInternetRadioHandlerJavaTest method offlineIfNullIp.

/**
 * Verify OFFLINE Thing status when the IP is NULL.
 */
@Test
public void offlineIfNullIp() {
    Configuration config = createConfiguration(null, DEFAULT_CONFIG_PROPERTY_PIN, String.valueOf(DEFAULT_CONFIG_PROPERTY_PORT), DEFAULT_CONFIG_PROPERTY_REFRESH);
    Thing radioThingWithNullIP = initializeRadioThing(config);
    testRadioThingConsideringConfiguration(radioThingWithNullIP);
}
Also used : Configuration(org.eclipse.smarthome.config.core.Configuration) Thing(org.eclipse.smarthome.core.thing.Thing) Test(org.junit.Test) JavaTest(org.eclipse.smarthome.test.java.JavaTest)

Example 98 with Thing

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

the class FSInternetRadioHandlerJavaTest method httpStatusNokHandling.

/**
 * Verify the HTTP status is handled correctly when it is not OK_200.
 */
@Test
public void httpStatusNokHandling() {
    // create a thing with two channels - the power channel and any of the others
    String modeChannelID = FSInternetRadioBindingConstants.CHANNEL_MODE;
    String acceptedItemType = acceptedItemTypes.get(modeChannelID);
    createChannel(DEFAULT_THING_UID, modeChannelID, acceptedItemType);
    Thing radioThing = initializeRadioThing(DEFAULT_COMPLETE_CONFIGURATION);
    testRadioThingConsideringConfiguration(radioThing);
    // turn-on the radio
    turnTheRadioOn(radioThing);
    /*
         * Setting the needed boolean variable to false, so we can be sure
         * that the XML response won't have a OK_200 status
         */
    ChannelUID modeChannelUID = getChannelUID(radioThing, modeChannelID);
    Item modeTestItem = initializeItem(modeChannelUID, CHANNEL_MODE, acceptedItemType);
    // try to handle a command
    radioHandler.handleCommand(modeChannelUID, DecimalType.valueOf("1"));
    waitForAssert(() -> {
        assertSame(UnDefType.NULL, modeTestItem.getState());
    });
}
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)

Aggregations

Thing (org.eclipse.smarthome.core.thing.Thing)98 Test (org.junit.Test)43 ThingUID (org.eclipse.smarthome.core.thing.ThingUID)28 ChannelUID (org.eclipse.smarthome.core.thing.ChannelUID)24 Configuration (org.eclipse.smarthome.config.core.Configuration)19 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)19 JavaTest (org.eclipse.smarthome.test.java.JavaTest)18 ThingHandler (org.eclipse.smarthome.core.thing.binding.ThingHandler)14 ThingTypeUID (org.eclipse.smarthome.core.thing.ThingTypeUID)13 ApiOperation (io.swagger.annotations.ApiOperation)9 ApiResponses (io.swagger.annotations.ApiResponses)9 Item (org.eclipse.smarthome.core.items.Item)9 Path (javax.ws.rs.Path)8 Nullable (org.eclipse.jdt.annotation.Nullable)8 Locale (java.util.Locale)7 RolesAllowed (javax.annotation.security.RolesAllowed)7 Channel (org.eclipse.smarthome.core.thing.Channel)7 ThingHandlerCallback (org.eclipse.smarthome.core.thing.binding.ThingHandlerCallback)7 Command (org.eclipse.smarthome.core.types.Command)7 List (java.util.List)6