@Test(dataProvider = "error") public void test_parse_error(ReducedPrinterParser pp, String text, int pos, Class<?> expected) { try { pp.parse(parseContext, text, pos); } catch (RuntimeException ex) { assertTrue(expected.isInstance(ex)); assertEquals(parseContext.toParsed().query(TemporalQueries.chronology()), null); assertEquals(parseContext.toParsed().query(TemporalQueries.zoneId()), null); } }
// ----------------------------------------------------------------------- // query(TemporalQuery) // ----------------------------------------------------------------------- @Test public void test_query() { assertEquals(Month.JUNE.query(TemporalQueries.chronology()), IsoChronology.INSTANCE); assertEquals(Month.JUNE.query(TemporalQueries.localDate()), null); assertEquals(Month.JUNE.query(TemporalQueries.localTime()), null); assertEquals(Month.JUNE.query(TemporalQueries.offset()), null); assertEquals(Month.JUNE.query(TemporalQueries.precision()), ChronoUnit.MONTHS); assertEquals(Month.JUNE.query(TemporalQueries.zone()), null); assertEquals(Month.JUNE.query(TemporalQueries.zoneId()), null); }
@SuppressWarnings("unchecked") @Override public <R> R query(TemporalQuery<R> query) { if (query == TemporalQueries.precision()) { return (R) ChronoUnit.ERAS; } if (query == TemporalQueries.chronology() || query == TemporalQueries.zone() || query == TemporalQueries.zoneId() || query == TemporalQueries.offset() || query == TemporalQueries.localDate() || query == TemporalQueries.localTime()) { return null; } return query.queryFrom(this); }