1 | package fr.sii.ogham.email.sender.impl; | |
2 | ||
3 | import static fr.sii.ogham.core.util.LogUtils.logString; | |
4 | import static fr.sii.ogham.email.JavaMailConstants.DEFAULT_JAVAMAIL_IMPLEMENTATION_PRIORITY; | |
5 | import static fr.sii.ogham.email.attachment.ContentDisposition.ATTACHMENT; | |
6 | import static fr.sii.ogham.email.attachment.ContentDisposition.INLINE; | |
7 | ||
8 | import java.io.IOException; | |
9 | import java.io.UnsupportedEncodingException; | |
10 | import java.util.Properties; | |
11 | ||
12 | import javax.mail.Authenticator; | |
13 | import javax.mail.BodyPart; | |
14 | import javax.mail.Message.RecipientType; | |
15 | import javax.mail.MessagingException; | |
16 | import javax.mail.Multipart; | |
17 | import javax.mail.Session; | |
18 | import javax.mail.Transport; | |
19 | import javax.mail.internet.AddressException; | |
20 | import javax.mail.internet.InternetAddress; | |
21 | import javax.mail.internet.MimeBodyPart; | |
22 | import javax.mail.internet.MimeMessage; | |
23 | import javax.mail.internet.MimeMultipart; | |
24 | ||
25 | import org.slf4j.Logger; | |
26 | import org.slf4j.LoggerFactory; | |
27 | ||
28 | import fr.sii.ogham.core.builder.priority.Priority; | |
29 | import fr.sii.ogham.core.env.PropertiesBridge; | |
30 | import fr.sii.ogham.core.env.PropertyResolver; | |
31 | import fr.sii.ogham.core.exception.InvalidMessageException; | |
32 | import fr.sii.ogham.core.exception.MessageException; | |
33 | import fr.sii.ogham.core.sender.AbstractSpecializedSender; | |
34 | import fr.sii.ogham.email.attachment.Attachment; | |
35 | import fr.sii.ogham.email.exception.handler.AttachmentResourceHandlerException; | |
36 | import fr.sii.ogham.email.exception.handler.ContentHandlerException; | |
37 | import fr.sii.ogham.email.message.Email; | |
38 | import fr.sii.ogham.email.message.EmailAddress; | |
39 | import fr.sii.ogham.email.message.Recipient; | |
40 | import fr.sii.ogham.email.sender.impl.javamail.JavaMailAttachmentHandler; | |
41 | import fr.sii.ogham.email.sender.impl.javamail.JavaMailContentHandler; | |
42 | import fr.sii.ogham.email.sender.impl.javamail.JavaMailInterceptor; | |
43 | ||
44 | /** | |
45 | * Java mail API implementation. | |
46 | * | |
47 | * @author Aurélien Baudet | |
48 | * @see JavaMailContentHandler | |
49 | */ | |
50 | @Priority(properties = "${ogham.email.implementation-priority.javamail}", defaultValue = DEFAULT_JAVAMAIL_IMPLEMENTATION_PRIORITY) | |
51 | public class JavaMailSender extends AbstractSpecializedSender<Email> { | |
52 | private static final Logger LOG = LoggerFactory.getLogger(JavaMailSender.class); | |
53 | ||
54 | /** | |
55 | * Properties that is used to initialize the session | |
56 | */ | |
57 | private final Properties properties; | |
58 | ||
59 | /** | |
60 | * The content handler used to add message content | |
61 | */ | |
62 | private final JavaMailContentHandler contentHandler; | |
63 | ||
64 | /** | |
65 | * The handler used to attach files to the email | |
66 | */ | |
67 | private final JavaMailAttachmentHandler attachmentHandler; | |
68 | ||
69 | /** | |
70 | * Extra operations to apply on the message | |
71 | */ | |
72 | private final JavaMailInterceptor interceptor; | |
73 | ||
74 | /** | |
75 | * Authentication mechanism | |
76 | */ | |
77 | private final Authenticator authenticator; | |
78 | ||
79 | public JavaMailSender(PropertyResolver propertyResolver, JavaMailContentHandler contentHandler, JavaMailAttachmentHandler attachmentHandler, Authenticator authenticator) { | |
80 | this(new PropertiesBridge(propertyResolver), contentHandler, attachmentHandler, authenticator); | |
81 | } | |
82 | ||
83 | public JavaMailSender(PropertyResolver propertyResolver, JavaMailContentHandler contentHandler, JavaMailAttachmentHandler attachmentHandler, Authenticator authenticator, | |
84 | JavaMailInterceptor interceptor) { | |
85 | this(new PropertiesBridge(propertyResolver), contentHandler, attachmentHandler, authenticator, interceptor); | |
86 | } | |
87 | ||
88 | public JavaMailSender(Properties properties, JavaMailContentHandler contentHandler, JavaMailAttachmentHandler attachmentHandler, Authenticator authenticator) { | |
89 | this(properties, contentHandler, attachmentHandler, authenticator, null); | |
90 | } | |
91 | ||
92 | public JavaMailSender(Properties properties, JavaMailContentHandler contentHandler, JavaMailAttachmentHandler attachmentHandler, Authenticator authenticator, JavaMailInterceptor interceptor) { | |
93 | super(); | |
94 | this.properties = properties; | |
95 | this.contentHandler = contentHandler; | |
96 | this.attachmentHandler = attachmentHandler; | |
97 | this.authenticator = authenticator; | |
98 | this.interceptor = interceptor; | |
99 | } | |
100 | ||
101 | @Override | |
102 | public void send(Email email) throws MessageException { | |
103 | try { | |
104 | LOG.debug("Initialize Java mail session with authenticator {} and properties {}", authenticator, properties); | |
105 | LOG.debug("Create the mime message for email {}", logString(email)); | |
106 | MimeMessage mimeMsg = createMimeMessage(); | |
107 | // set the sender address | |
108 |
3
1. send : removed call to fr/sii/ogham/email/sender/impl/JavaMailSender::setFrom → TIMED_OUT 2. send : removed call to fr/sii/ogham/email/sender/impl/JavaMailSender::setFrom → KILLED 3. send : removed call to fr/sii/ogham/email/sender/impl/JavaMailSender::setFrom → KILLED |
setFrom(email, mimeMsg); |
109 | // set recipients (to, cc, bcc) | |
110 |
3
1. send : removed call to fr/sii/ogham/email/sender/impl/JavaMailSender::setRecipients → TIMED_OUT 2. send : removed call to fr/sii/ogham/email/sender/impl/JavaMailSender::setRecipients → KILLED 3. send : removed call to fr/sii/ogham/email/sender/impl/JavaMailSender::setRecipients → KILLED |
setRecipients(email, mimeMsg); |
111 | // set subject and content | |
112 |
3
1. send : removed call to javax/mail/internet/MimeMessage::setSubject → TIMED_OUT 2. send : removed call to javax/mail/internet/MimeMessage::setSubject → KILLED 3. send : removed call to javax/mail/internet/MimeMessage::setSubject → KILLED |
mimeMsg.setSubject(email.getSubject()); |
113 |
3
1. send : removed call to fr/sii/ogham/email/sender/impl/JavaMailSender::setMimeContent → TIMED_OUT 2. send : removed call to fr/sii/ogham/email/sender/impl/JavaMailSender::setMimeContent → KILLED 3. send : removed call to fr/sii/ogham/email/sender/impl/JavaMailSender::setMimeContent → KILLED |
setMimeContent(email, mimeMsg); |
114 | // default behavior is done => message is ready but let possibility | |
115 | // to add extra operations to do on the message | |
116 |
3
1. send : negated conditional → TIMED_OUT 2. send : negated conditional → KILLED 3. send : negated conditional → KILLED |
if (interceptor != null) { |
117 | LOG.debug("Executing extra operations for email {}", logString(email)); | |
118 | interceptor.intercept(mimeMsg, email); | |
119 | } | |
120 | // message is ready => send it | |
121 | LOG.info("Sending email using Java Mail API through server {}:{}...", properties.getProperty("mail.smtp.host", properties.getProperty("mail.host")), | |
122 | properties.getProperty("mail.smtp.port", properties.getProperty("mail.port"))); | |
123 |
3
1. send : removed call to javax/mail/Transport::send → TIMED_OUT 2. send : removed call to javax/mail/Transport::send → KILLED 3. send : removed call to javax/mail/Transport::send → KILLED |
Transport.send(mimeMsg); |
124 | } catch (MessagingException | ContentHandlerException | AttachmentResourceHandlerException | IOException e) { | |
125 | throw new MessageException("failed to send message using Java Mail API", email, e); | |
126 | } | |
127 | } | |
128 | ||
129 | /** | |
130 | * Initialize the session and create the mime message. | |
131 | * | |
132 | * @return the mime message | |
133 | */ | |
134 | private MimeMessage createMimeMessage() { | |
135 | // prepare the message | |
136 | Session session = Session.getInstance(properties, authenticator); | |
137 |
3
1. createMimeMessage : replaced return value with null for fr/sii/ogham/email/sender/impl/JavaMailSender::createMimeMessage → TIMED_OUT 2. createMimeMessage : replaced return value with null for fr/sii/ogham/email/sender/impl/JavaMailSender::createMimeMessage → KILLED 3. createMimeMessage : replaced return value with null for fr/sii/ogham/email/sender/impl/JavaMailSender::createMimeMessage → KILLED |
return new MimeMessage(session); |
138 | } | |
139 | ||
140 | /** | |
141 | * Set the sender address on the mime message. | |
142 | * | |
143 | * @param email | |
144 | * the source email | |
145 | * @param mimeMsg | |
146 | * the mime message to fill | |
147 | * @throws MessagingException | |
148 | * when the email address is not valid | |
149 | * @throws AddressException | |
150 | * when the email address is not valid | |
151 | * @throws UnsupportedEncodingException | |
152 | * when the email address is not valid | |
153 | * @throws InvalidMessageException | |
154 | * when the email address is not valid | |
155 | */ | |
156 | private static void setFrom(Email email, MimeMessage mimeMsg) throws MessagingException, UnsupportedEncodingException, InvalidMessageException { | |
157 |
3
1. setFrom : negated conditional → TIMED_OUT 2. setFrom : negated conditional → KILLED 3. setFrom : negated conditional → KILLED |
if (email.getFrom() == null) { |
158 | throw new InvalidMessageException("The sender address has not been set", email, "Missing sender email address"); | |
159 | } | |
160 |
3
1. setFrom : removed call to javax/mail/internet/MimeMessage::setFrom → TIMED_OUT 2. setFrom : removed call to javax/mail/internet/MimeMessage::setFrom → KILLED 3. setFrom : removed call to javax/mail/internet/MimeMessage::setFrom → KILLED |
mimeMsg.setFrom(toInternetAddress(email.getFrom())); |
161 | } | |
162 | ||
163 | /** | |
164 | * Set the recipients addresses on the mime message. | |
165 | * | |
166 | * @param email | |
167 | * the source email | |
168 | * @param mimeMsg | |
169 | * the mime message to fill | |
170 | * @throws MessagingException | |
171 | * when the email address is not valid | |
172 | * @throws AddressException | |
173 | * when the email address is not valid | |
174 | * @throws UnsupportedEncodingException | |
175 | * when the email address is not valid | |
176 | */ | |
177 | private static void setRecipients(Email email, MimeMessage mimeMsg) throws MessagingException, UnsupportedEncodingException { | |
178 | for (Recipient recipient : email.getRecipients()) { | |
179 |
3
1. setRecipients : removed call to javax/mail/internet/MimeMessage::addRecipient → TIMED_OUT 2. setRecipients : removed call to javax/mail/internet/MimeMessage::addRecipient → KILLED 3. setRecipients : removed call to javax/mail/internet/MimeMessage::addRecipient → KILLED |
mimeMsg.addRecipient(convert(recipient.getType()), toInternetAddress(recipient.getAddress())); |
180 | } | |
181 | } | |
182 | ||
183 | /** | |
184 | * Set the content on the mime message. | |
185 | * | |
186 | * <ul> | |
187 | * <li>If the source email has only one textual content (text/html for | |
188 | * example), the structure is: | |
189 | * | |
190 | * <pre> | |
191 | * [text/html] (root/body) | |
192 | * </pre> | |
193 | * | |
194 | * </li> | |
195 | * <li>If the source email has HTML content with embedded attachments | |
196 | * (images for example), the structure is: | |
197 | * | |
198 | * <pre> | |
199 | * [multipart/related] (root/body) | |
200 | * [text/html] | |
201 | * [image/png] (embedded image 1) | |
202 | * [image/gif] (embedded image 2) | |
203 | * </pre> | |
204 | * | |
205 | * </li> | |
206 | * <li>If the source email has HTML content with attachments, the structure | |
207 | * is: | |
208 | * | |
209 | * <pre> | |
210 | * [multipart/mixed] (root) | |
211 | * [text/html] (body) | |
212 | * [application/pdf] (attached file 1) | |
213 | * [application/octet-stream] (attached file 2) | |
214 | * </pre> | |
215 | * | |
216 | * </li> | |
217 | * <li>If the source email has HTML content with embedded attachments | |
218 | * (images for example) and additional attachments, the structure is: | |
219 | * | |
220 | * <pre> | |
221 | * [multipart/mixed] (root) | |
222 | * [multipart/related] (body) | |
223 | * [text/html] | |
224 | * [image/png] (embedded image 1) | |
225 | * [image/gif] (embedded image 2) | |
226 | * [application/pdf] (attached file 1) | |
227 | * [application/octet-stream] (attached file 2) | |
228 | * </pre> | |
229 | * | |
230 | * </li> | |
231 | * <li>If the source email has several textual contents (text/html and | |
232 | * text/plain for example), the structure is: | |
233 | * | |
234 | * <pre> | |
235 | * [multipart/alternative] (root/body) | |
236 | * [text/plain] (alternative body) | |
237 | * [text/html] (main body) | |
238 | * </pre> | |
239 | * | |
240 | * </li> | |
241 | * <li>If the source email has several textual contents (text/html and | |
242 | * text/plain for example) and embedded attachments (images for example), | |
243 | * the structure is: | |
244 | * | |
245 | * <pre> | |
246 | * [multipart/related] (root/body) | |
247 | * [multipart/alternative] | |
248 | * [text/plain] (alternative body) | |
249 | * [text/html] (main body) | |
250 | * [image/png] (embedded image 1) | |
251 | * [image/gif] (embedded image 2) | |
252 | * </pre> | |
253 | * | |
254 | * </li> | |
255 | * <li>If the source email has several textual contents (text/html and | |
256 | * text/plain for example) and attachments, the structure is: | |
257 | * | |
258 | * <pre> | |
259 | * [multipart/mixed] (root) | |
260 | * [multipart/alternative] (body) | |
261 | * [text/plain] (alternative body) | |
262 | * [text/html] (main body) | |
263 | * [application/pdf] (attached file 1) | |
264 | * [application/octet-stream] (attached file 2) | |
265 | * </pre> | |
266 | * | |
267 | * </li> | |
268 | * <li>If the source email has several textual contents (text/html and | |
269 | * text/plain for example), embedded attachment (images for example) and | |
270 | * attachments, the structure is: | |
271 | * | |
272 | * <pre> | |
273 | * [multipart/mixed] (root) | |
274 | * [multipart/related] (body) | |
275 | * [multipart/alternative] | |
276 | * [text/plain] (alternative body) | |
277 | * [text/html] (main body) | |
278 | * [image/png] (embedded image 1) | |
279 | * [image/gif] (embedded image 2) | |
280 | * [application/pdf] (attached file 1) | |
281 | * [application/octet-stream] (attached file 2) | |
282 | * </pre> | |
283 | * | |
284 | * </li> | |
285 | * </ul> | |
286 | * | |
287 | * @param email | |
288 | * the source email | |
289 | * @param mimeMsg | |
290 | * the mime message to fill | |
291 | * @throws MessagingException | |
292 | * when the email address is not valid | |
293 | * @throws ContentHandlerException | |
294 | * when the email address is not valid | |
295 | * @throws AttachmentResourceHandlerException | |
296 | * when the email address is not valid | |
297 | * @throws IOException | |
298 | * when the content can't be constructed | |
299 | */ | |
300 | private void setMimeContent(Email email, MimeMessage mimeMsg) throws MessagingException, ContentHandlerException, AttachmentResourceHandlerException, IOException { | |
301 | LOG.debug("Add message content for email {}", logString(email)); | |
302 | ||
303 | Multipart mixedContainer = new MimeMultipart("mixed"); | |
304 | ||
305 | // prepare the body | |
306 |
3
1. setMimeContent : removed call to fr/sii/ogham/email/sender/impl/javamail/JavaMailContentHandler::setContent → TIMED_OUT 2. setMimeContent : removed call to fr/sii/ogham/email/sender/impl/javamail/JavaMailContentHandler::setContent → KILLED 3. setMimeContent : removed call to fr/sii/ogham/email/sender/impl/javamail/JavaMailContentHandler::setContent → KILLED |
contentHandler.setContent(mimeMsg, mixedContainer, email, email.getContent()); |
307 | ||
308 | // add the attachments (either embedded or attached) | |
309 | Multipart relatedContainer = getOrAddRelatedContainer(mixedContainer, email); | |
310 | for (Attachment attachment : email.getAttachments()) { | |
311 |
3
1. setMimeContent : negated conditional → NO_COVERAGE 2. setMimeContent : negated conditional → KILLED 3. setMimeContent : negated conditional → KILLED |
Multipart attachmentContainer = isEmbeddableAttachment(attachment) ? relatedContainer : mixedContainer; |
312 |
3
1. setMimeContent : removed call to fr/sii/ogham/email/sender/impl/javamail/JavaMailAttachmentHandler::addAttachment → NO_COVERAGE 2. setMimeContent : removed call to fr/sii/ogham/email/sender/impl/javamail/JavaMailAttachmentHandler::addAttachment → KILLED 3. setMimeContent : removed call to fr/sii/ogham/email/sender/impl/javamail/JavaMailAttachmentHandler::addAttachment → KILLED |
attachmentHandler.addAttachment(attachmentContainer, attachment); |
313 | } | |
314 | ||
315 | // set the content of the email | |
316 |
6
1. setMimeContent : negated conditional → TIMED_OUT 2. setMimeContent : negated conditional → TIMED_OUT 3. setMimeContent : negated conditional → KILLED 4. setMimeContent : negated conditional → KILLED 5. setMimeContent : negated conditional → KILLED 6. setMimeContent : negated conditional → KILLED |
if (hasDownloadableAttachments(email) || hasEmbeddableAttachments(email)) { |
317 |
6
1. setMimeContent : negated conditional → NO_COVERAGE 2. setMimeContent : removed call to javax/mail/internet/MimeMessage::setContent → NO_COVERAGE 3. setMimeContent : negated conditional → KILLED 4. setMimeContent : negated conditional → KILLED 5. setMimeContent : removed call to javax/mail/internet/MimeMessage::setContent → KILLED 6. setMimeContent : removed call to javax/mail/internet/MimeMessage::setContent → KILLED |
mimeMsg.setContent(hasDownloadableAttachments(email) ? mixedContainer : relatedContainer); |
318 | } else { | |
319 | // extract the body from the container (as it is not necessary) | |
320 | // and place the body at the root of the message | |
321 | BodyPart body = mixedContainer.getBodyPart(0); | |
322 |
3
1. setMimeContent : removed call to javax/mail/internet/MimeMessage::setContent → TIMED_OUT 2. setMimeContent : removed call to javax/mail/internet/MimeMessage::setContent → KILLED 3. setMimeContent : removed call to javax/mail/internet/MimeMessage::setContent → KILLED |
mimeMsg.setContent(body.getContent(), body.getContentType()); |
323 | } | |
324 | } | |
325 | ||
326 | private static Multipart getOrAddRelatedContainer(Multipart root, Email email) throws MessagingException, IOException { | |
327 | // no embeddable attachments means that there is no need of the related | |
328 | // container | |
329 |
3
1. getOrAddRelatedContainer : negated conditional → TIMED_OUT 2. getOrAddRelatedContainer : negated conditional → KILLED 3. getOrAddRelatedContainer : negated conditional → KILLED |
if (!hasEmbeddableAttachments(email)) { |
330 | return null; | |
331 | } | |
332 | Multipart related = findRelatedContainer(root); | |
333 |
3
1. getOrAddRelatedContainer : negated conditional → NO_COVERAGE 2. getOrAddRelatedContainer : negated conditional → KILLED 3. getOrAddRelatedContainer : negated conditional → KILLED |
if (related == null) { |
334 | related = new MimeMultipart("related"); | |
335 |
3
1. getOrAddRelatedContainer : removed call to fr/sii/ogham/email/sender/impl/JavaMailSender::moveBodyToRelatedContainer → NO_COVERAGE 2. getOrAddRelatedContainer : removed call to fr/sii/ogham/email/sender/impl/JavaMailSender::moveBodyToRelatedContainer → KILLED 3. getOrAddRelatedContainer : removed call to fr/sii/ogham/email/sender/impl/JavaMailSender::moveBodyToRelatedContainer → KILLED |
moveBodyToRelatedContainer(root, related); |
336 |
3
1. getOrAddRelatedContainer : removed call to fr/sii/ogham/email/sender/impl/JavaMailSender::addRelatedContainer → NO_COVERAGE 2. getOrAddRelatedContainer : removed call to fr/sii/ogham/email/sender/impl/JavaMailSender::addRelatedContainer → KILLED 3. getOrAddRelatedContainer : removed call to fr/sii/ogham/email/sender/impl/JavaMailSender::addRelatedContainer → KILLED |
addRelatedContainer(root, related); |
337 | } | |
338 |
3
1. getOrAddRelatedContainer : replaced return value with null for fr/sii/ogham/email/sender/impl/JavaMailSender::getOrAddRelatedContainer → NO_COVERAGE 2. getOrAddRelatedContainer : replaced return value with null for fr/sii/ogham/email/sender/impl/JavaMailSender::getOrAddRelatedContainer → KILLED 3. getOrAddRelatedContainer : replaced return value with null for fr/sii/ogham/email/sender/impl/JavaMailSender::getOrAddRelatedContainer → KILLED |
return related; |
339 | } | |
340 | ||
341 | private static void moveBodyToRelatedContainer(Multipart root, Multipart related) throws MessagingException { | |
342 |
6
1. moveBodyToRelatedContainer : changed conditional boundary → NO_COVERAGE 2. moveBodyToRelatedContainer : negated conditional → NO_COVERAGE 3. moveBodyToRelatedContainer : changed conditional boundary → KILLED 4. moveBodyToRelatedContainer : changed conditional boundary → KILLED 5. moveBodyToRelatedContainer : negated conditional → KILLED 6. moveBodyToRelatedContainer : negated conditional → KILLED |
while (root.getCount() > 0) { |
343 |
3
1. moveBodyToRelatedContainer : removed call to javax/mail/Multipart::addBodyPart → NO_COVERAGE 2. moveBodyToRelatedContainer : removed call to javax/mail/Multipart::addBodyPart → KILLED 3. moveBodyToRelatedContainer : removed call to javax/mail/Multipart::addBodyPart → KILLED |
related.addBodyPart(root.getBodyPart(0)); |
344 |
2
1. moveBodyToRelatedContainer : removed call to javax/mail/Multipart::removeBodyPart → NO_COVERAGE 2. moveBodyToRelatedContainer : removed call to javax/mail/Multipart::removeBodyPart → TIMED_OUT |
root.removeBodyPart(0); |
345 | } | |
346 | } | |
347 | ||
348 | private static void addRelatedContainer(Multipart root, Multipart related) throws MessagingException { | |
349 | MimeBodyPart part = new MimeBodyPart(); | |
350 |
3
1. addRelatedContainer : removed call to javax/mail/internet/MimeBodyPart::setContent → NO_COVERAGE 2. addRelatedContainer : removed call to javax/mail/internet/MimeBodyPart::setContent → KILLED 3. addRelatedContainer : removed call to javax/mail/internet/MimeBodyPart::setContent → KILLED |
part.setContent(related); |
351 |
3
1. addRelatedContainer : removed call to javax/mail/Multipart::addBodyPart → NO_COVERAGE 2. addRelatedContainer : removed call to javax/mail/Multipart::addBodyPart → KILLED 3. addRelatedContainer : removed call to javax/mail/Multipart::addBodyPart → KILLED |
root.addBodyPart(part); |
352 | } | |
353 | ||
354 | private static Multipart findRelatedContainer(Multipart container) throws MessagingException, IOException { | |
355 |
3
1. findRelatedContainer : negated conditional → SURVIVED 2. findRelatedContainer : negated conditional → NO_COVERAGE 3. findRelatedContainer : negated conditional → KILLED |
if (isRelated(container)) { |
356 |
1
1. findRelatedContainer : replaced return value with null for fr/sii/ogham/email/sender/impl/JavaMailSender::findRelatedContainer → NO_COVERAGE |
return container; |
357 | } | |
358 |
5
1. findRelatedContainer : changed conditional boundary → NO_COVERAGE 2. findRelatedContainer : negated conditional → NO_COVERAGE 3. findRelatedContainer : negated conditional → SURVIVED 4. findRelatedContainer : changed conditional boundary → KILLED 5. findRelatedContainer : changed conditional boundary → KILLED |
for (int i = 0; i < container.getCount(); i++) { |
359 | Object content = container.getBodyPart(i).getContent(); | |
360 |
3
1. findRelatedContainer : negated conditional → NO_COVERAGE 2. findRelatedContainer : negated conditional → KILLED 3. findRelatedContainer : negated conditional → KILLED |
if (content instanceof Multipart) { |
361 |
2
1. findRelatedContainer : replaced return value with null for fr/sii/ogham/email/sender/impl/JavaMailSender::findRelatedContainer → NO_COVERAGE 2. findRelatedContainer : replaced return value with null for fr/sii/ogham/email/sender/impl/JavaMailSender::findRelatedContainer → SURVIVED |
return findRelatedContainer((Multipart) content); |
362 | } | |
363 | } | |
364 | return null; | |
365 | } | |
366 | ||
367 | private static boolean isRelated(Multipart mp) { | |
368 |
5
1. isRelated : replaced boolean return with false for fr/sii/ogham/email/sender/impl/JavaMailSender::isRelated → NO_COVERAGE 2. isRelated : replaced boolean return with false for fr/sii/ogham/email/sender/impl/JavaMailSender::isRelated → SURVIVED 3. isRelated : replaced boolean return with true for fr/sii/ogham/email/sender/impl/JavaMailSender::isRelated → NO_COVERAGE 4. isRelated : replaced boolean return with true for fr/sii/ogham/email/sender/impl/JavaMailSender::isRelated → SURVIVED 5. isRelated : replaced boolean return with true for fr/sii/ogham/email/sender/impl/JavaMailSender::isRelated → KILLED |
return mp.getContentType().startsWith("multipart/related"); |
369 | } | |
370 | ||
371 | private static boolean isEmbeddableAttachment(Attachment attachment) { | |
372 |
6
1. isEmbeddableAttachment : replaced boolean return with false for fr/sii/ogham/email/sender/impl/JavaMailSender::isEmbeddableAttachment → NO_COVERAGE 2. isEmbeddableAttachment : replaced boolean return with true for fr/sii/ogham/email/sender/impl/JavaMailSender::isEmbeddableAttachment → NO_COVERAGE 3. isEmbeddableAttachment : replaced boolean return with true for fr/sii/ogham/email/sender/impl/JavaMailSender::isEmbeddableAttachment → SURVIVED 4. isEmbeddableAttachment : replaced boolean return with false for fr/sii/ogham/email/sender/impl/JavaMailSender::isEmbeddableAttachment → KILLED 5. isEmbeddableAttachment : replaced boolean return with false for fr/sii/ogham/email/sender/impl/JavaMailSender::isEmbeddableAttachment → KILLED 6. isEmbeddableAttachment : replaced boolean return with true for fr/sii/ogham/email/sender/impl/JavaMailSender::isEmbeddableAttachment → KILLED |
return INLINE.equals(attachment.getDisposition()); |
373 | } | |
374 | ||
375 | private static boolean isDownloadableAttachment(Attachment attachment) { | |
376 |
6
1. isDownloadableAttachment : replaced boolean return with false for fr/sii/ogham/email/sender/impl/JavaMailSender::isDownloadableAttachment → NO_COVERAGE 2. isDownloadableAttachment : replaced boolean return with true for fr/sii/ogham/email/sender/impl/JavaMailSender::isDownloadableAttachment → NO_COVERAGE 3. isDownloadableAttachment : replaced boolean return with true for fr/sii/ogham/email/sender/impl/JavaMailSender::isDownloadableAttachment → SURVIVED 4. isDownloadableAttachment : replaced boolean return with false for fr/sii/ogham/email/sender/impl/JavaMailSender::isDownloadableAttachment → KILLED 5. isDownloadableAttachment : replaced boolean return with false for fr/sii/ogham/email/sender/impl/JavaMailSender::isDownloadableAttachment → KILLED 6. isDownloadableAttachment : replaced boolean return with true for fr/sii/ogham/email/sender/impl/JavaMailSender::isDownloadableAttachment → KILLED |
return ATTACHMENT.equals(attachment.getDisposition()); |
377 | } | |
378 | ||
379 | private static boolean hasEmbeddableAttachments(Email email) { | |
380 |
6
1. hasEmbeddableAttachments : replaced boolean return with false for fr/sii/ogham/email/sender/impl/JavaMailSender::hasEmbeddableAttachments → TIMED_OUT 2. hasEmbeddableAttachments : replaced boolean return with true for fr/sii/ogham/email/sender/impl/JavaMailSender::hasEmbeddableAttachments → TIMED_OUT 3. hasEmbeddableAttachments : replaced boolean return with false for fr/sii/ogham/email/sender/impl/JavaMailSender::hasEmbeddableAttachments → KILLED 4. hasEmbeddableAttachments : replaced boolean return with false for fr/sii/ogham/email/sender/impl/JavaMailSender::hasEmbeddableAttachments → KILLED 5. hasEmbeddableAttachments : replaced boolean return with true for fr/sii/ogham/email/sender/impl/JavaMailSender::hasEmbeddableAttachments → KILLED 6. hasEmbeddableAttachments : replaced boolean return with true for fr/sii/ogham/email/sender/impl/JavaMailSender::hasEmbeddableAttachments → KILLED |
return email.getAttachments().stream().anyMatch(JavaMailSender::isEmbeddableAttachment); |
381 | } | |
382 | ||
383 | private static boolean hasDownloadableAttachments(Email email) { | |
384 |
6
1. hasDownloadableAttachments : replaced boolean return with true for fr/sii/ogham/email/sender/impl/JavaMailSender::hasDownloadableAttachments → SURVIVED 2. hasDownloadableAttachments : replaced boolean return with false for fr/sii/ogham/email/sender/impl/JavaMailSender::hasDownloadableAttachments → TIMED_OUT 3. hasDownloadableAttachments : replaced boolean return with true for fr/sii/ogham/email/sender/impl/JavaMailSender::hasDownloadableAttachments → TIMED_OUT 4. hasDownloadableAttachments : replaced boolean return with false for fr/sii/ogham/email/sender/impl/JavaMailSender::hasDownloadableAttachments → KILLED 5. hasDownloadableAttachments : replaced boolean return with false for fr/sii/ogham/email/sender/impl/JavaMailSender::hasDownloadableAttachments → KILLED 6. hasDownloadableAttachments : replaced boolean return with true for fr/sii/ogham/email/sender/impl/JavaMailSender::hasDownloadableAttachments → KILLED |
return email.getAttachments().stream().anyMatch(JavaMailSender::isDownloadableAttachment); |
385 | } | |
386 | ||
387 | private static RecipientType convert(fr.sii.ogham.email.message.RecipientType type) { | |
388 | switch (type) { | |
389 | case BCC: | |
390 |
2
1. convert : replaced return value with null for fr/sii/ogham/email/sender/impl/JavaMailSender::convert → NO_COVERAGE 2. convert : replaced return value with null for fr/sii/ogham/email/sender/impl/JavaMailSender::convert → KILLED |
return RecipientType.BCC; |
391 | case CC: | |
392 |
2
1. convert : replaced return value with null for fr/sii/ogham/email/sender/impl/JavaMailSender::convert → NO_COVERAGE 2. convert : replaced return value with null for fr/sii/ogham/email/sender/impl/JavaMailSender::convert → KILLED |
return RecipientType.CC; |
393 | case TO: | |
394 |
3
1. convert : replaced return value with null for fr/sii/ogham/email/sender/impl/JavaMailSender::convert → TIMED_OUT 2. convert : replaced return value with null for fr/sii/ogham/email/sender/impl/JavaMailSender::convert → KILLED 3. convert : replaced return value with null for fr/sii/ogham/email/sender/impl/JavaMailSender::convert → KILLED |
return RecipientType.TO; |
395 | default: | |
396 | throw new IllegalArgumentException("Invalid recipient type " + type); | |
397 | } | |
398 | } | |
399 | ||
400 | private static InternetAddress toInternetAddress(EmailAddress address) throws AddressException, UnsupportedEncodingException { | |
401 |
6
1. toInternetAddress : negated conditional → SURVIVED 2. toInternetAddress : negated conditional → TIMED_OUT 3. toInternetAddress : replaced return value with null for fr/sii/ogham/email/sender/impl/JavaMailSender::toInternetAddress → TIMED_OUT 4. toInternetAddress : negated conditional → KILLED 5. toInternetAddress : replaced return value with null for fr/sii/ogham/email/sender/impl/JavaMailSender::toInternetAddress → KILLED 6. toInternetAddress : replaced return value with null for fr/sii/ogham/email/sender/impl/JavaMailSender::toInternetAddress → KILLED |
return address.getPersonal() == null ? new InternetAddress(address.getAddress()) : new InternetAddress(address.getAddress(), address.getPersonal()); |
402 | } | |
403 | ||
404 | @Override | |
405 | public String toString() { | |
406 |
2
1. toString : replaced return value with "" for fr/sii/ogham/email/sender/impl/JavaMailSender::toString → SURVIVED 2. toString : replaced return value with "" for fr/sii/ogham/email/sender/impl/JavaMailSender::toString → TIMED_OUT |
return "JavaMailSender"; |
407 | } | |
408 | } | |
Mutations | ||
108 |
1.1 2.2 3.3 |
|
110 |
1.1 2.2 3.3 |
|
112 |
1.1 2.2 3.3 |
|
113 |
1.1 2.2 3.3 |
|
116 |
1.1 2.2 3.3 |
|
123 |
1.1 2.2 3.3 |
|
137 |
1.1 2.2 3.3 |
|
157 |
1.1 2.2 3.3 |
|
160 |
1.1 2.2 3.3 |
|
179 |
1.1 2.2 3.3 |
|
306 |
1.1 2.2 3.3 |
|
311 |
1.1 2.2 3.3 |
|
312 |
1.1 2.2 3.3 |
|
316 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
317 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
322 |
1.1 2.2 3.3 |
|
329 |
1.1 2.2 3.3 |
|
333 |
1.1 2.2 3.3 |
|
335 |
1.1 2.2 3.3 |
|
336 |
1.1 2.2 3.3 |
|
338 |
1.1 2.2 3.3 |
|
342 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
343 |
1.1 2.2 3.3 |
|
344 |
1.1 2.2 |
|
350 |
1.1 2.2 3.3 |
|
351 |
1.1 2.2 3.3 |
|
355 |
1.1 2.2 3.3 |
|
356 |
1.1 |
|
358 |
1.1 2.2 3.3 4.4 5.5 |
|
360 |
1.1 2.2 3.3 |
|
361 |
1.1 2.2 |
|
368 |
1.1 2.2 3.3 4.4 5.5 |
|
372 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
376 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
380 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
384 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
390 |
1.1 2.2 |
|
392 |
1.1 2.2 |
|
394 |
1.1 2.2 3.3 |
|
401 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
406 |
1.1 2.2 |