]> git.basschouten.com Git - openhab-addons.git/blob
8c40637e01d758abf8d66f0e6fc9ef67953786de
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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     private static final String NAME = "string";
33     private static final StringType STATE1 = new StringType("b001");
34     private static final StringType STATE2 = new StringType("c002");
35     private static final StringType STATE_BETWEEN = new StringType("b001");
36
37     @BeforeAll
38     public static void storeData() throws InterruptedException {
39         StringItem item = (StringItem) ITEMS.get(NAME);
40         item.setState(STATE1);
41         beforeStore = ZonedDateTime.now();
42         Thread.sleep(10);
43         service.store(item);
44         afterStore1 = ZonedDateTime.now();
45         Thread.sleep(10);
46         item.setState(STATE2);
47         service.store(item);
48         Thread.sleep(10);
49         afterStore2 = ZonedDateTime.now();
50
51         LOGGER.info("Created item between {} and {}", AbstractDynamoDBItem.DATEFORMATTER.format(beforeStore),
52                 AbstractDynamoDBItem.DATEFORMATTER.format(afterStore1));
53     }
54
55     @Override
56     protected String getItemName() {
57         return NAME;
58     }
59
60     @Override
61     protected State getFirstItemState() {
62         return STATE1;
63     }
64
65     @Override
66     protected State getSecondItemState() {
67         return STATE2;
68     }
69
70     @Override
71     protected @Nullable State getQueryItemStateBetween() {
72         return STATE_BETWEEN;
73     }
74 }