### Question:
XYSeries extends Series implements Cloneable, Serializable { public void update(Number x, Number y) { int index = indexOf(x); if (index < 0) { throw new SeriesException("No observation for x = " + x); } updateByIndex(index, y); } XYSeries(Comparable key);  XYSeries(Comparable key, boolean autoSort);  XYSeries(Comparable key, boolean autoSort,
            boolean allowDuplicateXValues); double getMinX(); double getMaxX(); double getMinY(); double getMaxY(); boolean getAutoSort(); boolean getAllowDuplicateXValues(); @Override int getItemCount(); List<XYDataItem> getItems(); int getMaximumItemCount(); void setMaximumItemCount(int maximum); void add(XYDataItem item); void add(double x, double y); void add(double x, double y, boolean notify); void add(double x, Number y); void add(double x, Number y, boolean notify); void add(Number x, Number y); void add(Number x, Number y, boolean notify); void add(XYDataItem item, boolean notify); void delete(int start, int end); XYDataItem remove(int index); XYDataItem remove(Number x); void clear(); XYDataItem getDataItem(int index); Number getX(int index); Number getY(int index); void updateByIndex(int index, Number y); void update(Number x, Number y); XYDataItem addOrUpdate(double x, double y); XYDataItem addOrUpdate(Number x, Number y); XYDataItem addOrUpdate(XYDataItem item); int indexOf(Number x); double[][] toArray(); @Override Object clone(); XYSeries createCopy(int start, int end); @Override boolean equals(Object obj); @Override int hashCode();  }### Answer:
@Test public void testUpdate() { XYSeries series = new XYSeries("S1"); series.add(new Integer(1), new Integer(2)); assertEquals(2, series.getY(0)); series.update(1, 3); assertEquals(3, series.getY(0)); try { series.update(2, 99); fail("SeriesException should have been thrown for unknown key"); } catch (SeriesException e) { assertEquals("No observation for x = 2", e.getMessage()); } }