### Question:
Pop3Store extends RemoteStore { @Override public void checkSettings() throws MessagingException { Pop3Folder folder = new Pop3Folder(this, mStoreConfig.getInboxFolderId()); try { folder.open(Folder.OPEN_MODE_RW); folder.requestUidl(); } finally { folder.close(); } } Pop3Store(StoreConfig storeConfig, TrustedSocketFactory socketFactory); static ServerSettings decodeUri(String uri); static String createUri(ServerSettings server); @Override @NonNull Pop3Folder getFolder(String name); @Override @NonNull List <Pop3Folder> getFolders(boolean forceListAll); @NonNull @Override List<? extends Folder> getSubFolders(String parentFolderId, boolean forceListAll); @Override void checkSettings(); @Override boolean isSeenFlagSupported(); Pop3Connection createConnection();  }### Answer:
@Test(expected = MessagingException.class) public void checkSetting_whenConnectionThrowsException_shouldThrowMessagingException() throws Exception { when(mockTrustedSocketFactory.createSocket(any(Socket.class), anyString(), anyInt(), anyString())).thenThrow(new IOException("Test")); store.checkSettings(); }
@Test(expected = MessagingException.class) public void checkSetting_whenUidlUnsupported_shouldThrowMessagingException() throws Exception { String response = INITIAL_RESPONSE + AUTH_HANDLE_RESPONSE + CAPA_RESPONSE + AUTH_PLAIN_AUTHENTICATED_RESPONSE + STAT_RESPONSE + UIDL_UNSUPPORTED_RESPONSE; when(mockSocket.getInputStream()).thenReturn(new ByteArrayInputStream(response.getBytes("UTF-8"))); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); when(mockSocket.getOutputStream()).thenReturn(byteArrayOutputStream); store.checkSettings(); }
@Test public void checkSetting_whenUidlSupported_shouldReturn() throws Exception { String response = INITIAL_RESPONSE + AUTH_HANDLE_RESPONSE + CAPA_RESPONSE + AUTH_PLAIN_AUTHENTICATED_RESPONSE + STAT_RESPONSE + UIDL_SUPPORTED_RESPONSE; when(mockSocket.getInputStream()).thenReturn(new ByteArrayInputStream(response.getBytes("UTF-8"))); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); when(mockSocket.getOutputStream()).thenReturn(byteArrayOutputStream); store.checkSettings(); }