1 | package fr.sii.ogham.email.message.content; | |
2 | ||
3 | import java.util.List; | |
4 | ||
5 | import fr.sii.ogham.core.message.content.Content; | |
6 | import fr.sii.ogham.core.message.content.DecoratorContent; | |
7 | import fr.sii.ogham.core.message.content.MayHaveStringContent; | |
8 | import fr.sii.ogham.core.message.content.UpdatableDecoratorContent; | |
9 | import fr.sii.ogham.core.message.content.UpdatableStringContent; | |
10 | import fr.sii.ogham.email.attachment.Attachment; | |
11 | ||
12 | /** | |
13 | * Decorator that embeds attachments with the decorated content. | |
14 | * | |
15 | * @author Aurélien Baudet | |
16 | * | |
17 | */ | |
18 | public class ContentWithAttachments implements DecoratorContent, UpdatableDecoratorContent, MayHaveStringContent, UpdatableStringContent { | |
19 | /** | |
20 | * The decorated content | |
21 | */ | |
22 | private Content content; | |
23 | | |
24 | /** | |
25 | * The attachments | |
26 | */ | |
27 | private List<Attachment> attachments; | |
28 | ||
29 | public ContentWithAttachments(Content content, List<Attachment> attachments) { | |
30 | super(); | |
31 | this.content = content; | |
32 | this.attachments = attachments; | |
33 | } | |
34 | ||
35 | @Override | |
36 | public Content getContent() { | |
37 |
2
1. getContent : replaced return value with null for fr/sii/ogham/email/message/content/ContentWithAttachments::getContent → NO_COVERAGE 2. getContent : replaced return value with null for fr/sii/ogham/email/message/content/ContentWithAttachments::getContent → KILLED |
return content; |
38 | } | |
39 | ||
40 | @Override | |
41 | public void setContent(Content content) { | |
42 | this.content = content; | |
43 | } | |
44 | ||
45 | public List<Attachment> getAttachments() { | |
46 |
2
1. getAttachments : replaced return value with Collections.emptyList for fr/sii/ogham/email/message/content/ContentWithAttachments::getAttachments → NO_COVERAGE 2. getAttachments : replaced return value with Collections.emptyList for fr/sii/ogham/email/message/content/ContentWithAttachments::getAttachments → KILLED |
return attachments; |
47 | } | |
48 | ||
49 | public void setAttachments(List<Attachment> attachments) { | |
50 | this.attachments = attachments; | |
51 | } | |
52 | | |
53 | public void addAttachments(List<Attachment> attachments) { | |
54 | this.attachments.addAll(attachments); | |
55 | } | |
56 | ||
57 | @Override | |
58 | public boolean canProvideString() { | |
59 |
6
1. canProvideString : replaced boolean return with true for fr/sii/ogham/email/message/content/ContentWithAttachments::canProvideString → NO_COVERAGE 2. canProvideString : replaced boolean return with true for fr/sii/ogham/email/message/content/ContentWithAttachments::canProvideString → SURVIVED 3. canProvideString : negated conditional → NO_COVERAGE 4. canProvideString : negated conditional → SURVIVED 5. canProvideString : negated conditional → NO_COVERAGE 6. canProvideString : negated conditional → SURVIVED |
return content instanceof MayHaveStringContent && ((MayHaveStringContent) content).canProvideString(); |
60 | } | |
61 | ||
62 | @Override | |
63 | public String asString() { | |
64 |
6
1. asString : replaced return value with "" for fr/sii/ogham/email/message/content/ContentWithAttachments::asString → SURVIVED 2. asString : replaced return value with "" for fr/sii/ogham/email/message/content/ContentWithAttachments::asString → NO_COVERAGE 3. asString : negated conditional → NO_COVERAGE 4. asString : replaced return value with "" for fr/sii/ogham/email/message/content/ContentWithAttachments::asString → KILLED 5. asString : negated conditional → KILLED 6. asString : negated conditional → KILLED |
return content instanceof MayHaveStringContent ? ((MayHaveStringContent) content).asString() : null; |
65 | } | |
66 | ||
67 | @Override | |
68 | public void setStringContent(String content) { | |
69 |
1
1. setStringContent : negated conditional → NO_COVERAGE |
if(this.content instanceof UpdatableStringContent) { |
70 |
1
1. setStringContent : removed call to fr/sii/ogham/core/message/content/UpdatableStringContent::setStringContent → NO_COVERAGE |
((UpdatableStringContent) this.content).setStringContent(content); |
71 | } | |
72 | } | |
73 | | |
74 | @Override | |
75 | public String toString() { | |
76 | StringBuilder builder = new StringBuilder(); | |
77 | builder.append("ContentWithAttachments [content=").append(content).append(", attachments=").append(attachments).append("]"); | |
78 |
1
1. toString : replaced return value with "" for fr/sii/ogham/email/message/content/ContentWithAttachments::toString → NO_COVERAGE |
return builder.toString(); |
79 | } | |
80 | } | |
Mutations | ||
37 |
1.1 2.2 |
|
46 |
1.1 2.2 |
|
59 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
64 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
69 |
1.1 |
|
70 |
1.1 |
|
78 |
1.1 |