]> git.basschouten.com Git - openhab-addons.git/blob
a751482eada7387abf1604e0e93bc95da6e6f5ca
[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.LocationItem;
21 import org.openhab.core.library.types.DecimalType;
22 import org.openhab.core.library.types.PointType;
23 import org.openhab.core.types.State;
24
25 /**
26  *
27  * @author Sami Salonen - Initial contribution
28  *
29  */
30 @NonNullByDefault
31 public class LocationItemIntegrationTest extends AbstractTwoItemIntegrationTest {
32
33     public static final boolean LEGACY_MODE = false;
34     private static final String NAME = "location";
35     // values are encoded as lat,lon[,alt] , ordering goes wrt strings
36     private static final PointType STATE1 = new PointType(
37             new DecimalType("60.012033100120453345435345345345346365434630300230230032020393149"), new DecimalType(30.),
38             new DecimalType(3.0));
39     private static final PointType STATE2 = new PointType(new DecimalType(61.0), new DecimalType(30.));
40     private static final PointType STATE_BETWEEN = new PointType(new DecimalType(60.5), new DecimalType(30.));
41
42     @SuppressWarnings("null")
43     @BeforeAll
44     public static void storeData() throws InterruptedException {
45         LocationItem item = (LocationItem) ITEMS.get(NAME);
46         item.setState(STATE1);
47         beforeStore = ZonedDateTime.now();
48         Thread.sleep(10);
49         service.store(item);
50         afterStore1 = ZonedDateTime.now();
51         Thread.sleep(10);
52         item.setState(STATE2);
53         service.store(item);
54         Thread.sleep(10);
55         afterStore2 = ZonedDateTime.now();
56
57         LOGGER.info("Created item between {} and {}", AbstractDynamoDBItem.DATEFORMATTER.format(beforeStore),
58                 AbstractDynamoDBItem.DATEFORMATTER.format(afterStore1));
59     }
60
61     @Override
62     protected String getItemName() {
63         return NAME;
64     }
65
66     @Override
67     protected State getFirstItemState() {
68         return STATE1;
69     }
70
71     @Override
72     protected State getSecondItemState() {
73         return STATE2;
74     }
75
76     @Override
77     protected @Nullable State getQueryItemStateBetween() {
78         return STATE_BETWEEN;
79     }
80 }