2 * Copyright (c) 2010-2022 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.time.ZonedDateTime;
17 import org.eclipse.jdt.annotation.NonNull;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.junit.jupiter.api.BeforeAll;
21 import org.junit.jupiter.api.TestInfo;
22 import org.openhab.core.library.items.PlayerItem;
23 import org.openhab.core.library.types.RewindFastforwardType;
24 import org.openhab.core.types.State;
28 * @author Sami Salonen - Initial contribution
32 public class PlayerItemRewindFastForwardIntegrationTest extends AbstractTwoItemIntegrationTest {
34 public static final boolean LEGACY_MODE = false;
35 private static final String NAME = "player_rewindfastforward";
37 private static @Nullable RewindFastforwardType STATE1, STATE2;
38 private static final @Nullable RewindFastforwardType STATE_BETWEEN = null;
40 @SuppressWarnings("null")
42 public static void storeData(TestInfo testInfo) throws InterruptedException {
44 RewindFastforwardType localState1, localState2;
45 if (isLegacyTest(testInfo)) {
46 // In legacy, FASTFORWARD < REWIND
47 STATE1 = RewindFastforwardType.FASTFORWARD;
48 STATE2 = RewindFastforwardType.REWIND;
50 // In non-legacy, FASTFORWARD (serialized as 1) > REWIND (-1)
51 STATE1 = RewindFastforwardType.REWIND;
52 STATE2 = RewindFastforwardType.FASTFORWARD;
54 localState1 = (@NonNull RewindFastforwardType) STATE1;
55 localState2 = (@NonNull RewindFastforwardType) STATE2;
56 assert localState1 != null;
57 assert localState2 != null;
59 PlayerItem item = (PlayerItem) ITEMS.get(NAME);
61 item.setState(localState1);
63 beforeStore = ZonedDateTime.now();
66 afterStore1 = ZonedDateTime.now();
68 item.setState(localState2);
71 afterStore2 = ZonedDateTime.now();
73 LOGGER.info("Created item between {} and {}", AbstractDynamoDBItem.DATEFORMATTER.format(beforeStore),
74 AbstractDynamoDBItem.DATEFORMATTER.format(afterStore1));
78 protected String getItemName() {
83 protected State getFirstItemState() {
84 return (@NonNull RewindFastforwardType) STATE1;
88 protected State getSecondItemState() {
89 return (@NonNull RewindFastforwardType) STATE2;
93 protected @Nullable State getQueryItemStateBetween() {