### Question:
TaskSeriesCollection extends AbstractSeriesDataset implements GanttCategoryDataset, Cloneable, PublicCloneable,
                   Serializable { public void remove(TaskSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } if (this.data.contains(series)) { series.removeChangeListener(this); this.data.remove(series); fireDatasetChanged(); } } TaskSeriesCollection(); TaskSeries getSeries(Comparable key); TaskSeries getSeries(int series); @Override int getSeriesCount(); @Override Comparable getSeriesKey(int series); @Override int getRowCount(); @Override List getRowKeys(); @Override int getColumnCount(); @Override List<Comparable> getColumnKeys(); @Override Comparable getColumnKey(int index); @Override int getColumnIndex(Comparable columnKey); @Override int getRowIndex(Comparable rowKey); @Override Comparable getRowKey(int index); void add(TaskSeries series); void remove(TaskSeries series); void remove(int series); void removeAll(); @Override Number getValue(Comparable rowKey, Comparable columnKey); @Override Number getValue(int row, int column); @Override Number getStartValue(Comparable rowKey, Comparable columnKey); @Override Number getStartValue(int row, int column); @Override Number getEndValue(Comparable rowKey, Comparable columnKey); @Override Number getEndValue(int row, int column); @Override Number getPercentComplete(int row, int column); @Override Number getPercentComplete(Comparable rowKey, Comparable columnKey); @Override int getSubIntervalCount(int row, int column); @Override int getSubIntervalCount(Comparable rowKey, Comparable columnKey); @Override Number getStartValue(int row, int column, int subinterval); @Override Number getStartValue(Comparable rowKey, Comparable columnKey,
                                int subinterval); @Override Number getEndValue(int row, int column, int subinterval); @Override Number getEndValue(Comparable rowKey, Comparable columnKey,
                              int subinterval); @Override Number getPercentComplete(int row, int column, int subinterval); @Override Number getPercentComplete(Comparable rowKey, Comparable columnKey,
                                     int subinterval); @Override void seriesChanged(SeriesChangeEvent event); @Override boolean equals(Object obj); @Override Object clone();  }### Answer:
@Test public void testRemove() { TaskSeriesCollection c = new TaskSeriesCollection(); TaskSeries s1 = new TaskSeries("S1"); c.add(s1); assertEquals("S1", c.getSeries(0).getKey()); c.remove(0); assertEquals(0, c.getSeriesCount()); c.add(s1); try { c.remove(-1); fail("Should have thrown an IllegalArgumentException on index out of bounds"); } catch (IllegalArgumentException e) { assertEquals("TaskSeriesCollection.remove(): index outside valid range.", e.getMessage()); } try { c.remove(1); fail("Should have thrown an IllegalArgumentException on index out of bounds"); } catch (IllegalArgumentException e) { assertEquals("TaskSeriesCollection.remove(): index outside valid range.", e.getMessage()); } }