1 | package fr.sii.ogham.testing.assertion.email; | |
2 | ||
3 | import static fr.sii.ogham.testing.assertion.util.EmailUtils.getBodyParts; | |
4 | import static java.nio.charset.StandardCharsets.UTF_8; | |
5 | import static java.util.Collections.emptyList; | |
6 | ||
7 | import java.io.IOException; | |
8 | import java.util.List; | |
9 | import java.util.regex.Pattern; | |
10 | ||
11 | import javax.mail.Address; | |
12 | import javax.mail.Message; | |
13 | import javax.mail.Message.RecipientType; | |
14 | import javax.mail.MessagingException; | |
15 | import javax.mail.Multipart; | |
16 | import javax.mail.Part; | |
17 | ||
18 | import org.junit.Assert; | |
19 | import org.junit.ComparisonFailure; | |
20 | ||
21 | import fr.sii.ogham.testing.assertion.html.AssertHtml; | |
22 | import fr.sii.ogham.testing.assertion.util.AssertionRegistry; | |
23 | import fr.sii.ogham.testing.assertion.util.EmailUtils; | |
24 | import fr.sii.ogham.testing.assertion.util.Executable; | |
25 | import fr.sii.ogham.testing.assertion.util.FailAtEndRegistry; | |
26 | ||
27 | /** | |
28 | * Utility class for checking if the received email content is as expected. | |
29 | * | |
30 | * @author Aurélien Baudet | |
31 | * | |
32 | */ | |
33 | @SuppressWarnings("squid:S1192") | |
34 | public final class AssertEmail { | |
35 | private static final Pattern HTML_PATTERN = Pattern.compile("<html", Pattern.CASE_INSENSITIVE); | |
36 | private static final Pattern NEW_LINES = Pattern.compile("\r|\n"); | |
37 | ||
38 | /** | |
39 | * Assert that the fields of the received email are equal to the expected | |
40 | * values. The expected email contains several parts (several contents). The | |
41 | * received email should also have the equivalent parts. It will check that: | |
42 | * <ul> | |
43 | * <li>The received headers are respected (see | |
44 | * {@link #assertHeaders(ExpectedEmailHeader, Message)})</li> | |
45 | * <li>The received message is a {@link Multipart} email</li> | |
46 | * <li>The number of parts are equal</li> | |
47 | * <li>Each received part body equals the expected one (order is important). | |
48 | * See {@link #assertBody(String, String, boolean)}</li> | |
49 | * <li>Each received part Mime Type equals the expected one (order is | |
50 | * important).</li> | |
51 | * </ul> | |
52 | * <p> | |
53 | * The checking of the body is done strictly (totally equal). | |
54 | * </p> | |
55 | * | |
56 | * @param expectedEmail | |
57 | * all the fields with their expected values | |
58 | * @param actualEmail | |
59 | * the received email | |
60 | * @throws MessagingException | |
61 | * when accessing the received email fails | |
62 | * @throws IOException | |
63 | * when reading the content of the email fails | |
64 | */ | |
65 | public static void assertEquals(ExpectedMultiPartEmail expectedEmail, Message actualEmail) throws MessagingException, IOException { | |
66 | AssertionRegistry assertions = new FailAtEndRegistry(); | |
67 |
2
1. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → NO_COVERAGE 2. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → KILLED |
assertEquals(expectedEmail, actualEmail, true, assertions); |
68 |
2
1. assertEquals : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE 2. assertEquals : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → KILLED |
assertions.execute(); |
69 | } | |
70 | ||
71 | /** | |
72 | * <p> | |
73 | * Shortcut to simplify unit testing with GreenMail. See | |
74 | * {@link #assertEquals(ExpectedMultiPartEmail[], Message[])}. | |
75 | * </p> | |
76 | * Assert that the fields of the received email are equal to the expected | |
77 | * values. The expected email contains several parts (several contents). The | |
78 | * received email should also have the equivalent parts. It will check that: | |
79 | * <ul> | |
80 | * <li>The received headers are respected (see | |
81 | * {@link #assertHeaders(ExpectedEmailHeader, Message)})</li> | |
82 | * <li>The received message is a {@link Multipart} email</li> | |
83 | * <li>The number of parts are equal</li> | |
84 | * <li>Each received part body equals the expected one (order is important). | |
85 | * See {@link #assertBody(String, String, boolean)}</li> | |
86 | * <li>Each received part Mime Type equals the expected one (order is | |
87 | * important).</li> | |
88 | * </ul> | |
89 | * <p> | |
90 | * The checking of the body is done strictly (totally equal). | |
91 | * </p> | |
92 | * | |
93 | * @param expectedEmail | |
94 | * all the fields with their expected values | |
95 | * @param actualEmails | |
96 | * the received email | |
97 | * @throws MessagingException | |
98 | * when accessing the received email fails | |
99 | * @throws IOException | |
100 | * when reading the content of the email fails | |
101 | */ | |
102 | public static void assertEquals(ExpectedMultiPartEmail expectedEmail, Message[] actualEmails) throws MessagingException, IOException { | |
103 |
2
1. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → NO_COVERAGE 2. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → KILLED |
assertEquals(new ExpectedMultiPartEmail[] { expectedEmail }, actualEmails); |
104 | } | |
105 | ||
106 | /** | |
107 | * Assert that each received email content respects the expected one. It | |
108 | * ensures that the number of received emails equals to the expected number. | |
109 | * Then for each email it calls | |
110 | * {@link #assertEquals(ExpectedMultiPartEmail, Message)} . | |
111 | * | |
112 | * @param expectedEmails | |
113 | * the list of expected emails | |
114 | * @param actualEmails | |
115 | * the received emails | |
116 | * @throws MessagingException | |
117 | * when accessing the received email fails | |
118 | * @throws IOException | |
119 | * when reading the content of the email fails | |
120 | */ | |
121 | public static void assertEquals(ExpectedMultiPartEmail[] expectedEmails, Message[] actualEmails) throws MessagingException, IOException { | |
122 | AssertionRegistry assertions = new FailAtEndRegistry(); | |
123 |
4
1. assertEquals : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 2. lambda$assertEquals$0 : removed call to org/junit/Assert::assertEquals → NO_COVERAGE 3. assertEquals : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED 4. lambda$assertEquals$0 : removed call to org/junit/Assert::assertEquals → KILLED |
assertions.register(() -> Assert.assertEquals("should have received " + expectedEmails.length + " email", expectedEmails.length, actualEmails.length)); |
124 |
4
1. assertEquals : changed conditional boundary → NO_COVERAGE 2. assertEquals : negated conditional → NO_COVERAGE 3. assertEquals : changed conditional boundary → KILLED 4. assertEquals : negated conditional → KILLED |
for (int i = 0; i < expectedEmails.length; i++) { |
125 |
6
1. assertEquals : changed conditional boundary → NO_COVERAGE 2. assertEquals : negated conditional → NO_COVERAGE 3. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → NO_COVERAGE 4. assertEquals : changed conditional boundary → KILLED 5. assertEquals : negated conditional → KILLED 6. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → KILLED |
assertEquals(expectedEmails[i], i < actualEmails.length ? actualEmails[i] : null, true, assertions); |
126 | } | |
127 |
2
1. assertEquals : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE 2. assertEquals : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → KILLED |
assertions.execute(); |
128 | } | |
129 | ||
130 | /** | |
131 | * <p> | |
132 | * Shortcut to simplify unit testing with GreenMail. See | |
133 | * {@link #assertEquals(ExpectedEmail[], Message[])}. | |
134 | * </p> | |
135 | * Assert that the fields of the received email are equal to the expected | |
136 | * values. The expected email contains only one part (only one content). It | |
137 | * will check that: | |
138 | * <ul> | |
139 | * <li>The received headers are respected (see | |
140 | * {@link #assertHeaders(ExpectedEmailHeader, Message)})</li> | |
141 | * <li>The body equals the expected one (order is important). See | |
142 | * {@link #assertBody(String, String, boolean)}</li> | |
143 | * <li>The Mime Type equals the expected one (order is important).</li> | |
144 | * </ul> | |
145 | * <p> | |
146 | * The checking of the body is done strictly (totally equal). | |
147 | * </p> | |
148 | * | |
149 | * | |
150 | * @param expectedEmail | |
151 | * all the fields with their expected values | |
152 | * @param actualEmails | |
153 | * the received emails | |
154 | * @throws MessagingException | |
155 | * when accessing the received email fails | |
156 | * @throws IOException | |
157 | * when reading the email content fails | |
158 | */ | |
159 | public static void assertEquals(ExpectedEmail expectedEmail, Message[] actualEmails) throws MessagingException, IOException { | |
160 |
2
1. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → NO_COVERAGE 2. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → KILLED |
assertEquals(new ExpectedEmail[] { expectedEmail }, actualEmails); |
161 | } | |
162 | ||
163 | /** | |
164 | * Assert that each received email content respects the expected one. It | |
165 | * ensures that the number of received emails equals to the expected number. | |
166 | * Then for each email it calls | |
167 | * {@link #assertEquals(ExpectedEmail, Message)} . | |
168 | * | |
169 | * @param expectedEmail | |
170 | * the expected email | |
171 | * @param actualEmails | |
172 | * the received emails | |
173 | * @throws MessagingException | |
174 | * when accessing the received email fails | |
175 | * @throws IOException | |
176 | * when reading the email content fails | |
177 | */ | |
178 | public static void assertEquals(ExpectedEmail[] expectedEmail, Message[] actualEmails) throws MessagingException, IOException { | |
179 | AssertionRegistry assertions = new FailAtEndRegistry(); | |
180 |
4
1. assertEquals : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 2. lambda$assertEquals$1 : removed call to org/junit/Assert::assertEquals → NO_COVERAGE 3. assertEquals : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED 4. lambda$assertEquals$1 : removed call to org/junit/Assert::assertEquals → KILLED |
assertions.register(() -> Assert.assertEquals("should have received " + expectedEmail.length + " email", expectedEmail.length, actualEmails.length)); |
181 |
4
1. assertEquals : changed conditional boundary → NO_COVERAGE 2. assertEquals : negated conditional → NO_COVERAGE 3. assertEquals : changed conditional boundary → KILLED 4. assertEquals : negated conditional → KILLED |
for (int i = 0; i < expectedEmail.length; i++) { |
182 |
6
1. assertEquals : changed conditional boundary → NO_COVERAGE 2. assertEquals : negated conditional → NO_COVERAGE 3. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → NO_COVERAGE 4. assertEquals : changed conditional boundary → KILLED 5. assertEquals : negated conditional → KILLED 6. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → KILLED |
assertEquals(expectedEmail[i], i < actualEmails.length ? actualEmails[i] : null, true, assertions); |
183 | } | |
184 |
2
1. assertEquals : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE 2. assertEquals : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → KILLED |
assertions.execute(); |
185 | } | |
186 | ||
187 | /** | |
188 | * Assert that the fields of the received email are equal to the expected | |
189 | * values. The expected email contains only one part (only one content). It | |
190 | * will check that: | |
191 | * <ul> | |
192 | * <li>The received headers are respected (see | |
193 | * {@link #assertHeaders(ExpectedEmailHeader, Message)})</li> | |
194 | * <li>The body equals the expected one (order is important). See | |
195 | * {@link #assertBody(String, String, boolean)}</li> | |
196 | * <li>The Mime Type equals the expected one (order is important).</li> | |
197 | * </ul> | |
198 | * <p> | |
199 | * The checking of the body is done strictly (totally equal). | |
200 | * </p> | |
201 | * | |
202 | * @param expectedEmail | |
203 | * all the fields with their expected values | |
204 | * @param actualEmail | |
205 | * the received email | |
206 | * @throws MessagingException | |
207 | * when accessing the received email fails | |
208 | * @throws IOException | |
209 | * when reading the email content fails | |
210 | */ | |
211 | public static void assertEquals(ExpectedEmail expectedEmail, Message actualEmail) throws MessagingException, IOException { | |
212 | AssertionRegistry assertions = new FailAtEndRegistry(); | |
213 |
2
1. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → NO_COVERAGE 2. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → KILLED |
assertEquals(expectedEmail, actualEmail, true, assertions); |
214 |
2
1. assertEquals : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE 2. assertEquals : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → KILLED |
assertions.execute(); |
215 | } | |
216 | ||
217 | /** | |
218 | * Assert that the fields of the received email are equal to the expected | |
219 | * values. The expected email contains several parts (several contents). The | |
220 | * received email should also have the equivalent parts. It will check that: | |
221 | * <ul> | |
222 | * <li>The received headers are respected (see | |
223 | * {@link #assertHeaders(ExpectedEmailHeader, Message)})</li> | |
224 | * <li>The received message is a {@link Multipart} email</li> | |
225 | * <li>The number of parts are equal</li> | |
226 | * <li>Each received part body equals the expected one (order is important). | |
227 | * See {@link #assertBody(String, String, boolean)}</li> | |
228 | * <li>Each received part Mime Type equals the expected one (order is | |
229 | * important).</li> | |
230 | * </ul> | |
231 | * <p> | |
232 | * The checking of the body ignores the new line characters. | |
233 | * </p> | |
234 | * | |
235 | * @param expectedEmail | |
236 | * all the fields with their expected values | |
237 | * @param actualEmail | |
238 | * the received email | |
239 | * @throws MessagingException | |
240 | * when accessing the received email fails | |
241 | * @throws IOException | |
242 | * when reading the content of the email fails | |
243 | */ | |
244 | public static void assertSimilar(ExpectedMultiPartEmail expectedEmail, Message actualEmail) throws MessagingException, IOException { | |
245 | AssertionRegistry assertions = new FailAtEndRegistry(); | |
246 |
2
1. assertSimilar : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → NO_COVERAGE 2. assertSimilar : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → KILLED |
assertEquals(expectedEmail, actualEmail, false, assertions); |
247 |
2
1. assertSimilar : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE 2. assertSimilar : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → KILLED |
assertions.execute(); |
248 | } | |
249 | ||
250 | /** | |
251 | * <p> | |
252 | * Shortcut to simplify unit testing with GreenMail. See | |
253 | * {@link #assertSimilar(ExpectedMultiPartEmail[], Message[])}. | |
254 | * </p> | |
255 | * Assert that the fields of the received email are equal to the expected | |
256 | * values. The expected email contains several parts (several contents). The | |
257 | * received email should also have the equivalent parts. It will check that: | |
258 | * <ul> | |
259 | * <li>The received headers are respected (see | |
260 | * {@link #assertHeaders(ExpectedEmailHeader, Message)})</li> | |
261 | * <li>The received message is a {@link Multipart} email</li> | |
262 | * <li>The number of parts are equal</li> | |
263 | * <li>Each received part body equals the expected one (order is important). | |
264 | * See {@link #assertBody(String, String, boolean)}</li> | |
265 | * <li>Each received part Mime Type equals the expected one (order is | |
266 | * important).</li> | |
267 | * </ul> | |
268 | * <p> | |
269 | * The checking of the body ignores the new line characters. | |
270 | * </p> | |
271 | * | |
272 | * @param expectedEmail | |
273 | * all the fields with their expected values | |
274 | * @param actualEmails | |
275 | * the received email | |
276 | * @throws MessagingException | |
277 | * when accessing the received email fails | |
278 | * @throws IOException | |
279 | * when reading the content of the email fails | |
280 | */ | |
281 | public static void assertSimilar(ExpectedMultiPartEmail expectedEmail, Message[] actualEmails) throws MessagingException, IOException { | |
282 |
2
1. assertSimilar : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertSimilar → NO_COVERAGE 2. assertSimilar : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertSimilar → KILLED |
assertSimilar(new ExpectedMultiPartEmail[] { expectedEmail }, actualEmails); |
283 | } | |
284 | ||
285 | /** | |
286 | * Assert that each received email content respects the expected one. It | |
287 | * ensures that the number of received emails equals to the expected number. | |
288 | * Then for each email it calls | |
289 | * {@link #assertSimilar(ExpectedMultiPartEmail, Message)} . | |
290 | * | |
291 | * @param expectedEmails | |
292 | * the list of expected emails | |
293 | * @param actualEmails | |
294 | * the received emails | |
295 | * @throws MessagingException | |
296 | * when accessing the received email fails | |
297 | * @throws IOException | |
298 | * when reading the content of the email fails | |
299 | */ | |
300 | public static void assertSimilar(ExpectedMultiPartEmail[] expectedEmails, Message[] actualEmails) throws MessagingException, IOException { | |
301 | AssertionRegistry assertions = new FailAtEndRegistry(); | |
302 |
4
1. assertSimilar : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 2. lambda$assertSimilar$2 : removed call to org/junit/Assert::assertEquals → NO_COVERAGE 3. assertSimilar : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED 4. lambda$assertSimilar$2 : removed call to org/junit/Assert::assertEquals → KILLED |
assertions.register(() -> Assert.assertEquals("should have received " + expectedEmails.length + " email", expectedEmails.length, actualEmails.length)); |
303 |
4
1. assertSimilar : changed conditional boundary → NO_COVERAGE 2. assertSimilar : negated conditional → NO_COVERAGE 3. assertSimilar : changed conditional boundary → KILLED 4. assertSimilar : negated conditional → KILLED |
for (int i = 0; i < expectedEmails.length; i++) { |
304 |
6
1. assertSimilar : changed conditional boundary → NO_COVERAGE 2. assertSimilar : negated conditional → NO_COVERAGE 3. assertSimilar : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → NO_COVERAGE 4. assertSimilar : changed conditional boundary → KILLED 5. assertSimilar : negated conditional → KILLED 6. assertSimilar : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → KILLED |
assertEquals(expectedEmails[i], i < actualEmails.length ? actualEmails[i] : null, false, assertions); |
305 | } | |
306 |
2
1. assertSimilar : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE 2. assertSimilar : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → KILLED |
assertions.execute(); |
307 | } | |
308 | ||
309 | /** | |
310 | * <p> | |
311 | * Shortcut to simplify unit testing with GreenMail. See | |
312 | * {@link #assertSimilar(ExpectedEmail[], Message[])}. | |
313 | * </p> | |
314 | * Assert that the fields of the received email are equal to the expected | |
315 | * values. The expected email contains only one part (only one content). It | |
316 | * will check that: | |
317 | * <ul> | |
318 | * <li>The received headers are respected (see | |
319 | * {@link #assertHeaders(ExpectedEmailHeader, Message)})</li> | |
320 | * <li>The body equals the expected one (order is important). See | |
321 | * {@link #assertBody(String, String, boolean)}</li> | |
322 | * <li>The Mime Type equals the expected one (order is important).</li> | |
323 | * </ul> | |
324 | * <p> | |
325 | * The checking of the body ignores the new line characters. | |
326 | * </p> | |
327 | * | |
328 | * | |
329 | * @param expectedEmail | |
330 | * all the fields with their expected values | |
331 | * @param actualEmails | |
332 | * the received emails | |
333 | * @throws MessagingException | |
334 | * when accessing the received email fails | |
335 | * @throws IOException | |
336 | * when reading the email content fails | |
337 | */ | |
338 | public static void assertSimilar(ExpectedEmail expectedEmail, Message[] actualEmails) throws MessagingException, IOException { | |
339 |
2
1. assertSimilar : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertSimilar → NO_COVERAGE 2. assertSimilar : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertSimilar → KILLED |
assertSimilar(new ExpectedEmail[] { expectedEmail }, actualEmails); |
340 | } | |
341 | ||
342 | /** | |
343 | * Assert that each received email content respects the expected one. It | |
344 | * ensures that the number of received emails equals to the expected number. | |
345 | * Then for each email it calls | |
346 | * {@link #assertSimilar(ExpectedEmail, Message)} . | |
347 | * | |
348 | * @param expectedEmail | |
349 | * the expected email | |
350 | * @param actualEmails | |
351 | * the received emails | |
352 | * @throws MessagingException | |
353 | * when accessing the received email fails | |
354 | * @throws IOException | |
355 | * when reading the email content fails | |
356 | */ | |
357 | public static void assertSimilar(ExpectedEmail[] expectedEmail, Message[] actualEmails) throws MessagingException, IOException { | |
358 | AssertionRegistry assertions = new FailAtEndRegistry(); | |
359 |
4
1. assertSimilar : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 2. lambda$assertSimilar$3 : removed call to org/junit/Assert::assertEquals → NO_COVERAGE 3. assertSimilar : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED 4. lambda$assertSimilar$3 : removed call to org/junit/Assert::assertEquals → KILLED |
assertions.register(() -> Assert.assertEquals("should have received " + expectedEmail.length + " email", expectedEmail.length, actualEmails.length)); |
360 |
4
1. assertSimilar : changed conditional boundary → NO_COVERAGE 2. assertSimilar : negated conditional → NO_COVERAGE 3. assertSimilar : changed conditional boundary → KILLED 4. assertSimilar : negated conditional → KILLED |
for (int i = 0; i < expectedEmail.length; i++) { |
361 |
6
1. assertSimilar : changed conditional boundary → NO_COVERAGE 2. assertSimilar : negated conditional → NO_COVERAGE 3. assertSimilar : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → NO_COVERAGE 4. assertSimilar : changed conditional boundary → KILLED 5. assertSimilar : negated conditional → KILLED 6. assertSimilar : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → KILLED |
assertEquals(expectedEmail[i], i < actualEmails.length ? actualEmails[i] : null, false, assertions); |
362 | } | |
363 |
2
1. assertSimilar : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE 2. assertSimilar : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → KILLED |
assertions.execute(); |
364 | } | |
365 | ||
366 | /** | |
367 | * Assert that the fields of the received email are equal to the expected | |
368 | * values. The expected email contains only one part (only one content). It | |
369 | * will check that: | |
370 | * <ul> | |
371 | * <li>The received headers are respected (see | |
372 | * {@link #assertHeaders(ExpectedEmailHeader, Message)})</li> | |
373 | * <li>The body equals the expected one (order is important). See | |
374 | * {@link #assertBody(String, String, boolean)}</li> | |
375 | * <li>The Mime Type equals the expected one (order is important).</li> | |
376 | * </ul> | |
377 | * <p> | |
378 | * The checking of the body ignores the new line characters. | |
379 | * </p> | |
380 | * | |
381 | * @param expectedEmail | |
382 | * all the fields with their expected values | |
383 | * @param actualEmail | |
384 | * the received email | |
385 | * @throws MessagingException | |
386 | * when accessing the received email fails | |
387 | * @throws IOException | |
388 | * when reading the email content fails | |
389 | */ | |
390 | public static void assertSimilar(ExpectedEmail expectedEmail, Message actualEmail) throws MessagingException, IOException { | |
391 | AssertionRegistry assertions = new FailAtEndRegistry(); | |
392 |
2
1. assertSimilar : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → NO_COVERAGE 2. assertSimilar : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → KILLED |
assertEquals(expectedEmail, actualEmail, false, assertions); |
393 |
2
1. assertSimilar : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE 2. assertSimilar : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → KILLED |
assertions.execute(); |
394 | } | |
395 | ||
396 | /** | |
397 | * Checks if the received body equals the expected body. It handles HTML | |
398 | * content and pure text content. | |
399 | * <p> | |
400 | * For text, the check can be done either strictly (totally equal) or not | |
401 | * (ignore new lines). | |
402 | * </p> | |
403 | * <p> | |
404 | * For HTML, the string content is parsed and DOM trees are compared. The | |
405 | * comparison can be done either strictly (DOM trees are totally equals, | |
406 | * attributes are in the same order) or not (attributes can be in any | |
407 | * order). | |
408 | * </p> | |
409 | * | |
410 | * @param expectedBody | |
411 | * the expected content as string | |
412 | * @param actualBody | |
413 | * the received content as string | |
414 | * @param strict | |
415 | * true for strict checking (totally equals) or false to ignore | |
416 | * new line characters | |
417 | */ | |
418 | public static void assertBody(String expectedBody, String actualBody, boolean strict) { | |
419 | AssertionRegistry assertions = new FailAtEndRegistry(); | |
420 |
2
1. assertBody : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertBody → NO_COVERAGE 2. assertBody : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertBody → KILLED |
assertBody("body", expectedBody, actualBody, strict, assertions); |
421 |
2
1. assertBody : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE 2. assertBody : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → KILLED |
assertions.execute(); |
422 | } | |
423 | ||
424 | /** | |
425 | * Checks if the received headers corresponds to the expected header values. | |
426 | * It checks if: | |
427 | * <ul> | |
428 | * <li>The received subject equals the expected subject</li> | |
429 | * <li>The email sender address equals the expected sender address</li> | |
430 | * <li>The total number of recipients equals the total number of expected | |
431 | * recipients</li> | |
432 | * <li>The number of "to" recipients equals the number of expected "to" | |
433 | * recipients</li> | |
434 | * <li>The number of "cc" recipients equals the number of expected "cc" | |
435 | * recipients</li> | |
436 | * <li>The number of "bcc" recipients equals the number of expected "bcc" | |
437 | * recipients</li> | |
438 | * <li>Each "to" recipient equals the expected "to" recipient value</li> | |
439 | * <li>Each "cc" recipient equals the expected "cc" recipient value</li> | |
440 | * <li>Each "bcc" recipient equals the expected "bcc" recipient value</li> | |
441 | * </ul> | |
442 | * | |
443 | * @param expectedEmail | |
444 | * the expected header values | |
445 | * @param actualEmail | |
446 | * the received header values | |
447 | * @throws MessagingException | |
448 | * when accessing the received email fails | |
449 | */ | |
450 | public static void assertHeaders(ExpectedEmailHeader expectedEmail, Message actualEmail) throws MessagingException { | |
451 | AssertionRegistry assertions = new FailAtEndRegistry(); | |
452 |
2
1. assertHeaders : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertHeaders → NO_COVERAGE 2. assertHeaders : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertHeaders → KILLED |
assertHeaders(expectedEmail, actualEmail, assertions); |
453 |
2
1. assertHeaders : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE 2. assertHeaders : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → KILLED |
assertions.execute(); |
454 | } | |
455 | ||
456 | /** | |
457 | * Checks if the received headers corresponds to the expected header values. | |
458 | * It checks if: | |
459 | * <ul> | |
460 | * <li>The number of recipients of the provided type equals the number of | |
461 | * expected recipients of the provided type</li> | |
462 | * <li>Each recipient of the provided type equals the expected recipient | |
463 | * value of the provided type</li> | |
464 | * </ul> | |
465 | * | |
466 | * @param expectedRecipients | |
467 | * the list of recipient string values | |
468 | * @param actualEmail | |
469 | * the received header values | |
470 | * @param recipientType | |
471 | * the type of the recipient to compare | |
472 | * @throws MessagingException | |
473 | * when accessing the received email fails | |
474 | */ | |
475 | public static void assertRecipients(List<String> expectedRecipients, Message actualEmail, RecipientType recipientType) throws MessagingException { | |
476 | AssertionRegistry assertions = new FailAtEndRegistry(); | |
477 |
2
1. assertRecipients : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertRecipients → NO_COVERAGE 2. assertRecipients : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertRecipients → KILLED |
assertRecipients(expectedRecipients, actualEmail, recipientType, assertions); |
478 |
2
1. assertRecipients : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE 2. assertRecipients : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → KILLED |
assertions.execute(); |
479 | } | |
480 | ||
481 | private static void assertEquals(ExpectedEmail expectedEmail, Message actualEmail, boolean strict, AssertionRegistry assertions) throws MessagingException, IOException { | |
482 |
2
1. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertHeaders → NO_COVERAGE 2. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertHeaders → KILLED |
assertHeaders(expectedEmail, actualEmail, assertions); |
483 |
4
1. assertEquals : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 2. lambda$assertEquals$4 : removed call to org/junit/Assert::assertNotNull → NO_COVERAGE 3. assertEquals : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED 4. lambda$assertEquals$4 : removed call to org/junit/Assert::assertNotNull → KILLED |
assertions.register(() -> Assert.assertNotNull("Expected at least one body part but none found", getBodyOrNull(actualEmail, assertions))); |
484 |
2
1. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertBody → NO_COVERAGE 2. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertBody → KILLED |
assertBody("body", expectedEmail.getExpectedContent().getBody(), getBodyContentOrNull(actualEmail, assertions), strict, assertions); |
485 |
2
1. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertMimetype → NO_COVERAGE 2. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertMimetype → KILLED |
assertMimetype(expectedEmail.getExpectedContent(), getBodyMimetypeOrNull(actualEmail, assertions), assertions); |
486 | } | |
487 | ||
488 | private static void assertEquals(ExpectedMultiPartEmail expectedEmail, Message actualEmail, boolean strict, AssertionRegistry assertions) throws MessagingException, IOException { | |
489 |
2
1. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertHeaders → NO_COVERAGE 2. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertHeaders → KILLED |
assertHeaders(expectedEmail, actualEmail, assertions); |
490 |
2
1. assertEquals : negated conditional → NO_COVERAGE 2. assertEquals : negated conditional → KILLED |
Object content = actualEmail == null ? null : actualEmail.getContent(); |
491 |
4
1. assertEquals : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 2. lambda$assertEquals$5 : removed call to org/junit/Assert::assertTrue → NO_COVERAGE 3. assertEquals : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED 4. lambda$assertEquals$5 : removed call to org/junit/Assert::assertTrue → KILLED |
assertions.register(() -> Assert.assertTrue("should be multipart message", content instanceof Multipart)); |
492 |
2
1. assertEquals : negated conditional → NO_COVERAGE 2. assertEquals : negated conditional → KILLED |
List<Part> bodyParts = actualEmail == null ? emptyList() : getBodyParts(actualEmail); |
493 |
4
1. assertEquals : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 2. lambda$assertEquals$6 : removed call to org/junit/Assert::assertEquals → NO_COVERAGE 3. assertEquals : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED 4. lambda$assertEquals$6 : removed call to org/junit/Assert::assertEquals → KILLED |
assertions.register(() -> Assert.assertEquals("should have " + expectedEmail.getExpectedContents().size() + " parts", expectedEmail.getExpectedContents().size(), bodyParts.size())); |
494 |
6
1. assertEquals : changed conditional boundary → NO_COVERAGE 2. assertEquals : Changed increment from 1 to -1 → NO_COVERAGE 3. assertEquals : negated conditional → NO_COVERAGE 4. assertEquals : changed conditional boundary → KILLED 5. assertEquals : Changed increment from 1 to -1 → KILLED 6. assertEquals : negated conditional → KILLED |
for (int i = 0; i < expectedEmail.getExpectedContents().size(); i++) { |
495 |
4
1. assertEquals : changed conditional boundary → NO_COVERAGE 2. assertEquals : negated conditional → NO_COVERAGE 3. assertEquals : changed conditional boundary → KILLED 4. assertEquals : negated conditional → KILLED |
Part part = i < bodyParts.size() ? bodyParts.get(i) : null; |
496 |
6
1. assertEquals : negated conditional → NO_COVERAGE 2. assertEquals : negated conditional → NO_COVERAGE 3. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertBody → NO_COVERAGE 4. assertEquals : negated conditional → KILLED 5. assertEquals : negated conditional → KILLED 6. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertBody → KILLED |
assertBody("body[" + i + "]", expectedEmail.getExpectedContents().get(i).getBody(), part == null || part.getContent() == null ? null : part.getContent().toString(), strict, assertions); |
497 |
4
1. assertEquals : negated conditional → NO_COVERAGE 2. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertMimetype → NO_COVERAGE 3. assertEquals : negated conditional → KILLED 4. assertEquals : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertMimetype → KILLED |
assertMimetype(expectedEmail.getExpectedContents().get(i), part == null ? null : part.getContentType(), assertions); |
498 | } | |
499 | } | |
500 | ||
501 | private static void assertMimetype(ExpectedContent expectedContent, String contentType, AssertionRegistry assertions) { | |
502 |
6
1. assertMimetype : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 2. lambda$assertMimetype$7 : negated conditional → NO_COVERAGE 3. lambda$assertMimetype$7 : removed call to org/junit/Assert::assertTrue → NO_COVERAGE 4. assertMimetype : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED 5. lambda$assertMimetype$7 : negated conditional → KILLED 6. lambda$assertMimetype$7 : removed call to org/junit/Assert::assertTrue → KILLED |
assertions.register(() -> Assert.assertTrue("mimetype should match " + expectedContent.getMimetype() + " instead of " + contentType, |
503 |
2
1. lambda$assertMimetype$7 : negated conditional → NO_COVERAGE 2. lambda$assertMimetype$7 : negated conditional → KILLED |
contentType != null && expectedContent.getMimetype().matcher(contentType).matches())); |
504 | } | |
505 | ||
506 | private static void assertBody(String name, String expectedBody, String actualBody, boolean strict, AssertionRegistry assertions) { | |
507 |
2
1. assertBody : negated conditional → NO_COVERAGE 2. assertBody : negated conditional → KILLED |
if (isHtml(expectedBody)) { |
508 |
2
1. assertBody : negated conditional → NO_COVERAGE 2. assertBody : negated conditional → KILLED |
if (strict) { |
509 |
4
1. assertBody : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 2. lambda$assertBody$8 : removed call to fr/sii/ogham/testing/assertion/html/AssertHtml::assertEquals → NO_COVERAGE 3. assertBody : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED 4. lambda$assertBody$8 : removed call to fr/sii/ogham/testing/assertion/html/AssertHtml::assertEquals → KILLED |
assertions.register(() -> AssertHtml.assertEquals(expectedBody, actualBody)); |
510 | } else { | |
511 |
4
1. assertBody : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 2. lambda$assertBody$9 : removed call to fr/sii/ogham/testing/assertion/html/AssertHtml::assertSimilar → NO_COVERAGE 3. assertBody : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED 4. lambda$assertBody$9 : removed call to fr/sii/ogham/testing/assertion/html/AssertHtml::assertSimilar → KILLED |
assertions.register(() -> AssertHtml.assertSimilar(expectedBody, actualBody)); |
512 | } | |
513 | } else { | |
514 |
4
1. assertBody : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 2. lambda$assertBody$10 : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::compareText → NO_COVERAGE 3. assertBody : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED 4. lambda$assertBody$10 : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::compareText → KILLED |
assertions.register(() -> compareText(name, expectedBody, actualBody, strict)); |
515 | } | |
516 | } | |
517 | ||
518 | private static void compareText(String name, String expectedBody, String actualBody, boolean strict) throws ComparisonFailure { | |
519 |
3
1. compareText : negated conditional → NO_COVERAGE 2. compareText : negated conditional → NO_COVERAGE 3. compareText : negated conditional → KILLED |
if (expectedBody == null && actualBody != null) { |
520 | throw new ComparisonFailure(name + " should be null", expectedBody, actualBody); | |
521 | } | |
522 |
2
1. compareText : negated conditional → NO_COVERAGE 2. compareText : negated conditional → KILLED |
if (expectedBody == null) { |
523 | return; | |
524 | } | |
525 |
6
1. compareText : negated conditional → NO_COVERAGE 2. compareText : negated conditional → NO_COVERAGE 3. compareText : negated conditional → NO_COVERAGE 4. compareText : negated conditional → KILLED 5. compareText : negated conditional → KILLED 6. compareText : negated conditional → KILLED |
if (strict ? !expectedBody.equals(actualBody) : !sanitize(expectedBody).equals(sanitize(actualBody))) { |
526 | throw new ComparisonFailure(name + " should be '" + expectedBody + "'", expectedBody, actualBody); | |
527 | } | |
528 | } | |
529 | ||
530 | private static void assertHeaders(ExpectedEmailHeader expectedEmail, Message actualEmail, AssertionRegistry assertions) throws MessagingException { | |
531 |
4
1. assertHeaders : negated conditional → NO_COVERAGE 2. assertHeaders : negated conditional → NO_COVERAGE 3. assertHeaders : negated conditional → KILLED 4. assertHeaders : negated conditional → KILLED |
Address[] from = actualEmail == null || actualEmail.getFrom() == null ? null : actualEmail.getFrom(); |
532 |
6
1. assertHeaders : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 2. lambda$assertHeaders$11 : negated conditional → NO_COVERAGE 3. lambda$assertHeaders$11 : removed call to org/junit/Assert::assertEquals → NO_COVERAGE 4. assertHeaders : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED 5. lambda$assertHeaders$11 : negated conditional → KILLED 6. lambda$assertHeaders$11 : removed call to org/junit/Assert::assertEquals → KILLED |
assertions.register(() -> Assert.assertEquals("subject should be '" + expectedEmail.getSubject() + "'", expectedEmail.getSubject(), actualEmail == null ? null : actualEmail.getSubject())); |
533 |
6
1. assertHeaders : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 2. lambda$assertHeaders$12 : negated conditional → NO_COVERAGE 3. lambda$assertHeaders$12 : removed call to org/junit/Assert::assertEquals → NO_COVERAGE 4. assertHeaders : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED 5. lambda$assertHeaders$12 : negated conditional → KILLED 6. lambda$assertHeaders$12 : removed call to org/junit/Assert::assertEquals → KILLED |
assertions.register(() -> Assert.assertEquals("should have only one from", (Integer) 1, from == null ? null : from.length)); |
534 |
6
1. assertHeaders : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 2. lambda$assertHeaders$13 : negated conditional → NO_COVERAGE 3. lambda$assertHeaders$13 : removed call to org/junit/Assert::assertEquals → NO_COVERAGE 4. assertHeaders : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED 5. lambda$assertHeaders$13 : negated conditional → KILLED 6. lambda$assertHeaders$13 : removed call to org/junit/Assert::assertEquals → KILLED |
assertions.register(() -> Assert.assertEquals("from should be '" + expectedEmail.getFrom() + "'", expectedEmail.getFrom(), from == null ? null : from[0].toString())); |
535 |
4
1. assertHeaders : Replaced integer addition with subtraction → NO_COVERAGE 2. assertHeaders : Replaced integer addition with subtraction → NO_COVERAGE 3. assertHeaders : Replaced integer addition with subtraction → KILLED 4. assertHeaders : Replaced integer addition with subtraction → KILLED |
int recipients = expectedEmail.getTo().size() + expectedEmail.getBcc().size() + expectedEmail.getCc().size(); |
536 |
6
1. assertHeaders : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 2. lambda$assertHeaders$14 : negated conditional → NO_COVERAGE 3. lambda$assertHeaders$14 : removed call to org/junit/Assert::assertEquals → NO_COVERAGE 4. assertHeaders : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED 5. lambda$assertHeaders$14 : negated conditional → KILLED 6. lambda$assertHeaders$14 : removed call to org/junit/Assert::assertEquals → KILLED |
assertions.register(() -> Assert.assertEquals("should be received by " + recipients + " recipients", (Integer) recipients, |
537 |
2
1. lambda$assertHeaders$14 : negated conditional → NO_COVERAGE 2. lambda$assertHeaders$14 : negated conditional → KILLED |
actualEmail == null || actualEmail.getAllRecipients() == null ? null : actualEmail.getAllRecipients().length)); |
538 |
2
1. assertHeaders : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertRecipients → NO_COVERAGE 2. assertHeaders : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertRecipients → KILLED |
assertRecipients(expectedEmail.getTo(), actualEmail, RecipientType.TO, assertions); |
539 |
2
1. assertHeaders : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertRecipients → NO_COVERAGE 2. assertHeaders : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertRecipients → KILLED |
assertRecipients(expectedEmail.getCc(), actualEmail, RecipientType.CC, assertions); |
540 |
2
1. assertHeaders : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertRecipients → NO_COVERAGE 2. assertHeaders : removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertRecipients → KILLED |
assertRecipients(expectedEmail.getBcc(), actualEmail, RecipientType.BCC, assertions); |
541 | } | |
542 | ||
543 | private static void assertRecipients(List<String> expectedRecipients, Message actualEmail, RecipientType recipientType, AssertionRegistry assertions) throws MessagingException { | |
544 |
2
1. assertRecipients : negated conditional → NO_COVERAGE 2. assertRecipients : negated conditional → KILLED |
Address[] actualRecipients = actualEmail == null ? null : actualEmail.getRecipients(recipientType); |
545 |
2
1. assertRecipients : negated conditional → NO_COVERAGE 2. assertRecipients : negated conditional → KILLED |
if (expectedRecipients.isEmpty()) { |
546 |
8
1. assertRecipients : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 2. lambda$assertRecipients$15 : negated conditional → NO_COVERAGE 3. lambda$assertRecipients$15 : negated conditional → NO_COVERAGE 4. lambda$assertRecipients$15 : removed call to org/junit/Assert::assertTrue → NO_COVERAGE 5. assertRecipients : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED 6. lambda$assertRecipients$15 : negated conditional → KILLED 7. lambda$assertRecipients$15 : negated conditional → KILLED 8. lambda$assertRecipients$15 : removed call to org/junit/Assert::assertTrue → KILLED |
assertions.register(() -> Assert.assertTrue("should be received by no recipients (of type RecipientType." + recipientType + ")", actualRecipients == null || actualRecipients.length == 0)); |
547 | } else { | |
548 |
4
1. assertRecipients : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 2. lambda$assertRecipients$16 : removed call to org/junit/Assert::assertEquals → NO_COVERAGE 3. assertRecipients : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED 4. lambda$assertRecipients$16 : removed call to org/junit/Assert::assertEquals → KILLED |
assertions.register(() -> Assert.assertEquals("should be received by " + expectedRecipients.size() + " recipients (of type RecipientType." + recipientType + ")", |
549 |
2
1. lambda$assertRecipients$16 : negated conditional → NO_COVERAGE 2. lambda$assertRecipients$16 : negated conditional → KILLED |
(Integer) expectedRecipients.size(), actualRecipients == null ? null : actualRecipients.length)); |
550 |
6
1. assertRecipients : changed conditional boundary → NO_COVERAGE 2. assertRecipients : Changed increment from 1 to -1 → NO_COVERAGE 3. assertRecipients : negated conditional → NO_COVERAGE 4. assertRecipients : Changed increment from 1 to -1 → TIMED_OUT 5. assertRecipients : changed conditional boundary → KILLED 6. assertRecipients : negated conditional → KILLED |
for (int i = 0; i < expectedRecipients.size(); i++) { |
551 | final int idx = i; | |
552 |
10
1. assertRecipients : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 2. lambda$assertRecipients$17 : changed conditional boundary → NO_COVERAGE 3. lambda$assertRecipients$17 : negated conditional → NO_COVERAGE 4. lambda$assertRecipients$17 : negated conditional → NO_COVERAGE 5. lambda$assertRecipients$17 : removed call to org/junit/Assert::assertEquals → NO_COVERAGE 6. assertRecipients : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED 7. lambda$assertRecipients$17 : changed conditional boundary → KILLED 8. lambda$assertRecipients$17 : negated conditional → KILLED 9. lambda$assertRecipients$17 : negated conditional → KILLED 10. lambda$assertRecipients$17 : removed call to org/junit/Assert::assertEquals → KILLED |
assertions.register(() -> Assert.assertEquals("recipient " + recipientType + "[" + idx + "] should be '" + expectedRecipients.get(idx) + "'", expectedRecipients.get(idx), |
553 | actualRecipients != null && idx < actualRecipients.length ? actualRecipients[idx].toString() : null)); | |
554 | } | |
555 | } | |
556 | } | |
557 | ||
558 | /** | |
559 | * Remove new lines from the string. | |
560 | * | |
561 | * @param str | |
562 | * the string to sanitize | |
563 | * @return the sanitized string | |
564 | */ | |
565 | private static String sanitize(String str) { | |
566 |
2
1. sanitize : negated conditional → NO_COVERAGE 2. sanitize : negated conditional → KILLED |
if (str == null) { |
567 |
2
1. sanitize : replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::sanitize → SURVIVED 2. sanitize : replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::sanitize → NO_COVERAGE |
return null; |
568 | } | |
569 |
2
1. sanitize : replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::sanitize → NO_COVERAGE 2. sanitize : replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::sanitize → KILLED |
return NEW_LINES.matcher(str).replaceAll(""); |
570 | } | |
571 | ||
572 | @SuppressWarnings("squid:S2147") // false positive: merging exception | |
573 | // doesn't compile in that case or we | |
574 | // are force to throw Exception instead | |
575 | // of MessagingException | |
576 | private static Part getBodyOrNull(Part actualEmail, AssertionRegistry registry) throws MessagingException { | |
577 | try { | |
578 |
2
1. getBodyOrNull : negated conditional → NO_COVERAGE 2. getBodyOrNull : negated conditional → KILLED |
if (actualEmail == null) { |
579 | return null; | |
580 | } | |
581 |
2
1. getBodyOrNull : replaced return value with null for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyOrNull → NO_COVERAGE 2. getBodyOrNull : replaced return value with null for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyOrNull → KILLED |
return EmailUtils.getBodyPart(actualEmail); |
582 | } catch (MessagingException e) { | |
583 |
1
1. getBodyOrNull : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE |
registry.register(failure(e)); |
584 | return null; | |
585 | } catch (IllegalStateException e) { | |
586 |
1
1. getBodyOrNull : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE |
registry.register(failure(e)); |
587 | return null; | |
588 | } | |
589 | } | |
590 | ||
591 | @SuppressWarnings("squid:S2147") // false positive: merging exception | |
592 | // doesn't compile in that case or we | |
593 | // are force to throw Exception instead | |
594 | // of MessagingException | |
595 | private static String getBodyContentOrNull(Part actualEmail, AssertionRegistry registry) throws MessagingException, IOException { | |
596 | try { | |
597 | Part bodyPart = getBodyOrNull(actualEmail, registry); | |
598 |
2
1. getBodyContentOrNull : negated conditional → NO_COVERAGE 2. getBodyContentOrNull : negated conditional → KILLED |
if (bodyPart == null) { |
599 |
2
1. getBodyContentOrNull : replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyContentOrNull → NO_COVERAGE 2. getBodyContentOrNull : replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyContentOrNull → KILLED |
return null; |
600 | } | |
601 |
2
1. getBodyContentOrNull : replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyContentOrNull → NO_COVERAGE 2. getBodyContentOrNull : replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyContentOrNull → KILLED |
return EmailUtils.getContent(bodyPart, UTF_8); |
602 | } catch (MessagingException e) { | |
603 |
1
1. getBodyContentOrNull : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE |
registry.register(failure(e)); |
604 |
1
1. getBodyContentOrNull : replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyContentOrNull → NO_COVERAGE |
return null; |
605 | } catch (IllegalStateException e) { | |
606 |
1
1. getBodyContentOrNull : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE |
registry.register(failure(e)); |
607 |
1
1. getBodyContentOrNull : replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyContentOrNull → NO_COVERAGE |
return null; |
608 | } catch (IOException e) { | |
609 |
1
1. getBodyContentOrNull : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE |
registry.register(failure(e)); |
610 |
1
1. getBodyContentOrNull : replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyContentOrNull → NO_COVERAGE |
return null; |
611 | } | |
612 | } | |
613 | ||
614 | private static <E extends Exception> Executable<E> failure(E exception) { | |
615 |
1
1. failure : replaced return value with null for fr/sii/ogham/testing/assertion/email/AssertEmail::failure → NO_COVERAGE |
return () -> { |
616 | throw exception; | |
617 | }; | |
618 | } | |
619 | ||
620 | @SuppressWarnings("squid:S2147") // false positive: merging exception | |
621 | // doesn't compile in that case or we | |
622 | // are force to throw Exception instead | |
623 | // of MessagingException | |
624 | private static String getBodyMimetypeOrNull(Part actualEmail, AssertionRegistry registry) throws MessagingException { | |
625 | try { | |
626 | Part bodyPart = getBodyOrNull(actualEmail, registry); | |
627 |
2
1. getBodyMimetypeOrNull : negated conditional → NO_COVERAGE 2. getBodyMimetypeOrNull : negated conditional → KILLED |
if (bodyPart == null) { |
628 |
2
1. getBodyMimetypeOrNull : replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyMimetypeOrNull → NO_COVERAGE 2. getBodyMimetypeOrNull : replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyMimetypeOrNull → KILLED |
return null; |
629 | } | |
630 |
2
1. getBodyMimetypeOrNull : replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyMimetypeOrNull → NO_COVERAGE 2. getBodyMimetypeOrNull : replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyMimetypeOrNull → KILLED |
return bodyPart.getContentType(); |
631 | } catch (MessagingException e) { | |
632 |
1
1. getBodyMimetypeOrNull : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE |
registry.register(failure(e)); |
633 |
1
1. getBodyMimetypeOrNull : replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyMimetypeOrNull → NO_COVERAGE |
return null; |
634 | } catch (IllegalStateException e) { | |
635 |
1
1. getBodyMimetypeOrNull : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE |
registry.register(failure(e)); |
636 |
1
1. getBodyMimetypeOrNull : replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyMimetypeOrNull → NO_COVERAGE |
return null; |
637 | } | |
638 | } | |
639 | ||
640 | private static boolean isHtml(String expectedBody) { | |
641 |
4
1. isHtml : replaced boolean return with false for fr/sii/ogham/testing/assertion/email/AssertEmail::isHtml → NO_COVERAGE 2. isHtml : replaced boolean return with true for fr/sii/ogham/testing/assertion/email/AssertEmail::isHtml → NO_COVERAGE 3. isHtml : replaced boolean return with false for fr/sii/ogham/testing/assertion/email/AssertEmail::isHtml → KILLED 4. isHtml : replaced boolean return with true for fr/sii/ogham/testing/assertion/email/AssertEmail::isHtml → KILLED |
return HTML_PATTERN.matcher(expectedBody).find(); |
642 | } | |
643 | ||
644 | private AssertEmail() { | |
645 | super(); | |
646 | } | |
647 | } | |
Mutations | ||
67 |
1.1 2.2 |
|
68 |
1.1 2.2 |
|
103 |
1.1 2.2 |
|
123 |
1.1 2.2 3.3 4.4 |
|
124 |
1.1 2.2 3.3 4.4 |
|
125 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
127 |
1.1 2.2 |
|
160 |
1.1 2.2 |
|
180 |
1.1 2.2 3.3 4.4 |
|
181 |
1.1 2.2 3.3 4.4 |
|
182 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
184 |
1.1 2.2 |
|
213 |
1.1 2.2 |
|
214 |
1.1 2.2 |
|
246 |
1.1 2.2 |
|
247 |
1.1 2.2 |
|
282 |
1.1 2.2 |
|
302 |
1.1 2.2 3.3 4.4 |
|
303 |
1.1 2.2 3.3 4.4 |
|
304 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
306 |
1.1 2.2 |
|
339 |
1.1 2.2 |
|
359 |
1.1 2.2 3.3 4.4 |
|
360 |
1.1 2.2 3.3 4.4 |
|
361 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
363 |
1.1 2.2 |
|
392 |
1.1 2.2 |
|
393 |
1.1 2.2 |
|
420 |
1.1 2.2 |
|
421 |
1.1 2.2 |
|
452 |
1.1 2.2 |
|
453 |
1.1 2.2 |
|
477 |
1.1 2.2 |
|
478 |
1.1 2.2 |
|
482 |
1.1 2.2 |
|
483 |
1.1 2.2 3.3 4.4 |
|
484 |
1.1 2.2 |
|
485 |
1.1 2.2 |
|
489 |
1.1 2.2 |
|
490 |
1.1 2.2 |
|
491 |
1.1 2.2 3.3 4.4 |
|
492 |
1.1 2.2 |
|
493 |
1.1 2.2 3.3 4.4 |
|
494 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
495 |
1.1 2.2 3.3 4.4 |
|
496 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
497 |
1.1 2.2 3.3 4.4 |
|
502 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
503 |
1.1 2.2 |
|
507 |
1.1 2.2 |
|
508 |
1.1 2.2 |
|
509 |
1.1 2.2 3.3 4.4 |
|
511 |
1.1 2.2 3.3 4.4 |
|
514 |
1.1 2.2 3.3 4.4 |
|
519 |
1.1 2.2 3.3 |
|
522 |
1.1 2.2 |
|
525 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
531 |
1.1 2.2 3.3 4.4 |
|
532 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
533 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
534 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
535 |
1.1 2.2 3.3 4.4 |
|
536 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
537 |
1.1 2.2 |
|
538 |
1.1 2.2 |
|
539 |
1.1 2.2 |
|
540 |
1.1 2.2 |
|
544 |
1.1 2.2 |
|
545 |
1.1 2.2 |
|
546 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
548 |
1.1 2.2 3.3 4.4 |
|
549 |
1.1 2.2 |
|
550 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
552 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 |
|
566 |
1.1 2.2 |
|
567 |
1.1 2.2 |
|
569 |
1.1 2.2 |
|
578 |
1.1 2.2 |
|
581 |
1.1 2.2 |
|
583 |
1.1 |
|
586 |
1.1 |
|
598 |
1.1 2.2 |
|
599 |
1.1 2.2 |
|
601 |
1.1 2.2 |
|
603 |
1.1 |
|
604 |
1.1 |
|
606 |
1.1 |
|
607 |
1.1 |
|
609 |
1.1 |
|
610 |
1.1 |
|
615 |
1.1 |
|
627 |
1.1 2.2 |
|
628 |
1.1 2.2 |
|
630 |
1.1 2.2 |
|
632 |
1.1 |
|
633 |
1.1 |
|
635 |
1.1 |
|
636 |
1.1 |
|
641 |
1.1 2.2 3.3 4.4 |