method2testcases
stringlengths
118
6.63k
### Question: ReplyToParser { public ReplyToAddresses getRecipientsToReplyListTo(Message message, Account account) { Address[] candidateAddress; Address[] listPostAddresses = ListHeaders.getListPostAddresses(message); Address[] replyToAddresses = message.getReplyTo(); Address[] fromAddresses = message.getFrom(); if (li...
### Question: ContactPictureLoader { @VisibleForTesting protected static String calcUnknownContactLetter(Address address) { String letter = null; String personal = address.getPersonal(); String str = (personal != null) ? personal : address.getAddress(); Matcher m = EXTRACT_LETTER_PATTERN.matcher(str); if (m.find()) { l...
### Question: RecipientPresenter implements PermissionPingCallback { @Nullable public ComposeCryptoStatus getCurrentCachedCryptoStatus() { return cachedCryptoStatus; } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider...
### Question: RecipientPresenter implements PermissionPingCallback { void onToTokenAdded() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInl...
### Question: RecipientPresenter implements PermissionPingCallback { void onToTokenChanged() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpI...
### Question: RecipientPresenter implements PermissionPingCallback { void onToTokenRemoved() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpI...
### Question: RecipientPresenter implements PermissionPingCallback { void onCcTokenAdded() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInl...
### Question: RecipientPresenter implements PermissionPingCallback { void onCcTokenChanged() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpI...
### Question: RecipientPresenter implements PermissionPingCallback { void onCcTokenRemoved() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpI...
### Question: RecipientPresenter implements PermissionPingCallback { void onBccTokenAdded() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpIn...
### Question: RecipientPresenter implements PermissionPingCallback { void onBccTokenChanged() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgp...
### Question: RecipientPresenter implements PermissionPingCallback { void onBccTokenRemoved() { asyncUpdateCryptoStatus(); listener.onRecipientsChanged(); } RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgp...
### Question: FolderInfoHolder implements Comparable<FolderInfoHolder> { public static String getDisplayName(Context context, Account account, String id, String name) { final String displayName; if (id.equals(account.getSpamFolderId())) { displayName = String.format( context.getString(R.string.special_mailbox_name_spam...
### Question: MessageReference { public String toIdentityString() { StringBuilder refString = new StringBuilder(); refString.append(IDENTITY_VERSION_1); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(accountUuid)); refString.append(IDENTITY_SEPARATOR); refString.append(Base64.encode(folderId)); re...
### Question: MessageReference { @Nullable public static MessageReference parse(String identity) { if (identity == null || identity.length() < 1 || identity.charAt(0) != IDENTITY_VERSION_1) { return null; } StringTokenizer tokens = new StringTokenizer(identity.substring(2), IDENTITY_SEPARATOR, false); if (tokens.countT...
### Question: MessageReference { @Override public boolean equals(Object o) { if (!(o instanceof MessageReference)) { return false; } MessageReference other = (MessageReference) o; return equals(other.accountUuid, other.folderId, other.uid); } MessageReference(String accountUuid, String folderId, String uid, Flag flag);...
### Question: BaseNotifications { protected NotificationCompat.Builder createAndInitializeNotificationBuilder(Account account) { return controller.createNotificationBuilder() .setSmallIcon(getNewMailNotificationIcon()) .setColor(account.getChipColor()) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setCateg...
### Question: BaseNotifications { protected boolean isDeleteActionEnabled() { NotificationQuickDelete deleteOption = QMail.getNotificationQuickDeleteBehaviour(); return deleteOption == NotificationQuickDelete.ALWAYS || deleteOption == NotificationQuickDelete.FOR_SINGLE_MSG; } protected BaseNotifications(NotificationCo...
### Question: BaseNotifications { protected NotificationCompat.Builder createBigTextStyleNotification(Account account, NotificationHolder holder, int notificationId) { String accountName = controller.getAccountName(account); NotificationContent content = holder.content; String groupKey = NotificationGroupKeys.getGroupK...
### Question: WearNotifications extends BaseNotifications { public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, ho...
### Question: WearNotifications extends BaseNotifications { public void addSummaryActions(Builder builder, NotificationData notificationData) { NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); addMarkAllAsReadAction(wearableExtender, notificationData); if (isDeleteAction...
### Question: AuthenticationErrorNotifications { public void showAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); Context context = controller.getContext(); PendingIntent editServerSettingsPendingIntent = c...
### Question: AuthenticationErrorNotifications { public void clearAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); getNotificationManager().cancel(notificationId); } AuthenticationErrorNotifications(Notific...
### Question: NotificationContentCreator { public NotificationContent createFromMessage(Account account, LocalMessage message) { MessageReference messageReference = message.makeMessageReference(); String sender = getMessageSender(account, message); String displaySender = getMessageSenderForDisplay(sender); String subje...
### Question: LockScreenNotification { String createCommaSeparatedListOfSenders(List<NotificationContent> contents) { Set<CharSequence> senders = new LinkedHashSet<CharSequence>(MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION); for (NotificationContent content : contents) { senders.add(content.sender); if (senders.si...
### Question: NotificationIds { public static int getNewMailSummaryNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_NEW_MAIL_SUMMARY; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetc...
### Question: NotificationIds { public static int getNewMailStackedNotificationId(Account account, int index) { if (index < 0 || index >= NUMBER_OF_STACKED_NOTIFICATIONS) { throw new IndexOutOfBoundsException("Invalid value: " + index); } return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index; } stati...
### Question: NotificationIds { public static int getFetchingMailNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_FETCHING_MAIL; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int getFetchingM...
### Question: NotificationIds { public static int getSendFailedNotificationId(Account account) { return getBaseNotificationId(account) + OFFSET_SEND_FAILED_NOTIFICATION; } static int getNewMailSummaryNotificationId(Account account); static int getNewMailStackedNotificationId(Account account, int index); static int get...
### Question: NotificationIds { public static int getCertificateErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_CERTIFICATE_ERROR_INCOMING : OFFSET_CERTIFICATE_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } static int getNewMailSummaryNotificationId(Account ac...
### Question: NotificationIds { public static int getAuthenticationErrorNotificationId(Account account, boolean incoming) { int offset = incoming ? OFFSET_AUTHENTICATION_ERROR_INCOMING : OFFSET_AUTHENTICATION_ERROR_OUTGOING; return getBaseNotificationId(account) + offset; } static int getNewMailSummaryNotificationId(A...
### Question: SyncNotifications { public void showSendingNotification(Account account) { Context context = controller.getContext(); String accountName = controller.getAccountName(account); String title = context.getString(R.string.notification_bg_send_title); String tickerText = context.getString(R.string.notification_...
### Question: SyncNotifications { public void clearSendingNotification(Account account) { int notificationId = NotificationIds.getFetchingMailNotificationId(account); getNotificationManager().cancel(notificationId); } SyncNotifications(NotificationController controller, NotificationActionCreator actionBuilder); void sh...
### Question: SyncNotifications { public void showFetchingMailNotification(Account account, Folder folder) { String accountName = account.getDescription(); String folderName = folder.getId(); Context context = controller.getContext(); String tickerText = context.getString(R.string.notification_bg_sync_ticker, accountNa...
### Question: SyncNotifications { public void clearFetchingMailNotification(Account account) { int notificationId = NotificationIds.getFetchingMailNotificationId(account); getNotificationManager().cancel(notificationId); } SyncNotifications(NotificationController controller, NotificationActionCreator actionBuilder); vo...
### Question: SendFailedNotifications { public void showSendFailedNotification(Account account, Exception exception) { Context context = controller.getContext(); String title = context.getString(R.string.send_failure_subject); String text = ExceptionHelper.getRootCauseMessage(exception); int notificationId = Notificati...
### Question: SendFailedNotifications { public void clearSendFailedNotification(Account account) { int notificationId = NotificationIds.getSendFailedNotificationId(account); getNotificationManager().cancel(notificationId); } SendFailedNotifications(NotificationController controller, NotificationActionCreator actionBuil...
### Question: NotificationData { public AddNotificationResult addNotificationContent(NotificationContent content) { int notificationId; boolean cancelNotificationIdBeforeReuse; if (isMaxNumberOfActiveNotificationsReached()) { NotificationHolder notificationHolder = activeNotifications.removeLast(); addToAdditionalNotif...
### Question: NotificationData { public RemoveNotificationResult removeNotificationForMessage(MessageReference messageReference) { NotificationHolder holder = getNotificationHolderForMessage(messageReference); if (holder == null) { return RemoveNotificationResult.unknownNotification(); } activeNotifications.remove(hold...
### Question: NotificationData { public boolean containsStarredMessages() { for (NotificationHolder holder : activeNotifications) { if (holder.content.starred) { return true; } } for (NotificationContent content : additionalNotifications) { if (content.starred) { return true; } } return false; } NotificationData(Accoun...
### Question: NotificationData { public boolean isSingleMessageNotification() { return activeNotifications.size() == 1; } NotificationData(Account account); AddNotificationResult addNotificationContent(NotificationContent content); boolean containsStarredMessages(); boolean hasSummaryOverflowMessages(); int getSummaryO...
### Question: NotificationData { public List<NotificationContent> getContentForSummaryNotification() { int size = calculateNumberOfMessagesForSummaryNotification(); List<NotificationContent> result = new ArrayList<NotificationContent>(size); Iterator<NotificationHolder> iterator = activeNotifications.iterator(); int no...
### Question: NotificationData { public int[] getActiveNotificationIds() { int size = activeNotifications.size(); int[] notificationIds = new int[size]; for (int i = 0; i < size; i++) { NotificationHolder holder = activeNotifications.get(i); notificationIds[i] = holder.notificationId; } return notificationIds; } Notifi...
### Question: NotificationData { public Account getAccount() { return account; } NotificationData(Account account); AddNotificationResult addNotificationContent(NotificationContent content); boolean containsStarredMessages(); boolean hasSummaryOverflowMessages(); int getSummaryOverflowMessagesCount(); int getNewMessage...
### Question: NotificationData { public ArrayList<MessageReference> getAllMessageReferences() { int newSize = activeNotifications.size() + additionalNotifications.size(); ArrayList<MessageReference> messageReferences = new ArrayList<MessageReference>(newSize); for (NotificationHolder holder : activeNotifications) { mes...
### Question: NewMailNotifications { public void removeNewMailNotification(Account account, MessageReference messageReference) { synchronized (lock) { NotificationData notificationData = getNotificationData(account); if (notificationData == null) { return; } RemoveNotificationResult result = notificationData.removeNoti...
### Question: NewMailNotifications { public void clearNewMailNotifications(Account account) { NotificationData notificationData; synchronized (lock) { notificationData = removeNotificationData(account); } if (notificationData == null) { return; } for (int notificationId : notificationData.getActiveNotificationIds()) { ...
### Question: CertificateErrorNotifications { public void showCertificateErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getCertificateErrorNotificationId(account, incoming); Context context = controller.getContext(); PendingIntent editServerSettingsPendingIntent = createCont...
### Question: CertificateErrorNotifications { public void clearCertificateErrorNotifications(Account account, boolean incoming) { int notificationId = NotificationIds.getCertificateErrorNotificationId(account, incoming); getNotificationManager().cancel(notificationId); } CertificateErrorNotifications(NotificationContro...
### Question: ServerNameSuggester { public String suggestServerName(Type serverType, String domainPart) { switch (serverType) { case IMAP: { return "imap." + domainPart; } case SMTP: { return "smtp." + domainPart; } case EWS: return "outlook.office365.com"; case WebDAV: { return "exchange." + domainPart; } case POP3: {...
### Question: SettingsExporter { static void exportPreferences(Context context, OutputStream os, boolean includeGlobals, Set<String> accountUuids) throws SettingsImportExportException { try { XmlSerializer serializer = Xml.newSerializer(); serializer.setOutput(os, "UTF-8"); serializer.startDocument(null, Boolean.TRUE);...
### Question: SettingsImporter { @VisibleForTesting static Imported parseSettings(InputStream inputStream, boolean globalSettings, List<String> accountUuids, boolean overview) throws SettingsImportExportException { if (!overview && accountUuids == null) { throw new IllegalArgumentException("Argument 'accountUuids' must...
### Question: SettingsImporter { public static ImportContents getImportStreamContents(InputStream inputStream) throws SettingsImportExportException { try { Imported imported = parseSettings(inputStream, false, null, true); boolean globalSettings = (imported.globalSettings != null); final List<AccountDescription> accoun...
### Question: ICalParser { public static ICalData parse(ICalPart part) { String iCalText = MessageExtractor.getTextFromPart(part.getPart()); if (iCalText == null) { return new ICalData(new ArrayList<ICalendar>()); } return new ICalData(Biweekly.parse(iCalText).all()); } static ICalData parse(ICalPart part); static fin...
### Question: TransportUris { public static ServerSettings decodeTransportUri(String uri) { if (uri.startsWith("smtp")) { return decodeSmtpUri(uri); } else if (uri.startsWith("webdav")) { return decodeWebDavUri(uri); } else if (uri.startsWith("ews")) { return decodeEwsUri(uri); } else { throw new IllegalArgumentExcepti...
### Question: MessageCryptoStructureDetector { public static boolean isPartPgpInlineEncrypted(@Nullable Part part) { if (part == null) { return false; } if (!part.isMimeType(TEXT_PLAIN) && !part.isMimeType(APPLICATION_PGP)) { return false; } String text = MessageExtractor.getTextFromPart(part, TEXT_LENGTH_FOR_INLINE_CH...
### Question: TransportUris { public static String createTransportUri(ServerSettings server) { if (Type.SMTP == server.type) { return createSmtpUri(server); } else if (Type.WebDAV == server.type) { return createWebDavUri(server); } else if (Type.EWS == server.type) { return createEwsUri(server); } else { throw new Ille...
### Question: MessageCryptoStructureDetector { @VisibleForTesting static boolean isPartPgpInlineEncryptedOrSigned(Part part) { if (!part.isMimeType(TEXT_PLAIN) && !part.isMimeType(APPLICATION_PGP)) { return false; } String text = MessageExtractor.getTextFromPart(part, TEXT_LENGTH_FOR_INLINE_CHECK); if (TextUtils.isEmpt...
### Question: OpenPgpApiHelper { public static String buildUserId(Identity identity) { StringBuilder sb = new StringBuilder(); String name = identity.getName(); if (!TextUtils.isEmpty(name)) { sb.append(name).append(" "); } sb.append("<").append(identity.getEmail()).append(">"); return sb.toString(); } static String b...
### Question: MessageIdGenerator { public String generateMessageId(Message message) { String hostname = null; Address[] from = message.getFrom(); if (from != null && from.length >= 1) { hostname = from[0].getHostname(); } if (hostname == null) { Address[] replyTo = message.getReplyTo(); if (replyTo != null && replyTo.l...
### Question: TextSignatureRemover { public static String stripSignature(String content) { if (DASH_SIGNATURE_PLAIN.matcher(content).find()) { content = DASH_SIGNATURE_PLAIN.matcher(content).replaceFirst("\r\n"); } return content; } static String stripSignature(String content); }### Answer: @Test public void shouldSt...
### Question: FlowedMessageUtils { static boolean isFormatFlowed(String contentType) { String mimeType = getHeaderParameter(contentType, null); if (isSameMimeType(TEXT_PLAIN, mimeType)) { String formatParameter = getHeaderParameter(contentType, HEADER_PARAM_FORMAT); return HEADER_FORMAT_FLOWED.equalsIgnoreCase(formatPa...
### Question: FlowedMessageUtils { static boolean isDelSp(String contentType) { if (isFormatFlowed(contentType)) { String delSpParameter = getHeaderParameter(contentType, HEADER_PARAM_DELSP); return HEADER_DELSP_YES.equalsIgnoreCase(delSpParameter); } return false; } }### Answer: @Test public void isDelSp_withFormat...
### Question: ListHeaders { public static Address[] getListPostAddresses(Message message) { String[] headerValues = message.getHeader(LIST_POST_HEADER); if (headerValues.length < 1) { return new Address[0]; } List<Address> listPostAddresses = new ArrayList<>(); for (String headerValue : headerValues) { Address address ...
### Question: HtmlSignatureRemover { public static String stripSignature(String content) { return new HtmlSignatureRemover().stripSignatureInternal(content); } static String stripSignature(String content); }### Answer: @Test public void shouldStripSignatureFromK9StyleHtml() throws Exception { String html = "This is t...
### Question: MimeUtility { public static String getHeaderParameter(String headerValue, String parameterName) { if (headerValue == null) { return null; } headerValue = headerValue.replaceAll("\r|\n", ""); String[] parts = headerValue.split(";"); if (parameterName == null && parts.length > 0) { return parts[0].trim(); }...
### Question: MimeUtility { public static boolean isMultipart(String mimeType) { return mimeType != null && mimeType.toLowerCase(Locale.US).startsWith("multipart/"); } static String unfold(String s); static String unfoldAndDecode(String s); static String unfoldAndDecode(String s, Message message); static String foldAn...
### Question: MimeUtility { public static boolean isMessage(String mimeType) { return isSameMimeType(mimeType, "message/rfc822"); } static String unfold(String s); static String unfoldAndDecode(String s); static String unfoldAndDecode(String s, Message message); static String foldAndEncode(String s); static String get...
### Question: MimeUtility { public static boolean isSameMimeType(String mimeType, String otherMimeType) { return mimeType != null && mimeType.equalsIgnoreCase(otherMimeType); } static String unfold(String s); static String unfoldAndDecode(String s); static String unfoldAndDecode(String s, Message message); static Stri...
### Question: SmtpDataStuffing extends FilterOutputStream { @Override public void write(int oneByte) throws IOException { if (oneByte == '\r') { state = STATE_CR; } else if ((state == STATE_CR) && (oneByte == '\n')) { state = STATE_CRLF; } else if ((state == STATE_CRLF) && (oneByte == '.')) { super.write('.'); state = ...
### Question: FixedLengthInputStream extends InputStream { @Override public int read() throws IOException { if (mCount >= mLength) { return -1; } int d = mIn.read(); if (d != -1) { mCount++; } return d; } FixedLengthInputStream(InputStream in, int length); @Override int available(); @Override int read(); @Override int ...
### Question: FixedLengthInputStream extends InputStream { @Override public int available() throws IOException { return mLength - mCount; } FixedLengthInputStream(InputStream in, int length); @Override int available(); @Override int read(); @Override int read(byte[] b, int offset, int length); @Override int read(byte[]...
### Question: FixedLengthInputStream extends InputStream { public void skipRemaining() throws IOException { while (available() > 0) { skip(available()); } } FixedLengthInputStream(InputStream in, int length); @Override int available(); @Override int read(); @Override int read(byte[] b, int offset, int length); @Overrid...
### Question: SignSafeOutputStream extends FilterOutputStream { public SignSafeOutputStream(OutputStream out) { super(out); outBuffer = new byte[DEFAULT_BUFFER_SIZE]; } SignSafeOutputStream(OutputStream out); void encode(byte next); @Override void write(int b); @Override void write(byte[] b, int off, int len); @Overrid...
### Question: Address implements Serializable { @VisibleForTesting static String quoteString(String s) { if (s == null) { return null; } if (!s.matches("^\".*\"$")) { return "\"" + s + "\""; } else { return s; } } Address(Address address); Address(String address, String personal); Address(String address); private Ad...
### Question: Pop3Store extends RemoteStore { public static ServerSettings decodeUri(String uri) { String host; int port; ConnectionSecurity connectionSecurity; String username = null; String password = null; String clientCertificateAlias = null; URI pop3Uri; try { pop3Uri = new URI(uri); } catch (URISyntaxException us...
### Question: Pop3Store extends RemoteStore { public static String createUri(ServerSettings server) { String userEnc = encodeUtf8(server.username); String passwordEnc = (server.password != null) ? encodeUtf8(server.password) : ""; String clientCertificateAliasEnc = (server.clientCertificateAlias != null) ? encodeUtf8(s...
### Question: Pop3Store extends RemoteStore { @Override @NonNull public Pop3Folder getFolder(String name) { Pop3Folder folder = mFolders.get(name); if (folder == null) { folder = new Pop3Folder(this, name); mFolders.put(folder.getId(), folder); } return folder; } Pop3Store(StoreConfig storeConfig, TrustedSocketFactory ...
### Question: Pop3Store extends RemoteStore { @Override @NonNull public List <Pop3Folder> getFolders(boolean forceListAll) throws MessagingException { List<Pop3Folder> folders = new LinkedList<>(); folders.add(getFolder(mStoreConfig.getInboxFolderId())); return folders; } Pop3Store(StoreConfig storeConfig, TrustedSocke...
### Question: EthereumUriParser implements UriParser { @Override public int linkifyUri(String text, int startPos, StringBuffer outputBuffer) { Matcher matcher = ETHEREUM_URI_PATTERN.matcher(text); if (!matcher.find(startPos) || matcher.start() != startPos) { return startPos; } String ethereumURI = matcher.group(); outp...
### Question: Pop3Store extends RemoteStore { @Override public boolean isSeenFlagSupported() { return false; } Pop3Store(StoreConfig storeConfig, TrustedSocketFactory socketFactory); static ServerSettings decodeUri(String uri); static String createUri(ServerSettings server); @Override @NonNull Pop3Folder getFolder(Stri...
### 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, Trus...
### Question: Pop3Capabilities { @Override public String toString() { return String.format("CRAM-MD5 %b, PLAIN %b, STLS %b, TOP %b, UIDL %b, EXTERNAL %b", cramMD5, authPlain, stls, top, uidl, external); } @Override String toString(); }### Answer: @Test public void toString_producesReadableOutput() { String result = n...
### Question: Pop3Folder extends Folder<Pop3Message> { @Override public boolean create(FolderType type) throws MessagingException { return false; } Pop3Folder(Pop3Store pop3Store, String name); @Override String getParentId(); @Override synchronized void open(int mode); @Override boolean isOpen(); @Override int getMode(...
### Question: Pop3Folder extends Folder<Pop3Message> { @Override public boolean exists() throws MessagingException { return name.equalsIgnoreCase(pop3Store.getConfig().getInboxFolderId()); } Pop3Folder(Pop3Store pop3Store, String name); @Override String getParentId(); @Override synchronized void open(int mode); @Overri...
### Question: UriLinkifier { public static void linkifyText(String text, StringBuffer outputBuffer) { int currentPos = 0; Matcher matcher = URI_SCHEME.matcher(text); while (matcher.find(currentPos)) { int startPos = matcher.start(1); String textBeforeMatch = text.substring(currentPos, startPos); outputBuffer.append(tex...
### Question: Pop3Folder extends Folder<Pop3Message> { @Override public int getUnreadMessageCount() throws MessagingException { return -1; } Pop3Folder(Pop3Store pop3Store, String name); @Override String getParentId(); @Override synchronized void open(int mode); @Override boolean isOpen(); @Override int getMode(); @Ove...
### Question: Pop3Folder extends Folder<Pop3Message> { @Override public int getFlaggedMessageCount() throws MessagingException { return -1; } Pop3Folder(Pop3Store pop3Store, String name); @Override String getParentId(); @Override synchronized void open(int mode); @Override boolean isOpen(); @Override int getMode(); @Ov...
### Question: Pop3Folder extends Folder<Pop3Message> { @Override public synchronized void open(int mode) throws MessagingException { if (isOpen()) { return; } if (!name.equalsIgnoreCase(pop3Store.getConfig().getInboxFolderId())) { throw new MessagingException("Folder does not exist"); } connection = pop3Store.createCon...
### Question: Pop3Folder extends Folder<Pop3Message> { @Override public void close() { try { if (isOpen()) { connection.executeSimpleCommand(QUIT_COMMAND); } } catch (Exception e) { } if (connection != null) { connection.close(); connection = null; } } Pop3Folder(Pop3Store pop3Store, String name); @Override String getP...
### Question: Pop3Connection { InputStream getInputStream() { return in; } Pop3Connection(Pop3Settings settings, TrustedSocketFactory trustedSocketFactory); }### Answer: @Test public void withTLS_connectsToSocket() throws Exception { String response = INITIAL_RESPONSE + AUTH_HANDLE_RESPONSE + CAPA_RESPONS...
### Question: WebDavStore extends RemoteStore { public static String createUri(ServerSettings server) { return WebDavStoreUriCreator.create(server); } WebDavStore(StoreConfig storeConfig, QMailHttpClientFactory clientFactory); static WebDavStoreSettings decodeUri(String uri); static String createUri(ServerSettings serv...
### Question: WebDavStore extends RemoteStore { @Override @NonNull public WebDavFolder getFolder(String name) { WebDavFolder folder = this.folderList.get(name); if (folder == null) { folder = new WebDavFolder(this, name); folderList.put(name, folder); } return folder; } WebDavStore(StoreConfig storeConfig, QMailHttpCli...
### Question: WebDavFolder extends Folder<WebDavMessage> { @Override public boolean isOpen() { return this.mIsOpen; } WebDavFolder(WebDavStore nStore, String id); void setUrl(String url); @Override void open(int mode); @Override Map<String, String> copyMessages(List<? extends Message> messages, Folder folder); @Overrid...
### Question: WebDavFolder extends Folder<WebDavMessage> { @Override public boolean exists() { return true; } WebDavFolder(WebDavStore nStore, String id); void setUrl(String url); @Override void open(int mode); @Override Map<String, String> copyMessages(List<? extends Message> messages, Folder folder); @Override Map<St...
### Question: WebDavFolder extends Folder<WebDavMessage> { private int getMessageCount(boolean read) throws MessagingException { String isRead; int messageCount = 0; Map<String, String> headers = new HashMap<String, String>(); String messageBody; if (read) { isRead = "True"; } else { isRead = "False"; } messageBody = s...
### Question: WebDavFolder extends Folder<WebDavMessage> { @Override public Map<String, String> moveMessages(List<? extends Message> messages, Folder folder) throws MessagingException { moveOrCopyMessages(messages, folder.getId(), true); return null; } WebDavFolder(WebDavStore nStore, String id); void setUrl(String url...
### Question: WebDavFolder extends Folder<WebDavMessage> { @Override public Map<String, String> copyMessages(List<? extends Message> messages, Folder folder) throws MessagingException { moveOrCopyMessages(messages, folder.getId(), false); return null; } WebDavFolder(WebDavStore nStore, String id); void setUrl(String ur...
### Question: WebDavMessage extends MimeMessage { @Override public void delete(String trashFolderName) throws MessagingException { WebDavFolder wdFolder = (WebDavFolder) getFolder(); Timber.i("Deleting message by moving to %s", trashFolderName); wdFolder.moveMessages(Collections.singletonList(this), wdFolder.getStore()...
### Question: WebDavMessage extends MimeMessage { public void setNewHeaders(ParsedMessageEnvelope envelope) throws MessagingException { String[] headers = envelope.getHeaderList(); Map<String, String> messageHeaders = envelope.getMessageHeaders(); for (String header : headers) { String headerValue = messageHeaders.get(...