### Question:
ImapList extends ArrayList<Object> { public Date getKeyedDate(String key) throws MessagingException { return getDate(getKeyedString(key)); }  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 getKeyedDate_returnsCorrectDateForValidString() throws MessagingException { ImapList list = new ImapList(); list.add("INTERNALDATE"); list.add("10-Mar-2000 12:02:01 GMT"); Calendar c = Calendar.getInstance(); c.setTime(list.getKeyedDate("INTERNALDATE")); assertEquals(2000, c.get(Calendar.YEAR)); assertEquals(Calendar.MARCH, c.get(Calendar.MONTH)); assertEquals(10, c.get(Calendar.DAY_OF_MONTH)); }
@Test(expected = MessagingException.class) public void getKeyedDate_throwsExceptionForInvalidDate() throws MessagingException { ImapList list = new ImapList(); list.add("INTERNALDATE"); list.add("InvalidDate"); list.getKeyedDate("INTERNALDATE"); }
@Test public void getKeyedDate_returnsNullForNIL() throws MessagingException { ImapList list = new ImapList(); list.add("INTERNALDATE"); list.add("NIL"); assertNull(list.getKeyedDate("INTERNALDATE")); }