use of tuwien.auto.calimero.dptxlator.DPT in project openhab1-addons by openhab.
the class KNXCoreTypeMapperTest method testTypeMappingSceneNumber_17_001.
/**
* KNXCoreTypeMapper tests method typeMapper.toType() for type “Scene Number" KNX ID: 17.001 DPT_SCENE_NUMBER
*
* @throws KNXFormatException
*/
@Test
public void testTypeMappingSceneNumber_17_001() throws KNXFormatException {
DPT dpt = DPTXlatorSceneNumber.DPT_SCENE_NUMBER;
testToTypeClass(dpt, DecimalType.class);
// Use a too short byte array
assertNull("KNXCoreTypeMapper.toType() should return null (required data length too short)", testToType(dpt, new byte[] {}, DecimalType.class));
// Use a too long byte array expecting that additional bytes will be ignored
Type type = testToType(dpt, new byte[] { (byte) 0xFF, 0 }, DecimalType.class);
testToDPTValue(dpt, type, "63");
type = testToType(dpt, new byte[] { 0x00 }, DecimalType.class);
testToDPTValue(dpt, type, "0");
type = testToType(dpt, new byte[] { 0x3F }, DecimalType.class);
testToDPTValue(dpt, type, "63");
// Test that the 2 msb (reserved) are ignored
type = testToType(dpt, new byte[] { (byte) 0xC0 }, DecimalType.class);
testToDPTValue(dpt, type, "0");
// Test that the 2 msb (reserved) are ignored
type = testToType(dpt, new byte[] { (byte) 0xFF }, DecimalType.class);
testToDPTValue(dpt, type, "63");
}
use of tuwien.auto.calimero.dptxlator.DPT in project openhab1-addons by openhab.
the class KNXCoreTypeMapperTest method testTypeMappingDate_11_001__DayZero.
/**
* KNXCoreTypeMapper tests method typeMapper.toType() for type “Time" KNX ID: 11.001 DPT_DATE
*
* Test illegal day (cannot be 0) This should throw an KNXIllegalArgumentException
*
* @throws KNXFormatException
*/
@Test
public void testTypeMappingDate_11_001__DayZero() throws KNXFormatException {
DPT dpt = DPTXlatorDate.DPT_DATE;
testToTypeClass(dpt, DateTimeType.class);
assertNull("KNXCoreTypeMapper.toType() should return null", testToType(dpt, new byte[] { 0x00, 0x01, 0x00 }, DateTimeType.class));
}
Aggregations