### Question:
TimePeriodValuesCollection extends AbstractIntervalXYDataset implements IntervalXYDataset, DomainInfo, Serializable { public TimePeriodValues getSeries(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Index 'series' out of range."); } return this.data.get(series); } TimePeriodValuesCollection();  TimePeriodValuesCollection(TimePeriodValues series); TimePeriodAnchor getXPosition(); void setXPosition(TimePeriodAnchor position); @Override int getSeriesCount(); TimePeriodValues getSeries(int series); @Override Comparable getSeriesKey(int series); void addSeries(TimePeriodValues series); void removeSeries(TimePeriodValues series); void removeSeries(int index); @Override int getItemCount(int series); @Override Number getX(int series, int item); @Override Number getStartX(int series, int item); @Override Number getEndX(int series, int item); @Override Number getY(int series, int item); @Override Number getStartY(int series, int item); @Override Number getEndY(int series, int item); @Override double getDomainLowerBound(boolean includeInterval); @Override double getDomainUpperBound(boolean includeInterval); @Override Range getDomainBounds(boolean includeInterval); @Override boolean equals(Object obj);  }### Answer:
@Test public void testGetSeries() { TimePeriodValuesCollection c1 = new TimePeriodValuesCollection(); TimePeriodValues s1 = new TimePeriodValues("Series 1"); c1.addSeries(s1); assertEquals("Series 1", c1.getSeries(0).getKey()); try { c1.getSeries(-1); fail("IllegalArgumentException should have been thrown on negative series"); } catch (IllegalArgumentException e) { assertEquals("Index 'series' out of range.", e.getMessage()); } try { c1.getSeries(1); fail("IllegalArgumentException should have been thrown on index greater than series length"); } catch (IllegalArgumentException e) { assertEquals("Index 'series' out of range.", e.getMessage()); } }