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.api;
15 import static org.hamcrest.MatcherAssert.assertThat;
16 import static org.hamcrest.Matchers.equalTo;
17 import static org.hamcrest.Matchers.is;
19 import java.time.Duration;
20 import java.time.LocalDate;
22 import org.eclipse.jdt.annotation.NonNullByDefault;
23 import org.junit.jupiter.api.Test;
24 import org.junit.jupiter.api.extension.ExtendWith;
25 import org.mockito.junit.jupiter.MockitoExtension;
28 * Tests for {@link DateQueryParameter}.
30 * @author Jacob Laursen - Initial contribution
33 @ExtendWith(MockitoExtension.class)
34 public class DateQueryParameterTest {
37 void dateQueryParameterTypeWithNegativeOffset() {
38 DateQueryParameter parameter = DateQueryParameter.of(DateQueryParameterType.UTC_NOW, Duration.ofHours(-12));
39 assertThat(parameter.toString(), is(equalTo("utcnow-PT12H")));
43 void dateQueryParameterTypeWithPositiveOffset() {
44 DateQueryParameter parameter = DateQueryParameter.of(DateQueryParameterType.UTC_NOW, Duration.ofHours(12));
45 assertThat(parameter.toString(), is(equalTo("utcnow+PT12H")));
49 void dateQueryParameterTypeWithZeroOffset() {
50 DateQueryParameter parameter = DateQueryParameter.of(DateQueryParameterType.UTC_NOW, Duration.ZERO);
51 assertThat(parameter.toString(), is(equalTo("utcnow")));
55 void dateQueryParameterTypeWithoutOffset() {
56 DateQueryParameter parameter = DateQueryParameter.of(DateQueryParameterType.NOW);
57 assertThat(parameter.toString(), is(equalTo("now")));
62 DateQueryParameter parameter = DateQueryParameter.of(LocalDate.of(2023, 2, 28));
63 assertThat(parameter.toString(), is(equalTo("2023-02-28")));