use of java.time.temporal.Temporal in project jdk8u_jdk by JetBrains.
the class TCKInstant method test_adjustInto.
@Test(dataProvider = "adjustInto")
public void test_adjustInto(Instant test, Temporal temporal, Temporal expected, Class<?> expectedEx) {
if (expectedEx == null) {
Temporal result = test.adjustInto(temporal);
assertEquals(result, expected);
} else {
try {
Temporal result = test.adjustInto(temporal);
fail();
} catch (Exception ex) {
assertTrue(expectedEx.isInstance(ex));
}
}
}
use of java.time.temporal.Temporal in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method test_with_adjustment.
//-----------------------------------------------------------------------
// with(TemporalAdjuster)
//-----------------------------------------------------------------------
@Test
public void test_with_adjustment() {
final LocalTime sample = LocalTime.of(23, 5);
TemporalAdjuster adjuster = new TemporalAdjuster() {
@Override
public Temporal adjustInto(Temporal dateTime) {
return sample;
}
};
assertEquals(TEST_12_30_40_987654321.with(adjuster), sample);
}
use of java.time.temporal.Temporal in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method test_with_adjustment.
//-----------------------------------------------------------------------
// with(WithAdjuster)
//-----------------------------------------------------------------------
@Test
public void test_with_adjustment() {
final OffsetDateTime sample = OffsetDateTime.of(LocalDate.of(2012, 3, 4), LocalTime.of(23, 5), OFFSET_PONE);
TemporalAdjuster adjuster = new TemporalAdjuster() {
@Override
public Temporal adjustInto(Temporal dateTime) {
return sample;
}
};
assertEquals(TEST_2008_6_30_11_30_59_000000500.with(adjuster), sample);
}
use of java.time.temporal.Temporal in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method test_adjustInto.
@Test(dataProvider = "adjustInto")
public void test_adjustInto(OffsetDateTime test, Temporal temporal, Temporal expected, Class<?> expectedEx) {
if (expectedEx == null) {
Temporal result = test.adjustInto(temporal);
assertEquals(result, expected);
} else {
try {
Temporal result = test.adjustInto(temporal);
fail();
} catch (Exception ex) {
assertTrue(expectedEx.isInstance(ex));
}
}
}
use of java.time.temporal.Temporal in project jdk8u_jdk by JetBrains.
the class TCKPeriod method test_minus_TemporalAmount_DaysHours.
@Test(expectedExceptions = DateTimeException.class)
public void test_minus_TemporalAmount_DaysHours() {
TemporalAmount amount = new TemporalAmount() {
@Override
public long get(TemporalUnit unit) {
if (unit == DAYS) {
return 1;
} else {
return 2;
}
}
@Override
public List<TemporalUnit> getUnits() {
List<TemporalUnit> list = new ArrayList<>();
list.add(DAYS);
list.add(HOURS);
return list;
}
@Override
public Temporal addTo(Temporal temporal) {
throw new UnsupportedOperationException();
}
@Override
public Temporal subtractFrom(Temporal temporal) {
throw new UnsupportedOperationException();
}
};
pymd(4, 5, 6).minus(amount);
}
Aggregations