### Question:
ImapStore extends RemoteStore { ImapConnection getConnection() throws MessagingException { ImapConnection connection; while ((connection = pollConnection()) != null) { try { connection.executeSimpleCommand(Commands.NOOP); break; } catch (IOException ioe) { connection.close(); } } if (connection == null) { connection = createImapConnection(); } return connection; } 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 getConnection_shouldCreateImapConnection() throws Exception { ImapConnection imapConnection = mock(ImapConnection.class); imapStore.enqueueImapConnection(imapConnection); ImapConnection result = imapStore.getConnection(); assertSame(imapConnection, result); }
@Test public void getConnection_calledTwiceWithoutRelease_shouldCreateTwoImapConnection() throws Exception { ImapConnection imapConnectionOne = mock(ImapConnection.class); ImapConnection imapConnectionTwo = mock(ImapConnection.class); imapStore.enqueueImapConnection(imapConnectionOne); imapStore.enqueueImapConnection(imapConnectionTwo); ImapConnection resultOne = imapStore.getConnection(); ImapConnection resultTwo = imapStore.getConnection(); assertSame(imapConnectionOne, resultOne); assertSame(imapConnectionTwo, resultTwo); }