### Question:
ImapList extends ArrayList<Object> { public int getKeyIndex(String key) { for (int i = 0, count = size() - 1; i < count; i++) { if (ImapResponseParser.equalsIgnoreCase(get(i), key)) { return i; } } throw new IllegalArgumentException("getKeyIndex() only works for keys that are in the collection."); }  ImapList getList(int index); boolean isList(int index); Object getObject(int index); String getString(int index); boolean isString(int index); long getLong(int index); int getNumber(int index); Date getDate(int index); Date getKeyedDate(String key); Object getKeyedValue(String key); ImapList getKeyedList(String key); String getKeyedString(String key); int getKeyedNumber(String key); boolean containsKey(String key); int getKeyIndex(String key);  }### Answer:
@Test public void getKeyIndex_providesIndexForKeys() { ImapList list = buildSampleList(); assertEquals(0, list.getKeyIndex("ONE")); assertEquals(1, list.getKeyIndex("TWO")); }
@Test(expected = IllegalArgumentException.class) public void getKeyIndex_throwsExceptionForValue() { ImapList list = buildSampleList(); list.getKeyIndex("THREE"); }
@Test(expected = IllegalArgumentException.class) public void getKeyIndex_throwsExceptionForNonExistantKey() { ImapList list = buildSampleList(); list.getKeyIndex("nonexistent"); }