### Question:
KeyedObjects implements Cloneable, PublicCloneable, Serializable { public int getIndex(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } int i = 0; for (KeyedObject ko : this.data) { if (ko.getKey().equals(key)) { return i; } i++; } return -1; } KeyedObjects(); int getItemCount(); Object getObject(int item); Comparable getKey(int index); int getIndex(Comparable key); List<Comparable> getKeys(); Object getObject(Comparable key); void addObject(Comparable key, Object object); void setObject(Comparable key, Object object); void insertValue(int position, Comparable key, Object value); void removeValue(int index); void removeValue(Comparable key); void clear(); @Override Object clone(); @Override boolean equals(Object obj); @Override int hashCode();  }### Answer:
@Test public void testGetIndex() { KeyedObjects ko1 = new KeyedObjects(); ko1.addObject("Key 1", "Object 1"); ko1.addObject("Key 2", null); ko1.addObject("Key 3", "Object 2"); assertEquals(0, ko1.getIndex("Key 1")); assertEquals(1, ko1.getIndex("Key 2")); assertEquals(2, ko1.getIndex("Key 3")); try { ko1.getIndex(null); fail("Should have thrown IllegalArgumentException on null key"); } catch (IllegalArgumentException e) { assertEquals("Null 'key' argument.", e.getMessage()); } }