Search in sources :

Example 1 with ZonedDateTime

use of java.time.ZonedDateTime in project dropwizard by dropwizard.

the class InstantArgumentTest method applyCalendar.

@Test
public void applyCalendar() throws Exception {
    final ZoneId systemDefault = ZoneId.systemDefault();
    // this test only asserts that a calendar was passed in. Not that the JDBC driver
    // will do the right thing and adjust the time.
    final ZonedDateTime zonedDateTime = ZonedDateTime.parse("2012-12-21T00:00:00.000Z");
    final ZonedDateTime expected = zonedDateTime.withZoneSameInstant(systemDefault);
    final Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone(systemDefault));
    new InstantArgument(zonedDateTime.toInstant(), Optional.of(calendar)).apply(1, statement, context);
    Mockito.verify(statement).setTimestamp(1, Timestamp.from(expected.toInstant()), calendar);
}
Also used : ZoneId(java.time.ZoneId) ZonedDateTime(java.time.ZonedDateTime) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) Test(org.junit.Test)

Example 2 with ZonedDateTime

use of java.time.ZonedDateTime 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 3 with ZonedDateTime

use of java.time.ZonedDateTime in project dropwizard by dropwizard.

the class ZonedDateTimeArgumentTest method apply.

@Test
public void apply() throws Exception {
    ZonedDateTime dateTime = ZonedDateTime.of(2007, 12, 3, 10, 15, 30, 375_000_000, ZoneId.systemDefault());
    new ZonedDateTimeArgument(dateTime, Optional.empty()).apply(1, statement, context);
    Mockito.verify(statement).setTimestamp(1, Timestamp.valueOf("2007-12-03 10:15:30.375"));
}
Also used : ZonedDateTime(java.time.ZonedDateTime) Test(org.junit.Test)

Example 4 with ZonedDateTime

use of java.time.ZonedDateTime in project dropwizard by dropwizard.

the class ZonedDateTimeMapperTest method mapColumnByIndex.

@Test
public void mapColumnByIndex() throws Exception {
    when(resultSet.getTimestamp(1)).thenReturn(Timestamp.valueOf("2007-12-03 10:15:30.375"));
    ZonedDateTime actual = new ZonedDateTimeMapper().mapColumn(resultSet, 1, null);
    assertThat(actual).isEqualTo(ZonedDateTime.of(2007, 12, 3, 10, 15, 30, 375_000_000, ZoneId.systemDefault()));
}
Also used : ZonedDateTime(java.time.ZonedDateTime) Test(org.junit.Test)

Example 5 with ZonedDateTime

use of java.time.ZonedDateTime in project dropwizard by dropwizard.

the class ZonedDateTimeMapperTest method mapColumnByName.

@Test
public void mapColumnByName() throws Exception {
    when(resultSet.getTimestamp("name")).thenReturn(Timestamp.valueOf("2007-12-03 10:15:30.375"));
    ZonedDateTime actual = new ZonedDateTimeMapper().mapColumn(resultSet, "name", null);
    assertThat(actual).isEqualTo(ZonedDateTime.of(2007, 12, 3, 10, 15, 30, 375_000_000, ZoneId.systemDefault()));
}
Also used : ZonedDateTime(java.time.ZonedDateTime) Test(org.junit.Test)

Aggregations

ZonedDateTime (java.time.ZonedDateTime)1375 Test (org.junit.Test)570 Test (org.testng.annotations.Test)182 LocalDateTime (java.time.LocalDateTime)136 ZoneId (java.time.ZoneId)122 Instant (java.time.Instant)112 ArrayList (java.util.ArrayList)102 Test (org.junit.jupiter.api.Test)93 LocalDate (java.time.LocalDate)84 DateTimeFormatter (java.time.format.DateTimeFormatter)77 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)76 List (java.util.List)75 Date (java.util.Date)63 IOException (java.io.IOException)58 UUID (java.util.UUID)58 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)54 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)53 HashMap (java.util.HashMap)46 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)44 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)43