From ecffe0875d228801085cf386ca7ae344b2f87670 Mon Sep 17 00:00:00 2001
From: Christian Bandowski
Date: Sun, 17 Jan 2021 14:34:14 +0100
Subject: [PATCH] [icalendar] Ensure DecimalType will be used if no unit given
(#9849)
Fixes #9820
Related to #9771
Signed-off-by: Christian Bandowski
Signed-off-by: John Marshall
---
.../binding/icalendar/internal/logic/CommandTag.java | 7 ++++---
.../logic/BiweeklyPresentableCalendarTest.java | 11 ++++++-----
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/bundles/org.openhab.binding.icalendar/src/main/java/org/openhab/binding/icalendar/internal/logic/CommandTag.java b/bundles/org.openhab.binding.icalendar/src/main/java/org/openhab/binding/icalendar/internal/logic/CommandTag.java
index b1d068a08bfb1..2c4f4867e1af4 100644
--- a/bundles/org.openhab.binding.icalendar/src/main/java/org/openhab/binding/icalendar/internal/logic/CommandTag.java
+++ b/bundles/org.openhab.binding.icalendar/src/main/java/org/openhab/binding/icalendar/internal/logic/CommandTag.java
@@ -17,6 +17,7 @@
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
+import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.HSBType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.OpenClosedType;
@@ -45,9 +46,9 @@
@NonNullByDefault
public class CommandTag {
- private static final List> otherCommandTypes = Arrays.asList(QuantityType.class,
- OnOffType.class, OpenClosedType.class, UpDownType.class, HSBType.class, PlayPauseType.class,
- RewindFastforwardType.class, StringType.class);
+ private static final List> otherCommandTypes = Arrays.asList(DecimalType.class,
+ QuantityType.class, OnOffType.class, OpenClosedType.class, UpDownType.class, HSBType.class,
+ PlayPauseType.class, RewindFastforwardType.class, StringType.class);
private static final List> percentCommandType = Arrays.asList(PercentType.class);
diff --git a/bundles/org.openhab.binding.icalendar/src/test/java/org/openhab/binding/icalendar/internal/logic/BiweeklyPresentableCalendarTest.java b/bundles/org.openhab.binding.icalendar/src/test/java/org/openhab/binding/icalendar/internal/logic/BiweeklyPresentableCalendarTest.java
index 680f057d3920a..98690a06eedcf 100644
--- a/bundles/org.openhab.binding.icalendar/src/test/java/org/openhab/binding/icalendar/internal/logic/BiweeklyPresentableCalendarTest.java
+++ b/bundles/org.openhab.binding.icalendar/src/test/java/org/openhab/binding/icalendar/internal/logic/BiweeklyPresentableCalendarTest.java
@@ -23,6 +23,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.HSBType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.OpenClosedType;
@@ -290,7 +291,7 @@ public void testCommandTagCode() {
// BEGIN:Calendar_Test_Number:12.3:abc
Command cmd3 = cmdTags.get(3).getCommand();
assertNotNull(cmd3);
- assertEquals(QuantityType.class, cmd3.getClass());
+ assertEquals(DecimalType.class, cmd3.getClass());
// BEGIN:Calendar_Test_Temperature:12.3°C:abc
Command cmd4 = cmdTags.get(4).getCommand();
@@ -353,7 +354,7 @@ public void testCommandTagCode() {
// BEGIN:Calendar_Test_Number:-12.3:abc
cmd3 = cmdTags.get(3).getCommand();
assertNotNull(cmd3);
- assertEquals(QuantityType.class, cmd3.getClass());
+ assertEquals(DecimalType.class, cmd3.getClass());
// BEGIN:Calendar_Test_Temperature:-12.3°C:abc
cmd4 = cmdTags.get(4).getCommand();
@@ -416,7 +417,7 @@ public void testCommandTagCode() {
// BEGIN:Calendar_Test_Number:-0:abc
cmd3 = cmdTags.get(3).getCommand();
assertNotNull(cmd3);
- assertEquals(QuantityType.class, cmd3.getClass());
+ assertEquals(DecimalType.class, cmd3.getClass());
// BEGIN:Calendar_Test_Temperature:0K:abc
cmd4 = cmdTags.get(4).getCommand();
@@ -541,12 +542,12 @@ public void testCommandTagCode() {
//
BEGIN:Calendar_Test_Number:12.3:abc
cmd6 = cmdTags.get(6).getCommand();
assertNotNull(cmd6);
- assertEquals(QuantityType.class, cmd6.getClass());
+ assertEquals(DecimalType.class, cmd6.getClass());
// END:Calendar_Test_Number:23.4:abc
cmd7 = cmdTags.get(7).getCommand();
assertNotNull(cmd7);
- assertEquals(QuantityType.class, cmd7.getClass());
+ assertEquals(DecimalType.class, cmd7.getClass());
}
@SuppressWarnings("null")