]> git.basschouten.com Git - openhab-addons.git/blob
c90b2adafc4e871b0b6bf645bc7935c29bdcf995
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.persistence.dynamodb.internal;
14
15 import static org.junit.jupiter.api.Assertions.assertEquals;
16
17 import java.io.IOException;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.junit.jupiter.params.ParameterizedTest;
21 import org.junit.jupiter.params.provider.CsvSource;
22 import org.openhab.core.library.items.CallItem;
23 import org.openhab.core.library.items.ColorItem;
24 import org.openhab.core.library.items.ContactItem;
25 import org.openhab.core.library.items.DateTimeItem;
26 import org.openhab.core.library.items.DimmerItem;
27 import org.openhab.core.library.items.LocationItem;
28 import org.openhab.core.library.items.NumberItem;
29 import org.openhab.core.library.items.PlayerItem;
30 import org.openhab.core.library.items.RollershutterItem;
31 import org.openhab.core.library.items.StringItem;
32 import org.openhab.core.library.items.SwitchItem;
33
34 /**
35  * Test for AbstractDynamoDBItem.getDynamoItemClass
36  *
37  * @author Sami Salonen - Initial contribution
38  */
39 @NonNullByDefault
40 public class AbstractDynamoDBItemGetDynamoItemClassTest {
41
42     @ParameterizedTest
43     @CsvSource({ "true", "false" })
44     public void testCallItem(boolean legacy) throws IOException {
45         assertEquals(DynamoDBStringItem.class, AbstractDynamoDBItem.getDynamoItemClass(CallItem.class, legacy));
46     }
47
48     @ParameterizedTest
49     @CsvSource({ "true", "false" })
50     public void testContactItem(boolean legacy) throws IOException {
51         assertEquals(DynamoDBBigDecimalItem.class, AbstractDynamoDBItem.getDynamoItemClass(ContactItem.class, legacy));
52     }
53
54     @ParameterizedTest
55     @CsvSource({ "true", "false" })
56     public void testDateTimeItem(boolean legacy) throws IOException {
57         assertEquals(DynamoDBStringItem.class, AbstractDynamoDBItem.getDynamoItemClass(DateTimeItem.class, legacy));
58     }
59
60     @ParameterizedTest
61     @CsvSource({ "true", "false" })
62     public void testStringItem(boolean legacy) throws IOException {
63         assertEquals(DynamoDBStringItem.class, AbstractDynamoDBItem.getDynamoItemClass(StringItem.class, legacy));
64     }
65
66     @ParameterizedTest
67     @CsvSource({ "true", "false" })
68     public void testLocationItem(boolean legacy) throws IOException {
69         assertEquals(DynamoDBStringItem.class, AbstractDynamoDBItem.getDynamoItemClass(LocationItem.class, legacy));
70     }
71
72     @ParameterizedTest
73     @CsvSource({ "true", "false" })
74     public void testNumberItem(boolean legacy) throws IOException {
75         assertEquals(DynamoDBBigDecimalItem.class, AbstractDynamoDBItem.getDynamoItemClass(NumberItem.class, legacy));
76     }
77
78     @ParameterizedTest
79     @CsvSource({ "true", "false" })
80     public void testColorItem(boolean legacy) throws IOException {
81         assertEquals(DynamoDBStringItem.class, AbstractDynamoDBItem.getDynamoItemClass(ColorItem.class, legacy));
82     }
83
84     @ParameterizedTest
85     @CsvSource({ "true", "false" })
86     public void testDimmerItem(boolean legacy) throws IOException {
87         assertEquals(DynamoDBBigDecimalItem.class, AbstractDynamoDBItem.getDynamoItemClass(DimmerItem.class, legacy));
88     }
89
90     @ParameterizedTest
91     @CsvSource({ "true", "false" })
92     public void testPlayerItem(boolean legacy) throws IOException {
93         assertEquals(legacy ? DynamoDBStringItem.class : DynamoDBBigDecimalItem.class,
94                 AbstractDynamoDBItem.getDynamoItemClass(PlayerItem.class, legacy));
95     }
96
97     @ParameterizedTest
98     @CsvSource({ "true", "false" })
99     public void testRollershutterItem(boolean legacy) throws IOException {
100         assertEquals(DynamoDBBigDecimalItem.class,
101                 AbstractDynamoDBItem.getDynamoItemClass(RollershutterItem.class, legacy));
102     }
103
104     @ParameterizedTest
105     @CsvSource({ "true", "false" })
106     public void testOnOffTypeWithSwitchItem(boolean legacy) throws IOException {
107         assertEquals(DynamoDBBigDecimalItem.class, AbstractDynamoDBItem.getDynamoItemClass(SwitchItem.class, legacy));
108     }
109 }