### Question:
ImapFolder extends Folder<ImapMessage> { protected List<ImapMessage> getMessagesFromUids(final List<String> mesgUids) throws MessagingException { ImapSearcher searcher = new ImapSearcher() { @Override public List<ImapResponse> search() throws IOException, MessagingException { String command = String.format("UID SEARCH UID %s", combine(mesgUids.toArray(), ',')); return executeSimpleCommand(command); } }; return search(searcher, null); } ImapFolder(ImapStore store, String id);   ImapFolder(ImapStore store, String id, FolderNameCodec folderNameCodec); @Override void open(int mode); @Override boolean isOpen(); @Override int getMode(); @Override void close(); @Override String getId(); @Override String getParentId(); @Override String getName(); @Override boolean exists(); @Override boolean canHaveSubFolders(); @Override boolean create(FolderType type); @Override Map<String, String> copyMessages(List<? extends Message> messages, Folder folder); @Override Map<String, String> moveMessages(List<? extends Message> messages, Folder folder); @Override void delete(List<? extends Message> messages, String trashFolderName); @Override int getMessageCount(); @Override int getUnreadMessageCount(); @Override int getFlaggedMessageCount(); @Override void delete(boolean recurse); @Override ImapMessage getMessage(String uid); @Override List<ImapMessage> getMessages(int start, int end, Date earliestDate,
            MessageRetrievalListener<ImapMessage> listener); @Override boolean areMoreMessagesAvailable(int indexOfOldestMessage, Date earliestDate); @Override void fetch(List<ImapMessage> messages, FetchProfile fetchProfile,
            MessageRetrievalListener<ImapMessage> listener); @Override void fetchPart(Message message, Part part, MessageRetrievalListener<Message> listener,
            BodyFactory bodyFactory); @Override Map<String, String> appendMessages(List<? extends Message> messages); @Override String getUidFromMessageId(Message message); @Override void expunge(); @Override void setFlags(Set<Flag> flags, boolean value); @Override String getNewPushState(String oldSerializedPushState, Message message); @Override void setFlags(List<? extends Message> messages, final Set<Flag> flags, boolean value); @Override boolean equals(Object other); @Override int hashCode(); @Override List<ImapMessage> search(final String queryString, final Set<Flag> requiredFlags,
            final Set<Flag> forbiddenFlags);  }### Answer:
@Test public void getMessagesFromUids_withClosedFolder_shouldThrow() throws Exception { ImapFolder folder = createFolder("Folder"); when(imapStore.getConnection()).thenReturn(imapConnection); try { folder.getMessagesFromUids(asList("11", "22", "25")); fail("Expected exception"); } catch (MessagingException e) { assertCheckOpenErrorMessage("Folder", e); } }
@Test public void getMessagesFromUids() throws Exception { ImapFolder folder = createFolder("Folder"); prepareImapFolderForOpen(OPEN_MODE_RW); List<ImapResponse> imapResponses = asList( createImapResponse("* SEARCH 11"), createImapResponse("* SEARCH 22"), createImapResponse("* SEARCH 25") ); when(imapConnection.executeSimpleCommand("UID SEARCH UID 11,22,25")).thenReturn(imapResponses); folder.open(OPEN_MODE_RW); List<ImapMessage> messages = folder.getMessagesFromUids(asList("11", "22", "25")); assertNotNull(messages); assertEquals(newSet("11", "22", "25"), extractMessageUids(messages)); }