generator.server.springboot.database.redis.JSR310DateConvertersTest.mustache Maven / Gradle / Ivy
package {{packageName}}.wire.redis.infrastructure.secondary;
import static org.assertj.core.api.Assertions.assertThat;
import {{packageName}}.UnitTest;
import {{packageName}}.wire.redis.infrastructure.secondary.JSR310DateConverters.*;
import java.time.ZonedDateTime;
import java.util.Date;
import org.junit.jupiter.api.Test;
@UnitTest
class JSR310DateConvertersTest {
@Test
void shouldConvertZoneDateTimeToDate() {
ZonedDateTime source = ZonedDateTime.parse("2022-02-15T12:00:00+01:00[Europe/Paris]");
Date expected = Date.from(source.toInstant());
Date result = ZonedDateTimeToDateConverter.INSTANCE.convert(source);
assertThat(result).isEqualTo(expected);
}
@Test
void shouldConvertDateToZoneDateTime() {
ZonedDateTime expected = ZonedDateTime.parse("2022-02-15T12:00:00+01:00[Europe/Paris]");
Date source = Date.from(expected.toInstant());
ZonedDateTime result = DateToZonedDateTimeConverter.INSTANCE.convert(source);
assertThat(result).isEqualTo(expected);
}
}