| 1 | package fr.sii.ogham.testing.assertion.filter; | |
| 2 | ||
| 3 | import static java.util.Collections.list; | |
| 4 | ||
| 5 | import java.util.function.Predicate; | |
| 6 | ||
| 7 | import javax.mail.Header; | |
| 8 | import javax.mail.MessagingException; | |
| 9 | import javax.mail.Part; | |
| 10 | ||
| 11 | /** | |
| 12 | * Predicate that matches the {@link Part} only if {@link Part#getAllHeaders()} | |
| 13 | * contains a {@code Content-ID} header that exactly matches the provided | |
| 14 | * Content-ID. | |
| 15 | * | |
| 16 | * @author Aurélien Baudet | |
| 17 | * | |
| 18 | */ | |
| 19 | public class ContentIdPredicate implements Predicate<Part> { | |
| 20 | private final String contentId; | |
| 21 | ||
| 22 | public ContentIdPredicate(String contentId) { | |
| 23 | super(); | |
| 24 | this.contentId = contentId; | |
| 25 | } | |
| 26 | ||
| 27 | @Override | |
| 28 | public boolean test(Part input) { | |
| 29 | try { | |
| 30 | // @formatter:off | |
| 31 |
4
1. test : replaced boolean return with false for fr/sii/ogham/testing/assertion/filter/ContentIdPredicate::test → NO_COVERAGE 2. test : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/ContentIdPredicate::test → NO_COVERAGE 3. test : replaced boolean return with false for fr/sii/ogham/testing/assertion/filter/ContentIdPredicate::test → KILLED 4. test : replaced boolean return with true for fr/sii/ogham/testing/assertion/filter/ContentIdPredicate::test → KILLED |
return list(input.getMatchingHeaders(new String[] { "Content-ID" })) |
| 32 | .stream() | |
| 33 | .map(Header::getValue) | |
| 34 | .anyMatch(contentId::equals); | |
| 35 | // @formatter:on | |
| 36 | } catch (MessagingException e) { | |
| 37 | throw new AssertionError("Failed to access message", e); | |
| 38 | } | |
| 39 | } | |
| 40 | ||
| 41 | @Override | |
| 42 | public String toString() { | |
| 43 |
2
1. toString : replaced return value with "" for fr/sii/ogham/testing/assertion/filter/ContentIdPredicate::toString → NO_COVERAGE 2. toString : replaced return value with "" for fr/sii/ogham/testing/assertion/filter/ContentIdPredicate::toString → SURVIVED |
return "having Content-ID header '" + contentId + "'"; |
| 44 | } | |
| 45 | ||
| 46 | } | |
Mutations | ||
| 31 |
1.1 2.2 3.3 4.4 |
|
| 43 |
1.1 2.2 |