Search in sources :

Example 36 with Instant

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());
}
Also used : ZonedDateTime(java.time.ZonedDateTime) Instant(java.time.Instant) Test(org.junit.Test)

Example 37 with Instant

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();
}
Also used : Instant(java.time.Instant) Test(org.junit.Test)

Example 38 with Instant

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));
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Instant(java.time.Instant) Test(org.junit.Test)

Example 39 with Instant

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()));
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Instant(java.time.Instant) Test(org.junit.Test)

Example 40 with Instant

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()));
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Instant(java.time.Instant) Test(org.junit.Test)

Aggregations

Instant (java.time.Instant)463 Test (org.testng.annotations.Test)143 Test (org.junit.Test)85 ZonedDateTime (java.time.ZonedDateTime)39 Duration (java.time.Duration)30 Clock (java.time.Clock)26 Lifetime (org.apache.cxf.sts.request.Lifetime)26 OffsetDateTime (java.time.OffsetDateTime)23 LocalDateTime (java.time.LocalDateTime)20 ArrayList (java.util.ArrayList)18 Element (org.w3c.dom.Element)18 LocalDate (java.time.LocalDate)17 IOException (java.io.IOException)14 Date (java.util.Date)14 LocalTime (java.time.LocalTime)12 DateTimeFormatter (java.time.format.DateTimeFormatter)12 STSException (org.apache.cxf.ws.security.sts.provider.STSException)12 SecurityToken (org.apache.cxf.ws.security.tokenstore.SecurityToken)12 Timestamp (java.sql.Timestamp)11 DefaultConditionsProvider (org.apache.cxf.sts.token.provider.DefaultConditionsProvider)10