[icalendar] Ensure DecimalType will be used if no unit given (#9849)

Fixes #9820
Related to #9771

Signed-off-by: Christian Bandowski <christian@myvm.de>
This commit is contained in:
Christian Bandowski 2021-01-17 14:34:14 +01:00 committed by GitHub
parent de3cacc603
commit 675de38272
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -17,6 +17,7 @@ import java.util.List;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; 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.HSBType;
import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.OpenClosedType; import org.openhab.core.library.types.OpenClosedType;
@ -45,9 +46,9 @@ import org.slf4j.LoggerFactory;
@NonNullByDefault @NonNullByDefault
public class CommandTag { public class CommandTag {
private static final List<Class<? extends Command>> otherCommandTypes = Arrays.asList(QuantityType.class, private static final List<Class<? extends Command>> otherCommandTypes = Arrays.asList(DecimalType.class,
OnOffType.class, OpenClosedType.class, UpDownType.class, HSBType.class, PlayPauseType.class, QuantityType.class, OnOffType.class, OpenClosedType.class, UpDownType.class, HSBType.class,
RewindFastforwardType.class, StringType.class); PlayPauseType.class, RewindFastforwardType.class, StringType.class);
private static final List<Class<? extends Command>> percentCommandType = Arrays.asList(PercentType.class); private static final List<Class<? extends Command>> percentCommandType = Arrays.asList(PercentType.class);

View File

@ -23,6 +23,7 @@ import java.util.List;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; 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.HSBType;
import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.OpenClosedType; import org.openhab.core.library.types.OpenClosedType;
@ -290,7 +291,7 @@ public class BiweeklyPresentableCalendarTest {
// BEGIN:Calendar_Test_Number:12.3:abc // BEGIN:Calendar_Test_Number:12.3:abc
Command cmd3 = cmdTags.get(3).getCommand(); Command cmd3 = cmdTags.get(3).getCommand();
assertNotNull(cmd3); assertNotNull(cmd3);
assertEquals(QuantityType.class, cmd3.getClass()); assertEquals(DecimalType.class, cmd3.getClass());
// BEGIN:Calendar_Test_Temperature:12.3°C:abc // BEGIN:Calendar_Test_Temperature:12.3°C:abc
Command cmd4 = cmdTags.get(4).getCommand(); Command cmd4 = cmdTags.get(4).getCommand();
@ -353,7 +354,7 @@ public class BiweeklyPresentableCalendarTest {
// BEGIN:Calendar_Test_Number:-12.3:abc // BEGIN:Calendar_Test_Number:-12.3:abc
cmd3 = cmdTags.get(3).getCommand(); cmd3 = cmdTags.get(3).getCommand();
assertNotNull(cmd3); assertNotNull(cmd3);
assertEquals(QuantityType.class, cmd3.getClass()); assertEquals(DecimalType.class, cmd3.getClass());
// BEGIN:Calendar_Test_Temperature:-12.3°C:abc // BEGIN:Calendar_Test_Temperature:-12.3°C:abc
cmd4 = cmdTags.get(4).getCommand(); cmd4 = cmdTags.get(4).getCommand();
@ -416,7 +417,7 @@ public class BiweeklyPresentableCalendarTest {
// BEGIN:Calendar_Test_Number:-0:abc // BEGIN:Calendar_Test_Number:-0:abc
cmd3 = cmdTags.get(3).getCommand(); cmd3 = cmdTags.get(3).getCommand();
assertNotNull(cmd3); assertNotNull(cmd3);
assertEquals(QuantityType.class, cmd3.getClass()); assertEquals(DecimalType.class, cmd3.getClass());
// BEGIN:Calendar_Test_Temperature:0K:abc // BEGIN:Calendar_Test_Temperature:0K:abc
cmd4 = cmdTags.get(4).getCommand(); cmd4 = cmdTags.get(4).getCommand();
@ -541,12 +542,12 @@ public class BiweeklyPresentableCalendarTest {
// </p><p>BEGIN:Calendar_Test_Number:12.3:abc</p> // </p><p>BEGIN:Calendar_Test_Number:12.3:abc</p>
cmd6 = cmdTags.get(6).getCommand(); cmd6 = cmdTags.get(6).getCommand();
assertNotNull(cmd6); assertNotNull(cmd6);
assertEquals(QuantityType.class, cmd6.getClass()); assertEquals(DecimalType.class, cmd6.getClass());
// <p>END:Calendar_Test_Number:23.4:abc</p> // <p>END:Calendar_Test_Number:23.4:abc</p>
cmd7 = cmdTags.get(7).getCommand(); cmd7 = cmdTags.get(7).getCommand();
assertNotNull(cmd7); assertNotNull(cmd7);
assertEquals(QuantityType.class, cmd7.getClass()); assertEquals(DecimalType.class, cmd7.getClass());
} }
@SuppressWarnings("null") @SuppressWarnings("null")