| 1 | package fr.sii.ogham.testing.assertion.email; | |
| 2 | ||
| 3 | import java.io.IOException; | |
| 4 | import java.io.InputStream; | |
| 5 | import java.nio.charset.Charset; | |
| 6 | import java.util.regex.Pattern; | |
| 7 | ||
| 8 | import org.apache.commons.io.IOUtils; | |
| 9 | ||
| 10 | /** | |
| 11 | * Class used in tests for ensuring that the content of an email is respected. | |
| 12 | * It contains the expected content and the expected Mime Type. | |
| 13 | * | |
| 14 | * @author Aurélien Baudet | |
| 15 | * | |
| 16 | */ | |
| 17 | public class ExpectedContent { | |
| 18 | /** | |
| 19 | * The expected body content as string | |
| 20 | */ | |
| 21 | private String body; | |
| 22 | ||
| 23 | /** | |
| 24 | * The expected Mime Type (regular expression) | |
| 25 | */ | |
| 26 | private Pattern mimetype; | |
| 27 | ||
| 28 | /** | |
| 29 | * Initialize with the expected body and the expected Mime Type (regular | |
| 30 | * expression). | |
| 31 | * | |
| 32 | * @param body | |
| 33 | * the expected body | |
| 34 | * @param mimetype | |
| 35 | * the expected Mime Type pattern | |
| 36 | */ | |
| 37 | public ExpectedContent(String body, String mimetype) { | |
| 38 | this(body, Pattern.compile(mimetype)); | |
| 39 | } | |
| 40 | ||
| 41 | /** | |
| 42 | * Initialize with the expected body and the expected Mime Type pattern. | |
| 43 | * | |
| 44 | * @param body | |
| 45 | * the expected body | |
| 46 | * @param mimetype | |
| 47 | * the expected Mime Type pattern | |
| 48 | */ | |
| 49 | public ExpectedContent(String body, Pattern mimetype) { | |
| 50 | super(); | |
| 51 | this.body = body; | |
| 52 | this.mimetype = mimetype; | |
| 53 | } | |
| 54 | ||
| 55 | /** | |
| 56 | * Initialize with the expected body and the expected Mime Type pattern. | |
| 57 | * | |
| 58 | * @param body | |
| 59 | * the expected body to read from the stream | |
| 60 | * @param mimetype | |
| 61 | * the expected Mime Type pattern | |
| 62 | * @throws IOException | |
| 63 | * when the expected content stream is not readable | |
| 64 | */ | |
| 65 | public ExpectedContent(InputStream body, String mimetype) throws IOException { | |
| 66 | this(IOUtils.toString(body, Charset.defaultCharset()), mimetype); | |
| 67 | } | |
| 68 | ||
| 69 | public String getBody() { | |
| 70 |
2
1. getBody : replaced return value with "" for fr/sii/ogham/testing/assertion/email/ExpectedContent::getBody → NO_COVERAGE 2. getBody : replaced return value with "" for fr/sii/ogham/testing/assertion/email/ExpectedContent::getBody → KILLED |
return body; |
| 71 | } | |
| 72 | ||
| 73 | public Pattern getMimetype() { | |
| 74 |
2
1. getMimetype : replaced return value with null for fr/sii/ogham/testing/assertion/email/ExpectedContent::getMimetype → NO_COVERAGE 2. getMimetype : replaced return value with null for fr/sii/ogham/testing/assertion/email/ExpectedContent::getMimetype → KILLED |
return mimetype; |
| 75 | } | |
| 76 | ||
| 77 | } | |
Mutations | ||
| 70 |
1.1 2.2 |
|
| 74 |
1.1 2.2 |