]> git.basschouten.com Git - openhab-addons.git/blob
c9ac27df9419e62839d3fc8e5e203f3295b1ff20
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.enturno.internal.util;
14
15 import static org.hamcrest.CoreMatchers.*;
16 import static org.hamcrest.MatcherAssert.assertThat;
17
18 import java.util.stream.Stream;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.junit.jupiter.params.ParameterizedTest;
22 import org.junit.jupiter.params.provider.Arguments;
23 import org.junit.jupiter.params.provider.MethodSource;
24
25 /**
26  * Tests for {@link DateUtil}.
27  *
28  * @author Jacob Laursen - Initial contribution
29  */
30 @NonNullByDefault
31 public class DateUtilTest {
32     @ParameterizedTest
33     @MethodSource("provideTestCasesForGetIsoDateTime")
34     void getIsoDateTime(String value, String expected) {
35         assertThat(DateUtil.getIsoDateTime(value), is(expected));
36     }
37
38     private static Stream<Arguments> provideTestCasesForGetIsoDateTime() {
39         return Stream.of( //
40                 Arguments.of("2023-10-25T09:01:00+0200", "2023-10-25T09:01:00+02:00"),
41                 Arguments.of("2023-10-25T09:01:00+02:00", "2023-10-25T09:01:00+02:00"),
42                 Arguments.of("2023-10-25T09:01:00-0300", "2023-10-25T09:01:00-03:00"),
43                 Arguments.of("2023-10-25T09:01:00+02:30", "2023-10-25T09:01:00+02:30"),
44                 Arguments.of("2023-10-25T09:01:00", "2023-10-25T09:01:00"));
45     }
46 }