Examples of DecimalTypeConverter


Examples of org.openhab.binding.homematic.internal.converter.state.DecimalTypeConverter

        converter.convertToBinding(OpenClosedType.CLOSED, getRollerShutterDatapoint("LEVEL", 0.0)));
  }

  @Test
  public void testDecimalTypeConverterFromBinding() throws Exception {
    DecimalTypeConverter converter = new DecimalTypeConverter();
    Assert.assertEquals(new DecimalType(1), converter.convertFromBinding(getDatapoint("PRESS_SHORT", 1)));
    Assert.assertEquals(new DecimalType(0), converter.convertFromBinding(getDatapoint("PRESS_SHORT", 0)));

    Assert.assertEquals(new DecimalType(1), converter.convertFromBinding(getDatapoint("PRESS_SHORT", true, 0, 1)));
    Assert.assertEquals(new DecimalType(5), converter.convertFromBinding(getDatapoint("PRESS_SHORT", true, 0, 5)));
    Assert.assertEquals(new DecimalType(5.4).doubleValue(),
        converter.convertFromBinding(getDatapoint("PRESS_SHORT", true, 0.0, 5.4)).doubleValue());
    Assert.assertEquals(new DecimalType(0), converter.convertFromBinding(getDatapoint("PRESS_SHORT", false, 0, 1)));

    Assert.assertEquals(new DecimalType(1), converter.convertFromBinding(getDatapoint("SENSOR", 1)));
    Assert.assertEquals(new DecimalType(0), converter.convertFromBinding(getDatapoint("SENSOR", 0)));

    Assert.assertEquals(new DecimalType(1.0).doubleValue(), converter
        .convertFromBinding(getDatapoint("LEVEL", 1.0)).doubleValue());
    Assert.assertEquals(new DecimalType(3.4).doubleValue(), converter
        .convertFromBinding(getDatapoint("LEVEL", 3.4)).doubleValue());

    Assert.assertEquals(new DecimalType(9876.678957).doubleValue(),
        converter.convertFromBinding(getDatapoint("LEVEL", 9876.6789568)).doubleValue());

    Assert.assertEquals(new DecimalType(5.3).doubleValue(),
        converter.convertFromBinding(getDatapoint("LEVEL", "true", 0.0, 5.3)).doubleValue());
    Assert.assertEquals(new DecimalType(0.0).doubleValue(),
        converter.convertFromBinding(getDatapoint("LEVEL", "false", 0.0, 5.3)).doubleValue());

    Assert.assertEquals(new DecimalType(1.0).doubleValue(), converter
        .convertFromBinding(getDatapoint("LEVEL", "1")).doubleValue());
    Assert.assertEquals(new DecimalType(1.0).doubleValue(),
        converter.convertFromBinding(getDatapoint("LEVEL", "1.0")).doubleValue());
    Assert.assertEquals(new DecimalType(9876.678957).doubleValue(),
        converter.convertFromBinding(getDatapoint("LEVEL", "9876.6789568")).doubleValue());

    Assert.assertEquals(new DecimalType(1.0).doubleValue(),
        converter.convertFromBinding(getRollerShutterDatapoint("LEVEL", 1.0)).doubleValue());
    Assert.assertEquals(new DecimalType(0.0).doubleValue(), converter
        .convertFromBinding(getDatapoint("LEVEL", 0.0)).doubleValue());
  }
View Full Code Here

Examples of org.openhab.binding.homematic.internal.converter.state.DecimalTypeConverter

        .convertFromBinding(getDatapoint("LEVEL", 0.0)).doubleValue());
  }

  @Test
  public void testDecimalTypeConverterToBinding() throws Exception {
    DecimalTypeConverter converter = new DecimalTypeConverter();

    Assert.assertEquals(true,
        converter.convertToBinding(new DecimalType(1), getDatapoint("PRESS_SHORT", true, 0, 1)));
    Assert.assertEquals(false,
        converter.convertToBinding(new DecimalType(0), getDatapoint("PRESS_SHORT", true, 0, 1)));

    Assert.assertEquals(true, converter.convertToBinding(new DecimalType(5), getDatapoint("LEVEL", true, 0, 5)));
    Assert.assertEquals(false, converter.convertToBinding(new DecimalType(4), getDatapoint("LEVEL", true, 0, 5)));
    Assert.assertEquals(false, converter.convertToBinding(new DecimalType(0), getDatapoint("LEVEL", true, 0, 1)));

    Assert.assertEquals(true, converter.convertToBinding(new DecimalType(1), getDatapoint("LEVEL", "true", 0, 1)));
    Assert.assertEquals(false, converter.convertToBinding(new DecimalType(0), getDatapoint("LEVEL", "false", 0, 1)));

    Assert.assertEquals(1, converter.convertToBinding(new DecimalType(1), getDatapoint("LEVEL", 0)));
    Assert.assertEquals(1.0, converter.convertToBinding(new DecimalType(1), getDatapoint("LEVEL", 0.0)));
    Assert.assertEquals(9876.678957,
        converter.convertToBinding(new DecimalType(9876.6789568), getDatapoint("LEVEL", 0.0)));

    Assert.assertEquals("1.0", converter.convertToBinding(new DecimalType(1), getDatapoint("LEVEL", "text")));

    Assert.assertEquals(0.5,
        converter.convertToBinding(new DecimalType(0.5), getRollerShutterDatapoint("LEVEL", 0.0)));
    Assert.assertEquals(0.4,
        converter.convertToBinding(new DecimalType(0.4), getRollerShutterDatapoint("LEVEL", 0.0)));
  }
View Full Code Here

Examples of org.openhab.binding.homematic.internal.converter.state.DecimalTypeConverter

        converter.convertToBinding(new StringType("two"), getValueListVariable(true, "one;two")));
  }

  @Test
  public void testValueListByNumber() throws Exception {
    DecimalTypeConverter converter = new DecimalTypeConverter();

    Assert.assertEquals(new DecimalType(0),
        converter.convertFromBinding(getValueListVariable(0, "0;10;20;30;40;50")));
    Assert.assertEquals(new DecimalType(1),
        converter.convertFromBinding(getValueListVariable(1, "0;10;20;30;40;50")));
    Assert.assertEquals(new DecimalType(5),
        converter.convertFromBinding(getValueListVariable(5, "0;10;20;30;40;50")));
    Assert.assertEquals(new DecimalType(6),
        converter.convertFromBinding(getValueListVariable(6, "0;10;20;30;40;50")));
    Assert.assertEquals(new DecimalType(1), converter.convertFromBinding(getValueListVariable(1, "one;two;three")));
    Assert.assertEquals(new DecimalType(1),
        converter.convertFromBinding(getValueListVariable("1", "one;two;three")));
    Assert.assertEquals(new DecimalType(1),
        converter.convertFromBinding(getValueListVariable(true, "one;two;three")));
    Assert.assertEquals(new DecimalType(0),
        converter.convertFromBinding(getValueListVariable(false, "one;two;three")));

    Assert.assertEquals(0,
        converter.convertToBinding(new DecimalType("0"), getValueListVariable(0, "0;10;20;30;40;50")));
    Assert.assertEquals(10,
        converter.convertToBinding(new DecimalType("10"), getValueListVariable(0, "0;10;20;30;40;50")));
    Assert.assertEquals(50,
        converter.convertToBinding(new DecimalType("50"), getValueListVariable(0, "0;10;20;30;40;50")));
    Assert.assertEquals(60,
        converter.convertToBinding(new DecimalType("60"), getValueListVariable(0, "0;10;20;30;40;50")));
    Assert.assertEquals(60,
        converter.convertToBinding(new DecimalType("60"), getValueListVariable(1, "0;10;20;30;40;50")));

    Assert.assertEquals(1,
        converter.convertToBinding(new DecimalType("1"), getValueListVariable(1, "one;two;three")));

    Assert.assertEquals("1.0",
        converter.convertToBinding(new DecimalType("1"), getValueListVariable("1", "one;two;three")));
    Assert.assertEquals(true,
        converter.convertToBinding(new DecimalType("1"), getValueListVariable(true, "one;two;three")));
    Assert.assertEquals(false,
        converter.convertToBinding(new DecimalType("0"), getValueListVariable(true, "one;two;three")));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.