Search in sources :

Example 1 with LocalDateTime

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

the class LocalDateTimeArgumentTest method apply.

@Test
public void apply() throws Exception {
    LocalDateTime localDateTime = LocalDateTime.parse("2007-12-03T10:15:30.375");
    new LocalDateTimeArgument(localDateTime).apply(1, statement, context);
    Mockito.verify(statement).setTimestamp(1, Timestamp.valueOf("2007-12-03 10:15:30.375"));
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.junit.Test)

Example 2 with LocalDateTime

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

the class LocalDateTimeMapperTest method mapColumnByName_TimestampIsNull.

@Test
public void mapColumnByName_TimestampIsNull() throws Exception {
    when(resultSet.getTimestamp("name")).thenReturn(null);
    LocalDateTime actual = new LocalDateTimeMapper().mapColumn(resultSet, "name", null);
    assertThat(actual).isNull();
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.junit.Test)

Example 3 with LocalDateTime

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

the class LocalDateTimeMapperTest method mapColumnByIndex.

@Test
public void mapColumnByIndex() throws Exception {
    when(resultSet.getTimestamp(1)).thenReturn(Timestamp.valueOf("2007-12-03 10:15:30.375"));
    LocalDateTime actual = new LocalDateTimeMapper().mapColumn(resultSet, 1, null);
    assertThat(actual).isEqualTo(LocalDateTime.parse("2007-12-03T10:15:30.375"));
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.junit.Test)

Example 4 with LocalDateTime

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

the class LocalDateTimeMapperTest method mapColumnByIndex_TimestampIsNull.

@Test
public void mapColumnByIndex_TimestampIsNull() throws Exception {
    when(resultSet.getTimestamp(1)).thenReturn(null);
    LocalDateTime actual = new LocalDateTimeMapper().mapColumn(resultSet, 1, null);
    assertThat(actual).isNull();
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.junit.Test)

Example 5 with LocalDateTime

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

the class OptionalLocalDateTimeTest method testPresent.

@Test
public void testPresent() {
    final LocalDateTime startDate = LocalDateTime.now();
    final LocalDateTime endDate = startDate.plusDays(1L);
    dao.insert(1, Optional.of("John Hughes"), startDate, Optional.of(endDate), Optional.empty());
    assertThat(dao.findEndDateById(1).get()).isEqualTo(endDate);
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.junit.Test)

Aggregations

LocalDateTime (java.time.LocalDateTime)1858 Test (org.junit.Test)640 Test (org.testng.annotations.Test)298 LocalDate (java.time.LocalDate)226 Test (org.junit.jupiter.api.Test)177 ZonedDateTime (java.time.ZonedDateTime)139 LocalTime (java.time.LocalTime)126 Date (java.util.Date)122 DateTimeFormatter (java.time.format.DateTimeFormatter)106 Instant (java.time.Instant)80 ArrayList (java.util.ArrayList)78 ZoneId (java.time.ZoneId)68 List (java.util.List)65 ZoneOffsetTransition (java.time.zone.ZoneOffsetTransition)55 Timestamp (java.sql.Timestamp)49 OffsetDateTime (java.time.OffsetDateTime)47 ZoneOffset (java.time.ZoneOffset)43 HashMap (java.util.HashMap)41 IOException (java.io.IOException)39 Map (java.util.Map)38