### Question:
ResponseCodeExtractor { public static String getResponseCode(ImapResponse response) { if (response.size() < 2 || !response.isList(1)) { return null; } ImapList responseTextCode = response.getList(1); return responseTextCode.size() != 1 ? null : responseTextCode.getString(0); } private  ResponseCodeExtractor(); static String getResponseCode(ImapResponse response); static final String AUTHENTICATION_FAILED; }### Answer:
@Test public void getResponseCode_withResponseCode() throws Exception { ImapResponse imapResponse = createImapResponse("x NO [AUTHENTICATIONFAILED] No sir"); String result = ResponseCodeExtractor.getResponseCode(imapResponse); assertEquals("AUTHENTICATIONFAILED", result); }
@Test public void getResponseCode_withoutResponseCode() throws Exception { ImapResponse imapResponse = createImapResponse("x NO Authentication failed"); String result = ResponseCodeExtractor.getResponseCode(imapResponse); assertNull(result); }
@Test public void getResponseCode_withoutSingleItemResponse() throws Exception { ImapResponse imapResponse = createImapResponse("x NO"); String result = ResponseCodeExtractor.getResponseCode(imapResponse); assertNull(result); }