use of org.eclipse.smarthome.core.library.items.NumberItem in project smarthome by eclipse.
the class GroupItemTest method assertAcceptedCommandTypesOnGroupItemsReturnsSubsetOfCommandTypesSupportedByAllMembers.
@SuppressWarnings("unchecked")
@Test()
public void assertAcceptedCommandTypesOnGroupItemsReturnsSubsetOfCommandTypesSupportedByAllMembers() {
SwitchItem switchItem = new SwitchItem("switch");
NumberItem numberItem = new NumberItem("number");
GroupItem groupItem = new GroupItem("group");
groupItem.addMember(switchItem);
groupItem.addMember(numberItem);
assertThat(groupItem.getAcceptedCommandTypes(), hasItems(RefreshType.class));
}
use of org.eclipse.smarthome.core.library.items.NumberItem in project smarthome by eclipse.
the class ItemDTOMapperTest method testMapFunctionWithNumberItemAndCountFunction.
@Test
public void testMapFunctionWithNumberItemAndCountFunction() {
// testing Group:Number:Count(".*hello.*")
NumberItem item1 = new NumberItem("item1");
GroupFunctionDTO gFuncDTO = new GroupFunctionDTO();
gFuncDTO.name = "COUNT";
gFuncDTO.params = new String[] { ".*hello.*" };
GroupFunction gFunc = ItemDTOMapper.mapFunction(item1, gFuncDTO);
assertThat(gFunc, instanceOf(ArithmeticGroupFunction.Count.class));
assertThat(gFunc.getParameters().length, is(1));
assertThat(gFunc.getParameters()[0], instanceOf(StringType.class));
}
use of org.eclipse.smarthome.core.library.items.NumberItem in project smarthome by eclipse.
the class CoreItemFactoryTest method createNumberItemWithDimension.
@Test
public void createNumberItemWithDimension() {
NumberItem numberItem = (NumberItem) coreItemFactory.createItem(CoreItemFactory.NUMBER + ":Temperature", "myNumberItem");
assertThat(numberItem.getDimension(), equalTo(Temperature.class));
}
use of org.eclipse.smarthome.core.library.items.NumberItem in project smarthome by eclipse.
the class ItemStateConverterImplTest method numberItemWitDimensionShouldConvertToLocaleBasedUnit.
@Test
public void numberItemWitDimensionShouldConvertToLocaleBasedUnit() {
NumberItem item = mock(NumberItem.class);
doReturn(Temperature.class).when(item).getDimension();
UnitProvider unitProvider = mock(UnitProvider.class);
when(unitProvider.getUnit(Temperature.class)).thenReturn(ImperialUnits.FAHRENHEIT);
itemStateConverter.setUnitProvider(unitProvider);
State originalState = new QuantityType<>("12.34 °C");
State convertedState = itemStateConverter.convertToAcceptedState(originalState, item);
assertThat(convertedState, is(new QuantityType<>("54.212 °F")));
}
use of org.eclipse.smarthome.core.library.items.NumberItem in project smarthome by eclipse.
the class ItemStateConverterImplTest method numberItemWithoutDimensionShouldConvertToDecimalType.
@Test
public void numberItemWithoutDimensionShouldConvertToDecimalType() {
Item item = new NumberItem("number");
State originalState = new QuantityType<>("12.34 °C");
State convertedState = itemStateConverter.convertToAcceptedState(originalState, item);
assertThat(convertedState, is(new DecimalType("12.34")));
}
Aggregations