2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.persistence.dynamodb.internal;
15 import static org.junit.jupiter.api.Assertions.assertEquals;
17 import java.io.IOException;
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;
35 * Test for AbstractDynamoDBItem.getDynamoItemClass
37 * @author Sami Salonen - Initial contribution
40 public class AbstractDynamoDBItemGetDynamoItemClassTest {
43 @CsvSource({ "true", "false" })
44 public void testCallItem(boolean legacy) throws IOException {
45 assertEquals(DynamoDBStringItem.class, AbstractDynamoDBItem.getDynamoItemClass(CallItem.class, legacy));
49 @CsvSource({ "true", "false" })
50 public void testContactItem(boolean legacy) throws IOException {
51 assertEquals(DynamoDBBigDecimalItem.class, AbstractDynamoDBItem.getDynamoItemClass(ContactItem.class, legacy));
55 @CsvSource({ "true", "false" })
56 public void testDateTimeItem(boolean legacy) throws IOException {
57 assertEquals(DynamoDBStringItem.class, AbstractDynamoDBItem.getDynamoItemClass(DateTimeItem.class, legacy));
61 @CsvSource({ "true", "false" })
62 public void testStringItem(boolean legacy) throws IOException {
63 assertEquals(DynamoDBStringItem.class, AbstractDynamoDBItem.getDynamoItemClass(StringItem.class, legacy));
67 @CsvSource({ "true", "false" })
68 public void testLocationItem(boolean legacy) throws IOException {
69 assertEquals(DynamoDBStringItem.class, AbstractDynamoDBItem.getDynamoItemClass(LocationItem.class, legacy));
73 @CsvSource({ "true", "false" })
74 public void testNumberItem(boolean legacy) throws IOException {
75 assertEquals(DynamoDBBigDecimalItem.class, AbstractDynamoDBItem.getDynamoItemClass(NumberItem.class, legacy));
79 @CsvSource({ "true", "false" })
80 public void testColorItem(boolean legacy) throws IOException {
81 assertEquals(DynamoDBStringItem.class, AbstractDynamoDBItem.getDynamoItemClass(ColorItem.class, legacy));
85 @CsvSource({ "true", "false" })
86 public void testDimmerItem(boolean legacy) throws IOException {
87 assertEquals(DynamoDBBigDecimalItem.class, AbstractDynamoDBItem.getDynamoItemClass(DimmerItem.class, legacy));
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));
98 @CsvSource({ "true", "false" })
99 public void testRollershutterItem(boolean legacy) throws IOException {
100 assertEquals(DynamoDBBigDecimalItem.class,
101 AbstractDynamoDBItem.getDynamoItemClass(RollershutterItem.class, legacy));
105 @CsvSource({ "true", "false" })
106 public void testOnOffTypeWithSwitchItem(boolean legacy) throws IOException {
107 assertEquals(DynamoDBBigDecimalItem.class, AbstractDynamoDBItem.getDynamoItemClass(SwitchItem.class, legacy));