/** Test of dateTrans method, of class DefaultCalendar. */ @Test public void testDateTrans_CalendarDate_ClockTime() { int[] cal = {2012, 9, 10}; CalendarDate calendarDate = new DefaultCalendarDate( calendar1, IndeterminateValue.NOW, new SimpleInternationalString("new Era"), cal); Number[] clock = {12, 10, 5.488}; ClockTime clockTime = new DefaultClockTime(calendar1, IndeterminateValue.NOW, clock); JulianDate result = calendar1.dateTrans(calendarDate, clockTime); assertTrue(calendar2.dateTrans(calendarDate, clockTime).equals(result)); }
/** * {@inheritDoc } */ @Override public boolean equals(Object object, ComparisonMode mode) { if (object instanceof Calendar) { final Calendar that = (Calendar) object; return Objects.equals(this.getName(), that.getName()) && Objects.equals(this.getDomainOfValidity(), that.getDomainOfValidity()) && Objects.equals(this.referenceFrame, that.getReferenceFrame()) &&Objects.equals(this.timeBasis, that.getTimeBasis()); } return false; }
/** * Constructs a new instance initialized with the values from the specified metadata object. * This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the * given object are not recursively copied. * * @param object The Calendar to copy values from, or {@code null} if none. * * @see #castOrCopy(Calendar) * @throws NullArgumentException if referenceFrame is {@code null}. */ private DefaultCalendar(final Calendar object) { super(object); if (object != null) { referenceFrame = object.getReferenceFrame(); ArgumentChecks.ensureNonNull("referenceFrame", referenceFrame); timeBasis = object.getTimeBasis(); } }
/** * Test of getClock method, of class DefaultCalendar. */ @Test public void testGetClock() { Clock result = calendar1.getTimeBasis(); assertEquals(calendar2.getTimeBasis(), result); } //
/** * Test of getBasis method, of class DefaultCalendar. */ @Test public void testGetBasis() { Collection<CalendarEra> result = (Collection<CalendarEra>) calendar1.getReferenceFrame(); assertEquals(calendar2.getReferenceFrame(), result); }
/** * Test of dateTrans method, of class DefaultCalendar. */ @Test public void testDateTrans_CalendarDate_ClockTime() { int[] cal = {2012, 9, 10}; CalendarDate calendarDate = new DefaultCalendarDate(calendar1, IndeterminateValue.NOW, new SimpleInternationalString("new Era"), cal); Number[] clock = {12, 10, 5.488}; ClockTime clockTime = new DefaultClockTime(calendar1, IndeterminateValue.NOW, clock); JulianDate result = calendar1.dateTrans(calendarDate, clockTime); assertTrue(calendar2.dateTrans(calendarDate, clockTime).equals(result)); }
/** Test of setBasis method, of class DefaultCalendar. */ @Test public void testSetBasis() throws ParseException { Collection<CalendarEra> result = calendar1.getBasis(); int[] calendarDate = {1, 1, 1}; CalendarEra calendarEra = new DefaultCalendarEra( new SimpleInternationalString("Babylonian calendar"), new SimpleInternationalString( "Ascension of Nebuchadnezzar II to the throne of Babylon"), new DefaultCalendarDate(calendar1, null, null, calendarDate), new DefaultJulianDate(calendar1, null, 1721423.25), new DefaultPeriod( new DefaultInstant( new DefaultPosition( new DefaultJulianDate(calendar1, null, 2087769))), new DefaultInstant( new DefaultPosition( new DefaultJulianDate(calendar1, null, 2299160))))); Collection<CalendarEra> collection = new ArrayList<CalendarEra>(); collection.add(calendarEra); ((DefaultCalendar) calendar1).setBasis(collection); assertFalse(calendar1.getBasis().equals(result)); }