/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you under the Apache License, Version 2.0 (the
 *  "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 */
package org.apache.isis.commons.internal.base;

import java.time.LocalDate;
import java.time.LocalTime;
import java.time.OffsetDateTime;
import java.time.OffsetTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

import lombok.val;

class TemporalsTest {

    @Test
    void roundtripOffsetTime() {
        val temporal = OffsetTime.of(sampleTime(), sampleOffset());
        assertEquals(temporal, _Temporals.destringAsOffsetTime(_Temporals.enstringOffsetTime(temporal)));
    }

    @Test
    void roundtripOffsetDateTime() {
        val temporal = OffsetDateTime.of(sampleDate(), sampleTime(), sampleOffset());
        assertEquals(temporal, _Temporals.destringAsOffsetDateTime(_Temporals.enstringOffsetDateTime(temporal)));
    }

    @Test
    void roundtripZonedDateTime() {
        val temporal = ZonedDateTime.of(sampleDate(), sampleTime(), sampleZone());
        assertEquals(temporal, _Temporals.destringAsZonedDateTime(_Temporals.enstringZonedDateTime(temporal)));
    }

    // -- HELPER

    private static LocalDate sampleDate() {
        return _Temporals.sampleLocalDate().getElseFail(0);
    }

    private static LocalTime sampleTime() {
        return _Temporals.sampleLocalTime().getElseFail(0);
    }

    private static ZoneOffset sampleOffset() {
        return ZoneOffset.ofHoursMinutes(6, 15);
    }

    private static ZoneId sampleZone() {
        return ZoneId.of("Europe/Paris");
    }


}

@@ -871,213 +871,8 @@
 e;%0A%0A
-import java.time.LocalDate;%0Aimport java.time.LocalTime;%0Aimport java.time.OffsetDateTime;%0Aimport java.time.OffsetTime;%0Aimport java.time.ZoneId;%0Aimport java.time.ZoneOffset;%0Aimport java.time.ZonedDateTime;%0A%0A
 impo
@@ -1051,32 +1051,36 @@
 ime() %7B%0A        
+for(
 val temporal = O
@@ -1079,56 +1079,47 @@
 oral
- = OffsetTime.of(sampleTime(), sampleOffset());%0A
+: _Temporals.sampleOffsetTime()) %7B%0A    
     
@@ -1212,32 +1212,42 @@
 me(temporal)));%0A
+        %7D%0A
     %7D%0A%0A    @Test
@@ -1284,32 +1284,36 @@
 ime() %7B%0A        
+for(
 val temporal = O
@@ -1312,74 +1312,51 @@
 oral
- = OffsetDateTime.of(sampleDate(), sampleTime(), sampleOffset());%0A
+: _Temporals.sampleOffsetDateTime()) %7B%0A    
     
@@ -1457,32 +1457,42 @@
 me(temporal)));%0A
+        %7D%0A
     %7D%0A%0A    @Test
@@ -1536,16 +1536,20 @@
         
+for(
 val temp
@@ -1556,71 +1556,50 @@
 oral
- = ZonedDateTime.of(sampleDate(), sampleTime(), sampleZone());%0A
+: _Temporals.sampleZonedDateTime()) %7B%0A    
     
@@ -1714,443 +1714,19 @@
     
-%7D%0A%0A    // -- HELPER%0A%0A    private static LocalDate sampleDate() %7B%0A        return _Temporals.sampleLocalDate().getElseFail(0);%0A    %7D%0A%0A    private static LocalTime sampleTime() %7B%0A        return _Temporals.sampleLocalTime().getElseFail(0);%0A    %7D%0A%0A    private static ZoneOffset sampleOffset() %7B%0A        return ZoneOffset.ofHoursMinutes(6, 15);%0A    %7D%0A%0A    private static ZoneId sampleZone() %7B%0A        return ZoneId.of(%22Europe/Paris%22);%0A
     %7D%0A
+    %7D
 %0A%0A%7D%0A

consolidate temporal samplers for testing (2)