2 * Copyright (c) 2010-2023 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 public static final boolean LEGACY_MODE = false;
37 private static HSBType color(double hue, int saturation, int brightness) {
38 return new HSBType(new DecimalType(hue), new PercentType(saturation), new PercentType(brightness));
41 private static HSBType color(String hue, int saturation, int brightness) {
42 return new HSBType(new DecimalType(new BigDecimal(hue)), new PercentType(saturation),
43 new PercentType(brightness));
46 private static final String NAME = "color";
47 // values are encoded as <hue>,<saturation>,<brightness>, ordering goes wrt strings
48 private static final HSBType STATE1 = color("3.1493842988948932984298384892384823984923849238492839483294893", 50,
50 private static final HSBType STATE2 = color(75, 100, 90);
51 private static final HSBType STATE_BETWEEN = color(60, 50, 50);
53 @SuppressWarnings("null")
55 public static void storeData() throws InterruptedException {
56 ColorItem item = (ColorItem) ITEMS.get(NAME);
57 item.setState(STATE1);
58 beforeStore = ZonedDateTime.now();
61 afterStore1 = ZonedDateTime.now();
63 item.setState(STATE2);
66 afterStore2 = ZonedDateTime.now();
68 LOGGER.info("Created item between {} and {}", AbstractDynamoDBItem.DATEFORMATTER.format(beforeStore),
69 AbstractDynamoDBItem.DATEFORMATTER.format(afterStore1));
73 protected String getItemName() {
78 protected State getFirstItemState() {
83 protected State getSecondItemState() {
88 protected @Nullable State getQueryItemStateBetween() {