OghamAssertions.java

1
package fr.sii.ogham.testing.assertion;
2
3
import fr.sii.ogham.testing.assertion.email.FluentEmailsAssert;
4
import fr.sii.ogham.testing.assertion.email.FluentReceivedEmailsAssert;
5
import fr.sii.ogham.testing.assertion.sms.FluentReceivedSmsAssert;
6
import fr.sii.ogham.testing.assertion.sms.FluentSmsListAssert;
7
import fr.sii.ogham.testing.assertion.util.AssertionRegistry;
8
import fr.sii.ogham.testing.assertion.util.FailAtEndRegistry;
9
import fr.sii.ogham.testing.assertion.util.FailImmediatelyRegistry;
10
import fr.sii.ogham.testing.extension.junit.sms.SmppServerExtension;
11
import fr.sii.ogham.testing.extension.junit.sms.SmppServerRule;
12
import fr.sii.ogham.testing.sms.simulator.SmppServerSimulator;
13
import fr.sii.ogham.testing.sms.simulator.bean.SubmitSm;
14
import fr.sii.ogham.testing.sms.simulator.jsmpp.SubmitSmAdapter;
15
import ogham.testing.com.icegreen.greenmail.junit4.GreenMailRule;
16
import ogham.testing.com.icegreen.greenmail.junit5.GreenMailExtension;
17
import ogham.testing.com.icegreen.greenmail.util.GreenMail;
18
import ogham.testing.jakarta.mail.internet.MimeMessage;
19
20
import java.util.List;
21
import java.util.function.Consumer;
22
import java.util.stream.Collectors;
23
24
import static java.util.Arrays.asList;
25
26
/**
27
 * Utility class that helps writing message assertions. For emails, you can
28
 * write something like this:
29
 * 
30
 * <pre>
31
 * {@code
32
 * assertThat(greenMail)
33
 *   .receivedMessages()
34
 *     .count(is(1))
35
 *       .message(0)
36
 *         .subject(is("Test"))
37
 *         .from()
38
 *           .address(hasItems("test.sender@sii.fr"))
39
 *           .and()
40
 *         .to()
41
 *           .address(hasItems("recipient@sii.fr"))
42
 *         .and()
43
 *       .body()
44
 * 		   .contentAsString(is("body"))
45
 *         .contentType(startsWith("text/plain"))
46
 *         .and()
47
 *       .alternative(nullValue())
48
 *       .attachments(hasSize(1))
49
 *         .attachment("04-Java-OOP-Basics.pdf")
50
 * 		     .content(is(resource("/attachment/04-Java-OOP-Basics.pdf")))
51
 *           .contentType(startsWith("application/pdf"))
52
 *           .filename(is("04-Java-OOP-Basics.pdf"))
53
 *           .disposition(is(ATTACHMENT_DISPOSITION));
54
 * }
55
 * </pre>
56
 * 
57
 * For sms, you can write something like this:
58
 * 
59
 * <pre>
60
 * {@code
61
 * assertThat(smppServer)
62
 *   .receivedMessages()
63
 *     .count(is(1))
64
 *       .message(0)
65
 *         .content(is("sms content"))
66
 *         .from()
67
 *           .number(is(INTERNATIONAL_PHONE_NUMBER))
68
 *           .typeOfNumber(is(TypeOfNumber.INTERNATIONAL))
69
 * 		     .numberPlanIndicator(is(NumberingPlanIndicator.ISDN))
70
 *           .and()
71
 *         .to()
72
 *           .number(is(NATIONAL_PHONE_NUMBER))
73
 *           .typeOfNumber(is(TypeOfNumber.UNKNOWN))
74
 * 		     .numberPlanIndicator(is(NumberingPlanIndicator.ISDN));
75
 * }
76
 * </pre>
77
 * 
78
 * 
79
 * @author Aurélien Baudet
80
 *
81
 */
82
public final class OghamAssertions {
83
84
	/**
85
	 * Helper method to write assertions on mails using fluent API. For example:
86
	 * 
87
	 * <pre>
88
	 * {@code
89
	 * assertThat(greenMail).receivedMessages()
90
	 *   .count(is(1))
91
	 *   .message(0)
92
	 *     .subject(is("Test"))
93
	 *     .from().address(hasItems("test.sender@sii.fr")).and()
94
	 *     .to().address(hasItems("recipient@sii.fr")).and()
95
	 *   .body()
96
	 *      .contentAsString(is("body"))
97
	 *      .contentType(startsWith("text/plain")).and()
98
	 *   .alternative(nullValue())
99
	 *   .attachments(hasSize(1))
100
	 *   .attachment("04-Java-OOP-Basics.pdf")
101
	 *      .content(is(resource("/attachment/04-Java-OOP-Basics.pdf")))
102
	 *      .contentType(startsWith("application/pdf"))
103
	 *      .filename(is("04-Java-OOP-Basics.pdf"))
104
	 *      .disposition(is(ATTACHMENT_DISPOSITION));
105
	 * }
106
	 * </pre>
107
	 * 
108
	 * @param greenMail
109
	 *            email server that stores received messages
110
	 * @return builder for fluent assertions on received messages
111
	 */
112
	public static FluentReceivedEmailsAssert assertThat(GreenMailExtension greenMail) {
113 1 1. assertThat : replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE
		return assertThat(greenMail, new FailImmediatelyRegistry());
114
	}
115
116
	/**
117
	 * Helper method to write assertions on mails using fluent API. For example:
118
	 * 
119
	 * <pre>
120
	 * {@code
121
	 * assertAll(registry -> 
122
	 *   assertThat(greenMail, registry).receivedMessages()
123
	 *     .count(is(1))
124
	 *     .message(0)
125
	 *       .subject(is("Test"))
126
	 *       .from().address(hasItems("test.sender@sii.fr")).and()
127
	 *       .to().address(hasItems("recipient@sii.fr")).and()
128
	 *     .body()
129
	 *        .contentAsString(is("body"))
130
	 *        .contentType(startsWith("text/plain")).and()
131
	 *     .alternative(nullValue())
132
	 *     .attachments(hasSize(1))
133
	 *     .attachment("04-Java-OOP-Basics.pdf")
134
	 *        .content(is(resource("/attachment/04-Java-OOP-Basics.pdf")))
135
	 *        .contentType(startsWith("application/pdf"))
136
	 *        .filename(is("04-Java-OOP-Basics.pdf"))
137
	 *        .disposition(is(ATTACHMENT_DISPOSITION)));
138
	 * }
139
	 * </pre>
140
	 * 
141
	 * <p>
142
	 * This method is used in combination of {@link #assertAll(Consumer...)} in
143
	 * order to report all exceptions/assertion failures at the end instead of
144
	 * stopping at the first failure.
145
	 * 
146
	 * @param greenMail
147
	 *            email server that stores received messages
148
	 * @param registry
149
	 *            the registry used to register assertions
150
	 * @return builder for fluent assertions on received messages
151
	 */
152
	public static FluentReceivedEmailsAssert assertThat(GreenMailExtension greenMail, AssertionRegistry registry) {
153 1 1. assertThat : replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE
		return new FluentReceivedEmailsAssert(asList(greenMail.getReceivedMessages()), registry);
154
	}
155
156
157
	/**
158
	 * Helper method to write assertions on mails using fluent API. For example:
159
	 *
160
	 * <pre>
161
	 * {@code
162
	 * assertThat(greenMail).receivedMessages()
163
	 *   .count(is(1))
164
	 *   .message(0)
165
	 *     .subject(is("Test"))
166
	 *     .from().address(hasItems("test.sender@sii.fr")).and()
167
	 *     .to().address(hasItems("recipient@sii.fr")).and()
168
	 *   .body()
169
	 *      .contentAsString(is("body"))
170
	 *      .contentType(startsWith("text/plain")).and()
171
	 *   .alternative(nullValue())
172
	 *   .attachments(hasSize(1))
173
	 *   .attachment("04-Java-OOP-Basics.pdf")
174
	 *      .content(is(resource("/attachment/04-Java-OOP-Basics.pdf")))
175
	 *      .contentType(startsWith("application/pdf"))
176
	 *      .filename(is("04-Java-OOP-Basics.pdf"))
177
	 *      .disposition(is(ATTACHMENT_DISPOSITION));
178
	 * }
179
	 * </pre>
180
	 *
181
	 * @param greenMail
182
	 *            email server that stores received messages
183
	 * @return builder for fluent assertions on received messages
184
	 */
185
	public static FluentReceivedEmailsAssert assertThat(GreenMailRule greenMail) {
186 1 1. assertThat : replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE
		return assertThat(greenMail, new FailImmediatelyRegistry());
187
	}
188
189
	/**
190
	 * Helper method to write assertions on mails using fluent API. For example:
191
	 *
192
	 * <pre>
193
	 * {@code
194
	 * assertAll(registry ->
195
	 *   assertThat(greenMail, registry).receivedMessages()
196
	 *     .count(is(1))
197
	 *     .message(0)
198
	 *       .subject(is("Test"))
199
	 *       .from().address(hasItems("test.sender@sii.fr")).and()
200
	 *       .to().address(hasItems("recipient@sii.fr")).and()
201
	 *     .body()
202
	 *        .contentAsString(is("body"))
203
	 *        .contentType(startsWith("text/plain")).and()
204
	 *     .alternative(nullValue())
205
	 *     .attachments(hasSize(1))
206
	 *     .attachment("04-Java-OOP-Basics.pdf")
207
	 *        .content(is(resource("/attachment/04-Java-OOP-Basics.pdf")))
208
	 *        .contentType(startsWith("application/pdf"))
209
	 *        .filename(is("04-Java-OOP-Basics.pdf"))
210
	 *        .disposition(is(ATTACHMENT_DISPOSITION)));
211
	 * }
212
	 * </pre>
213
	 *
214
	 * <p>
215
	 * This method is used in combination of {@link #assertAll(Consumer...)} in
216
	 * order to report all exceptions/assertion failures at the end instead of
217
	 * stopping at the first failure.
218
	 *
219
	 * @param greenMail
220
	 *            email server that stores received messages
221
	 * @param registry
222
	 *            the registry used to register assertions
223
	 * @return builder for fluent assertions on received messages
224
	 */
225
	public static FluentReceivedEmailsAssert assertThat(GreenMailRule greenMail, AssertionRegistry registry) {
226 1 1. assertThat : replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE
		return new FluentReceivedEmailsAssert(asList(greenMail.getReceivedMessages()), registry);
227
	}
228
229
	/**
230
	 * Helper method to write assertions on mails using fluent API. For example:
231
	 *
232
	 * <pre>
233
	 * {@code
234
	 * assertThat(greenMail).receivedMessages()
235
	 *   .count(is(1))
236
	 *   .message(0)
237
	 *     .subject(is("Test"))
238
	 *     .from().address(hasItems("test.sender@sii.fr")).and()
239
	 *     .to().address(hasItems("recipient@sii.fr")).and()
240
	 *   .body()
241
	 *      .contentAsString(is("body"))
242
	 *      .contentType(startsWith("text/plain")).and()
243
	 *   .alternative(nullValue())
244
	 *   .attachments(hasSize(1))
245
	 *   .attachment("04-Java-OOP-Basics.pdf")
246
	 *      .content(is(resource("/attachment/04-Java-OOP-Basics.pdf")))
247
	 *      .contentType(startsWith("application/pdf"))
248
	 *      .filename(is("04-Java-OOP-Basics.pdf"))
249
	 *      .disposition(is(ATTACHMENT_DISPOSITION));
250
	 * }
251
	 * </pre>
252
	 *
253
	 * @param greenMail
254
	 *            email server that stores received messages
255
	 * @return builder for fluent assertions on received messages
256
	 */
257
	public static FluentReceivedEmailsAssert assertThat(GreenMail greenMail) {
258 1 1. assertThat : replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE
		return assertThat(greenMail, new FailImmediatelyRegistry());
259
	}
260
261
	/**
262
	 * Helper method to write assertions on mails using fluent API. For example:
263
	 *
264
	 * <pre>
265
	 * {@code
266
	 * assertAll(registry ->
267
	 *   assertThat(greenMail, registry).receivedMessages()
268
	 *     .count(is(1))
269
	 *     .message(0)
270
	 *       .subject(is("Test"))
271
	 *       .from().address(hasItems("test.sender@sii.fr")).and()
272
	 *       .to().address(hasItems("recipient@sii.fr")).and()
273
	 *     .body()
274
	 *        .contentAsString(is("body"))
275
	 *        .contentType(startsWith("text/plain")).and()
276
	 *     .alternative(nullValue())
277
	 *     .attachments(hasSize(1))
278
	 *     .attachment("04-Java-OOP-Basics.pdf")
279
	 *        .content(is(resource("/attachment/04-Java-OOP-Basics.pdf")))
280
	 *        .contentType(startsWith("application/pdf"))
281
	 *        .filename(is("04-Java-OOP-Basics.pdf"))
282
	 *        .disposition(is(ATTACHMENT_DISPOSITION)));
283
	 * }
284
	 * </pre>
285
	 *
286
	 * <p>
287
	 * This method is used in combination of {@link #assertAll(Consumer...)} in
288
	 * order to report all exceptions/assertion failures at the end instead of
289
	 * stopping at the first failure.
290
	 *
291
	 * @param greenMail
292
	 *            email server that stores received messages
293
	 * @param registry
294
	 *            the registry used to register assertions
295
	 * @return builder for fluent assertions on received messages
296
	 */
297
	public static FluentReceivedEmailsAssert assertThat(GreenMail greenMail, AssertionRegistry registry) {
298 1 1. assertThat : replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE
		return new FluentReceivedEmailsAssert(asList(greenMail.getReceivedMessages()), registry);
299
	}
300
301
	/**
302
	 * Helper method to write assertions on mails using fluent API. For example:
303
	 * 
304
	 * <pre>
305
	 * {@code
306
	 * assertThat(greenMail.getReceivedMessages())
307
	 *   .count(is(1))
308
	 *   .message(0)
309
	 *     .subject(is("Test"))
310
	 *     .from().address(hasItems("test.sender@sii.fr")).and()
311
	 *     .to().address(hasItems("recipient@sii.fr")).and()
312
	 *   .body()
313
	 *      .contentAsString(is("body"))
314
	 *      .contentType(startsWith("text/plain")).and()
315
	 *   .alternative(nullValue())
316
	 *   .attachments(hasSize(1))
317
	 *   .attachment("04-Java-OOP-Basics.pdf")
318
	 *      .content(is(resource("/attachment/04-Java-OOP-Basics.pdf")))
319
	 *      .contentType(startsWith("application/pdf"))
320
	 *      .filename(is("04-Java-OOP-Basics.pdf"))
321
	 *      .disposition(is(ATTACHMENT_DISPOSITION));
322
	 * }
323
	 * </pre>
324
	 * 
325
	 * @param receivedEmails
326
	 *            list of messages received by the email server
327
	 * @return builder for fluent assertions on received messages
328
	 */
329
	public static FluentEmailsAssert<Void> assertThat(MimeMessage[] receivedEmails) {
330 1 1. assertThat : replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE
		return assertThat(receivedEmails, new FailImmediatelyRegistry());
331
	}
332
333
	/**
334
	 * Helper method to write assertions on mails using fluent API. For example:
335
	 * 
336
	 * <pre>
337
	 * {@code
338
	 * assertAll(registry -> 
339
	 *   assertThat(greenMail.getReceivedMessages(), registry)
340
	 *     .count(is(1))
341
	 *     .message(0)
342
	 *       .subject(is("Test"))
343
	 *       .from().address(hasItems("test.sender@sii.fr")).and()
344
	 *       .to().address(hasItems("recipient@sii.fr")).and()
345
	 *     .body()
346
	 *        .contentAsString(is("body"))
347
	 *        .contentType(startsWith("text/plain")).and()
348
	 *     .alternative(nullValue())
349
	 *     .attachments(hasSize(1))
350
	 *     .attachment("04-Java-OOP-Basics.pdf")
351
	 *        .content(is(resource("/attachment/04-Java-OOP-Basics.pdf")))
352
	 *        .contentType(startsWith("application/pdf"))
353
	 *        .filename(is("04-Java-OOP-Basics.pdf"))
354
	 *        .disposition(is(ATTACHMENT_DISPOSITION)));
355
	 * }
356
	 * </pre>
357
	 * 
358
	 * <p>
359
	 * This method is used in combination of {@link #assertAll(Consumer...)} in
360
	 * order to report all exceptions/assertion failures at the end instead of
361
	 * stopping at the first failure.
362
	 * 
363
	 * @param receivedEmails
364
	 *            list of messages received by the email server
365
	 * @param registry
366
	 *            the registry used to register assertions
367
	 * @return builder for fluent assertions on received messages
368
	 */
369
	public static FluentEmailsAssert<Void> assertThat(MimeMessage[] receivedEmails, AssertionRegistry registry) {
370 1 1. assertThat : replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE
		return new FluentEmailsAssert<>(asList(receivedEmails), null, registry);
371
	}
372
373
	/**
374
	 * Helper method to write assertions on sms using fluent API. For example:
375
	 * 
376
	 * <pre>
377
	 * {@code
378
	 * assertThat(smppServer).receivedMessages()
379
	 *   .count(is(1))
380
	 *   .message(0)
381
	 *     .content(is("sms content"))
382
	 *     .from()
383
	 *       .number(is(INTERNATIONAL_PHONE_NUMBER))
384
	 *       .typeOfNumber(is(TypeOfNumber.INTERNATIONAL))
385
	 *       .numberPlanIndicator(is(NumberingPlanIndicator.ISDN)).and()
386
	 *     .to()
387
	 *       .number(is(NATIONAL_PHONE_NUMBER))
388
	 *       .typeOfNumber(is(TypeOfNumber.UNKNOWN))
389
	 *       .numberPlanIndicator(is(NumberingPlanIndicator.ISDN));
390
	 * }
391
	 * </pre>
392
	 * 
393
	 * @param smsServer
394
	 *            SMS server that stores received messages
395
	 * @param <M>
396
	 *            the type of messages handled by the server
397
	 * @return builder for fluent assertions on received messages
398
	 */
399
	public static <M> FluentReceivedSmsAssert<SubmitSm> assertThat(SmppServerExtension<M> smsServer) {
400 1 1. assertThat : replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE
		return assertThat(smsServer, new FailImmediatelyRegistry());
401
	}
402
403
404
	/**
405
	 * Helper method to write assertions on sms using fluent API. For example:
406
	 * 
407
	 * <pre>
408
	 * {@code
409
	 * assertAll(registry ->
410
	 *   assertThat(smppServer, registry).receivedMessages()
411
	 *     .count(is(1))
412
	 *     .message(0)
413
	 *       .content(is("sms content"))
414
	 *       .from()
415
	 *         .number(is(INTERNATIONAL_PHONE_NUMBER))
416
	 *         .typeOfNumber(is(TypeOfNumber.INTERNATIONAL))
417
	 *         .numberPlanIndicator(is(NumberingPlanIndicator.ISDN)).and()
418
	 *       .to()
419
	 *         .number(is(NATIONAL_PHONE_NUMBER))
420
	 *         .typeOfNumber(is(TypeOfNumber.UNKNOWN))
421
	 *         .numberPlanIndicator(is(NumberingPlanIndicator.ISDN)));
422
	 * }
423
	 * </pre>
424
	 * 
425
	 * <p>
426
	 * This method is used in combination of {@link #assertAll(Consumer...)} in
427
	 * order to report all exceptions/assertion failures at the end instead of
428
	 * stopping at the first failure.
429
	 * 
430
	 * @param smsServer
431
	 *            SMS server that stores received messages
432
	 * @param registry
433
	 *            the registry used to register assertions
434
	 * @param <M>
435
	 *            the type of messages handled by the server
436
	 * @return builder for fluent assertions on received messages
437
	 */
438
	public static <M> FluentReceivedSmsAssert<SubmitSm> assertThat(SmppServerExtension<M> smsServer, AssertionRegistry registry) {
439 1 1. assertThat : replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE
		return new FluentReceivedSmsAssert<>(smsServer.getReceivedMessages(), registry);
440
	}
441
442
	/**
443
	 * Helper method to write assertions on sms using fluent API. For example:
444
	 *
445
	 * <pre>
446
	 * {@code
447
	 * assertThat(smppServer).receivedMessages()
448
	 *   .count(is(1))
449
	 *   .message(0)
450
	 *     .content(is("sms content"))
451
	 *     .from()
452
	 *       .number(is(INTERNATIONAL_PHONE_NUMBER))
453
	 *       .typeOfNumber(is(TypeOfNumber.INTERNATIONAL))
454
	 *       .numberPlanIndicator(is(NumberingPlanIndicator.ISDN)).and()
455
	 *     .to()
456
	 *       .number(is(NATIONAL_PHONE_NUMBER))
457
	 *       .typeOfNumber(is(TypeOfNumber.UNKNOWN))
458
	 *       .numberPlanIndicator(is(NumberingPlanIndicator.ISDN));
459
	 * }
460
	 * </pre>
461
	 *
462
	 * @param smsServer
463
	 *            SMS server that stores received messages
464
	 * @param <M>
465
	 *            the type of messages handled by the server
466
	 * @return builder for fluent assertions on received messages
467
	 */
468
	public static <M> FluentReceivedSmsAssert<SubmitSm> assertThat(SmppServerRule<M> smsServer) {
469 1 1. assertThat : replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE
		return assertThat(smsServer, new FailImmediatelyRegistry());
470
	}
471
472
	/**
473
	 * Helper method to write assertions on sms using fluent API. For example:
474
	 *
475
	 * <pre>
476
	 * {@code
477
	 * assertAll(registry ->
478
	 *   assertThat(smppServer, registry).receivedMessages()
479
	 *     .count(is(1))
480
	 *     .message(0)
481
	 *       .content(is("sms content"))
482
	 *       .from()
483
	 *         .number(is(INTERNATIONAL_PHONE_NUMBER))
484
	 *         .typeOfNumber(is(TypeOfNumber.INTERNATIONAL))
485
	 *         .numberPlanIndicator(is(NumberingPlanIndicator.ISDN)).and()
486
	 *       .to()
487
	 *         .number(is(NATIONAL_PHONE_NUMBER))
488
	 *         .typeOfNumber(is(TypeOfNumber.UNKNOWN))
489
	 *         .numberPlanIndicator(is(NumberingPlanIndicator.ISDN)));
490
	 * }
491
	 * </pre>
492
	 *
493
	 * <p>
494
	 * This method is used in combination of {@link #assertAll(Consumer...)} in
495
	 * order to report all exceptions/assertion failures at the end instead of
496
	 * stopping at the first failure.
497
	 *
498
	 * @param smsServer
499
	 *            SMS server that stores received messages
500
	 * @param registry
501
	 *            the registry used to register assertions
502
	 * @param <M>
503
	 *            the type of messages handled by the server
504
	 * @return builder for fluent assertions on received messages
505
	 */
506
	public static <M> FluentReceivedSmsAssert<SubmitSm> assertThat(SmppServerRule<M> smsServer, AssertionRegistry registry) {
507 1 1. assertThat : replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE
		return new FluentReceivedSmsAssert<>(smsServer.getReceivedMessages(), registry);
508
	}
509
510
	/**
511
	 * Helper method to write assertions on sms using fluent API. For example:
512
	 *
513
	 * <pre>
514
	 * {@code
515
	 * assertThat(smppServer).receivedMessages()
516
	 *   .count(is(1))
517
	 *   .message(0)
518
	 *     .content(is("sms content"))
519
	 *     .from()
520
	 *       .number(is(INTERNATIONAL_PHONE_NUMBER))
521
	 *       .typeOfNumber(is(TypeOfNumber.INTERNATIONAL))
522
	 *       .numberPlanIndicator(is(NumberingPlanIndicator.ISDN)).and()
523
	 *     .to()
524
	 *       .number(is(NATIONAL_PHONE_NUMBER))
525
	 *       .typeOfNumber(is(TypeOfNumber.UNKNOWN))
526
	 *       .numberPlanIndicator(is(NumberingPlanIndicator.ISDN));
527
	 * }
528
	 * </pre>
529
	 *
530
	 * @param smsServer
531
	 *            SMS server that stores received messages
532
	 * @return builder for fluent assertions on received messages
533
	 */
534
	public static FluentReceivedSmsAssert<SubmitSm> assertThat(SmppServerSimulator<ogham.testing.org.jsmpp.bean.SubmitSm> smsServer) {
535 1 1. assertThat : replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE
		return assertThat(smsServer, new FailImmediatelyRegistry());
536
	}
537
538
539
	/**
540
	 * Helper method to write assertions on sms using fluent API. For example:
541
	 *
542
	 * <pre>
543
	 * {@code
544
	 * assertAll(registry ->
545
	 *   assertThat(smppServer, registry).receivedMessages()
546
	 *     .count(is(1))
547
	 *     .message(0)
548
	 *       .content(is("sms content"))
549
	 *       .from()
550
	 *         .number(is(INTERNATIONAL_PHONE_NUMBER))
551
	 *         .typeOfNumber(is(TypeOfNumber.INTERNATIONAL))
552
	 *         .numberPlanIndicator(is(NumberingPlanIndicator.ISDN)).and()
553
	 *       .to()
554
	 *         .number(is(NATIONAL_PHONE_NUMBER))
555
	 *         .typeOfNumber(is(TypeOfNumber.UNKNOWN))
556
	 *         .numberPlanIndicator(is(NumberingPlanIndicator.ISDN)));
557
	 * }
558
	 * </pre>
559
	 *
560
	 * <p>
561
	 * This method is used in combination of {@link #assertAll(Consumer...)} in
562
	 * order to report all exceptions/assertion failures at the end instead of
563
	 * stopping at the first failure.
564
	 *
565
	 * @param smsServer
566
	 *            SMS server that stores received messages
567
	 * @param registry
568
	 *            the registry used to register assertions
569
	 * @return builder for fluent assertions on received messages
570
	 */
571
	public static FluentReceivedSmsAssert<SubmitSm> assertThat(SmppServerSimulator<ogham.testing.org.jsmpp.bean.SubmitSm> smsServer, AssertionRegistry registry) {
572
		List<SubmitSm> receivedMessages = smsServer.getReceivedMessages().stream()
573
				.map(SubmitSmAdapter::new)
574
				.collect(Collectors.toList());
575 1 1. assertThat : replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE
		return new FluentReceivedSmsAssert<>(receivedMessages, registry);
576
	}
577
578
	/**
579
	 * Helper method to write assertions on sms using fluent API. For example:
580
	 * 
581
	 * <pre>
582
	 * {@code
583
	 * assertThat(smppServer.getReceivedMessages())
584
	 *   .count(is(1))
585
	 *   .message(0)
586
	 *     .content(is("sms content"))
587
	 *     .from()
588
	 *       .number(is(INTERNATIONAL_PHONE_NUMBER))
589
	 *       .typeOfNumber(is(TypeOfNumber.INTERNATIONAL))
590
	 *       .numberPlanIndicator(is(NumberingPlanIndicator.ISDN)).and()
591
	 *     .to()
592
	 *       .number(is(NATIONAL_PHONE_NUMBER))
593
	 *       .typeOfNumber(is(TypeOfNumber.UNKNOWN))
594
	 *       .numberPlanIndicator(is(NumberingPlanIndicator.ISDN));
595
	 * }
596
	 * </pre>
597
	 * 
598
	 * @param receivedSms
599
	 *            The list of messages received by the SMS server
600
	 * @return builder for fluent assertions on received messages
601
	 */
602
	public static FluentSmsListAssert<Void, SubmitSm> assertThat(List<SubmitSm> receivedSms) {
603 1 1. assertThat : replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE
		return assertThat(receivedSms, new FailImmediatelyRegistry());
604
	}
605
606
	/**
607
	 * Helper method to write assertions on sms using fluent API. For example:
608
	 * 
609
	 * <pre>
610
	 * {@code
611
	 * assertAll(registry ->
612
	 *   assertThat(smppServer.getReceivedMessages(), registry)
613
	 *     .count(is(1))
614
	 *     .message(0)
615
	 *       .content(is("sms content"))
616
	 *       .from()
617
	 *         .number(is(INTERNATIONAL_PHONE_NUMBER))
618
	 *         .typeOfNumber(is(TypeOfNumber.INTERNATIONAL))
619
	 *         .numberPlanIndicator(is(NumberingPlanIndicator.ISDN)).and()
620
	 *       .to()
621
	 *         .number(is(NATIONAL_PHONE_NUMBER))
622
	 *         .typeOfNumber(is(TypeOfNumber.UNKNOWN))
623
	 *         .numberPlanIndicator(is(NumberingPlanIndicator.ISDN)));
624
	 * }
625
	 * </pre>
626
	 * 
627
	 * <p>
628
	 * This method is used in combination of {@link #assertAll(Consumer...)} in
629
	 * order to report all exceptions/assertion failures at the end instead of
630
	 * stopping at the first failure.
631
	 * 
632
	 * @param receivedSms
633
	 *            The list of messages received by the SMS server
634
	 * @param registry
635
	 *            the registry used to register assertions
636
	 * @return builder for fluent assertions on received messages
637
	 */
638
	public static FluentSmsListAssert<Void, SubmitSm> assertThat(List<SubmitSm> receivedSms, AssertionRegistry registry) {
639 1 1. assertThat : replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE
		return new FluentSmsListAssert<>(receivedSms, null, registry);
640
	}
641
642
	/**
643
	 * Register all assertions in order to report all failures/failed assertions
644
	 * at once instead of reporting error one by one.
645
	 * 
646
	 * <pre>
647
	 * {@code
648
	 * assertAll(registry -> 
649
	 *   assertThat(smppServer.getReceivedMessages(), registry)
650
	 *     .count(is(1))
651
	 *     .message(0)
652
	 *       .content(is("sms content"))
653
	 *       .from()
654
	 *         .number(is(INTERNATIONAL_PHONE_NUMBER))
655
	 *         .typeOfNumber(is(TypeOfNumber.INTERNATIONAL))
656
	 *         .numberPlanIndicator(is(NumberingPlanIndicator.ISDN)).and()
657
	 *       .to()
658
	 *         .number(is(NATIONAL_PHONE_NUMBER))
659
	 *         .typeOfNumber(is(TypeOfNumber.UNKNOWN))
660
	 *         .numberPlanIndicator(is(NumberingPlanIndicator.ISDN)));
661
	 * }
662
	 * </pre>
663
	 * 
664
	 * 
665
	 * @param executables
666
	 *            the list of functions to register
667
	 */
668
	@SafeVarargs
669
	public static void assertAll(Consumer<AssertionRegistry>... executables) {
670
		AssertionRegistry registry = new FailAtEndRegistry();
671
		for (Consumer<AssertionRegistry> executable : executables) {
672 1 1. assertAll : removed call to java/util/function/Consumer::accept → NO_COVERAGE
			executable.accept(registry);
673
		}
674 1 1. assertAll : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::execute → NO_COVERAGE
		registry.execute();
675
	}
676
677
	private OghamAssertions() {
678
		super();
679
	}
680
681
}

Mutations

113

1.1
Location : assertThat
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE

153

1.1
Location : assertThat
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE

186

1.1
Location : assertThat
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE

226

1.1
Location : assertThat
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE

258

1.1
Location : assertThat
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE

298

1.1
Location : assertThat
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE

330

1.1
Location : assertThat
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE

370

1.1
Location : assertThat
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE

400

1.1
Location : assertThat
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE

439

1.1
Location : assertThat
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE

469

1.1
Location : assertThat
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE

507

1.1
Location : assertThat
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE

535

1.1
Location : assertThat
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE

575

1.1
Location : assertThat
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE

603

1.1
Location : assertThat
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE

639

1.1
Location : assertThat
Killed by :
replaced return value with null for fr/sii/ogham/testing/assertion/OghamAssertions::assertThat → NO_COVERAGE

672

1.1
Location : assertAll
Killed by :
removed call to java/util/function/Consumer::accept → NO_COVERAGE

674

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

Active mutators

Tests examined


Report generated by PIT 1.13.1