Search in sources :

Example 11 with ChannelUID

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

the class ThingRegistryOSGiTest method assertThatThingRegistryDelegatesConfigUpdateToThingHandler.

@Test
public void assertThatThingRegistryDelegatesConfigUpdateToThingHandler() {
    ThingUID thingUID = new ThingUID("binding:type:thing");
    Thing thing = ThingBuilder.create(THING_TYPE_UID, thingUID).build();
    ThingHandler thingHandler = new BaseThingHandler(thing) {

        @Override
        public void handleCommand(@NonNull ChannelUID channelUID, @NonNull Command command) {
        }

        @Override
        public void handleConfigurationUpdate(@NonNull Map<@NonNull String, @NonNull Object> configurationParameters) {
            changedParameters = configurationParameters;
        }
    };
    thing.setHandler(thingHandler);
    ThingProvider thingProvider = new ThingProvider() {

        @Override
        public void addProviderChangeListener(ProviderChangeListener<@NonNull Thing> listener) {
        }

        @Override
        public Collection<@NonNull Thing> getAll() {
            return Collections.singleton(thing);
        }

        @Override
        public void removeProviderChangeListener(ProviderChangeListener<@NonNull Thing> listener) {
        }
    };
    registerService(thingProvider);
    ThingRegistry thingRegistry = getService(ThingRegistry.class);
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("param1", "value1");
    parameters.put("param2", 1);
    thingRegistry.updateConfiguration(thingUID, parameters);
    assertThat(changedParameters.entrySet(), is(equalTo(parameters.entrySet())));
}
Also used : BaseThingHandler(org.eclipse.smarthome.core.thing.binding.BaseThingHandler) HashMap(java.util.HashMap) BaseThingHandler(org.eclipse.smarthome.core.thing.binding.BaseThingHandler) ThingHandler(org.eclipse.smarthome.core.thing.binding.ThingHandler) ThingRegistry(org.eclipse.smarthome.core.thing.ThingRegistry) ThingProvider(org.eclipse.smarthome.core.thing.ThingProvider) ManagedThingProvider(org.eclipse.smarthome.core.thing.ManagedThingProvider) Command(org.eclipse.smarthome.core.types.Command) ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID) ThingUID(org.eclipse.smarthome.core.thing.ThingUID) NonNull(org.eclipse.jdt.annotation.NonNull) ProviderChangeListener(org.eclipse.smarthome.core.common.registry.ProviderChangeListener) HashMap(java.util.HashMap) Map(java.util.Map) Thing(org.eclipse.smarthome.core.thing.Thing) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) Test(org.junit.Test)

Example 12 with ChannelUID

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

the class SystemProfileFactoryTest method testGetSuggestedProfileTypeUID_nullChannelType2.

@Test
public void testGetSuggestedProfileTypeUID_nullChannelType2() {
    Channel channel = ChannelBuilder.create(new ChannelUID("test:test:test:test"), CoreItemFactory.SWITCH).build();
    assertThat(factory.getSuggestedProfileTypeUID(channel, CoreItemFactory.SWITCH), is(SystemProfiles.DEFAULT));
}
Also used : ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID) Channel(org.eclipse.smarthome.core.thing.Channel) Test(org.junit.Test)

Example 13 with ChannelUID

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

the class ThingBuilderTest method testWithChannel_wrongThing.

@Test(expected = IllegalArgumentException.class)
public void testWithChannel_wrongThing() {
    ThingBuilder thingBuilder = ThingBuilder.create(THING_TYPE_UID, THING_UID);
    thingBuilder.withChannel(ChannelBuilder.create(new ChannelUID(new ThingUID(THING_TYPE_UID, "wrong"), "channel1"), "").build());
}
Also used : ThingBuilder(org.eclipse.smarthome.core.thing.binding.builder.ThingBuilder) ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID) ThingUID(org.eclipse.smarthome.core.thing.ThingUID) Test(org.junit.Test)

Example 14 with ChannelUID

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

the class ThingBuilderTest method testWithChannels_duplicatesCollections.

@Test(expected = IllegalArgumentException.class)
public void testWithChannels_duplicatesCollections() {
    ThingBuilder thingBuilder = ThingBuilder.create(THING_TYPE_UID, THING_UID);
    thingBuilder.withChannels(// 
    Arrays.asList(// 
    ChannelBuilder.create(new ChannelUID(THING_UID, "channel1"), "").build(), ChannelBuilder.create(new ChannelUID(THING_UID, "channel1"), "").build()));
}
Also used : ThingBuilder(org.eclipse.smarthome.core.thing.binding.builder.ThingBuilder) ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID) Test(org.junit.Test)

Example 15 with ChannelUID

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

the class ThingBuilderTest method testWithChannels_duplicatesVararg.

@Test(expected = IllegalArgumentException.class)
public void testWithChannels_duplicatesVararg() {
    ThingBuilder thingBuilder = ThingBuilder.create(THING_TYPE_UID, THING_UID);
    // 
    thingBuilder.withChannels(// 
    ChannelBuilder.create(new ChannelUID(THING_UID, "channel1"), "").build(), ChannelBuilder.create(new ChannelUID(THING_UID, "channel1"), "").build());
}
Also used : ThingBuilder(org.eclipse.smarthome.core.thing.binding.builder.ThingBuilder) 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