### Question:
DefaultKeyedValues implements KeyedValues, Cloneable,
        PublicCloneable, Serializable { public void addValue(Comparable key, double value) { addValue(key, new Double(value)); } DefaultKeyedValues(); @Override int getItemCount(); @Override Number getValue(int item); @Override Comparable getKey(int index); @Override int getIndex(Comparable key); @Override List<Comparable> getKeys(); @Override Number getValue(Comparable key); void addValue(Comparable key, double value); void addValue(Comparable key, Number value); void setValue(Comparable key, double value); void setValue(Comparable key, Number value); void insertValue(int position, Comparable key, double value); void insertValue(int position, Comparable key, Number value); void removeValue(int index); void removeValue(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 testAddValue() { DefaultKeyedValues v1 = new DefaultKeyedValues(); v1.addValue("A", 1.0); assertEquals(1.0, v1.getValue("A")); v1.addValue("B", 2.0); assertEquals(2.0, v1.getValue("B")); v1.addValue("B", 3.0); assertEquals(3.0, v1.getValue("B")); assertEquals(2, v1.getItemCount()); v1.addValue("A", null); assertNull(v1.getValue("A")); assertEquals(2, v1.getItemCount()); try { v1.addValue(null, 99.9); fail("Should have thrown IllegalArgumentException on null key"); } catch (IllegalArgumentException e) { assertEquals("Null 'key' argument.", e.getMessage()); } }
@Test public void testSerialization() throws IOException, ClassNotFoundException { DefaultKeyedValues v1 = new DefaultKeyedValues(); v1.addValue("Key 1", new Double(23)); v1.addValue("Key 2", null); v1.addValue("Key 3", new Double(42)); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(v1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); DefaultKeyedValues v2 = (DefaultKeyedValues) in.readObject(); in.close(); assertEquals(v1, v2); }