Search in sources :

Example 6 with BaseDmxChannel

use of org.eclipse.smarthome.binding.dmx.internal.multiverse.BaseDmxChannel in project smarthome by eclipse.

the class DmxBridgeHandlerTest method assertRetrievingOfChannels.

@Test
public void assertRetrievingOfChannels() {
    BaseDmxChannel channel = new BaseDmxChannel(TEST_UNIVERSE, TEST_CHANNEL);
    BaseDmxChannel returnedChannel = bridgeHandler.getDmxChannel(channel, ThingBuilder.create(THING_TYPE_DIMMER, "testthing").build());
    Integer channelId = returnedChannel.getChannelId();
    assertThat(channelId, is(TEST_CHANNEL));
}
Also used : BaseDmxChannel(org.eclipse.smarthome.binding.dmx.internal.multiverse.BaseDmxChannel) Test(org.junit.Test) JavaTest(org.eclipse.smarthome.test.java.JavaTest)

Example 7 with BaseDmxChannel

use of org.eclipse.smarthome.binding.dmx.internal.multiverse.BaseDmxChannel in project smarthome by eclipse.

the class BaseChannelTest method stringConversion.

@Test
public void stringConversion() {
    // to string
    BaseDmxChannel baseChannel = new BaseDmxChannel(5, 100);
    assertThat(baseChannel.toString(), is(equalTo("5:100")));
    // single channel from string with universe
    String parseString = new String("2:100");
    List<BaseDmxChannel> channelList = BaseDmxChannel.fromString(parseString, 0);
    assertThat(channelList.size(), is(1));
    assertThat(channelList.get(0).toString(), is(equalTo("2:100")));
    // single channel from string without universe
    parseString = new String("100");
    channelList = BaseDmxChannel.fromString(parseString, 2);
    assertThat(channelList.size(), is(1));
    assertThat(channelList.get(0).toString(), is(equalTo("2:100")));
    // two channels with channel width
    parseString = new String("100/2");
    channelList = BaseDmxChannel.fromString(parseString, 2);
    assertThat(channelList.size(), is(2));
    assertThat(channelList.get(0).toString(), is(equalTo("2:100")));
    assertThat(channelList.get(1).toString(), is(equalTo("2:101")));
    // to channels with comma
    parseString = new String("100,102");
    channelList = BaseDmxChannel.fromString(parseString, 2);
    assertThat(channelList.size(), is(2));
    assertThat(channelList.get(0).toString(), is(equalTo("2:100")));
    assertThat(channelList.get(1).toString(), is(equalTo("2:102")));
    // complex string
    parseString = new String("257,100/3,426");
    channelList = BaseDmxChannel.fromString(parseString, 2);
    assertThat(channelList.size(), is(5));
    assertThat(channelList.get(0).toString(), is(equalTo("2:257")));
    assertThat(channelList.get(1).toString(), is(equalTo("2:100")));
    assertThat(channelList.get(2).toString(), is(equalTo("2:101")));
    assertThat(channelList.get(3).toString(), is(equalTo("2:102")));
    assertThat(channelList.get(4).toString(), is(equalTo("2:426")));
}
Also used : BaseDmxChannel(org.eclipse.smarthome.binding.dmx.internal.multiverse.BaseDmxChannel) Test(org.junit.Test)

Example 8 with BaseDmxChannel

use of org.eclipse.smarthome.binding.dmx.internal.multiverse.BaseDmxChannel in project smarthome by eclipse.

the class BaseChannelTest method creatingBaseChannelfromBaseChannel.

@Test
public void creatingBaseChannelfromBaseChannel() {
    BaseDmxChannel baseChannel = new BaseDmxChannel(5, 100);
    BaseDmxChannel copyChannel = new BaseDmxChannel(baseChannel);
    assertThat(copyChannel.getChannelId(), is(100));
    assertThat(copyChannel.getUniverseId(), is(5));
}
Also used : BaseDmxChannel(org.eclipse.smarthome.binding.dmx.internal.multiverse.BaseDmxChannel) Test(org.junit.Test)

Example 9 with BaseDmxChannel

use of org.eclipse.smarthome.binding.dmx.internal.multiverse.BaseDmxChannel in project smarthome by eclipse.

the class BaseChannelTest method comparingChannels.

@Test
public void comparingChannels() {
    BaseDmxChannel channel1 = new BaseDmxChannel(5, 100);
    BaseDmxChannel channel2 = new BaseDmxChannel(7, 140);
    assertThat(channel1.compareTo(channel2), is(-1));
    assertThat(channel2.compareTo(channel1), is(1));
    assertThat(channel1.compareTo(channel1), is(0));
}
Also used : BaseDmxChannel(org.eclipse.smarthome.binding.dmx.internal.multiverse.BaseDmxChannel) Test(org.junit.Test)

Aggregations

BaseDmxChannel (org.eclipse.smarthome.binding.dmx.internal.multiverse.BaseDmxChannel)9 Test (org.junit.Test)5 DmxBridgeHandler (org.eclipse.smarthome.binding.dmx.internal.DmxBridgeHandler)4 Configuration (org.eclipse.smarthome.config.core.Configuration)4 Bridge (org.eclipse.smarthome.core.thing.Bridge)4 ValueSet (org.eclipse.smarthome.binding.dmx.internal.ValueSet)3 ChannelUID (org.eclipse.smarthome.core.thing.ChannelUID)3 JavaTest (org.eclipse.smarthome.test.java.JavaTest)1