use of java.time.Instant in project dropwizard by dropwizard.
the class InstantMapperTest method mapColumnByName.
@Test
public void mapColumnByName() throws Exception {
ZonedDateTime expected = ZonedDateTime.parse("2012-12-21T00:00:00.000Z");
ZonedDateTime stored = expected.withZoneSameInstant(ZoneId.systemDefault());
when(resultSet.getTimestamp("instant")).thenReturn(Timestamp.from(stored.toInstant()));
Instant actual = new InstantMapper().mapColumn(resultSet, "instant", null);
assertThat(actual).isEqualTo(expected.toInstant());
}
use of java.time.Instant in project dropwizard by dropwizard.
the class InstantMapperTest method mapColumnByIndex_TimestampIsNull.
@Test
public void mapColumnByIndex_TimestampIsNull() throws Exception {
when(resultSet.getTimestamp(1)).thenReturn(null);
Instant actual = new InstantMapper().mapColumn(resultSet, 1, null);
assertThat(actual).isNull();
}
use of java.time.Instant in project dropwizard by dropwizard.
the class OffsetDateTimeArgumentTest method apply.
@Test
public void apply() throws Exception {
final Instant now = OffsetDateTime.now().toInstant();
final OffsetDateTime dateTime = OffsetDateTime.ofInstant(now, ZoneId.systemDefault());
new OffsetDateTimeArgument(dateTime, Optional.empty()).apply(1, statement, context);
Mockito.verify(statement).setTimestamp(1, Timestamp.from(now));
}
use of java.time.Instant in project dropwizard by dropwizard.
the class OffsetDateTimeMapperTest method mapColumnByIndex.
@Test
public void mapColumnByIndex() throws Exception {
final Instant now = OffsetDateTime.now().toInstant();
when(resultSet.getTimestamp(1)).thenReturn(Timestamp.from(now));
OffsetDateTime actual = new OffsetDateTimeMapper().mapColumn(resultSet, 1, null);
assertThat(actual).isEqualTo(OffsetDateTime.ofInstant(now, ZoneId.systemDefault()));
}
use of java.time.Instant in project dropwizard by dropwizard.
the class OffsetDateTimeMapperTest method mapColumnByName.
@Test
public void mapColumnByName() throws Exception {
final Instant now = OffsetDateTime.now().toInstant();
when(resultSet.getTimestamp("name")).thenReturn(Timestamp.from(now));
OffsetDateTime actual = new OffsetDateTimeMapper().mapColumn(resultSet, "name", null);
assertThat(actual).isEqualTo(OffsetDateTime.ofInstant(now, ZoneId.systemDefault()));
}
Aggregations