### Question:
ImapStore extends RemoteStore { @Override public void checkSettings() throws MessagingException { try { ImapConnection connection = createImapConnection(); connection.open(); autoconfigureFolders(connection); connection.close(); } catch (IOException ioe) { throw new MessagingException("Unable to connect", ioe); } } ImapStore(StoreConfig storeConfig, TrustedSocketFactory trustedSocketFactory,
            ConnectivityManager connectivityManager, OAuth2TokenProvider oauthTokenProvider); static ImapStoreSettings decodeUri(String uri); static String createUri(ServerSettings server); @Override @NonNull ImapFolder getFolder(String folderId); @Override @NonNull List<ImapFolder> getFolders(boolean forceListAll); @Override @NonNull List<ImapFolder> getSubFolders(final String parentFolderId, boolean forceListAll); @NonNull List<ImapFolder> getPersonalNamespaces(boolean forceListAll); @Override void checkSettings(); @Override boolean isMoveCapable(); @Override boolean isCopyCapable(); @Override boolean isPushCapable(); @Override boolean isExpungeCapable(); @Override Pusher getPusher(PushReceiver receiver); String getFolderName(String id);  }### Answer:
@Test public void checkSettings_shouldCreateImapConnectionAndCallOpen() throws Exception { ImapConnection imapConnection = mock(ImapConnection.class); imapStore.enqueueImapConnection(imapConnection); imapStore.checkSettings(); verify(imapConnection).open(); }
@Test public void checkSettings_withOpenThrowing_shouldThrowMessagingException() throws Exception { ImapConnection imapConnection = mock(ImapConnection.class); doThrow(IOException.class).when(imapConnection).open(); imapStore.enqueueImapConnection(imapConnection); try { imapStore.checkSettings(); fail("Expected exception"); } catch (MessagingException e) { assertEquals("Unable to connect", e.getMessage()); assertNotNull(e.getCause()); assertEquals(IOException.class, e.getCause().getClass()); } }