| 1 | package fr.sii.ogham.testing.assertion.email; | |
| 2 | ||
| 3 | import static fr.sii.ogham.testing.assertion.util.AssertionHelper.assertThat; | |
| 4 | import static fr.sii.ogham.testing.assertion.util.AssertionHelper.overrideDescription; | |
| 5 | import static org.hamcrest.Matchers.lessThan; | |
| 6 | ||
| 7 | import java.util.List; | |
| 8 | ||
| 9 | import javax.mail.Message; | |
| 10 | ||
| 11 | import org.hamcrest.Matcher; | |
| 12 | ||
| 13 | import fr.sii.ogham.testing.assertion.util.AssertionRegistry; | |
| 14 | import fr.sii.ogham.testing.util.HasParent; | |
| 15 | ||
| 16 | public class FluentEmailsAssert<P> extends HasParent<P> { | |
| 17 | /** | |
| 18 | * The list of messages that will be used for assertions | |
| 19 | */ | |
| 20 | private final List<? extends Message> actual; | |
| 21 | /** | |
| 22 | * Registry to register assertions | |
| 23 | */ | |
| 24 | private final AssertionRegistry registry; | |
| 25 | ||
| 26 | ||
| 27 | public FluentEmailsAssert(List<? extends Message> actual, P parent, AssertionRegistry registry) { | |
| 28 | super(parent); | |
| 29 | this.actual = actual; | |
| 30 | this.registry = registry; | |
| 31 | } | |
| 32 | ||
| 33 | /** | |
| 34 | * Assertion on the number of received messages: | |
| 35 | * | |
| 36 | * <pre> | |
| 37 | * .count(is(1)) | |
| 38 | * </pre> | |
| 39 | * | |
| 40 | * @param matcher | |
| 41 | * the assertion applied on the number of received messages | |
| 42 | * @return the fluent API for chaining assertions on received messages | |
| 43 | */ | |
| 44 | public FluentEmailsAssert<P> count(Matcher<Integer> matcher) { | |
| 45 |
8
1. count : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → SURVIVED 2. count : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 3. lambda$count$0 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → NO_COVERAGE 4. lambda$count$0 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → SURVIVED 5. count : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → TIMED_OUT 6. lambda$count$0 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → TIMED_OUT 7. count : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED 8. lambda$count$0 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → KILLED |
registry.register(() -> assertThat("Received messages count", actual.size(), matcher)); |
| 46 |
5
1. count : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentEmailsAssert::count → SURVIVED 2. count : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentEmailsAssert::count → NO_COVERAGE 3. count : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentEmailsAssert::count → TIMED_OUT 4. count : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentEmailsAssert::count → KILLED 5. count : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentEmailsAssert::count → KILLED |
return this; |
| 47 | } | |
| 48 | ||
| 49 | /** | |
| 50 | * Access a particular message to write assertions for it: | |
| 51 | * | |
| 52 | * <pre> | |
| 53 | * .message(0).subject(is("foobar")) | |
| 54 | * </pre> | |
| 55 | * | |
| 56 | * You can use this method to chain several assertions on different | |
| 57 | * messages: | |
| 58 | * | |
| 59 | * <pre> | |
| 60 | * .message(0).subject(is("foobar")) | |
| 61 | * .and() | |
| 62 | * .message(1).subject(is("toto")) | |
| 63 | * </pre> | |
| 64 | * | |
| 65 | * | |
| 66 | * @param index | |
| 67 | * the index of the message in the received list | |
| 68 | * @return the fluent API for chaining assertions on received messages | |
| 69 | */ | |
| 70 | public FluentEmailAssert<FluentEmailsAssert<P>> message(int index) { | |
| 71 |
8
1. lambda$message$1 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → NO_COVERAGE 2. lambda$message$1 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → SURVIVED 3. message : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 4. message : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → SURVIVED 5. lambda$message$1 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → TIMED_OUT 6. message : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → TIMED_OUT 7. lambda$message$1 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → KILLED 8. message : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED |
registry.register(() -> assertThat(index, overrideDescription("Assertions on message "+index+" can't be executed because "+actual.size()+" messages were received", lessThan(actual.size())))); |
| 72 |
14
1. message : changed conditional boundary → NO_COVERAGE 2. message : changed conditional boundary → SURVIVED 3. message : negated conditional → NO_COVERAGE 4. message : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentEmailsAssert::message → NO_COVERAGE 5. message : changed conditional boundary → TIMED_OUT 6. message : negated conditional → TIMED_OUT 7. message : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentEmailsAssert::message → TIMED_OUT 8. message : changed conditional boundary → KILLED 9. message : negated conditional → KILLED 10. message : negated conditional → KILLED 11. message : negated conditional → KILLED 12. message : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentEmailsAssert::message → KILLED 13. message : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentEmailsAssert::message → KILLED 14. message : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentEmailsAssert::message → KILLED |
return new FluentEmailAssert<>(index<actual.size() ? actual.get(index) : null, index, this, registry); |
| 73 | } | |
| 74 | ||
| 75 | /** | |
| 76 | * Fluent API to write assertions on every received messages. Any defined | |
| 77 | * assertion will be applied on every message: | |
| 78 | * | |
| 79 | * <pre> | |
| 80 | * .receivedMessages().every().subject(is("foobar")) | |
| 81 | * </pre> | |
| 82 | * | |
| 83 | * Will check that subject of every message is "foobar". | |
| 84 | * | |
| 85 | * <p> | |
| 86 | * You can use this method to factorize several assertions on a message and | |
| 87 | * then make dedicated assertions on some messages: | |
| 88 | * | |
| 89 | * <pre> | |
| 90 | * .receivedMessages().every().subject(is("foobar")) | |
| 91 | * .and() | |
| 92 | * .message(0).body().contentAsString(is("toto")) | |
| 93 | * </pre> | |
| 94 | * | |
| 95 | * Will check that subject of every message is "foobar" and that body of | |
| 96 | * first received message is "toto". | |
| 97 | * | |
| 98 | * @return the fluent API for chaining assertions on received messages | |
| 99 | */ | |
| 100 | public FluentEmailAssert<FluentEmailsAssert<P>> every() { | |
| 101 |
3
1. every : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentEmailsAssert::every → NO_COVERAGE 2. every : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentEmailsAssert::every → KILLED 3. every : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentEmailsAssert::every → KILLED |
return new FluentEmailAssert<>(actual, this, registry); |
| 102 | } | |
| 103 | } | |
Mutations | ||
| 45 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
| 46 |
1.1 2.2 3.3 4.4 5.5 |
|
| 71 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
| 72 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 11.11 12.12 13.13 14.14 |
|
| 101 |
1.1 2.2 3.3 |