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.binding.energidataservice.internal.retry.strategy;
15 import static org.hamcrest.CoreMatchers.*;
16 import static org.hamcrest.MatcherAssert.assertThat;
17 import static org.hamcrest.Matchers.is;
19 import java.time.Clock;
20 import java.time.Duration;
21 import java.time.Instant;
22 import java.time.LocalTime;
23 import java.time.ZoneId;
25 import org.eclipse.jdt.annotation.NonNullByDefault;
26 import org.junit.jupiter.api.Test;
27 import org.openhab.binding.energidataservice.internal.retry.RetryStrategy;
30 * Tests for {@link FixedTime}.
32 * @author Jacob Laursen - Initial contribution
35 public class FixedTimeTest {
39 RetryStrategy retryPolicy = new FixedTime(LocalTime.of(12, 0),
40 Clock.fixed(Instant.parse("2023-01-24T10:00:00Z"), ZoneId.of("UTC")));
41 assertThat(retryPolicy.getDuration(), is(Duration.ofHours(2)));
46 RetryStrategy retryPolicy = new FixedTime(LocalTime.of(12, 0),
47 Clock.fixed(Instant.parse("2023-01-24T12:00:00Z"), ZoneId.of("UTC")));
48 assertThat(retryPolicy.getDuration(), is(Duration.ZERO));
53 RetryStrategy retryPolicy = new FixedTime(LocalTime.of(12, 0),
54 Clock.fixed(Instant.parse("2023-01-24T13:00:00Z"), ZoneId.of("UTC")));
55 assertThat(retryPolicy.getDuration(), is(Duration.ofHours(23)));