target stringlengths 20 113k | src_fm stringlengths 11 86.3k | src_fm_fc stringlengths 21 86.4k | src_fm_fc_co stringlengths 30 86.4k | src_fm_fc_ms stringlengths 42 86.8k | src_fm_fc_ms_ff stringlengths 43 86.8k |
|---|---|---|---|---|---|
@Test public void shouldRemoveMetaRefreshWithSpacesInAttributeValue() { String html = "<html>" + "<head><meta http-equiv=\"refresh \" content=\"1; URL=http: "<body>Message</body>" + "</html>"; Document result = htmlSanitizer.sanitize(html); assertEquals("<html><head></head><body>Message</body></html>", toCompactString(... | public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } HtmlSanitizer(); } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } HtmlSanitizer(); Document sanitize(String html); } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } HtmlSanitizer(); Document sanitize(String html); } |
@Test public void shouldRemoveMultipleMetaRefreshTags() { String html = "<html>" + "<head><meta http-equiv=\"refresh\" content=\"1; URL=http: "<body><meta http-equiv=\"refresh\" content=\"1; URL=http: "</html>"; Document result = htmlSanitizer.sanitize(html); assertEquals("<html><head></head><body>Message</body></html>... | public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } HtmlSanitizer(); } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } HtmlSanitizer(); Document sanitize(String html); } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } HtmlSanitizer(); Document sanitize(String html); } |
@Test public void shouldRemoveMetaRefreshButKeepOtherMetaTags() { String html = "<html>" + "<head>" + "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">" + "<meta http-equiv=\"refresh\" content=\"1; URL=http: "</head>" + "<body>Message</body>" + "</html>"; Document result = htmlSanitizer.sanitize(... | public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } HtmlSanitizer(); } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } HtmlSanitizer(); Document sanitize(String html); } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } HtmlSanitizer(); Document sanitize(String html); } |
@Test public void shouldProduceValidHtmlFromHtmlWithXmlDeclaration() { String html = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<html><head></head><body></body></html>"; Document result = htmlSanitizer.sanitize(html); assertEquals("<html><head></head><body></body></html>", toCompactString(result)); } | public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } HtmlSanitizer(); } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } HtmlSanitizer(); Document sanitize(String html); } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } HtmlSanitizer(); Document sanitize(String html); } |
@Test public void shouldNormalizeTables() { String html = "<html><head></head><body><table><tr><td></td><td></td></tr></table></body></html>"; Document result = htmlSanitizer.sanitize(html); assertEquals("<html><head></head><body><table><tbody>" + "<tr><td></td><td></td></tr>" + "</tbody></table></body></html>", toComp... | public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } HtmlSanitizer(); } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } HtmlSanitizer(); Document sanitize(String html); } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } HtmlSanitizer(); Document sanitize(String html); } |
@Test public void findEncryptedPartsShouldReturnMultipleEncryptedParts() throws Exception { MimeMessage message = new MimeMessage(); MimeMultipart multipartMixed = MimeMultipart.newInstance(); multipartMixed.setSubType("mixed"); MimeMessageHelper.setBody(message, multipartMixed); MimeMultipart multipartEncryptedOne = M... | public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encrypt... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... |
@Test public void shouldHtmlEncodeXmlDirectives() { String html = "<html><head></head><body><table>" + "<tr><td><!==><!==>Hmailserver service shutdown:</td><td><!==><!==>Ok</td></tr>" + "</table></body></html>"; Document result = htmlSanitizer.sanitize(html); assertEquals("<html><head></head><body><table><tbody>" + "<t... | public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } HtmlSanitizer(); } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } HtmlSanitizer(); Document sanitize(String html); } | HtmlSanitizer { public Document sanitize(String html) { Document dirtyDocument = Jsoup.parse(html); Document cleanedDocument = cleaner.clean(dirtyDocument); headCleaner.clean(dirtyDocument, cleanedDocument); return cleanedDocument; } HtmlSanitizer(); Document sanitize(String html); } |
@Test public void uriInMiddleOfInput() throws Exception { String prefix = "prefix "; String uri = "bitcoin:12A1MyfXbW6RhdRAZEqofac5jCQQjwEPBu?amount=1.2"; String text = prefix + uri; parser.linkifyUri(text, prefix.length(), outputBuffer); assertLinkOnly(uri, outputBuffer); } | @Override public int linkifyUri(String text, int startPos, StringBuffer outputBuffer) { Matcher matcher = BITCOIN_URI_PATTERN.matcher(text); if (!matcher.find(startPos) || matcher.start() != startPos) { return startPos; } String bitcoinUri = matcher.group(); outputBuffer.append("<a href=\"") .append(bitcoinUri) .append... | BitcoinUriParser implements UriParser { @Override public int linkifyUri(String text, int startPos, StringBuffer outputBuffer) { Matcher matcher = BITCOIN_URI_PATTERN.matcher(text); if (!matcher.find(startPos) || matcher.start() != startPos) { return startPos; } String bitcoinUri = matcher.group(); outputBuffer.append("... | BitcoinUriParser implements UriParser { @Override public int linkifyUri(String text, int startPos, StringBuffer outputBuffer) { Matcher matcher = BITCOIN_URI_PATTERN.matcher(text); if (!matcher.find(startPos) || matcher.start() != startPos) { return startPos; } String bitcoinUri = matcher.group(); outputBuffer.append("... | BitcoinUriParser implements UriParser { @Override public int linkifyUri(String text, int startPos, StringBuffer outputBuffer) { Matcher matcher = BITCOIN_URI_PATTERN.matcher(text); if (!matcher.find(startPos) || matcher.start() != startPos) { return startPos; } String bitcoinUri = matcher.group(); outputBuffer.append("... | BitcoinUriParser implements UriParser { @Override public int linkifyUri(String text, int startPos, StringBuffer outputBuffer) { Matcher matcher = BITCOIN_URI_PATTERN.matcher(text); if (!matcher.find(startPos) || matcher.start() != startPos) { return startPos; } String bitcoinUri = matcher.group(); outputBuffer.append("... |
@Test public void build_shouldSucceed() throws Exception { MessageBuilder messageBuilder = createSimpleMessageBuilder(); messageBuilder.buildAsync(callback); MimeMessage message = getMessageFromCallback(); assertEquals("text/plain", message.getMimeType()); assertEquals(TEST_SUBJECT, message.getSubject()); assertEquals(... | final public void buildAsync(Callback callback) { synchronized (callbackLock) { asyncCallback = callback; queuedMimeMessage = null; queuedException = null; queuedPendingIntent = null; } new AsyncTask<Void,Void,Void>() { @Override protected Void doInBackground(Void... params) { buildMessageInternal(); return null; } @Ov... | MessageBuilder { final public void buildAsync(Callback callback) { synchronized (callbackLock) { asyncCallback = callback; queuedMimeMessage = null; queuedException = null; queuedPendingIntent = null; } new AsyncTask<Void,Void,Void>() { @Override protected Void doInBackground(Void... params) { buildMessageInternal(); r... | MessageBuilder { final public void buildAsync(Callback callback) { synchronized (callbackLock) { asyncCallback = callback; queuedMimeMessage = null; queuedException = null; queuedPendingIntent = null; } new AsyncTask<Void,Void,Void>() { @Override protected Void doInBackground(Void... params) { buildMessageInternal(); r... | MessageBuilder { final public void buildAsync(Callback callback) { synchronized (callbackLock) { asyncCallback = callback; queuedMimeMessage = null; queuedException = null; queuedPendingIntent = null; } new AsyncTask<Void,Void,Void>() { @Override protected Void doInBackground(Void... params) { buildMessageInternal(); r... | MessageBuilder { final public void buildAsync(Callback callback) { synchronized (callbackLock) { asyncCallback = callback; queuedMimeMessage = null; queuedException = null; queuedPendingIntent = null; } new AsyncTask<Void,Void,Void>() { @Override protected Void doInBackground(Void... params) { buildMessageInternal(); r... |
@Test public void build_usingHtmlFormat_shouldUseMultipartAlternativeInCorrectOrder() { MessageBuilder messageBuilder = createHtmlMessageBuilder(); messageBuilder.buildAsync(callback); MimeMessage message = getMessageFromCallback(); assertEquals(MimeMultipart.class, message.getBody().getClass()); assertEquals("multipar... | final public void buildAsync(Callback callback) { synchronized (callbackLock) { asyncCallback = callback; queuedMimeMessage = null; queuedException = null; queuedPendingIntent = null; } new AsyncTask<Void,Void,Void>() { @Override protected Void doInBackground(Void... params) { buildMessageInternal(); return null; } @Ov... | MessageBuilder { final public void buildAsync(Callback callback) { synchronized (callbackLock) { asyncCallback = callback; queuedMimeMessage = null; queuedException = null; queuedPendingIntent = null; } new AsyncTask<Void,Void,Void>() { @Override protected Void doInBackground(Void... params) { buildMessageInternal(); r... | MessageBuilder { final public void buildAsync(Callback callback) { synchronized (callbackLock) { asyncCallback = callback; queuedMimeMessage = null; queuedException = null; queuedPendingIntent = null; } new AsyncTask<Void,Void,Void>() { @Override protected Void doInBackground(Void... params) { buildMessageInternal(); r... | MessageBuilder { final public void buildAsync(Callback callback) { synchronized (callbackLock) { asyncCallback = callback; queuedMimeMessage = null; queuedException = null; queuedPendingIntent = null; } new AsyncTask<Void,Void,Void>() { @Override protected Void doInBackground(Void... params) { buildMessageInternal(); r... | MessageBuilder { final public void buildAsync(Callback callback) { synchronized (callbackLock) { asyncCallback = callback; queuedMimeMessage = null; queuedException = null; queuedPendingIntent = null; } new AsyncTask<Void,Void,Void>() { @Override protected Void doInBackground(Void... params) { buildMessageInternal(); r... |
@Test public void findFirstTextPart_withTextPlainPart() throws Exception { Part part = createTextPart("text/plain"); Part result = textPartFinder.findFirstTextPart(part); assertEquals(part, result); } | @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(multipart); } else {... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... |
@Test public void findFirstTextPart_withTextHtmlPart() throws Exception { Part part = createTextPart("text/html"); Part result = textPartFinder.findFirstTextPart(part); assertEquals(part, result); } | @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(multipart); } else {... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... |
@Test public void findFirstTextPart_withoutTextPart() throws Exception { Part part = createPart("image/jpeg"); Part result = textPartFinder.findFirstTextPart(part); assertNull(result); } | @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(multipart); } else {... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... |
@Test public void findFirstTextPart_withMultipartAlternative() throws Exception { BodyPart expected = createTextPart("text/plain"); Part part = createMultipart("multipart/alternative", expected, createTextPart("text/html")); Part result = textPartFinder.findFirstTextPart(part); assertEquals(expected, result); } | @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(multipart); } else {... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... |
@Test public void findFirstTextPart_withMultipartAlternativeHtmlPartFirst() throws Exception { BodyPart expected = createTextPart("text/plain"); Part part = createMultipart("multipart/alternative", createTextPart("text/html"), expected); Part result = textPartFinder.findFirstTextPart(part); assertEquals(expected, resul... | @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(multipart); } else {... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... |
@Test public void findFirstTextPart_withMultipartAlternativeContainingOnlyTextHtmlPart() throws Exception { BodyPart expected = createTextPart("text/html"); Part part = createMultipart("multipart/alternative", createPart("image/gif"), expected, createTextPart("text/html")); Part result = textPartFinder.findFirstTextPar... | @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(multipart); } else {... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... |
@Test public void findEncrypted__withMultipartEncrypted__shouldReturnRoot() throws Exception { Message message = messageFromBody( multipart("encrypted", bodypart("application/pgp-encrypted"), bodypart("application/octet-stream") ) ); List<Part> encryptedParts = MessageDecryptVerifier.findEncryptedParts(message); assert... | public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encrypt... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... |
@Test public void findFirstTextPart_withMultipartAlternativeNotContainingTextPart() throws Exception { Part part = createMultipart("multipart/alternative", createPart("image/gif"), createPart("application/pdf")); Part result = textPartFinder.findFirstTextPart(part); assertNull(result); } | @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(multipart); } else {... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... |
@Test public void findFirstTextPart_withMultipartAlternativeContainingMultipartRelatedContainingTextPlain() throws Exception { BodyPart expected = createTextPart("text/plain"); Part part = createMultipart("multipart/alternative", createMultipart("multipart/related", expected, createPart("image/jpeg")), createTextPart("... | @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(multipart); } else {... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... |
@Test public void findFirstTextPart_withMultipartAlternativeContainingMultipartRelatedContainingTextHtmlFirst() throws Exception { BodyPart expected = createTextPart("text/plain"); Part part = createMultipart("multipart/alternative", createMultipart("multipart/related", createTextPart("text/html"), createPart("image/jp... | @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(multipart); } else {... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... |
@Test public void findFirstTextPart_withMultipartMixedContainingTextPlain() throws Exception { BodyPart expected = createTextPart("text/plain"); Part part = createMultipart("multipart/mixed", createPart("image/jpeg"), expected); Part result = textPartFinder.findFirstTextPart(part); assertEquals(expected, result); } | @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(multipart); } else {... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... |
@Test public void findFirstTextPart_withMultipartMixedContainingTextHtmlFirst() throws Exception { BodyPart expected = createTextPart("text/html"); Part part = createMultipart("multipart/mixed", expected, createTextPart("text/plain")); Part result = textPartFinder.findFirstTextPart(part); assertEquals(expected, result)... | @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(multipart); } else {... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... |
@Test public void findFirstTextPart_withMultipartMixedNotContainingTextPart() throws Exception { Part part = createMultipart("multipart/mixed", createPart("image/jpeg"), createPart("image/gif")); Part result = textPartFinder.findFirstTextPart(part); assertNull(result); } | @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(multipart); } else {... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... |
@Test public void findFirstTextPart_withMultipartMixedContainingMultipartAlternative() throws Exception { BodyPart expected = createTextPart("text/plain"); Part part = createMultipart("multipart/mixed", createPart("image/jpeg"), createMultipart("multipart/alternative", expected, createTextPart("text/html")), createText... | @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(multipart); } else {... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... |
@Test public void findFirstTextPart_withMultipartMixedContainingMultipartAlternativeWithTextPlainPartLast() throws Exception { BodyPart expected = createTextPart("text/plain"); Part part = createMultipart("multipart/mixed", createMultipart("multipart/alternative", createTextPart("text/html"), expected)); Part result = ... | @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(multipart); } else {... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... |
@Test public void findFirstTextPart_withMultipartAlternativeContainingEmptyTextPlainPart() throws Exception { BodyPart expected = createEmptyPart("text/plain"); Part part = createMultipart("multipart/alternative", expected, createTextPart("text/html")); Part result = textPartFinder.findFirstTextPart(part); assertEquals... | @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(multipart); } else {... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... |
@Test public void findFirstTextPart_withMultipartMixedContainingEmptyTextHtmlPart() throws Exception { BodyPart expected = createEmptyPart("text/html"); Part part = createMultipart("multipart/mixed", expected, createTextPart("text/plain")); Part result = textPartFinder.findFirstTextPart(part); assertEquals(expected, re... | @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(multipart); } else {... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... | TextPartFinder { @Nullable public Part findFirstTextPart(@NonNull Part part) { String mimeType = part.getMimeType(); Body body = part.getBody(); if (body instanceof Multipart) { Multipart multipart = (Multipart) body; if (isSameMimeType(mimeType, "multipart/alternative")) { return findTextPartInMultipartAlternative(mul... |
@Test public void findEncrypted__withMultipartMixedSubEncrypted__shouldReturnRoot() throws Exception { Message message = messageFromBody( multipart("mixed", multipart("encrypted", bodypart("application/pgp-encrypted"), bodypart("application/octet-stream") ) ) ); List<Part> encryptedParts = MessageDecryptVerifier.findEn... | public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encrypt... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... |
@Test(expected = IllegalArgumentException.class) public void extractInfo__withGenericPart_shouldThrow() throws Exception { Part part = mock(Part.class); attachmentInfoExtractor.extractAttachmentInfo(part); } | @WorkerThread public AttachmentViewInfo extractAttachmentInfo(Part part) throws MessagingException { Uri uri; long size; boolean isContentAvailable; if (part instanceof LocalPart) { LocalPart localPart = (LocalPart) part; String accountUuid = localPart.getAccountUuid(); long messagePartId = localPart.getPartId(); size ... | AttachmentInfoExtractor { @WorkerThread public AttachmentViewInfo extractAttachmentInfo(Part part) throws MessagingException { Uri uri; long size; boolean isContentAvailable; if (part instanceof LocalPart) { LocalPart localPart = (LocalPart) part; String accountUuid = localPart.getAccountUuid(); long messagePartId = lo... | AttachmentInfoExtractor { @WorkerThread public AttachmentViewInfo extractAttachmentInfo(Part part) throws MessagingException { Uri uri; long size; boolean isContentAvailable; if (part instanceof LocalPart) { LocalPart localPart = (LocalPart) part; String accountUuid = localPart.getAccountUuid(); long messagePartId = lo... | AttachmentInfoExtractor { @WorkerThread public AttachmentViewInfo extractAttachmentInfo(Part part) throws MessagingException { Uri uri; long size; boolean isContentAvailable; if (part instanceof LocalPart) { LocalPart localPart = (LocalPart) part; String accountUuid = localPart.getAccountUuid(); long messagePartId = lo... | AttachmentInfoExtractor { @WorkerThread public AttachmentViewInfo extractAttachmentInfo(Part part) throws MessagingException { Uri uri; long size; boolean isContentAvailable; if (part instanceof LocalPart) { LocalPart localPart = (LocalPart) part; String accountUuid = localPart.getAccountUuid(); long messagePartId = lo... |
@Test public void extractInfo__fromLocalBodyPart__shouldReturnProvidedValues() throws Exception { LocalBodyPart part = new LocalBodyPart(TEST_ACCOUNT_UUID, null, TEST_ID, TEST_SIZE); part.setHeader(MimeHeader.HEADER_CONTENT_TYPE, TEST_MIME_TYPE); AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAt... | @WorkerThread public AttachmentViewInfo extractAttachmentInfo(Part part) throws MessagingException { Uri uri; long size; boolean isContentAvailable; if (part instanceof LocalPart) { LocalPart localPart = (LocalPart) part; String accountUuid = localPart.getAccountUuid(); long messagePartId = localPart.getPartId(); size ... | AttachmentInfoExtractor { @WorkerThread public AttachmentViewInfo extractAttachmentInfo(Part part) throws MessagingException { Uri uri; long size; boolean isContentAvailable; if (part instanceof LocalPart) { LocalPart localPart = (LocalPart) part; String accountUuid = localPart.getAccountUuid(); long messagePartId = lo... | AttachmentInfoExtractor { @WorkerThread public AttachmentViewInfo extractAttachmentInfo(Part part) throws MessagingException { Uri uri; long size; boolean isContentAvailable; if (part instanceof LocalPart) { LocalPart localPart = (LocalPart) part; String accountUuid = localPart.getAccountUuid(); long messagePartId = lo... | AttachmentInfoExtractor { @WorkerThread public AttachmentViewInfo extractAttachmentInfo(Part part) throws MessagingException { Uri uri; long size; boolean isContentAvailable; if (part instanceof LocalPart) { LocalPart localPart = (LocalPart) part; String accountUuid = localPart.getAccountUuid(); long messagePartId = lo... | AttachmentInfoExtractor { @WorkerThread public AttachmentViewInfo extractAttachmentInfo(Part part) throws MessagingException { Uri uri; long size; boolean isContentAvailable; if (part instanceof LocalPart) { LocalPart localPart = (LocalPart) part; String accountUuid = localPart.getAccountUuid(); long messagePartId = lo... |
@Test public void extractInfoForDb__withNoHeaders__shouldReturnEmptyValues() throws Exception { MimeBodyPart part = new MimeBodyPart(); AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part); assertEquals(Uri.EMPTY, attachmentViewInfo.internalUri); assertEquals(Attachment... | public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } } | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... |
@Test public void extractInfoForDb__withTextMimeType__shouldReturnTxtExtension() throws Exception { MimeBodyPart part = new MimeBodyPart(); part.setHeader(MimeHeader.HEADER_CONTENT_TYPE, "text/plain"); AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part); assertEquals("... | public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } } | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... |
@Test public void extractInfoForDb__withContentTypeAndName__shouldReturnNamedAttachment() throws Exception { MimeBodyPart part = new MimeBodyPart(); part.setHeader(MimeHeader.HEADER_CONTENT_TYPE, TEST_MIME_TYPE + "; name=\"filename.ext\""); AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachme... | public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } } | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... |
@Test public void extractInfoForDb__withContentTypeAndEncodedWordName__shouldReturnDecodedName() throws Exception { Part part = new MimeBodyPart(); part.addRawHeader(MimeHeader.HEADER_CONTENT_TYPE, MimeHeader.HEADER_CONTENT_TYPE + ": " +TEST_MIME_TYPE + "; name=\"=?ISO-8859-1?Q?Sm=F8rrebr=F8d?=\""); AttachmentViewInfo ... | public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } } | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... |
@Test public void extractInfoForDb__withDispositionAttach__shouldReturnNamedAttachment() throws Exception { MimeBodyPart part = new MimeBodyPart(); part.setHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, "attachment" + "; filename=\"filename.ext\"; meaningless=\"dummy\""); AttachmentViewInfo attachmentViewInfo = attachme... | public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } } | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... |
@Test public void extractInfoForDb__withDispositionInlineAndContentId__shouldReturnInlineAttachment() throws Exception { Part part = new MimeBodyPart(); part.addRawHeader(MimeHeader.HEADER_CONTENT_ID, MimeHeader.HEADER_CONTENT_ID + ": " + TEST_CONTENT_ID); part.addRawHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, MimeHe... | public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } } | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... |
@Test public void extractInfoForDb__withDispositionSizeParam__shouldReturnThatSize() throws Exception { MimeBodyPart part = new MimeBodyPart(); part.setHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, "attachment" + "; size=\"" + TEST_SIZE + "\""); AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAtt... | public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } } | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... |
@Test public void extractInfoForDb__withDispositionInvalidSizeParam__shouldReturnUnknownSize() throws Exception { MimeBodyPart part = new MimeBodyPart(); part.setHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, "attachment" + "; size=\"notanint\""); AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAt... | public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } } | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... |
@Test public void findEncrypted__withMultipartMixedSubEncryptedAndEncrypted__shouldReturnBoth() throws Exception { Message message = messageFromBody( multipart("mixed", multipart("encrypted", bodypart("application/pgp-encrypted"), bodypart("application/octet-stream") ), multipart("encrypted", bodypart("application/pgp-... | public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encrypt... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... |
@Test public void extractInfoForDb__withNoBody__shouldReturnContentNotAvailable() throws Exception { MimeBodyPart part = new MimeBodyPart(); AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part); assertFalse(attachmentViewInfo.isContentAvailable()); } | public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } } | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... |
@Test public void extractInfoForDb__withNoBody__shouldReturnContentAvailable() throws Exception { MimeBodyPart part = new MimeBodyPart(); part.setBody(new TextBody("data")); AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part); assertTrue(attachmentViewInfo.isContentAva... | public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } } | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... | AttachmentInfoExtractor { public AttachmentViewInfo extractAttachmentInfoForDatabase(Part part) throws MessagingException { boolean isContentAvailable = part.getBody() != null; return extractAttachmentInfo(part, Uri.EMPTY, AttachmentViewInfo.UNKNOWN_SIZE, isContentAvailable); } @VisibleForTesting AttachmentInfoExtract... |
@Test public void extractInfo__withDeferredFileBody() throws Exception { attachmentInfoExtractor = new AttachmentInfoExtractor(context) { @Nullable @Override protected Uri getDecryptedFileProviderUri(DeferredFileBody decryptedTempFileBody, String mimeType) { return TEST_URI; } }; DeferredFileBody body = mock(DeferredFi... | @WorkerThread public AttachmentViewInfo extractAttachmentInfo(Part part) throws MessagingException { Uri uri; long size; boolean isContentAvailable; if (part instanceof LocalPart) { LocalPart localPart = (LocalPart) part; String accountUuid = localPart.getAccountUuid(); long messagePartId = localPart.getPartId(); size ... | AttachmentInfoExtractor { @WorkerThread public AttachmentViewInfo extractAttachmentInfo(Part part) throws MessagingException { Uri uri; long size; boolean isContentAvailable; if (part instanceof LocalPart) { LocalPart localPart = (LocalPart) part; String accountUuid = localPart.getAccountUuid(); long messagePartId = lo... | AttachmentInfoExtractor { @WorkerThread public AttachmentViewInfo extractAttachmentInfo(Part part) throws MessagingException { Uri uri; long size; boolean isContentAvailable; if (part instanceof LocalPart) { LocalPart localPart = (LocalPart) part; String accountUuid = localPart.getAccountUuid(); long messagePartId = lo... | AttachmentInfoExtractor { @WorkerThread public AttachmentViewInfo extractAttachmentInfo(Part part) throws MessagingException { Uri uri; long size; boolean isContentAvailable; if (part instanceof LocalPart) { LocalPart localPart = (LocalPart) part; String accountUuid = localPart.getAccountUuid(); long messagePartId = lo... | AttachmentInfoExtractor { @WorkerThread public AttachmentViewInfo extractAttachmentInfo(Part part) throws MessagingException { Uri uri; long size; boolean isContentAvailable; if (part instanceof LocalPart) { LocalPart localPart = (LocalPart) part; String accountUuid = localPart.getAccountUuid(); long messagePartId = lo... |
@Test public void createPreview_withEncryptedMessage() throws Exception { Message message = createDummyMessage(); when(encryptionDetector.isEncrypted(message)).thenReturn(true); PreviewResult result = previewCreator.createPreview(message); assertFalse(result.isPreviewTextAvailable()); assertEquals(PreviewType.ENCRYPTED... | public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } | MessagePreviewCreator { public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } } | MessagePreviewCreator { public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } MessagePreviewCreator(TextPartFinder textPartFinder, PreviewTextExtractor previewTextExtractor,
EncryptionD... | MessagePreviewCreator { public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } MessagePreviewCreator(TextPartFinder textPartFinder, PreviewTextExtractor previewTextExtractor,
EncryptionD... | MessagePreviewCreator { public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } MessagePreviewCreator(TextPartFinder textPartFinder, PreviewTextExtractor previewTextExtractor,
EncryptionD... |
@Test public void createPreview_withoutTextPart() throws Exception { Message message = createDummyMessage(); when(encryptionDetector.isEncrypted(message)).thenReturn(false); when(textPartFinder.findFirstTextPart(message)).thenReturn(null); PreviewResult result = previewCreator.createPreview(message); assertFalse(result... | public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } | MessagePreviewCreator { public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } } | MessagePreviewCreator { public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } MessagePreviewCreator(TextPartFinder textPartFinder, PreviewTextExtractor previewTextExtractor,
EncryptionD... | MessagePreviewCreator { public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } MessagePreviewCreator(TextPartFinder textPartFinder, PreviewTextExtractor previewTextExtractor,
EncryptionD... | MessagePreviewCreator { public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } MessagePreviewCreator(TextPartFinder textPartFinder, PreviewTextExtractor previewTextExtractor,
EncryptionD... |
@Test public void createPreview_withEmptyTextPart() throws Exception { Message message = createDummyMessage(); Part textPart = createEmptyPart("text/plain"); when(encryptionDetector.isEncrypted(message)).thenReturn(false); when(textPartFinder.findFirstTextPart(message)).thenReturn(textPart); PreviewResult result = prev... | public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } | MessagePreviewCreator { public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } } | MessagePreviewCreator { public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } MessagePreviewCreator(TextPartFinder textPartFinder, PreviewTextExtractor previewTextExtractor,
EncryptionD... | MessagePreviewCreator { public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } MessagePreviewCreator(TextPartFinder textPartFinder, PreviewTextExtractor previewTextExtractor,
EncryptionD... | MessagePreviewCreator { public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } MessagePreviewCreator(TextPartFinder textPartFinder, PreviewTextExtractor previewTextExtractor,
EncryptionD... |
@Test public void createPreview_withTextPart() throws Exception { Message message = createDummyMessage(); Part textPart = createTextPart("text/plain"); when(encryptionDetector.isEncrypted(message)).thenReturn(false); when(textPartFinder.findFirstTextPart(message)).thenReturn(textPart); when(previewTextExtractor.extract... | public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } | MessagePreviewCreator { public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } } | MessagePreviewCreator { public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } MessagePreviewCreator(TextPartFinder textPartFinder, PreviewTextExtractor previewTextExtractor,
EncryptionD... | MessagePreviewCreator { public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } MessagePreviewCreator(TextPartFinder textPartFinder, PreviewTextExtractor previewTextExtractor,
EncryptionD... | MessagePreviewCreator { public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } MessagePreviewCreator(TextPartFinder textPartFinder, PreviewTextExtractor previewTextExtractor,
EncryptionD... |
@Test public void createPreview_withPreviewTextExtractorThrowing() throws Exception { Message message = createDummyMessage(); Part textPart = createTextPart("text/plain"); when(encryptionDetector.isEncrypted(message)).thenReturn(false); when(textPartFinder.findFirstTextPart(message)).thenReturn(textPart); when(previewT... | public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } | MessagePreviewCreator { public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } } | MessagePreviewCreator { public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } MessagePreviewCreator(TextPartFinder textPartFinder, PreviewTextExtractor previewTextExtractor,
EncryptionD... | MessagePreviewCreator { public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } MessagePreviewCreator(TextPartFinder textPartFinder, PreviewTextExtractor previewTextExtractor,
EncryptionD... | MessagePreviewCreator { public PreviewResult createPreview(@NonNull Message message) { if (encryptionDetector.isEncrypted(message)) { return PreviewResult.encrypted(); } return extractText(message); } MessagePreviewCreator(TextPartFinder textPartFinder, PreviewTextExtractor previewTextExtractor,
EncryptionD... |
@Test public void isEncrypted_withTextPlain_shouldReturnFalse() throws Exception { Message message = createTextMessage("text/plain", "plain text"); boolean encrypted = encryptionDetector.isEncrypted(message); assertFalse(encrypted); } | public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); boolean isEncrypted(@NonNull Message message); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); boolean isEncrypted(@NonNull Message message); } |
@Test public void isEncrypted_withMultipartEncrypted_shouldReturnTrue() throws Exception { Message message = createMultipartMessage("multipart/encrypted", createPart("application/octet-stream"), createPart("application/octet-stream")); boolean encrypted = encryptionDetector.isEncrypted(message); assertTrue(encrypted); ... | public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); boolean isEncrypted(@NonNull Message message); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); boolean isEncrypted(@NonNull Message message); } |
@Test public void findEncrypted__withMultipartMixedSubTextAndEncrypted__shouldReturnEncrypted() throws Exception { Message message = messageFromBody( multipart("mixed", bodypart("text/plain"), multipart("encrypted", bodypart("application/pgp-encrypted"), bodypart("application/octet-stream") ) ) ); List<Part> encryptedP... | public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encrypt... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... |
@Test public void isEncrypted_withSMimePart_shouldReturnTrue() throws Exception { Message message = createMessage("application/pkcs7-mime"); boolean encrypted = encryptionDetector.isEncrypted(message); assertTrue(encrypted); } | public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); boolean isEncrypted(@NonNull Message message); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); boolean isEncrypted(@NonNull Message message); } |
@Test public void isEncrypted_withMultipartMixedContainingSMimePart_shouldReturnTrue() throws Exception { Message message = createMultipartMessage("multipart/mixed", createPart("application/pkcs7-mime"), createPart("text/plain")); boolean encrypted = encryptionDetector.isEncrypted(message); assertTrue(encrypted); } | public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); boolean isEncrypted(@NonNull Message message); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); boolean isEncrypted(@NonNull Message message); } |
@Test public void isEncrypted_withInlinePgp_shouldReturnTrue() throws Exception { Message message = createTextMessage("text/plain", "" + "-----BEGIN PGP MESSAGE-----" + CRLF + "some encrypted stuff here" + CRLF + "-----END PGP MESSAGE-----"); when(textPartFinder.findFirstTextPart(message)).thenReturn(message); boolean ... | public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); boolean isEncrypted(@NonNull Message message); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); boolean isEncrypted(@NonNull Message message); } |
@Test public void isEncrypted_withPlainTextAndPreambleWithInlinePgp_shouldReturnFalse() throws Exception { Message message = createTextMessage("text/plain", "" + "preamble" + CRLF + "-----BEGIN PGP MESSAGE-----" + CRLF + "some encrypted stuff here" + CRLF + "-----END PGP MESSAGE-----" + CRLF + "epilogue"); when(textPar... | public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); boolean isEncrypted(@NonNull Message message); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); boolean isEncrypted(@NonNull Message message); } |
@Test public void isEncrypted_withQuotedInlinePgp_shouldReturnFalse() throws Exception { Message message = createTextMessage("text/plain", "" + "good talk!" + CRLF + CRLF + "> -----BEGIN PGP MESSAGE-----" + CRLF + "> some encrypted stuff here" + CRLF + "> -----END PGP MESSAGE-----" + CRLF + CRLF + "-- " + CRLF + "my si... | public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); boolean isEncrypted(@NonNull Message message); } | EncryptionDetector { public boolean isEncrypted(@NonNull Message message) { return isPgpMimeOrSMimeEncrypted(message) || containsInlinePgpEncryptedText(message); } EncryptionDetector(TextPartFinder textPartFinder); boolean isEncrypted(@NonNull Message message); } |
@Test(expected = PreviewExtractionException.class) public void extractPreview_withEmptyBody_shouldThrow() throws Exception { Part part = new MimeBodyPart(null, "text/plain"); previewTextExtractor.extractPreview(part); } | @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainText = convertFromHtmlIfN... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... |
@Test public void extractPreview_withSimpleTextPlain() throws Exception { String text = "The quick brown fox jumps over the lazy dog"; Part part = createTextPart("text/plain", text); String preview = previewTextExtractor.extractPreview(part); assertEquals(text, preview); } | @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainText = convertFromHtmlIfN... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... |
@Test public void extractPreview_withSimpleTextHtml() throws Exception { String text = "<b>The quick brown fox jumps over the lazy dog</b>"; Part part = createTextPart("text/html", text); String preview = previewTextExtractor.extractPreview(part); assertEquals("The quick brown fox jumps over the lazy dog", preview); } | @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainText = convertFromHtmlIfN... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... |
@Test public void extractPreview_withLongTextPlain() throws Exception { String text = "" + "10--------20--------30--------40--------50--------" + "60--------70--------80--------90--------100-------" + "110-------120-------130-------140-------150-------" + "160-------170-------180-------190-------200-------" + "210-----... | @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainText = convertFromHtmlIfN... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... |
@Test public void extractPreview_shouldStripSignature() throws Exception { String text = "" + "Some text\r\n" + "-- \r\n" + "Signature"; Part part = createTextPart("text/plain", text); String preview = previewTextExtractor.extractPreview(part); assertEquals("Some text", preview); } | @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainText = convertFromHtmlIfN... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... |
@Test public void findEncrypted__withMultipartMixedSubEncryptedAndText__shouldReturnEncrypted() throws Exception { Message message = messageFromBody( multipart("mixed", multipart("encrypted", bodypart("application/pgp-encrypted"), bodypart("application/octet-stream") ), bodypart("text/plain") ) ); List<Part> encryptedP... | public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartEncrypted(part)) { encrypt... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... | MessageDecryptVerifier { public static List<Part> findEncryptedParts(Part startPart) { List<Part> encryptedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); Body body = part.getBody(); if (isPartMultipartE... |
@Test public void extractPreview_shouldStripHorizontalLine() throws Exception { String text = "" + "line 1\r\n" + "----\r\n" + "line 2"; Part part = createTextPart("text/plain", text); String preview = previewTextExtractor.extractPreview(part); assertEquals("line 1 line 2", preview); } | @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainText = convertFromHtmlIfN... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... |
@Test public void extractPreview_shouldStripQuoteHeaderAndQuotedText() throws Exception { String text = "" + "some text\r\n" + "On 01/02/03 someone wrote\r\n" + "> some quoted text\r\n" + "# some other quoted text\r\n"; Part part = createTextPart("text/plain", text); String preview = previewTextExtractor.extractPreview... | @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainText = convertFromHtmlIfN... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... |
@Test public void extractPreview_shouldStripGenericQuoteHeader() throws Exception { String text = "" + "Am 13.12.2015 um 23:42 schrieb Hans:\r\n" + "> hallo\r\n" + "hi there\r\n"; Part part = createTextPart("text/plain", text); String preview = previewTextExtractor.extractPreview(part); assertEquals("hi there", preview... | @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainText = convertFromHtmlIfN... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... |
@Test public void extractPreview_shouldStripHorizontalRules() throws Exception { String text = "line 1" + "------------------------------\r\n" + "line 2"; Part part = createTextPart("text/plain", text); String preview = previewTextExtractor.extractPreview(part); assertEquals("line 1 line 2", preview); } | @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainText = convertFromHtmlIfN... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... |
@Test public void extractPreview_shouldReplaceUrl() throws Exception { String text = "some url: https: Part part = createTextPart("text/plain", text); String preview = previewTextExtractor.extractPreview(part); assertEquals("some url: ...", preview); } | @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainText = convertFromHtmlIfN... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... |
@Test public void extractPreview_shouldCollapseAndTrimWhitespace() throws Exception { String text = " whitespace is\t\tfun "; Part part = createTextPart("text/plain", text); String preview = previewTextExtractor.extractPreview(part); assertEquals("whitespace is fun", preview); } | @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainText = convertFromHtmlIfN... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... | PreviewTextExtractor { @NonNull public String extractPreview(@NonNull Part textPart) throws PreviewExtractionException { String text = MessageExtractor.getTextFromPart(textPart, MAX_CHARACTERS_CHECKED_FOR_PREVIEW); if (text == null) { throw new PreviewExtractionException("Couldn't get text from part"); } String plainTe... |
@Test public void build__withCryptoProviderUnconfigured__shouldThrow() throws MessagingException { cryptoStatusBuilder.setCryptoMode(CryptoMode.NO_CHOICE); cryptoStatusBuilder.setCryptoProviderState(CryptoProviderState.UNCONFIGURED); pgpMessageBuilder.setCryptoStatus(cryptoStatusBuilder.build()); Callback mockCallback ... | public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... |
@Test public void build__withCryptoProviderUninitialized__shouldThrow() throws MessagingException { cryptoStatusBuilder.setCryptoMode(CryptoMode.NO_CHOICE); cryptoStatusBuilder.setCryptoProviderState(CryptoProviderState.UNINITIALIZED); pgpMessageBuilder.setCryptoStatus(cryptoStatusBuilder.build()); Callback mockCallbac... | public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... |
@Test public void build__withCryptoProviderError__shouldThrow() throws MessagingException { cryptoStatusBuilder.setCryptoMode(CryptoMode.NO_CHOICE); cryptoStatusBuilder.setCryptoProviderState(CryptoProviderState.ERROR); pgpMessageBuilder.setCryptoStatus(cryptoStatusBuilder.build()); Callback mockCallback = mock(Callbac... | public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... |
@Test public void build__withCryptoProviderLostConnection__shouldThrow() throws MessagingException { cryptoStatusBuilder.setCryptoMode(CryptoMode.NO_CHOICE); cryptoStatusBuilder.setCryptoProviderState(CryptoProviderState.LOST_CONNECTION); pgpMessageBuilder.setCryptoStatus(cryptoStatusBuilder.build()); Callback mockCall... | public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... |
@Test public void findSigned__withSimpleMultipartSigned__shouldReturnRoot() throws Exception { Message message = messageFromBody( multipart("signed", bodypart("text/plain"), bodypart("application/pgp-signature") ) ); List<Part> signedParts = MessageDecryptVerifier.findSignedParts(message, messageCryptoAnnotations); ass... | public static List<Part> findSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if (messageCryptoAnnotations... | MessageDecryptVerifier { public static List<Part> findSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if ... | MessageDecryptVerifier { public static List<Part> findSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if ... | MessageDecryptVerifier { public static List<Part> findSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if ... | MessageDecryptVerifier { public static List<Part> findSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if ... |
@Test public void buildCleartext__withNoSigningKey__shouldBuildTrivialMessage() { cryptoStatusBuilder.setCryptoMode(CryptoMode.NO_CHOICE); cryptoStatusBuilder.setOpenPgpKeyId(null); pgpMessageBuilder.setCryptoStatus(cryptoStatusBuilder.build()); Callback mockCallback = mock(Callback.class); pgpMessageBuilder.buildAsync... | public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... |
@Test public void buildCleartext__shouldSucceed() { cryptoStatusBuilder.setCryptoMode(CryptoMode.NO_CHOICE); pgpMessageBuilder.setCryptoStatus(cryptoStatusBuilder.build()); Callback mockCallback = mock(Callback.class); pgpMessageBuilder.buildAsync(mockCallback); ArgumentCaptor<MimeMessage> captor = ArgumentCaptor.forCl... | public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... |
@Test public void buildSign__withNoDetachedSignatureInResult__shouldThrow() throws MessagingException { cryptoStatusBuilder.setCryptoMode(CryptoMode.SIGN_ONLY); pgpMessageBuilder.setCryptoStatus(cryptoStatusBuilder.build()); Intent returnIntent = new Intent(); returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RE... | public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... |
@Test public void buildSign__withDetachedSignatureInResult__shouldSucceed() throws MessagingException { cryptoStatusBuilder.setCryptoMode(CryptoMode.SIGN_ONLY); pgpMessageBuilder.setCryptoStatus(cryptoStatusBuilder.build()); ArgumentCaptor<Intent> capturedApiIntent = ArgumentCaptor.forClass(Intent.class); Intent return... | public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... |
@Test public void buildSign__withUserInteractionResult__shouldReturnUserInteraction() throws MessagingException { cryptoStatusBuilder.setCryptoMode(CryptoMode.SIGN_ONLY); pgpMessageBuilder.setCryptoStatus(cryptoStatusBuilder.build()); Intent returnIntent = mock(Intent.class); when(returnIntent.getIntExtra(eq(OpenPgpApi... | public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... |
@Test public void buildSign__withReturnAfterUserInteraction__shouldSucceed() throws MessagingException { cryptoStatusBuilder.setCryptoMode(CryptoMode.SIGN_ONLY); pgpMessageBuilder.setCryptoStatus(cryptoStatusBuilder.build()); int returnedRequestCode; { Intent returnIntent = spy(new Intent()); returnIntent.putExtra(Open... | public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... |
@Test public void buildEncrypt__withoutRecipients__shouldThrow() throws MessagingException { cryptoStatusBuilder .setCryptoMode(CryptoMode.CHOICE_ENABLED) .setRecipients(new ArrayList<Recipient>()); pgpMessageBuilder.setCryptoStatus(cryptoStatusBuilder.build()); Intent returnIntent = spy(new Intent()); returnIntent.put... | public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... |
@Test public void buildEncrypt__shouldSucceed() throws MessagingException { ComposeCryptoStatus cryptoStatus = cryptoStatusBuilder .setCryptoMode(CryptoMode.CHOICE_ENABLED) .setRecipients(Collections.singletonList(new Recipient("test", "test@example.org", "labru", -1, "key"))) .build(); pgpMessageBuilder.setCryptoStatu... | public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... |
@Test public void buildEncrypt__withInlineEnabled__shouldSucceed() throws MessagingException { ComposeCryptoStatus cryptoStatus = cryptoStatusBuilder .setCryptoMode(CryptoMode.CHOICE_ENABLED) .setRecipients(Collections.singletonList(new Recipient("test", "test@example.org", "labru", -1, "key"))) .setEnablePgpInline(tru... | public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... |
@Test public void buildSign__withInlineEnabled__shouldSucceed() throws MessagingException { ComposeCryptoStatus cryptoStatus = cryptoStatusBuilder .setCryptoMode(CryptoMode.SIGN_ONLY) .setRecipients(Collections.singletonList(new Recipient("test", "test@example.org", "labru", -1, "key"))) .setEnablePgpInline(true) .buil... | public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... |
@Test public void findSigned__withComplexMultipartSigned__shouldReturnRoot() throws Exception { Message message = messageFromBody( multipart("signed", multipart("mixed", bodypart("text/plain"), bodypart("application/pdf") ), bodypart("application/pgp-signature") ) ); List<Part> signedParts = MessageDecryptVerifier.find... | public static List<Part> findSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if (messageCryptoAnnotations... | MessageDecryptVerifier { public static List<Part> findSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if ... | MessageDecryptVerifier { public static List<Part> findSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if ... | MessageDecryptVerifier { public static List<Part> findSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if ... | MessageDecryptVerifier { public static List<Part> findSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if ... |
@Test public void buildSignWithAttach__withInlineEnabled__shouldThrow() throws MessagingException { ComposeCryptoStatus cryptoStatus = cryptoStatusBuilder .setCryptoMode(CryptoMode.SIGN_ONLY) .setEnablePgpInline(true) .build(); pgpMessageBuilder.setCryptoStatus(cryptoStatus); pgpMessageBuilder.setAttachments(Collection... | public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... |
@Test public void buildEncryptWithAttach__withInlineEnabled__shouldThrow() throws MessagingException { ComposeCryptoStatus cryptoStatus = cryptoStatusBuilder .setCryptoMode(CryptoMode.CHOICE_ENABLED) .setEnablePgpInline(true) .build(); pgpMessageBuilder.setCryptoStatus(cryptoStatus); pgpMessageBuilder.setAttachments(Co... | public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... |
@Test public void buildOpportunisticEncrypt__withNoKeysAndNoSignOnly__shouldNotBeSigned() throws MessagingException { ComposeCryptoStatus cryptoStatus = cryptoStatusBuilder .setRecipients(Collections.singletonList(new Recipient("test", "test@example.org", "labru", -1, "key"))) .setCryptoMode(CryptoMode.NO_CHOICE) .buil... | public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... |
@Test public void buildSign__withNoDetachedSignatureExtra__shouldFail() throws MessagingException { ComposeCryptoStatus cryptoStatus = cryptoStatusBuilder .setCryptoMode(CryptoMode.SIGN_ONLY) .build(); pgpMessageBuilder.setCryptoStatus(cryptoStatus); Intent returnIntentSigned = new Intent(); returnIntentSigned.putExtra... | public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } } | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... | PgpMessageBuilder extends MessageBuilder { public void setCryptoStatus(ComposeCryptoStatus cryptoStatus) { this.cryptoStatus = cryptoStatus; } @VisibleForTesting PgpMessageBuilder(Context context, MessageIdGenerator messageIdGenerator, BoundaryGenerator boundaryGenerator,
AutocryptOperations autocryptOpera... |
@Test public void getDefaultDeletePolicy_withImap_shouldReturn_ON_DELETE() { DeletePolicy result = AccountCreator.getDefaultDeletePolicy(Type.IMAP); assertEquals(DeletePolicy.ON_DELETE, result); } | public static DeletePolicy getDefaultDeletePolicy(Type type) { switch (type) { case IMAP: { return DeletePolicy.ON_DELETE; } case POP3: { return DeletePolicy.NEVER; } case WebDAV: { return DeletePolicy.ON_DELETE; } case EWS: { return DeletePolicy.ON_DELETE; } case SMTP: { throw new IllegalStateException("Delete policy ... | AccountCreator { public static DeletePolicy getDefaultDeletePolicy(Type type) { switch (type) { case IMAP: { return DeletePolicy.ON_DELETE; } case POP3: { return DeletePolicy.NEVER; } case WebDAV: { return DeletePolicy.ON_DELETE; } case EWS: { return DeletePolicy.ON_DELETE; } case SMTP: { throw new IllegalStateExceptio... | AccountCreator { public static DeletePolicy getDefaultDeletePolicy(Type type) { switch (type) { case IMAP: { return DeletePolicy.ON_DELETE; } case POP3: { return DeletePolicy.NEVER; } case WebDAV: { return DeletePolicy.ON_DELETE; } case EWS: { return DeletePolicy.ON_DELETE; } case SMTP: { throw new IllegalStateExceptio... | AccountCreator { public static DeletePolicy getDefaultDeletePolicy(Type type) { switch (type) { case IMAP: { return DeletePolicy.ON_DELETE; } case POP3: { return DeletePolicy.NEVER; } case WebDAV: { return DeletePolicy.ON_DELETE; } case EWS: { return DeletePolicy.ON_DELETE; } case SMTP: { throw new IllegalStateExceptio... | AccountCreator { public static DeletePolicy getDefaultDeletePolicy(Type type) { switch (type) { case IMAP: { return DeletePolicy.ON_DELETE; } case POP3: { return DeletePolicy.NEVER; } case WebDAV: { return DeletePolicy.ON_DELETE; } case EWS: { return DeletePolicy.ON_DELETE; } case SMTP: { throw new IllegalStateExceptio... |
@Test public void getDefaultDeletePolicy_withPop3_shouldReturn_NEVER() { DeletePolicy result = AccountCreator.getDefaultDeletePolicy(Type.POP3); assertEquals(DeletePolicy.NEVER, result); } | public static DeletePolicy getDefaultDeletePolicy(Type type) { switch (type) { case IMAP: { return DeletePolicy.ON_DELETE; } case POP3: { return DeletePolicy.NEVER; } case WebDAV: { return DeletePolicy.ON_DELETE; } case EWS: { return DeletePolicy.ON_DELETE; } case SMTP: { throw new IllegalStateException("Delete policy ... | AccountCreator { public static DeletePolicy getDefaultDeletePolicy(Type type) { switch (type) { case IMAP: { return DeletePolicy.ON_DELETE; } case POP3: { return DeletePolicy.NEVER; } case WebDAV: { return DeletePolicy.ON_DELETE; } case EWS: { return DeletePolicy.ON_DELETE; } case SMTP: { throw new IllegalStateExceptio... | AccountCreator { public static DeletePolicy getDefaultDeletePolicy(Type type) { switch (type) { case IMAP: { return DeletePolicy.ON_DELETE; } case POP3: { return DeletePolicy.NEVER; } case WebDAV: { return DeletePolicy.ON_DELETE; } case EWS: { return DeletePolicy.ON_DELETE; } case SMTP: { throw new IllegalStateExceptio... | AccountCreator { public static DeletePolicy getDefaultDeletePolicy(Type type) { switch (type) { case IMAP: { return DeletePolicy.ON_DELETE; } case POP3: { return DeletePolicy.NEVER; } case WebDAV: { return DeletePolicy.ON_DELETE; } case EWS: { return DeletePolicy.ON_DELETE; } case SMTP: { throw new IllegalStateExceptio... | AccountCreator { public static DeletePolicy getDefaultDeletePolicy(Type type) { switch (type) { case IMAP: { return DeletePolicy.ON_DELETE; } case POP3: { return DeletePolicy.NEVER; } case WebDAV: { return DeletePolicy.ON_DELETE; } case EWS: { return DeletePolicy.ON_DELETE; } case SMTP: { throw new IllegalStateExceptio... |
@Test public void getDefaultDeletePolicy_withWebDav_shouldReturn_ON_DELETE() { DeletePolicy result = AccountCreator.getDefaultDeletePolicy(Type.WebDAV); assertEquals(DeletePolicy.ON_DELETE, result); } | public static DeletePolicy getDefaultDeletePolicy(Type type) { switch (type) { case IMAP: { return DeletePolicy.ON_DELETE; } case POP3: { return DeletePolicy.NEVER; } case WebDAV: { return DeletePolicy.ON_DELETE; } case EWS: { return DeletePolicy.ON_DELETE; } case SMTP: { throw new IllegalStateException("Delete policy ... | AccountCreator { public static DeletePolicy getDefaultDeletePolicy(Type type) { switch (type) { case IMAP: { return DeletePolicy.ON_DELETE; } case POP3: { return DeletePolicy.NEVER; } case WebDAV: { return DeletePolicy.ON_DELETE; } case EWS: { return DeletePolicy.ON_DELETE; } case SMTP: { throw new IllegalStateExceptio... | AccountCreator { public static DeletePolicy getDefaultDeletePolicy(Type type) { switch (type) { case IMAP: { return DeletePolicy.ON_DELETE; } case POP3: { return DeletePolicy.NEVER; } case WebDAV: { return DeletePolicy.ON_DELETE; } case EWS: { return DeletePolicy.ON_DELETE; } case SMTP: { throw new IllegalStateExceptio... | AccountCreator { public static DeletePolicy getDefaultDeletePolicy(Type type) { switch (type) { case IMAP: { return DeletePolicy.ON_DELETE; } case POP3: { return DeletePolicy.NEVER; } case WebDAV: { return DeletePolicy.ON_DELETE; } case EWS: { return DeletePolicy.ON_DELETE; } case SMTP: { throw new IllegalStateExceptio... | AccountCreator { public static DeletePolicy getDefaultDeletePolicy(Type type) { switch (type) { case IMAP: { return DeletePolicy.ON_DELETE; } case POP3: { return DeletePolicy.NEVER; } case WebDAV: { return DeletePolicy.ON_DELETE; } case EWS: { return DeletePolicy.ON_DELETE; } case SMTP: { throw new IllegalStateExceptio... |
@Test public void getDefaultPort_withNoConnectionSecurityAndImap_shouldReturnDefaultPort() { int result = AccountCreator.getDefaultPort(ConnectionSecurity.NONE, Type.IMAP); assertEquals(Type.IMAP.defaultPort, result); } | public static int getDefaultPort(ConnectionSecurity securityType, Type storeType) { switch (securityType) { case NONE: case STARTTLS_REQUIRED: { return storeType.defaultPort; } case SSL_TLS_REQUIRED: { return storeType.defaultTlsPort; } } throw new AssertionError("Unhandled ConnectionSecurity type encountered: " + secu... | AccountCreator { public static int getDefaultPort(ConnectionSecurity securityType, Type storeType) { switch (securityType) { case NONE: case STARTTLS_REQUIRED: { return storeType.defaultPort; } case SSL_TLS_REQUIRED: { return storeType.defaultTlsPort; } } throw new AssertionError("Unhandled ConnectionSecurity type enco... | AccountCreator { public static int getDefaultPort(ConnectionSecurity securityType, Type storeType) { switch (securityType) { case NONE: case STARTTLS_REQUIRED: { return storeType.defaultPort; } case SSL_TLS_REQUIRED: { return storeType.defaultTlsPort; } } throw new AssertionError("Unhandled ConnectionSecurity type enco... | AccountCreator { public static int getDefaultPort(ConnectionSecurity securityType, Type storeType) { switch (securityType) { case NONE: case STARTTLS_REQUIRED: { return storeType.defaultPort; } case SSL_TLS_REQUIRED: { return storeType.defaultTlsPort; } } throw new AssertionError("Unhandled ConnectionSecurity type enco... | AccountCreator { public static int getDefaultPort(ConnectionSecurity securityType, Type storeType) { switch (securityType) { case NONE: case STARTTLS_REQUIRED: { return storeType.defaultPort; } case SSL_TLS_REQUIRED: { return storeType.defaultTlsPort; } } throw new AssertionError("Unhandled ConnectionSecurity type enco... |
@Test public void getDefaultPort_withStartTlsAndImap_shouldReturnDefaultPort() { int result = AccountCreator.getDefaultPort(ConnectionSecurity.STARTTLS_REQUIRED, Type.IMAP); assertEquals(Type.IMAP.defaultPort, result); } | public static int getDefaultPort(ConnectionSecurity securityType, Type storeType) { switch (securityType) { case NONE: case STARTTLS_REQUIRED: { return storeType.defaultPort; } case SSL_TLS_REQUIRED: { return storeType.defaultTlsPort; } } throw new AssertionError("Unhandled ConnectionSecurity type encountered: " + secu... | AccountCreator { public static int getDefaultPort(ConnectionSecurity securityType, Type storeType) { switch (securityType) { case NONE: case STARTTLS_REQUIRED: { return storeType.defaultPort; } case SSL_TLS_REQUIRED: { return storeType.defaultTlsPort; } } throw new AssertionError("Unhandled ConnectionSecurity type enco... | AccountCreator { public static int getDefaultPort(ConnectionSecurity securityType, Type storeType) { switch (securityType) { case NONE: case STARTTLS_REQUIRED: { return storeType.defaultPort; } case SSL_TLS_REQUIRED: { return storeType.defaultTlsPort; } } throw new AssertionError("Unhandled ConnectionSecurity type enco... | AccountCreator { public static int getDefaultPort(ConnectionSecurity securityType, Type storeType) { switch (securityType) { case NONE: case STARTTLS_REQUIRED: { return storeType.defaultPort; } case SSL_TLS_REQUIRED: { return storeType.defaultTlsPort; } } throw new AssertionError("Unhandled ConnectionSecurity type enco... | AccountCreator { public static int getDefaultPort(ConnectionSecurity securityType, Type storeType) { switch (securityType) { case NONE: case STARTTLS_REQUIRED: { return storeType.defaultPort; } case SSL_TLS_REQUIRED: { return storeType.defaultTlsPort; } } throw new AssertionError("Unhandled ConnectionSecurity type enco... |
@Test public void getDefaultPort_withTlsAndImap_shouldReturnDefaultTlsPort() { int result = AccountCreator.getDefaultPort(ConnectionSecurity.SSL_TLS_REQUIRED, Type.IMAP); assertEquals(Type.IMAP.defaultTlsPort, result); } | public static int getDefaultPort(ConnectionSecurity securityType, Type storeType) { switch (securityType) { case NONE: case STARTTLS_REQUIRED: { return storeType.defaultPort; } case SSL_TLS_REQUIRED: { return storeType.defaultTlsPort; } } throw new AssertionError("Unhandled ConnectionSecurity type encountered: " + secu... | AccountCreator { public static int getDefaultPort(ConnectionSecurity securityType, Type storeType) { switch (securityType) { case NONE: case STARTTLS_REQUIRED: { return storeType.defaultPort; } case SSL_TLS_REQUIRED: { return storeType.defaultTlsPort; } } throw new AssertionError("Unhandled ConnectionSecurity type enco... | AccountCreator { public static int getDefaultPort(ConnectionSecurity securityType, Type storeType) { switch (securityType) { case NONE: case STARTTLS_REQUIRED: { return storeType.defaultPort; } case SSL_TLS_REQUIRED: { return storeType.defaultTlsPort; } } throw new AssertionError("Unhandled ConnectionSecurity type enco... | AccountCreator { public static int getDefaultPort(ConnectionSecurity securityType, Type storeType) { switch (securityType) { case NONE: case STARTTLS_REQUIRED: { return storeType.defaultPort; } case SSL_TLS_REQUIRED: { return storeType.defaultTlsPort; } } throw new AssertionError("Unhandled ConnectionSecurity type enco... | AccountCreator { public static int getDefaultPort(ConnectionSecurity securityType, Type storeType) { switch (securityType) { case NONE: case STARTTLS_REQUIRED: { return storeType.defaultPort; } case SSL_TLS_REQUIRED: { return storeType.defaultTlsPort; } } throw new AssertionError("Unhandled ConnectionSecurity type enco... |
@Test public void findEncrypted__withMultipartMixedSubSigned__shouldReturnSigned() throws Exception { Message message = messageFromBody( multipart("mixed", multipart("signed", bodypart("text/plain"), bodypart("application/pgp-signature") ) ) ); List<Part> signedParts = MessageDecryptVerifier.findSignedParts(message, me... | public static List<Part> findSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if (messageCryptoAnnotations... | MessageDecryptVerifier { public static List<Part> findSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if ... | MessageDecryptVerifier { public static List<Part> findSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if ... | MessageDecryptVerifier { public static List<Part> findSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if ... | MessageDecryptVerifier { public static List<Part> findSignedParts(Part startPart, MessageCryptoAnnotations messageCryptoAnnotations) { List<Part> signedParts = new ArrayList<>(); Stack<Part> partsToCheck = new Stack<>(); partsToCheck.push(startPart); while (!partsToCheck.isEmpty()) { Part part = partsToCheck.pop(); if ... |
@Test public void compare_withTwoNullArguments_shouldReturnZero() throws Exception { Message messageLeft = null; Message messageRight = null; int result = comparator.compare(messageLeft, messageRight); assertEquals("result must be 0 when both arguments are null", 0, result); } | @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } else if (uidRight == null) { return -1; } return uidRight... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... |
@Test public void compare_withNullArgumentAndMessageWithNullUid_shouldReturnZero() throws Exception { Message messageLeft = null; Message messageRight = createMessageWithNullUid(); int result = comparator.compare(messageLeft, messageRight); assertEquals("result must be 0 when both arguments are not a message with valid... | @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } else if (uidRight == null) { return -1; } return uidRight... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... |
@Test public void compare_withMessageWithNullUidAndNullArgument_shouldReturnZero() throws Exception { Message messageLeft = createMessageWithNullUid(); Message messageRight = null; int result = comparator.compare(messageLeft, messageRight); assertEquals("result must be 0 when both arguments are not a message with valid... | @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } else if (uidRight == null) { return -1; } return uidRight... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... |
@Test public void compare_withTwoMessagesWithNullUid_shouldReturnZero() throws Exception { Message messageLeft = createMessageWithNullUid(); Message messageRight = createMessageWithNullUid(); int result = comparator.compare(messageLeft, messageRight); assertEquals("result must be 0 when both arguments are a message wit... | @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } else if (uidRight == null) { return -1; } return uidRight... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... |
@Test public void compare_withNullArgumentAndMessageWithInvalidUid_shouldReturnZero() throws Exception { Message messageLeft = null; Message messageRight = createMessageWithInvalidUid(); int result = comparator.compare(messageLeft, messageRight); assertEquals("result must be 0 when both arguments are not a message with... | @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } else if (uidRight == null) { return -1; } return uidRight... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... |
@Test public void compare_withMessageWithInvalidUidAndNullArgument_shouldReturnZero() throws Exception { Message messageLeft = createMessageWithInvalidUid(); Message messageRight = null; int result = comparator.compare(messageLeft, messageRight); assertEquals("result must be 0 when both arguments are not a message with... | @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } else if (uidRight == null) { return -1; } return uidRight... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... | UidReverseComparator implements Comparator<Message> { @Override public int compare(Message messageLeft, Message messageRight) { Long uidLeft = getUidForMessage(messageLeft); Long uidRight = getUidForMessage(messageRight); if (uidLeft == null && uidRight == null) { return 0; } else if (uidLeft == null) { return 1; } els... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.