]> git.basschouten.com Git - openhab-addons.git/blob
5b2f0dba6da36bebc82f6f60a8a636538d23817c
[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 java.time.ZonedDateTime;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.junit.jupiter.api.BeforeAll;
20 import org.openhab.core.library.items.StringItem;
21 import org.openhab.core.library.types.StringType;
22 import org.openhab.core.types.State;
23
24 /**
25  *
26  * @author Sami Salonen - Initial contribution
27  *
28  */
29 @NonNullByDefault
30 public class StringItemIntegrationTest extends AbstractTwoItemIntegrationTest {
31
32     public static final boolean LEGACY_MODE = false;
33     private static final String NAME = "string";
34     private static final StringType STATE1 = new StringType("b001");
35     private static final StringType STATE2 = new StringType("c002");
36     private static final StringType STATE_BETWEEN = new StringType("b001");
37
38     @SuppressWarnings("null")
39     @BeforeAll
40     public static void storeData() throws InterruptedException {
41         StringItem item = (StringItem) ITEMS.get(NAME);
42         item.setState(STATE1);
43         beforeStore = ZonedDateTime.now();
44         Thread.sleep(10);
45         service.store(item);
46         afterStore1 = ZonedDateTime.now();
47         Thread.sleep(10);
48         item.setState(STATE2);
49         service.store(item);
50         Thread.sleep(10);
51         afterStore2 = ZonedDateTime.now();
52
53         LOGGER.info("Created item between {} and {}", AbstractDynamoDBItem.DATEFORMATTER.format(beforeStore),
54                 AbstractDynamoDBItem.DATEFORMATTER.format(afterStore1));
55     }
56
57     @Override
58     protected String getItemName() {
59         return NAME;
60     }
61
62     @Override
63     protected State getFirstItemState() {
64         return STATE1;
65     }
66
67     @Override
68     protected State getSecondItemState() {
69         return STATE2;
70     }
71
72     @Override
73     protected @Nullable State getQueryItemStateBetween() {
74         return STATE_BETWEEN;
75     }
76 }