Search in sources :

Example 1 with StringTypeConverter

use of org.openhab.binding.homematic.internal.converter.state.StringTypeConverter in project openhab1-addons by openhab.

the class ConverterTest method testValueListByString.

@Test
public void testValueListByString() throws Exception {
    StringTypeConverter converter = new StringTypeConverter();
    Assert.assertEquals(new StringType("0"), converter.convertFromBinding(getValueListVariable("0", "0;10;20;30;40;50")));
    Assert.assertEquals(new StringType("10"), converter.convertFromBinding(getValueListVariable("1", "0;10;20;30;40;50")));
    Assert.assertEquals(new StringType("50"), converter.convertFromBinding(getValueListVariable("5", "0;10;20;30;40;50")));
    Assert.assertEquals(new StringType("6"), converter.convertFromBinding(getValueListVariable("6", "0;10;20;30;40;50")));
    Assert.assertEquals(new StringType("10"), converter.convertFromBinding(getValueListVariable(1, "0;10;20;30;40;50")));
    Assert.assertEquals(new StringType("6"), converter.convertFromBinding(getValueListVariable(6, "0;10;20;30;40;50")));
    Assert.assertEquals(new StringType("two"), converter.convertFromBinding(getValueListVariable(1, "one;two")));
    Assert.assertEquals(new StringType("one"), converter.convertFromBinding(getValueListVariable(false, "one;two")));
    Assert.assertEquals(new StringType("two"), converter.convertFromBinding(getValueListVariable(true, "one;two")));
    Assert.assertEquals("0", converter.convertToBinding(new StringType("0"), getValueListVariable("", "0;10;20;30;40;50")));
    Assert.assertEquals("1", converter.convertToBinding(new StringType("10"), getValueListVariable("", "0;10;20;30;40;50")));
    Assert.assertEquals("5", converter.convertToBinding(new StringType("50"), getValueListVariable("", "0;10;20;30;40;50")));
    Assert.assertEquals("2", converter.convertToBinding(new StringType("three"), getValueListVariable("", "one;two;three")));
    Assert.assertEquals("2", converter.convertToBinding(new StringType("three"), getValueListVariable("1", "one;two;three")));
    Assert.assertEquals(2, converter.convertToBinding(new StringType("three"), getValueListVariable(1, "one;two;three")));
    Assert.assertEquals(false, converter.convertToBinding(new StringType("one"), getValueListVariable(false, "one;two")));
    Assert.assertEquals(true, converter.convertToBinding(new StringType("two"), getValueListVariable(true, "one;two")));
}
Also used : StringType(org.openhab.core.library.types.StringType) StringTypeConverter(org.openhab.binding.homematic.internal.converter.state.StringTypeConverter) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 StringTypeConverter (org.openhab.binding.homematic.internal.converter.state.StringTypeConverter)1 StringType (org.openhab.core.library.types.StringType)1