All Downloads are FREE. Search and download functionalities are using the official Maven repository.

generator.server.springboot.database.redis.JSR310DateConvertersTest.mustache Maven / Gradle / Ivy

There is a newer version: 1.22.0
Show newest version
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);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy