### Question:
TimeSeries extends Series implements Cloneable, Serializable { public void removeAgedItems(boolean notify) { if (getItemCount() > 1) { long latest = getTimePeriod(getItemCount() - 1).getSerialIndex(); boolean removed = false; while ((latest - getTimePeriod(0).getSerialIndex()) > this.maximumItemAge) { this.data.remove(0); removed = true; } if (removed) { updateMinMaxYByIteration(); if (notify) { fireSeriesChanged(); } } } } TimeSeries(Comparable name);  TimeSeries(Comparable name, String domain, String range); String getDomainDescription(); void setDomainDescription(String description); String getRangeDescription(); void setRangeDescription(String description); @Override int getItemCount(); List<TimeSeriesDataItem> getItems(); int getMaximumItemCount(); void setMaximumItemCount(int maximum); long getMaximumItemAge(); void setMaximumItemAge(long periods); Range findValueRange(); Range findValueRange(Range xRange, TimeZone timeZone); Range findValueRange(Range xRange, TimePeriodAnchor xAnchor, 
            TimeZone zone); double getMinY(); double getMaxY(); Class getTimePeriodClass(); TimeSeriesDataItem getDataItem(int index); TimeSeriesDataItem getDataItem(RegularTimePeriod period); RegularTimePeriod getTimePeriod(int index); RegularTimePeriod getNextTimePeriod(); Collection<RegularTimePeriod> getTimePeriods(); Collection<RegularTimePeriod> getTimePeriodsUniqueToOtherSeries(TimeSeries series); int getIndex(RegularTimePeriod period); Number getValue(int index); Number getValue(RegularTimePeriod period); void add(TimeSeriesDataItem item); void add(TimeSeriesDataItem item, boolean notify); void add(RegularTimePeriod period, double value); void add(RegularTimePeriod period, double value, boolean notify); void add(RegularTimePeriod period, Number value); void add(RegularTimePeriod period, Number value, boolean notify); void update(RegularTimePeriod period, double value); void update(RegularTimePeriod period, Number value); void update(int index, Number value); TimeSeries addAndOrUpdate(TimeSeries series); TimeSeriesDataItem addOrUpdate(RegularTimePeriod period,
                                          double value); TimeSeriesDataItem addOrUpdate(RegularTimePeriod period,
                                          Number value); TimeSeriesDataItem addOrUpdate(TimeSeriesDataItem item); void removeAgedItems(boolean notify); void removeAgedItems(long latest, boolean notify); void clear(); void delete(RegularTimePeriod period); void delete(int start, int end); void delete(int start, int end, boolean notify); @Override Object clone(); TimeSeries createCopy(int start, int end); TimeSeries createCopy(RegularTimePeriod start, RegularTimePeriod end); @Override boolean equals(Object obj); @Override int hashCode();  }### Answer:
@Test public void testRemoveAgedItems() { TimeSeries series = new TimeSeries("Test Series"); series.addChangeListener(this); assertEquals(Long.MAX_VALUE, series.getMaximumItemAge()); assertEquals(Integer.MAX_VALUE, series.getMaximumItemCount()); this.gotSeriesChangeEvent = false; series.removeAgedItems(true); assertEquals(0, series.getItemCount()); assertFalse(this.gotSeriesChangeEvent); series.add(new Year(1999), 1.0); series.setMaximumItemAge(0); this.gotSeriesChangeEvent = false; series.removeAgedItems(true); assertEquals(1, series.getItemCount()); assertFalse(this.gotSeriesChangeEvent); series.setMaximumItemAge(10); series.add(new Year(2001), 2.0); this.gotSeriesChangeEvent = false; series.setMaximumItemAge(2); assertEquals(2, series.getItemCount()); assertEquals(0, series.getIndex(new Year(1999))); assertFalse(this.gotSeriesChangeEvent); series.setMaximumItemAge(1); assertEquals(1, series.getItemCount()); assertEquals(0, series.getIndex(new Year(2001))); assertTrue(this.gotSeriesChangeEvent); }
@Test public void testRemoveAgedItems3() { TimeSeries s = new TimeSeries("Test"); s.removeAgedItems(0L, true); }