Search in sources :

Example 51 with Period

use of java.time.Period in project j2objc by google.

the class TCKPeriod method test_plusMonths_overflowTooBig.

@Test(expected = ArithmeticException.class)
public void test_plusMonths_overflowTooBig() {
    Period test = Period.ofMonths(Integer.MAX_VALUE);
    test.plusMonths(1);
}
Also used : Period(java.time.Period) Test(org.junit.Test)

Example 52 with Period

use of java.time.Period in project j2objc by google.

the class TCKPeriod method test_multipliedBy_overflowTooSmall.

@Test(expected = ArithmeticException.class)
public void test_multipliedBy_overflowTooSmall() {
    Period test = Period.ofYears(Integer.MIN_VALUE / 2 - 1);
    test.multipliedBy(2);
}
Also used : Period(java.time.Period) Test(org.junit.Test)

Example 53 with Period

use of java.time.Period in project j2objc by google.

the class TCKPeriod method test_plusDays_overflowTooSmall.

@Test(expected = ArithmeticException.class)
public void test_plusDays_overflowTooSmall() {
    Period test = Period.ofDays(Integer.MIN_VALUE);
    test.plusDays(-1);
}
Also used : Period(java.time.Period) Test(org.junit.Test)

Example 54 with Period

use of java.time.Period in project j2objc by google.

the class TCKPeriod method test_good_getUnit.

@Test()
@UseDataProvider("data_goodTemporalUnit")
public void test_good_getUnit(long amount, TemporalUnit unit) {
    Period period = Period.of(2, 2, 2);
    long actual = period.get(unit);
    assertEquals("Value of unit: " + unit, actual, amount);
}
Also used : Period(java.time.Period) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 55 with Period

use of java.time.Period in project cayenne by apache.

the class Java8TimeIT method testJava8Period.

@Test
public void testJava8Period() {
    PeriodTestEntity periodTestEntity = context.newObject(PeriodTestEntity.class);
    Period period = Period.of(100, 10, 5);
    periodTestEntity.setPeriodField(period);
    context.commitChanges();
    PeriodTestEntity testRead = ObjectSelect.query(PeriodTestEntity.class).selectOne(context);
    assertNotNull(testRead.getPeriodField());
    assertEquals(Period.class, testRead.getPeriodField().getClass());
    assertEquals(period, testRead.getPeriodField());
}
Also used : Period(java.time.Period) PeriodTestEntity(org.apache.cayenne.testdo.java8.PeriodTestEntity) Test(org.junit.Test)

Aggregations

Period (java.time.Period)110 Test (org.junit.Test)37 Test (org.testng.annotations.Test)27 LocalDate (java.time.LocalDate)21 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)8 Duration (java.time.Duration)8 LocalDateTime (java.time.LocalDateTime)7 ZonedDateTime (java.time.ZonedDateTime)7 DateTimeFormatter (java.time.format.DateTimeFormatter)6 Date (java.util.Date)6 Instant (java.time.Instant)5 LocalTime (java.time.LocalTime)5 ZoneId (java.time.ZoneId)5 Test (org.junit.jupiter.api.Test)5 DateTimeParseException (java.time.format.DateTimeParseException)4 TemporalAmount (java.time.temporal.TemporalAmount)4 Arrays (java.util.Arrays)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 OffsetTime (java.time.OffsetTime)3