### Question:
DefaultPieDataset extends AbstractDataset implements PieDataset, Cloneable, PublicCloneable, Serializable { @Override public int getIndex(Comparable key) { return this.data.getIndex(key); } 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 testGetIndex() { DefaultPieDataset d = new DefaultPieDataset(); d.setValue("A", 1.0); d.setValue("B", 2.0); assertEquals(0, d.getIndex("A")); assertEquals(1, d.getIndex("B")); assertEquals(-1, d.getIndex("XX")); try { d.getIndex(null); fail("IllegalArgumentException should have been thrown on null key"); } catch (IllegalArgumentException e) { assertEquals("Null 'key' argument.", e.getMessage()); } }