| 1 | package fr.sii.ogham.testing.assertion.sms; | |
| 2 | ||
| 3 | import static fr.sii.ogham.testing.assertion.util.AssertionHelper.assertThat; | |
| 4 | import static fr.sii.ogham.testing.assertion.util.AssertionHelper.usingContext; | |
| 5 | ||
| 6 | import java.util.List; | |
| 7 | ||
| 8 | import org.hamcrest.Matcher; | |
| 9 | ||
| 10 | import fr.sii.ogham.testing.assertion.util.AssertionRegistry; | |
| 11 | import fr.sii.ogham.testing.sms.simulator.bean.NumberingPlanIndicator; | |
| 12 | import fr.sii.ogham.testing.sms.simulator.bean.TypeOfNumber; | |
| 13 | import fr.sii.ogham.testing.util.HasParent; | |
| 14 | ||
| 15 | /** | |
| 16 | * Make assertions on phone number of received messages. | |
| 17 | * | |
| 18 | * @author Aurélien Baudet | |
| 19 | * | |
| 20 | * @param <P> | |
| 21 | * the parent type | |
| 22 | */ | |
| 23 | public class FluentPhoneNumberAssert<P> extends HasParent<P> { | |
| 24 | /** | |
| 25 | * The list of phone numbers that will be used for assertions | |
| 26 | */ | |
| 27 | private final List<PhoneNumberWithContext> actual; | |
| 28 | private final AssertionRegistry registry; | |
| 29 | ||
| 30 | /** | |
| 31 | * | |
| 32 | * @param actual | |
| 33 | * the received messages | |
| 34 | * @param parent | |
| 35 | * the parent | |
| 36 | * @param registry | |
| 37 | * used to register assertions | |
| 38 | */ | |
| 39 | public FluentPhoneNumberAssert(List<PhoneNumberWithContext> actual, P parent, AssertionRegistry registry) { | |
| 40 | super(parent); | |
| 41 | this.actual = actual; | |
| 42 | this.registry = registry; | |
| 43 | } | |
| 44 | ||
| 45 | /** | |
| 46 | * Make assertions on a phone number. | |
| 47 | * | |
| 48 | * <pre> | |
| 49 | * .receivedMessages().message(0).to() | |
| 50 | * .number(is("+33102030405")) | |
| 51 | * </pre> | |
| 52 | * | |
| 53 | * Will check if the recipient phone number of the first message is exactly | |
| 54 | * "+33102030405". | |
| 55 | * | |
| 56 | * <pre> | |
| 57 | * .receivedMessages().every().to() | |
| 58 | * .number(is("+33102030405")) | |
| 59 | * </pre> | |
| 60 | * | |
| 61 | * Will check if the recipient phone number of every message is exactly | |
| 62 | * "+33102030405". | |
| 63 | * | |
| 64 | * @param matcher | |
| 65 | * the assertion to apply on the phone number | |
| 66 | * @return the fluent API for chaining assertions on received message(s) | |
| 67 | */ | |
| 68 | public FluentPhoneNumberAssert<P> number(Matcher<String> matcher) { | |
| 69 | String message = "number of ${numberName} of message ${messageIndex}"; | |
| 70 | for (PhoneNumberWithContext numberWithContext : actual) { | |
| 71 | PhoneNumberInfo number = numberWithContext.getNumber(); | |
| 72 |
6
1. lambda$number$0 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → SURVIVED 2. lambda$number$0 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → NO_COVERAGE 3. number : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 4. number : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → SURVIVED 5. lambda$number$0 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → KILLED 6. number : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED |
registry.register(() -> assertThat(number.getAddress(), usingContext(message, numberWithContext, matcher))); |
| 73 | } | |
| 74 |
4
1. number : replaced return value with null for fr/sii/ogham/testing/assertion/sms/FluentPhoneNumberAssert::number → NO_COVERAGE 2. number : replaced return value with null for fr/sii/ogham/testing/assertion/sms/FluentPhoneNumberAssert::number → KILLED 3. number : replaced return value with null for fr/sii/ogham/testing/assertion/sms/FluentPhoneNumberAssert::number → KILLED 4. number : replaced return value with null for fr/sii/ogham/testing/assertion/sms/FluentPhoneNumberAssert::number → KILLED |
return this; |
| 75 | } | |
| 76 | ||
| 77 | /** | |
| 78 | * Make assertions on a phone number. | |
| 79 | * | |
| 80 | * <pre> | |
| 81 | * .receivedMessages().message(0).to() | |
| 82 | * .typeOfNumber(is(TypeOfNumber.INTERNATIONAL)) | |
| 83 | * </pre> | |
| 84 | * | |
| 85 | * Will check if the recipient phone number type of the first message is an | |
| 86 | * international number. | |
| 87 | * | |
| 88 | * <pre> | |
| 89 | * .receivedMessages().every().to() | |
| 90 | * .typeOfNumber(is(TypeOfNumber.INTERNATIONAL)) | |
| 91 | * </pre> | |
| 92 | * | |
| 93 | * Will check if the recipient phone number type of every message is an | |
| 94 | * international number. | |
| 95 | * | |
| 96 | * @param matcher | |
| 97 | * the assertion to apply on the type of number | |
| 98 | * @return the fluent API for chaining assertions on received message(s) | |
| 99 | */ | |
| 100 | public FluentPhoneNumberAssert<P> typeOfNumber(Matcher<TypeOfNumber> matcher) { | |
| 101 | String message = "TypeOfNumber of ${numberName} of message ${messageIndex}"; | |
| 102 | for (PhoneNumberWithContext numberWithContext : actual) { | |
| 103 | PhoneNumberInfo number = numberWithContext.getNumber(); | |
| 104 |
6
1. lambda$typeOfNumber$1 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → SURVIVED 2. lambda$typeOfNumber$1 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → NO_COVERAGE 3. typeOfNumber : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 4. typeOfNumber : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → SURVIVED 5. lambda$typeOfNumber$1 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → KILLED 6. typeOfNumber : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED |
registry.register(() -> assertThat(TypeOfNumber.valueOf(number.getTon()), usingContext(message, numberWithContext, matcher))); |
| 105 | } | |
| 106 |
4
1. typeOfNumber : replaced return value with null for fr/sii/ogham/testing/assertion/sms/FluentPhoneNumberAssert::typeOfNumber → NO_COVERAGE 2. typeOfNumber : replaced return value with null for fr/sii/ogham/testing/assertion/sms/FluentPhoneNumberAssert::typeOfNumber → KILLED 3. typeOfNumber : replaced return value with null for fr/sii/ogham/testing/assertion/sms/FluentPhoneNumberAssert::typeOfNumber → KILLED 4. typeOfNumber : replaced return value with null for fr/sii/ogham/testing/assertion/sms/FluentPhoneNumberAssert::typeOfNumber → KILLED |
return this; |
| 107 | } | |
| 108 | ||
| 109 | /** | |
| 110 | * Make assertions on a phone number. | |
| 111 | * | |
| 112 | * <pre> | |
| 113 | * .receivedMessages().message(0).to() | |
| 114 | * .numberingPlanIndicator(is(NumberingPlanIndicator.ISDN)) | |
| 115 | * </pre> | |
| 116 | * | |
| 117 | * Will check if the numbering plan indicator of the recipient phone number | |
| 118 | * of the first message is NumberingPlanIndicator.ISDN. | |
| 119 | * | |
| 120 | * <pre> | |
| 121 | * .receivedMessages().every().to() | |
| 122 | * .numberingPlanIndicator(is(NumberingPlanIndicator.ISDN)) | |
| 123 | * </pre> | |
| 124 | * | |
| 125 | * Will check if the numbering plan indicator of the recipient phone number | |
| 126 | * of every message is NumberingPlanIndicator.ISDN. | |
| 127 | * | |
| 128 | * @param matcher | |
| 129 | * the assertion to apply on the numbering plan indicator | |
| 130 | * @return the fluent API for chaining assertions on received message(s) | |
| 131 | */ | |
| 132 | public FluentPhoneNumberAssert<P> numberingPlanIndicator(Matcher<NumberingPlanIndicator> matcher) { | |
| 133 | String message = "NumberPlanIndicator of ${numberName} of message ${messageIndex}"; | |
| 134 | for (PhoneNumberWithContext numberWithContext : actual) { | |
| 135 | PhoneNumberInfo number = numberWithContext.getNumber(); | |
| 136 |
6
1. lambda$numberingPlanIndicator$2 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → NO_COVERAGE 2. lambda$numberingPlanIndicator$2 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → SURVIVED 3. numberingPlanIndicator : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → SURVIVED 4. numberingPlanIndicator : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE 5. lambda$numberingPlanIndicator$2 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → KILLED 6. numberingPlanIndicator : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED |
registry.register(() -> assertThat(NumberingPlanIndicator.valueOf(number.getNpi()), usingContext(message, numberWithContext, matcher))); |
| 137 | } | |
| 138 |
4
1. numberingPlanIndicator : replaced return value with null for fr/sii/ogham/testing/assertion/sms/FluentPhoneNumberAssert::numberingPlanIndicator → NO_COVERAGE 2. numberingPlanIndicator : replaced return value with null for fr/sii/ogham/testing/assertion/sms/FluentPhoneNumberAssert::numberingPlanIndicator → KILLED 3. numberingPlanIndicator : replaced return value with null for fr/sii/ogham/testing/assertion/sms/FluentPhoneNumberAssert::numberingPlanIndicator → KILLED 4. numberingPlanIndicator : replaced return value with null for fr/sii/ogham/testing/assertion/sms/FluentPhoneNumberAssert::numberingPlanIndicator → KILLED |
return this; |
| 139 | } | |
| 140 | } | |
Mutations | ||
| 72 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
| 74 |
1.1 2.2 3.3 4.4 |
|
| 104 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
| 106 |
1.1 2.2 3.3 4.4 |
|
| 136 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
| 138 |
1.1 2.2 3.3 4.4 |