AssertEmail.java

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

Mutations

61

1.1
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → NO_COVERAGE

62

1.1
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE

95

1.1
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → NO_COVERAGE

113

1.1
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

2.2
Location : lambda$assertEquals$0
Killed by :
removed call to org/junit/jupiter/api/Assertions::assertEquals → NO_COVERAGE

114

1.1
Location : assertEquals
Killed by :
changed conditional boundary → NO_COVERAGE

2.2
Location : assertEquals
Killed by :
negated conditional → NO_COVERAGE

115

1.1
Location : assertEquals
Killed by :
changed conditional boundary → NO_COVERAGE

2.2
Location : assertEquals
Killed by :
negated conditional → NO_COVERAGE

3.3
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → NO_COVERAGE

117

1.1
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE

148

1.1
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → NO_COVERAGE

166

1.1
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

2.2
Location : lambda$assertEquals$1
Killed by :
removed call to org/junit/jupiter/api/Assertions::assertEquals → NO_COVERAGE

167

1.1
Location : assertEquals
Killed by :
negated conditional → NO_COVERAGE

2.2
Location : assertEquals
Killed by :
changed conditional boundary → NO_COVERAGE

168

1.1
Location : assertEquals
Killed by :
negated conditional → NO_COVERAGE

2.2
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → NO_COVERAGE

3.3
Location : assertEquals
Killed by :
changed conditional boundary → NO_COVERAGE

170

1.1
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE

197

1.1
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → NO_COVERAGE

198

1.1
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE

228

1.1
Location : assertSimilar
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → NO_COVERAGE

229

1.1
Location : assertSimilar
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE

262

1.1
Location : assertSimilar
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertSimilar → NO_COVERAGE

280

1.1
Location : assertSimilar
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

2.2
Location : lambda$assertSimilar$2
Killed by :
removed call to org/junit/jupiter/api/Assertions::assertEquals → NO_COVERAGE

281

1.1
Location : assertSimilar
Killed by :
negated conditional → NO_COVERAGE

2.2
Location : assertSimilar
Killed by :
changed conditional boundary → NO_COVERAGE

282

1.1
Location : assertSimilar
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → NO_COVERAGE

2.2
Location : assertSimilar
Killed by :
negated conditional → NO_COVERAGE

3.3
Location : assertSimilar
Killed by :
changed conditional boundary → NO_COVERAGE

284

1.1
Location : assertSimilar
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE

315

1.1
Location : assertSimilar
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertSimilar → NO_COVERAGE

333

1.1
Location : lambda$assertSimilar$3
Killed by :
removed call to org/junit/jupiter/api/Assertions::assertEquals → NO_COVERAGE

2.2
Location : assertSimilar
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

334

1.1
Location : assertSimilar
Killed by :
changed conditional boundary → NO_COVERAGE

2.2
Location : assertSimilar
Killed by :
negated conditional → NO_COVERAGE

335

1.1
Location : assertSimilar
Killed by :
changed conditional boundary → NO_COVERAGE

2.2
Location : assertSimilar
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → NO_COVERAGE

3.3
Location : assertSimilar
Killed by :
negated conditional → NO_COVERAGE

337

1.1
Location : assertSimilar
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE

364

1.1
Location : assertSimilar
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertEquals → NO_COVERAGE

365

1.1
Location : assertSimilar
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE

392

1.1
Location : assertBody
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertBody → NO_COVERAGE

393

1.1
Location : assertBody
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE

424

1.1
Location : assertHeaders
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertHeaders → NO_COVERAGE

425

1.1
Location : assertHeaders
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE

449

1.1
Location : assertRecipients
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertRecipients → NO_COVERAGE

450

1.1
Location : assertRecipients
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE

454

1.1
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertHeaders → NO_COVERAGE

455

1.1
Location : lambda$assertEquals$4
Killed by :
removed call to org/junit/jupiter/api/Assertions::assertNotNull → NO_COVERAGE

2.2
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

456

1.1
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertBody → NO_COVERAGE

457

1.1
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertMimetype → NO_COVERAGE

462

1.1
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertHeaders → NO_COVERAGE

463

1.1
Location : assertEquals
Killed by :
negated conditional → NO_COVERAGE

464

1.1
Location : lambda$assertEquals$5
Killed by :
removed call to org/junit/jupiter/api/Assertions::assertTrue → NO_COVERAGE

2.2
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

465

1.1
Location : assertEquals
Killed by :
negated conditional → NO_COVERAGE

466

1.1
Location : lambda$assertEquals$6
Killed by :
removed call to org/junit/jupiter/api/Assertions::assertEquals → NO_COVERAGE

2.2
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

467

1.1
Location : assertEquals
Killed by :
negated conditional → NO_COVERAGE

2.2
Location : assertEquals
Killed by :
changed conditional boundary → NO_COVERAGE

468

1.1
Location : assertEquals
Killed by :
changed conditional boundary → NO_COVERAGE

2.2
Location : assertEquals
Killed by :
negated conditional → NO_COVERAGE

469

1.1
Location : assertEquals
Killed by :
negated conditional → NO_COVERAGE

2.2
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertBody → NO_COVERAGE

3.3
Location : assertEquals
Killed by :
negated conditional → NO_COVERAGE

470

1.1
Location : assertEquals
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertMimetype → NO_COVERAGE

2.2
Location : assertEquals
Killed by :
negated conditional → NO_COVERAGE

478

1.1
Location : assertMimetype
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

2.2
Location : lambda$assertMimetype$7
Killed by :
removed call to org/junit/jupiter/api/Assertions::assertTrue → NO_COVERAGE

3.3
Location : lambda$assertMimetype$7
Killed by :
negated conditional → NO_COVERAGE

4.4
Location : lambda$assertMimetype$7
Killed by :
negated conditional → NO_COVERAGE

483

1.1
Location : assertBody
Killed by :
negated conditional → NO_COVERAGE

484

1.1
Location : assertBody
Killed by :
negated conditional → NO_COVERAGE

485

1.1
Location : assertBody
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

2.2
Location : lambda$assertBody$8
Killed by :
removed call to fr/sii/ogham/testing/assertion/html/AssertHtml::assertEquals → NO_COVERAGE

487

1.1
Location : lambda$assertBody$9
Killed by :
removed call to fr/sii/ogham/testing/assertion/html/AssertHtml::assertSimilar → NO_COVERAGE

2.2
Location : assertBody
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

490

1.1
Location : lambda$assertBody$10
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::compareText → NO_COVERAGE

2.2
Location : assertBody
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

495

1.1
Location : compareText
Killed by :
negated conditional → NO_COVERAGE

2.2
Location : compareText
Killed by :
negated conditional → NO_COVERAGE

496

1.1
Location : compareText
Killed by :
removed call to org/junit/jupiter/api/Assertions::assertNull → NO_COVERAGE

498

1.1
Location : compareText
Killed by :
negated conditional → NO_COVERAGE

501

1.1
Location : compareText
Killed by :
negated conditional → NO_COVERAGE

2.2
Location : compareText
Killed by :
negated conditional → NO_COVERAGE

3.3
Location : compareText
Killed by :
negated conditional → NO_COVERAGE

502

1.1
Location : compareText
Killed by :
removed call to org/junit/jupiter/api/Assertions::assertEquals → NO_COVERAGE

508

1.1
Location : assertHeaders
Killed by :
negated conditional → NO_COVERAGE

2.2
Location : assertHeaders
Killed by :
negated conditional → NO_COVERAGE

509

1.1
Location : lambda$assertHeaders$11
Killed by :
negated conditional → NO_COVERAGE

2.2
Location : lambda$assertHeaders$11
Killed by :
removed call to org/junit/jupiter/api/Assertions::assertEquals → NO_COVERAGE

3.3
Location : assertHeaders
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

510

1.1
Location : assertHeaders
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

2.2
Location : lambda$assertHeaders$12
Killed by :
negated conditional → NO_COVERAGE

3.3
Location : lambda$assertHeaders$12
Killed by :
removed call to org/junit/jupiter/api/Assertions::assertEquals → NO_COVERAGE

511

1.1
Location : lambda$assertHeaders$13
Killed by :
negated conditional → NO_COVERAGE

2.2
Location : assertHeaders
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

3.3
Location : lambda$assertHeaders$13
Killed by :
removed call to org/junit/jupiter/api/Assertions::assertEquals → NO_COVERAGE

512

1.1
Location : assertHeaders
Killed by :
Replaced integer addition with subtraction → NO_COVERAGE

2.2
Location : assertHeaders
Killed by :
Replaced integer addition with subtraction → NO_COVERAGE

513

1.1
Location : assertHeaders
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

2.2
Location : lambda$assertHeaders$14
Killed by :
removed call to org/junit/jupiter/api/Assertions::assertEquals → NO_COVERAGE

3.3
Location : lambda$assertHeaders$14
Killed by :
negated conditional → NO_COVERAGE

514

1.1
Location : lambda$assertHeaders$14
Killed by :
negated conditional → NO_COVERAGE

516

1.1
Location : assertHeaders
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertRecipients → NO_COVERAGE

517

1.1
Location : assertHeaders
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertRecipients → NO_COVERAGE

518

1.1
Location : assertHeaders
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::assertRecipients → NO_COVERAGE

526

1.1
Location : assertRecipients
Killed by :
negated conditional → NO_COVERAGE

527

1.1
Location : assertRecipients
Killed by :
negated conditional → NO_COVERAGE

528

1.1
Location : assertRecipients
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

2.2
Location : lambda$assertRecipients$15
Killed by :
negated conditional → NO_COVERAGE

3.3
Location : lambda$assertRecipients$15
Killed by :
removed call to org/junit/jupiter/api/Assertions::assertTrue → NO_COVERAGE

4.4
Location : lambda$assertRecipients$15
Killed by :
negated conditional → NO_COVERAGE

530

1.1
Location : assertRecipients
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

2.2
Location : lambda$assertRecipients$16
Killed by :
removed call to org/junit/jupiter/api/Assertions::assertEquals → NO_COVERAGE

3.3
Location : lambda$assertRecipients$16
Killed by :
negated conditional → NO_COVERAGE

531

1.1
Location : assertRecipients
Killed by :
negated conditional → NO_COVERAGE

2.2
Location : assertRecipients
Killed by :
changed conditional boundary → NO_COVERAGE

533

1.1
Location : lambda$assertRecipients$17
Killed by :
removed call to org/junit/jupiter/api/Assertions::assertEquals → NO_COVERAGE

2.2
Location : lambda$assertRecipients$17
Killed by :
negated conditional → NO_COVERAGE

3.3
Location : assertRecipients
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

4.4
Location : lambda$assertRecipients$17
Killed by :
changed conditional boundary → NO_COVERAGE

5.5
Location : lambda$assertRecipients$17
Killed by :
negated conditional → NO_COVERAGE

551

1.1
Location : sanitize
Killed by :
negated conditional → NO_COVERAGE

552

1.1
Location : sanitize
Killed by :
replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::sanitize → NO_COVERAGE

554

1.1
Location : sanitize
Killed by :
replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::sanitize → NO_COVERAGE

563

1.1
Location : getBodyOrNull
Killed by :
negated conditional → NO_COVERAGE

566

1.1
Location : getBodyOrNull
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyOrNull → NO_COVERAGE

568

1.1
Location : getBodyOrNull
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::registerAndWrap → NO_COVERAGE

2.2
Location : lambda$getBodyOrNull$18
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/email/AssertEmail::lambda$getBodyOrNull$18 → NO_COVERAGE

571

1.1
Location : getBodyOrNull
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

583

1.1
Location : getBodyContentOrNull
Killed by :
negated conditional → NO_COVERAGE

584

1.1
Location : getBodyContentOrNull
Killed by :
replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyContentOrNull → NO_COVERAGE

586

1.1
Location : getBodyContentOrNull
Killed by :
replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyContentOrNull → NO_COVERAGE

588

1.1
Location : lambda$getBodyContentOrNull$19
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/email/AssertEmail::lambda$getBodyContentOrNull$19 → NO_COVERAGE

2.2
Location : getBodyContentOrNull
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::registerAndWrap → NO_COVERAGE

589

1.1
Location : getBodyContentOrNull
Killed by :
replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyContentOrNull → NO_COVERAGE

591

1.1
Location : getBodyContentOrNull
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

592

1.1
Location : getBodyContentOrNull
Killed by :
replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyContentOrNull → NO_COVERAGE

604

1.1
Location : getBodyMimetypeOrNull
Killed by :
negated conditional → NO_COVERAGE

605

1.1
Location : getBodyMimetypeOrNull
Killed by :
replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyMimetypeOrNull → NO_COVERAGE

607

1.1
Location : getBodyMimetypeOrNull
Killed by :
replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyMimetypeOrNull → NO_COVERAGE

609

1.1
Location : getBodyMimetypeOrNull
Killed by :
removed call to fr/sii/ogham/testing/assertion/email/AssertEmail::registerAndWrap → NO_COVERAGE

2.2
Location : lambda$getBodyMimetypeOrNull$20
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/email/AssertEmail::lambda$getBodyMimetypeOrNull$20 → NO_COVERAGE

610

1.1
Location : getBodyMimetypeOrNull
Killed by :
replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyMimetypeOrNull → NO_COVERAGE

612

1.1
Location : getBodyMimetypeOrNull
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

613

1.1
Location : getBodyMimetypeOrNull
Killed by :
replaced return value with "" for fr/sii/ogham/testing/assertion/email/AssertEmail::getBodyMimetypeOrNull → NO_COVERAGE

618

1.1
Location : isHtml
Killed by :
replaced boolean return with true for fr/sii/ogham/testing/assertion/email/AssertEmail::isHtml → NO_COVERAGE

2.2
Location : isHtml
Killed by :
replaced boolean return with false for fr/sii/ogham/testing/assertion/email/AssertEmail::isHtml → NO_COVERAGE

622

1.1
Location : failure
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/email/AssertEmail::failure → NO_COVERAGE

629

1.1
Location : registerAndWrap
Killed by :
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.13.1