use of org.eclipse.smarthome.core.types.State in project smarthome by eclipse.
the class ArithmeticGroupFunctionTest method testCountFunction.
@Test
public void testCountFunction() {
items.add(new TestItem("TestItem1", new StringType("hello world")));
items.add(new TestItem("TestItem2", new StringType("world")));
items.add(new TestItem("TestItem3", new StringType("foo bar")));
function = new ArithmeticGroupFunction.Count(new StringType(".*world.*"));
State state = function.calculate(items);
assertEquals(new DecimalType("2"), state);
}
use of org.eclipse.smarthome.core.types.State in project smarthome by eclipse.
the class ArithmeticGroupFunctionTest method testNAndFunction_negative.
@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);
assertEquals(OpenClosedType.OPEN, state);
}
use of org.eclipse.smarthome.core.types.State in project smarthome by eclipse.
the class DateTimeGroupFunctionTest method testLatestFunction.
@Test
public void testLatestFunction() {
ZonedDateTime expectedDateTime = ZonedDateTime.now();
items.add(new TestItem("TestItem1", new DateTimeType(expectedDateTime)));
items.add(new TestItem("TestItem2", UnDefType.UNDEF));
items.add(new TestItem("TestItem3", new DateTimeType(expectedDateTime.minusDays(10))));
items.add(new TestItem("TestItem4", new DateTimeType(expectedDateTime.minusYears(1))));
items.add(new TestItem("TestItem5", UnDefType.UNDEF));
items.add(new TestItem("TestItem6", new DateTimeType(expectedDateTime.minusSeconds(1))));
function = new DateTimeGroupFunction.Latest();
State state = function.calculate(items);
assertTrue(expectedDateTime.isEqual(((DateTimeType) state).getZonedDateTime()));
}
use of org.eclipse.smarthome.core.types.State in project smarthome by eclipse.
the class DateTimeGroupFunctionTest method testEarliestFunction.
@Test
public void testEarliestFunction() {
ZonedDateTime expectedDateTime = ZonedDateTime.now();
items.add(new TestItem("TestItem1", new DateTimeType(expectedDateTime)));
items.add(new TestItem("TestItem2", UnDefType.UNDEF));
items.add(new TestItem("TestItem3", new DateTimeType(expectedDateTime.plusDays(10))));
items.add(new TestItem("TestItem4", new DateTimeType(expectedDateTime.plusYears(1))));
items.add(new TestItem("TestItem5", UnDefType.UNDEF));
items.add(new TestItem("TestItem6", new DateTimeType(expectedDateTime.plusSeconds(1))));
function = new DateTimeGroupFunction.Earliest();
State state = function.calculate(items);
assertTrue(expectedDateTime.isEqual(((DateTimeType) state).getZonedDateTime()));
}
use of org.eclipse.smarthome.core.types.State in project smarthome by eclipse.
the class QuantityTypeArithmeticGroupFunctionTest method testMaxFunctionQuantityTypeDifferentUnits.
@Test
public void testMaxFunctionQuantityTypeDifferentUnits() {
items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<Temperature>("100 °C")));
items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL));
items.add(createNumberItem("TestItem3", Temperature.class, new QuantityType<Temperature>("113 °F")));
items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF));
items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<Temperature>("294.15 K")));
function = new QuantityTypeArithmeticGroupFunction.Max(Temperature.class);
State state = function.calculate(items);
assertEquals(new QuantityType<Temperature>("100 °C"), state);
}
Aggregations