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