package org.apereo.cas.mongo;

import lombok.val;
import org.apache.commons.lang3.StringUtils;
import org.bson.BsonReader;
import org.bson.BsonTimestamp;
import org.bson.BsonWriter;
import org.bson.codecs.DecoderContext;
import org.bson.codecs.EncoderContext;
import org.bson.codecs.configuration.CodecRegistry;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;

import java.time.ZonedDateTime;

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;

/**
 * This is {@link ConvertersTests}.
 *
 * @author Misagh Moayyed
 * @since 6.3.0
 */
@Tag("MongoDb")
public class ConvertersTests {

    @Test
    public void verifyOperation() {
        assertNull(new BaseConverters.NullConverter().convert(new Object()));
        assertNull(new BaseConverters.StringToZonedDateTimeConverter().convert(StringUtils.EMPTY));
        assertNull(new BaseConverters.StringToPatternConverter().convert(StringUtils.EMPTY));
        assertNotNull(new BaseConverters.StringToZonedDateTimeConverter().convert(ZonedDateTime.now().toString()));
        assertNotNull(new BaseConverters.ZonedDateTimeToStringConverter().convert(ZonedDateTime.now()));
        assertNotNull(new BaseConverters.BsonTimestampToDateConverter().convert(new BsonTimestamp()));
        assertNotNull(new BaseConverters.BsonTimestampToStringConverter().convert(new BsonTimestamp()));
        assertNotNull(new BaseConverters.ZonedDateTimeTransformer().transform(ZonedDateTime.now()));
        val codec = new BaseConverters.ZonedDateTimeCodecProvider().get(ZonedDateTime.class, mock(CodecRegistry.class));
        assertNotNull(codec);

        assertDoesNotThrow(new Executable() {
            @Override
            public void execute() {
                codec.encode(mock(BsonWriter.class), ZonedDateTime.now(), mock(EncoderContext.class));

                val r = mock(BsonReader.class);
                when(r.readTimestamp()).thenReturn(new BsonTimestamp());
                codec.decode(r, mock(DecoderContext.class));
            }
        });
        assertNotNull(codec.getEncoderClass());
    }

}

@@ -421,24 +421,48 @@
 xecutable;%0A%0A
+import java.time.Clock;%0A
 import java.
@@ -481,16 +481,16 @@
 teTime;%0A
-
 %0Aimport 
@@ -1125,16 +1125,33 @@
 ime.now(
+Clock.systemUTC()
 ).toStri
@@ -1250,32 +1250,49 @@
 nedDateTime.now(
+Clock.systemUTC()
 )));%0A        ass
@@ -1584,16 +1584,33 @@
 ime.now(
+Clock.systemUTC()
 )));%0A   
@@ -1858,24 +1858,24 @@
 execute() %7B%0A
-
             
@@ -1933,16 +1933,33 @@
 ime.now(
+Clock.systemUTC()
 ), mock(

fix tests