use of java.time.LocalDate in project dropwizard by dropwizard.
the class LocalDateMapperTest method mapColumnByName_TimestampIsNull.
@Test
public void mapColumnByName_TimestampIsNull() throws Exception {
when(resultSet.getTimestamp("name")).thenReturn(null);
LocalDate actual = new LocalDateMapper().mapColumn(resultSet, "name", null);
assertThat(actual).isNull();
}
use of java.time.LocalDate in project dropwizard by dropwizard.
the class LocalDateMapperTest method mapColumnByIndex.
@Test
public void mapColumnByIndex() throws Exception {
when(resultSet.getTimestamp(1)).thenReturn(Timestamp.valueOf("2007-12-03 00:00:00.000"));
LocalDate actual = new LocalDateMapper().mapColumn(resultSet, 1, null);
assertThat(actual).isEqualTo(LocalDate.parse("2007-12-03"));
}
use of java.time.LocalDate in project dropwizard by dropwizard.
the class LocalDateMapperTest method mapColumnByIndex_TimestampIsNull.
@Test
public void mapColumnByIndex_TimestampIsNull() throws Exception {
when(resultSet.getTimestamp(1)).thenReturn(null);
LocalDate actual = new LocalDateMapper().mapColumn(resultSet, 1, null);
assertThat(actual).isNull();
}
use of java.time.LocalDate in project morphia by mongodb.
the class Java8EntityTest method rangeQueries.
@Test
public void rangeQueries() {
Instant instant = Instant.ofEpochMilli(System.currentTimeMillis());
LocalDate localDate = LocalDate.of(1995, 10, 15);
LocalDateTime localDateTime = LocalDateTime.of(2016, 4, 10, 14, 15, 16, 123 * 1000000);
LocalTime localTime = LocalTime.of(10, 29, 15, 848493);
for (int i = 0; i < 10; i++) {
createEntity(getDs(), instant.plus(i, DAYS), localDate.plus(i, DAYS), localDateTime.plus(i, DAYS), localTime.plus(i, ChronoUnit.HOURS));
}
Assert.assertEquals(2L, getDs().find(Java8Entity.class).field("instant").lessThanOrEq(instant.plus(1, DAYS)).count());
Assert.assertEquals(1L, getDs().find(Java8Entity.class).field("localDate").equal(localDate.plus(1, DAYS)).count());
Assert.assertEquals(0L, getDs().find(Java8Entity.class).field("localDate").equal(localDate.minus(1, DAYS)).count());
Assert.assertEquals(9L, getDs().find(Java8Entity.class).field("localDateTime").notEqual(localDateTime.plus(6, DAYS)).count());
}
use of java.time.LocalDate in project morphia by mongodb.
the class Java8EntityTest method queries.
@Test
public void queries() {
Instant instant = Instant.ofEpochMilli(System.currentTimeMillis());
LocalDate localDate = LocalDate.of(1995, 10, 15);
LocalDateTime localDateTime = LocalDateTime.of(2016, 4, 10, 14, 15, 16, 123 * 1000000);
LocalTime localTime = LocalTime.of(10, 29, 15, 848000000);
Java8Entity entity = createEntity(getDs(), instant, localDate, localDateTime, localTime);
compare(getDs(), entity, "instant", instant);
compare(getDs(), entity, "localDate", localDate);
compare(getDs(), entity, "localDateTime", localDateTime);
compare(getDs(), entity, "localTime", localTime);
}
Aggregations