コード例 #1
0
  @Test
  public void testOrFunction_justsOneItem() {
    items.add(new TestItem("TestItem1", UnDefType.UNDEF));

    function = new ArithmeticGroupFunction.Or(OpenClosedType.OPEN, OpenClosedType.CLOSED);
    State state = function.calculate(items);

    Assert.assertEquals(OpenClosedType.CLOSED, state);
  }
コード例 #2
0
  @Test
  public void testNAndFunction_negative() {
    items.add(new TestItem("TestItem1", OpenClosedType.OPEN));
    items.add(new TestItem("TestItem2", OpenClosedType.OPEN));
    items.add(new TestItem("TestItem3", OpenClosedType.CLOSED));

    function = new ArithmeticGroupFunction.NAnd(OpenClosedType.OPEN, OpenClosedType.CLOSED);
    State state = function.calculate(items);

    Assert.assertEquals(OpenClosedType.OPEN, state);
  }
コード例 #3
0
  @Test
  public void testSumFunction() {
    items.add(new TestItem("TestItem1", new DecimalType("23.54")));
    items.add(new TestItem("TestItem2", UnDefType.NULL));
    items.add(new TestItem("TestItem3", new DecimalType("89")));
    items.add(new TestItem("TestItem4", UnDefType.UNDEF));
    items.add(new TestItem("TestItem5", new DecimalType("122.41")));

    function = new ArithmeticGroupFunction.Sum();
    State state = function.calculate(items);

    Assert.assertEquals(new DecimalType("234.95"), state);
  }
コード例 #4
0
  @Test
  public void testOrFunction_differntTypes() {
    DimmerItem dimmer1 = new DimmerItem("TestDimmer1");
    dimmer1.setState(new DecimalType("42"));
    DimmerItem dimmer2 = new DimmerItem("TestDimmer2");
    dimmer2.setState(new DecimalType("0"));
    SwitchItem switch1 = new SwitchItem("TestSwitch1");
    switch1.setState(OnOffType.ON);
    SwitchItem switch2 = new SwitchItem("TestSwitch2");
    switch2.setState(OnOffType.OFF);

    items.add(dimmer1);
    items.add(dimmer2);
    items.add(switch1);
    items.add(switch2);

    function = new ArithmeticGroupFunction.Or(OnOffType.ON, OnOffType.OFF);
    State state = function.calculate(items);
    State decimalState = function.getStateAs(items, DecimalType.class);

    Assert.assertEquals(OnOffType.ON, state);
    Assert.assertEquals(new DecimalType("2"), decimalState);
  }