2 * Copyright (c) 2010-2020 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.persistence.dynamodb.internal;
15 import java.math.BigDecimal;
16 import java.time.ZonedDateTime;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.junit.jupiter.api.BeforeAll;
21 import org.openhab.core.library.items.ColorItem;
22 import org.openhab.core.library.types.DecimalType;
23 import org.openhab.core.library.types.HSBType;
24 import org.openhab.core.library.types.PercentType;
25 import org.openhab.core.types.State;
29 * @author Sami Salonen - Initial contribution
33 public class ColorItemIntegrationTest extends AbstractTwoItemIntegrationTest {
35 private static HSBType color(double hue, int saturation, int brightness) {
36 return new HSBType(new DecimalType(hue), new PercentType(saturation), new PercentType(brightness));
39 private static HSBType color(String hue, int saturation, int brightness) {
40 return new HSBType(new DecimalType(new BigDecimal(hue)), new PercentType(saturation),
41 new PercentType(brightness));
44 private static final String NAME = "color";
45 // values are encoded as <hue>,<saturation>,<brightness>, ordering goes wrt strings
46 private static final HSBType STATE1 = color("3.1493842988948932984298384892384823984923849238492839483294893", 50,
48 private static final HSBType STATE2 = color(75, 100, 90);
49 private static final HSBType STATE_BETWEEN = color(60, 50, 50);
52 public static void storeData() throws InterruptedException {
53 ColorItem item = (ColorItem) ITEMS.get(NAME);
54 item.setState(STATE1);
55 beforeStore = ZonedDateTime.now();
58 afterStore1 = ZonedDateTime.now();
60 item.setState(STATE2);
63 afterStore2 = ZonedDateTime.now();
65 LOGGER.info("Created item between {} and {}", AbstractDynamoDBItem.DATEFORMATTER.format(beforeStore),
66 AbstractDynamoDBItem.DATEFORMATTER.format(afterStore1));
70 protected String getItemName() {
75 protected State getFirstItemState() {
80 protected State getSecondItemState() {
85 protected @Nullable State getQueryItemStateBetween() {