1
|
|
package fr.sii.ogham.testing.assertion.filter; |
2
|
|
|
3
|
|
import java.util.function.Predicate; |
4
|
|
|
5
|
|
import javax.mail.Message; |
6
|
|
import javax.mail.MessagingException; |
7
|
|
import javax.mail.Part; |
8
|
|
import javax.mail.internet.MimePart; |
9
|
|
|
10
|
|
import fr.sii.ogham.testing.assertion.exception.FilterException; |
11
|
|
import fr.sii.ogham.testing.assertion.util.EmailUtils; |
12
|
|
|
13
|
|
/** |
14
|
|
* Attachments may be everywhere in the message hierarchy. The default |
15
|
|
* filter skips any body part that is either text/plain or text/html. All |
16
|
|
* other parts are considered attachments (even if related to HTML message |
17
|
|
* like images). |
18
|
|
* |
19
|
|
* @author Aurélien Baudet |
20
|
|
*/ |
21
|
|
public class DefaultAttachmentPredicate implements Predicate<Part> { |
22
|
|
|
23
|
|
@Override |
24
|
|
public boolean test(Part p) { |
25
|
4
1. test : negated conditional → NO_COVERAGE
2. test : negated conditional → KILLED
3. test : negated conditional → KILLED
4. test : negated conditional → KILLED
|
if (p instanceof Message) { |
26
|
4
1. test : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::test → NO_COVERAGE
2. test : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::test → KILLED
3. test : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::test → KILLED
4. test : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::test → KILLED
|
return false; |
27
|
|
} |
28
|
15
1. test : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::test → NO_COVERAGE
2. test : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::test → SURVIVED
3. test : negated conditional → NO_COVERAGE
4. test : negated conditional → NO_COVERAGE
5. test : negated conditional → NO_COVERAGE
6. test : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::test → KILLED
7. test : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::test → KILLED
8. test : negated conditional → KILLED
9. test : negated conditional → KILLED
10. test : negated conditional → KILLED
11. test : negated conditional → KILLED
12. test : negated conditional → KILLED
13. test : negated conditional → KILLED
14. test : negated conditional → KILLED
15. test : negated conditional → KILLED
|
return !EmailUtils.isMultipart(p) && (isDownloadableAttachment(p) || isEmbeddableAttachment(p)); |
29
|
|
} |
30
|
|
|
31
|
|
private boolean isDownloadableAttachment(Part p) { |
32
|
|
try { |
33
|
12
1. isDownloadableAttachment : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::isDownloadableAttachment → SURVIVED
2. isDownloadableAttachment : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::isDownloadableAttachment → NO_COVERAGE
3. isDownloadableAttachment : negated conditional → SURVIVED
4. isDownloadableAttachment : negated conditional → NO_COVERAGE
5. isDownloadableAttachment : negated conditional → NO_COVERAGE
6. isDownloadableAttachment : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::isDownloadableAttachment → KILLED
7. isDownloadableAttachment : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::isDownloadableAttachment → KILLED
8. isDownloadableAttachment : negated conditional → KILLED
9. isDownloadableAttachment : negated conditional → KILLED
10. isDownloadableAttachment : negated conditional → KILLED
11. isDownloadableAttachment : negated conditional → KILLED
12. isDownloadableAttachment : negated conditional → KILLED
|
return Part.ATTACHMENT.equalsIgnoreCase(p.getDisposition()) || p.getFileName() != null; |
34
|
|
} catch(MessagingException e) { |
35
|
|
throw new FilterException("Failed to check if attachment is downloadable", e); |
36
|
|
} |
37
|
|
} |
38
|
|
|
39
|
|
private boolean isEmbeddableAttachment(Part p) { |
40
|
|
try { |
41
|
9
1. isEmbeddableAttachment : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::isEmbeddableAttachment → NO_COVERAGE
2. isEmbeddableAttachment : negated conditional → NO_COVERAGE
3. isEmbeddableAttachment : negated conditional → NO_COVERAGE
4. isEmbeddableAttachment : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::isEmbeddableAttachment → KILLED
5. isEmbeddableAttachment : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::isEmbeddableAttachment → KILLED
6. isEmbeddableAttachment : negated conditional → KILLED
7. isEmbeddableAttachment : negated conditional → KILLED
8. isEmbeddableAttachment : negated conditional → KILLED
9. isEmbeddableAttachment : negated conditional → KILLED
|
return Part.INLINE.equalsIgnoreCase(p.getDisposition()) || hasContentID(p); |
42
|
|
} catch(MessagingException e) { |
43
|
|
throw new FilterException("Failed to check if attachment is embeddable", e); |
44
|
|
} |
45
|
|
} |
46
|
|
|
47
|
|
private boolean hasContentID(Part p) throws MessagingException { |
48
|
2
1. hasContentID : negated conditional → NO_COVERAGE
2. hasContentID : negated conditional → SURVIVED
|
if (p instanceof MimePart) { |
49
|
6
1. hasContentID : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::hasContentID → NO_COVERAGE
2. hasContentID : negated conditional → NO_COVERAGE
3. hasContentID : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::hasContentID → KILLED
4. hasContentID : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::hasContentID → KILLED
5. hasContentID : negated conditional → KILLED
6. hasContentID : negated conditional → KILLED
|
return ((MimePart) p).getContentID() != null; |
50
|
|
} |
51
|
1
1. hasContentID : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::hasContentID → NO_COVERAGE
|
return false; |
52
|
|
} |
53
|
|
|
54
|
|
} |
| | Mutations |
25 |
|
1.1 Location : test Killed by : oghamtesting.it.assertion.FluentEmailAssertionsSpec negated conditional → KILLED 2.2 Location : test Killed by : none negated conditional → NO_COVERAGE 3.3 Location : test Killed by : oghamjavamail.it.JavaMailSmtpTest.attachment(oghamjavamail.it.JavaMailSmtpTest) negated conditional → KILLED 4.4 Location : test Killed by : oghamall.it.email.EmailSMTPDefaultsTest.attachmentLookup(oghamall.it.email.EmailSMTPDefaultsTest) negated conditional → KILLED
|
26 |
|
1.1 Location : test Killed by : oghamjavamail.it.JavaMailSmtpTest.simple(oghamjavamail.it.JavaMailSmtpTest) replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::test → KILLED 2.2 Location : test Killed by : oghamtesting.it.assertion.FluentEmailAssertionsSpec replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::test → KILLED 3.3 Location : test Killed by : none replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::test → NO_COVERAGE 4.4 Location : test Killed by : oghamall.it.email.EmailSMTPAuthenticationTest.authenticated(oghamall.it.email.EmailSMTPAuthenticationTest) replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::test → KILLED
|
28 |
|
1.1 Location : test Killed by : none replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::test → NO_COVERAGE 2.2 Location : test Killed by : oghamall.it.email.EmailExtractSubjectTest.subjectExtractedFromTextWithDefaultSubjectShouldSendWithSubjectExtractedFromText(oghamall.it.email.EmailExtractSubjectTest) replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::test → KILLED 3.3 Location : test Killed by : oghamjavamail.it.JavaMailSmtpTest.attachment(oghamjavamail.it.JavaMailSmtpTest) replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::test → KILLED 4.4 Location : test Killed by : none replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::test → SURVIVED 5.5 Location : test Killed by : oghamall.it.email.EmailSMTPDefaultsTest.attachmentLookup(oghamall.it.email.EmailSMTPDefaultsTest) negated conditional → KILLED 6.6 Location : test Killed by : none negated conditional → NO_COVERAGE 7.7 Location : test Killed by : oghamjavamail.it.JavaMailSmtpTest.attachment(oghamjavamail.it.JavaMailSmtpTest) negated conditional → KILLED 8.8 Location : test Killed by : oghamtesting.it.assertion.FluentEmailAssertionsSpec negated conditional → KILLED 9.9 Location : test Killed by : oghamtesting.it.assertion.FluentEmailAssertionsSpec negated conditional → KILLED 10.10 Location : test Killed by : oghamall.it.email.EmailExtractSubjectTest.subjectExtractedFromTextWithDefaultSubjectShouldSendWithSubjectExtractedFromText(oghamall.it.email.EmailExtractSubjectTest) negated conditional → KILLED 11.11 Location : test Killed by : none negated conditional → NO_COVERAGE 12.12 Location : test Killed by : oghamjavamail.it.JavaMailSmtpTest.attachment(oghamjavamail.it.JavaMailSmtpTest) negated conditional → KILLED 13.13 Location : test Killed by : oghamjavamail.it.JavaMailSmtpTest.attachment(oghamjavamail.it.JavaMailSmtpTest) negated conditional → KILLED 14.14 Location : test Killed by : oghamall.it.email.EmailExtractSubjectTest.subjectExtractedFromTextWithDefaultSubjectShouldSendWithSubjectExtractedFromText(oghamall.it.email.EmailExtractSubjectTest) negated conditional → KILLED 15.15 Location : test Killed by : none negated conditional → NO_COVERAGE
|
33 |
|
1.1 Location : isDownloadableAttachment Killed by : none replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::isDownloadableAttachment → SURVIVED 2.2 Location : isDownloadableAttachment Killed by : oghamjavamail.it.JavaMailSmtpTest.attachment(oghamjavamail.it.JavaMailSmtpTest) replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::isDownloadableAttachment → KILLED 3.3 Location : isDownloadableAttachment Killed by : oghamall.it.email.EmailExtractSubjectTest.subjectExtractedFromTextWithDefaultSubjectShouldSendWithSubjectExtractedFromText(oghamall.it.email.EmailExtractSubjectTest) replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::isDownloadableAttachment → KILLED 4.4 Location : isDownloadableAttachment Killed by : none replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::isDownloadableAttachment → NO_COVERAGE 5.5 Location : isDownloadableAttachment Killed by : none negated conditional → SURVIVED 6.6 Location : isDownloadableAttachment Killed by : none negated conditional → NO_COVERAGE 7.7 Location : isDownloadableAttachment Killed by : oghamjavamail.it.JavaMailSmtpTest.attachment(oghamjavamail.it.JavaMailSmtpTest) negated conditional → KILLED 8.8 Location : isDownloadableAttachment Killed by : oghamall.it.email.EmailExtractSubjectTest.subjectExtractedFromTextWithDefaultSubjectShouldSendWithSubjectExtractedFromText(oghamall.it.email.EmailExtractSubjectTest) negated conditional → KILLED 9.9 Location : isDownloadableAttachment Killed by : oghamtesting.it.assertion.FluentEmailAssertionsSpec negated conditional → KILLED 10.10 Location : isDownloadableAttachment Killed by : oghamall.it.email.EmailExtractSubjectTest.subjectExtractedFromTextWithDefaultSubjectShouldSendWithSubjectExtractedFromText(oghamall.it.email.EmailExtractSubjectTest) negated conditional → KILLED 11.11 Location : isDownloadableAttachment Killed by : oghamjavamail.it.JavaMailSmtpTest.attachment(oghamjavamail.it.JavaMailSmtpTest) negated conditional → KILLED 12.12 Location : isDownloadableAttachment Killed by : none negated conditional → NO_COVERAGE
|
41 |
|
1.1 Location : isEmbeddableAttachment Killed by : none replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::isEmbeddableAttachment → NO_COVERAGE 2.2 Location : isEmbeddableAttachment Killed by : oghamall.it.email.EmailExtractSubjectTest.subjectExtractedFromTextWithDefaultSubjectShouldSendWithSubjectExtractedFromText(oghamall.it.email.EmailExtractSubjectTest) replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::isEmbeddableAttachment → KILLED 3.3 Location : isEmbeddableAttachment Killed by : oghamjavamail.it.JavaMailSmtpTest.attachment(oghamjavamail.it.JavaMailSmtpTest) replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::isEmbeddableAttachment → KILLED 4.4 Location : isEmbeddableAttachment Killed by : none negated conditional → NO_COVERAGE 5.5 Location : isEmbeddableAttachment Killed by : oghamall.it.email.EmailExtractSubjectTest.subjectExtractedFromTextWithDefaultSubjectShouldSendWithSubjectExtractedFromText(oghamall.it.email.EmailExtractSubjectTest) negated conditional → KILLED 6.6 Location : isEmbeddableAttachment Killed by : oghamjavamail.it.JavaMailSmtpTest.attachment(oghamjavamail.it.JavaMailSmtpTest) negated conditional → KILLED 7.7 Location : isEmbeddableAttachment Killed by : none negated conditional → NO_COVERAGE 8.8 Location : isEmbeddableAttachment Killed by : oghamall.it.email.EmailExtractSubjectTest.subjectExtractedFromTextWithDefaultSubjectShouldSendWithSubjectExtractedFromText(oghamall.it.email.EmailExtractSubjectTest) negated conditional → KILLED 9.9 Location : isEmbeddableAttachment Killed by : oghamjavamail.it.JavaMailSmtpTest.attachment(oghamjavamail.it.JavaMailSmtpTest) negated conditional → KILLED
|
48 |
|
1.1 Location : hasContentID Killed by : none negated conditional → NO_COVERAGE 2.2 Location : hasContentID Killed by : none negated conditional → SURVIVED
|
49 |
|
1.1 Location : hasContentID Killed by : none replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::hasContentID → NO_COVERAGE 2.2 Location : hasContentID Killed by : oghamall.it.email.EmailExtractSubjectTest.subjectExtractedFromTextWithDefaultSubjectShouldSendWithSubjectExtractedFromText(oghamall.it.email.EmailExtractSubjectTest) replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::hasContentID → KILLED 3.3 Location : hasContentID Killed by : oghamjavamail.it.JavaMailSmtpTest.attachment(oghamjavamail.it.JavaMailSmtpTest) replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::hasContentID → KILLED 4.4 Location : hasContentID Killed by : oghamjavamail.it.JavaMailSmtpTest.attachment(oghamjavamail.it.JavaMailSmtpTest) negated conditional → KILLED 5.5 Location : hasContentID Killed by : oghamall.it.email.EmailExtractSubjectTest.subjectExtractedFromTextWithDefaultSubjectShouldSendWithSubjectExtractedFromText(oghamall.it.email.EmailExtractSubjectTest) negated conditional → KILLED 6.6 Location : hasContentID Killed by : none negated conditional → NO_COVERAGE
|
51 |
|
1.1 Location : hasContentID Killed by : none replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/DefaultAttachmentPredicate::hasContentID → NO_COVERAGE
|