]> git.basschouten.com Git - openhab-addons.git/blob
e59a5c85b522b077872ddc1719cf49051c11d4b6
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.DimmerItem;
21 import org.openhab.core.library.types.PercentType;
22 import org.openhab.core.types.State;
23
24 /**
25  *
26  * @author Sami Salonen - Initial contribution
27  *
28  */
29 @NonNullByDefault
30 public class DimmerItemIntegrationTest extends AbstractTwoItemIntegrationTest {
31
32     private static final String NAME = "dimmer";
33     private static final PercentType STATE1 = new PercentType(66);
34     private static final PercentType STATE2 = new PercentType(68);
35     private static final PercentType STATE_BETWEEN = new PercentType(67);
36
37     @BeforeAll
38     public static void storeData() throws InterruptedException {
39         DimmerItem item = (DimmerItem) ITEMS.get(NAME);
40
41         item.setState(STATE1);
42
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 }