@DataProvider(name = "era_epochSecond_dataProvider") Object[][] data_era_epochSecond() { return new Object[][] { {JapaneseChronology.INSTANCE, JapaneseEra.MEIJI, 1873 - YDIFF_MEIJI, 9, 7, 1, 2, 2, OFFSET_P0100}, {JapaneseChronology.INSTANCE, JapaneseEra.SHOWA, 1928 - YDIFF_SHOWA, 2, 28, 1, 2, 2, OFFSET_M0100}, {JapaneseChronology.INSTANCE, JapaneseEra.HEISEI, 1989 - YDIFF_HEISEI, 1, 8, 1, 2, 2, OFFSET_P0100}, {HijrahChronology.INSTANCE, HijrahEra.AH, 1434, 9, 7, 1, 2, 2, OFFSET_P0100}, {MinguoChronology.INSTANCE, MinguoEra.BEFORE_ROC, 1873 - YDIFF_MINGUO, 9, 7, 1, 2, 2, OFFSET_P0100}, {MinguoChronology.INSTANCE, MinguoEra.ROC, 1928 - YDIFF_MINGUO, 2, 28, 1, 2, 2, OFFSET_M0100}, {MinguoChronology.INSTANCE, MinguoEra.ROC, 1989 - YDIFF_MINGUO, 1, 8, 1, 2, 2, OFFSET_P0100}, {ThaiBuddhistChronology.INSTANCE, ThaiBuddhistEra.BE, 1873 + YDIFF_THAIBUDDHIST, 9, 7, 1, 2, 2, OFFSET_P0100}, {ThaiBuddhistChronology.INSTANCE, ThaiBuddhistEra.BE, 1928 + YDIFF_THAIBUDDHIST, 2, 28, 1, 2, 2, OFFSET_M0100}, {ThaiBuddhistChronology.INSTANCE, ThaiBuddhistEra.BE, 1989 + YDIFF_THAIBUDDHIST, 1, 8, 1, 2, 2, OFFSET_P0100}, {IsoChronology.INSTANCE, IsoEra.CE, 1873, 9, 7, 1, 2, 2, OFFSET_P0100}, {IsoChronology.INSTANCE, IsoEra.CE, 1928, 2, 28, 1, 2, 2, OFFSET_M0100}, {IsoChronology.INSTANCE, IsoEra.CE, 1989, 1, 8, 1, 2, 2, OFFSET_P0100}, }; }
@Test public void test_HijrahChronology_dateYearDay() { Chronology chrono = Chronology.of("Hijrah"); ChronoLocalDate date1 = chrono.dateYearDay(HijrahEra.AH, 1434, 178); ChronoLocalDate date2 = chrono.date(HijrahEra.AH, 1434, 7, 1); assertEquals(date1, HijrahChronology.INSTANCE.dateYearDay(HijrahEra.AH, 1434, 178)); assertEquals(date2, HijrahChronology.INSTANCE.dateYearDay(HijrahEra.AH, 1434, 178)); }
@Test(dataProvider="HijrahEras") public void test_valueOf(HijrahEra era , String eraName, int eraValue) { assertEquals(era.getValue(), eraValue); assertEquals(HijrahChronology.INSTANCE.eraOf(eraValue), era); assertEquals(HijrahEra.of(eraValue), era); assertEquals(HijrahEra.valueOf(eraName), era); }
@DataProvider(name = "resolve_styleByEra") Object[][] data_resolve_styleByEra() { Object[][] result = new Object[ResolverStyle.values().length * HijrahEra.values().length][]; int i = 0; for (ResolverStyle style : ResolverStyle.values()) { for (HijrahEra era : HijrahEra.values()) { result[i++] = new Object[] {style, era}; } } return result; }
@Test(dataProvider = "resolve_styleByEra") public void test_resolve_yearOfEra_eraOnly_valid(ResolverStyle style, HijrahEra era) { Map<TemporalField, Long> fieldValues = new HashMap<>(); fieldValues.put(ChronoField.ERA, (long) era.getValue()); HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues, style); assertEquals(date, null); assertEquals(fieldValues.get(ChronoField.ERA), (Long) (long) era.getValue()); assertEquals(fieldValues.size(), 1); }
@Test(dataProvider = "resolve_styleByEra") public void test_resolve_yearOfEra_eraAndYearOfEraOnly_valid(ResolverStyle style, HijrahEra era) { Map<TemporalField, Long> fieldValues = new HashMap<>(); fieldValues.put(ChronoField.ERA, (long) era.getValue()); fieldValues.put(ChronoField.YEAR_OF_ERA, 1343L); HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues, style); assertEquals(date, null); assertEquals(fieldValues.get(ChronoField.ERA), null); assertEquals(fieldValues.get(ChronoField.YEAR_OF_ERA), null); assertEquals(fieldValues.get(ChronoField.YEAR), (Long) 1343L); assertEquals(fieldValues.size(), 1); }
@Test(dataProvider = "resolve_styleByEra") public void test_resolve_yearOfEra_eraAndYearOnly_valid(ResolverStyle style, HijrahEra era) { Map<TemporalField, Long> fieldValues = new HashMap<>(); fieldValues.put(ChronoField.ERA, (long) era.getValue()); fieldValues.put(ChronoField.YEAR, 1343L); HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues, style); assertEquals(date, null); assertEquals(fieldValues.get(ChronoField.ERA), (Long) (long) era.getValue()); assertEquals(fieldValues.get(ChronoField.YEAR), (Long) 1343L); assertEquals(fieldValues.size(), 2); }
@DataProvider(name = "Eras") Era[][] data_of_calendars() { return new Era[][] { {HijrahEra.AH}, {IsoEra.BCE}, {IsoEra.CE}, {MinguoEra.BEFORE_ROC}, {MinguoEra.ROC}, {ThaiBuddhistEra.BEFORE_BE}, {ThaiBuddhistEra.BE}, }; }