Search in sources :

Example 1 with LocalDate

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

Example 2 with LocalDate

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

Example 3 with LocalDate

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

Example 4 with LocalDate

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

Example 5 with LocalDate

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

Aggregations

LocalDate (java.time.LocalDate)1513 Test (org.junit.Test)472 Test (org.testng.annotations.Test)372 LocalDateTime (java.time.LocalDateTime)155 LocalTime (java.time.LocalTime)126 Date (java.util.Date)99 DateTimeFormatter (java.time.format.DateTimeFormatter)96 Ignore (org.junit.Ignore)94 ArrayList (java.util.ArrayList)87 BigDecimal (java.math.BigDecimal)69 Instant (java.time.Instant)56 ZonedDateTime (java.time.ZonedDateTime)55 Test (org.junit.jupiter.api.Test)54 List (java.util.List)50 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)46 HashMap (java.util.HashMap)44 Member (cz.metacentrum.perun.core.api.Member)41 ZoneId (java.time.ZoneId)40 TemporalField (java.time.temporal.TemporalField)40 Attribute (cz.metacentrum.perun.core.api.Attribute)39