### Question:
DefaultPieDataset extends AbstractDataset implements PieDataset, Cloneable, PublicCloneable, Serializable { @Override public Comparable getKey(int item) { return this.data.getKey(item); } DefaultPieDataset();  DefaultPieDataset(KeyedValues data); @Override int getItemCount(); @Override List<Comparable> getKeys(); @Override Comparable getKey(int item); @Override int getIndex(Comparable key); @Override Number getValue(int item); @Override Number getValue(Comparable key); void setValue(Comparable key, Number value); void setValue(Comparable key, double value); void insertValue(int position, Comparable key, double value); void insertValue(int position, Comparable key, Number value); void remove(Comparable key); void clear(); void sortByKeys(SortOrder order); void sortByValues(SortOrder order); @Override boolean equals(Object obj); @Override int hashCode(); @Override Object clone();  }### Answer:
@Test public void testGetKey() { DefaultPieDataset d = new DefaultPieDataset(); d.setValue("A", 1.0); d.setValue("B", 2.0); assertEquals("A", d.getKey(0)); assertEquals("B", d.getKey(1)); try { d.getKey(-1); fail("IndexOutOfBoundsException should have been thrown on negative key"); } catch (IndexOutOfBoundsException e) { assertEquals("-1", e.getMessage()); } try { d.getKey(2); fail("IndexOutOfBoundsException should have been thrown on key out of range"); } catch (IndexOutOfBoundsException e) { assertEquals("Index: 2, Size: 2", e.getMessage()); } }
@Test public void testGetKey() { DefaultPieDataset d = new DefaultPieDataset(); d.setValue("A", 1.0); d.setValue("B", 2.0); assertEquals("A", d.getKey(0)); assertEquals("B", d.getKey(1)); try { d.getKey(-1); fail("IndexOutOfBoundsException should have been thrown on negative key"); } catch (IndexOutOfBoundsException e) { } try { d.getKey(2); fail("IndexOutOfBoundsException should have been thrown on key out of range"); } catch (IndexOutOfBoundsException e) { assertEquals("Index: 2, Size: 2", e.getMessage()); } }