1 | package fr.sii.ogham.testing.assertion.internal; | |
2 | ||
3 | import static fr.sii.ogham.testing.assertion.internal.helper.ImplementationFinder.findSender; | |
4 | import static fr.sii.ogham.testing.assertion.util.AssertionHelper.assertThat; | |
5 | import static org.apache.commons.lang3.reflect.FieldUtils.readField; | |
6 | ||
7 | import org.hamcrest.Matcher; | |
8 | ||
9 | import fr.sii.ogham.core.service.MessagingService; | |
10 | import fr.sii.ogham.sms.sender.impl.CloudhopperSMPPSender; | |
11 | import fr.sii.ogham.sms.sender.impl.cloudhopper.ExtendedSmppSessionConfiguration; | |
12 | import fr.sii.ogham.testing.util.HasParent; | |
13 | ||
14 | /** | |
15 | * Helper class to make assertions on Cloudhopper instance created by Ogham. | |
16 | * | |
17 | * For example, to ensure that particular configuration is used for emails: | |
18 | * | |
19 | * <pre> | |
20 | * {@code | |
21 | * cloudhopper() | |
22 | * .host(is("localhost") | |
23 | * .splitter() | |
24 | * .enabled(is(true)) | |
25 | * } | |
26 | * </pre> | |
27 | * | |
28 | * @author Aurélien Baudet | |
29 | * | |
30 | */ | |
31 | public class CloudhopperAssertions extends HasParent<MessagingServiceAssertions> { | |
32 | private final CloudhopperSMPPSender cloudhopperSender; | |
33 | ||
34 | public CloudhopperAssertions(MessagingServiceAssertions parent, CloudhopperSMPPSender cloudhopperSender) { | |
35 | super(parent); | |
36 | this.cloudhopperSender = cloudhopperSender; | |
37 | } | |
38 | ||
39 | /** | |
40 | * Ensures that configured host is correct. | |
41 | * | |
42 | * @param matcher | |
43 | * the matcher to ensure that host is correct. | |
44 | * @return this instance for fluent chaining | |
45 | */ | |
46 | public CloudhopperAssertions host(Matcher<String> matcher) { | |
47 |
2
1. host : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → SURVIVED 2. host : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → NO_COVERAGE |
assertThat(getHost(cloudhopperSender), matcher); |
48 |
3
1. host : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::host → NO_COVERAGE 2. host : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::host → SURVIVED 3. host : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::host → KILLED |
return this; |
49 | } | |
50 | ||
51 | /** | |
52 | * Ensures that configured port is correct. | |
53 | * | |
54 | * @param matcher | |
55 | * the matcher to ensure that port is correct. | |
56 | * @return this instance for fluent chaining | |
57 | */ | |
58 | public CloudhopperAssertions port(Matcher<Integer> matcher) { | |
59 |
2
1. port : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → SURVIVED 2. port : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → NO_COVERAGE |
assertThat(getPort(cloudhopperSender), matcher); |
60 |
2
1. port : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::port → NO_COVERAGE 2. port : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::port → KILLED |
return this; |
61 | } | |
62 | ||
63 | /** | |
64 | * Ensures that configured SMPP version is correct. | |
65 | * | |
66 | * @param matcher | |
67 | * the matcher to ensure that SMPP version in is correct. | |
68 | * @return this instance for fluent chaining | |
69 | */ | |
70 | public CloudhopperAssertions interfaceVersion(Matcher<Byte> matcher) { | |
71 |
2
1. interfaceVersion : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → NO_COVERAGE 2. interfaceVersion : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → SURVIVED |
assertThat(getConfiguration(cloudhopperSender).getInterfaceVersion(), matcher); |
72 |
2
1. interfaceVersion : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::interfaceVersion → NO_COVERAGE 2. interfaceVersion : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::interfaceVersion → KILLED |
return this; |
73 | } | |
74 | ||
75 | /** | |
76 | * Make assertions on "User Data" to ensure that it is correctly configured. | |
77 | * | |
78 | * For example: | |
79 | * | |
80 | * <pre> | |
81 | * {@code | |
82 | * userData() | |
83 | * .useShortMessage(is(true)) | |
84 | * } | |
85 | * </pre> | |
86 | * | |
87 | * @return builder for fluent chaining | |
88 | */ | |
89 | public CloudhopperUserDataAssertions userData() { | |
90 |
2
1. userData : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::userData → NO_COVERAGE 2. userData : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::userData → KILLED |
return new CloudhopperUserDataAssertions(this, cloudhopperSender); |
91 | } | |
92 | ||
93 | /** | |
94 | * Make assertions on splitter instance to ensure that it is correctly | |
95 | * configured. | |
96 | * | |
97 | * For example: | |
98 | * | |
99 | * <pre> | |
100 | * {@code | |
101 | * splitter() | |
102 | * .enabled(is(true)) | |
103 | * } | |
104 | * </pre> | |
105 | * | |
106 | * @return builder for fluent chaining | |
107 | */ | |
108 | public CloudhopperSplitterAssertions splitter() { | |
109 |
2
1. splitter : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::splitter → NO_COVERAGE 2. splitter : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::splitter → KILLED |
return new CloudhopperSplitterAssertions(this, cloudhopperSender); |
110 | } | |
111 | ||
112 | /** | |
113 | * Find instance of {@link CloudhopperSMPPSender}. | |
114 | * | |
115 | * @param messagingService | |
116 | * the messaging service | |
117 | * @return the found instance | |
118 | */ | |
119 | public static CloudhopperSMPPSender getCloudhopperSender(MessagingService messagingService) { | |
120 |
3
1. getCloudhopperSender : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::getCloudhopperSender → NO_COVERAGE 2. getCloudhopperSender : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::getCloudhopperSender → KILLED 3. getCloudhopperSender : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::getCloudhopperSender → KILLED |
return findSender(messagingService, CloudhopperSMPPSender.class); |
121 | } | |
122 | ||
123 | private static ExtendedSmppSessionConfiguration getConfiguration(CloudhopperSMPPSender cloudhopperSender) { | |
124 | try { | |
125 |
3
1. getConfiguration : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::getConfiguration → NO_COVERAGE 2. getConfiguration : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::getConfiguration → KILLED 3. getConfiguration : replaced return value with null for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::getConfiguration → KILLED |
return (ExtendedSmppSessionConfiguration) readField(cloudhopperSender, "configuration", true); |
126 | } catch (IllegalAccessException e) { | |
127 | throw new IllegalStateException("Failed to read 'configuration' of CloudhopperSMPPSender", e); | |
128 | } | |
129 | } | |
130 | | |
131 | private static String getHost(CloudhopperSMPPSender cloudhopperSender) { | |
132 |
3
1. getHost : replaced return value with "" for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::getHost → NO_COVERAGE 2. getHost : replaced return value with "" for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::getHost → KILLED 3. getHost : replaced return value with "" for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::getHost → KILLED |
return getConfiguration(cloudhopperSender).getHost(); |
133 | } | |
134 | ||
135 | private static int getPort(CloudhopperSMPPSender cloudhopperSender) { | |
136 |
2
1. getPort : replaced int return with 0 for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::getPort → NO_COVERAGE 2. getPort : replaced int return with 0 for fr/sii/ogham/testing/assertion/internal/CloudhopperAssertions::getPort → KILLED |
return getConfiguration(cloudhopperSender).getPort(); |
137 | } | |
138 | } | |
Mutations | ||
47 |
1.1 2.2 |
|
48 |
1.1 2.2 3.3 |
|
59 |
1.1 2.2 |
|
60 |
1.1 2.2 |
|
71 |
1.1 2.2 |
|
72 |
1.1 2.2 |
|
90 |
1.1 2.2 |
|
109 |
1.1 2.2 |
|
120 |
1.1 2.2 3.3 |
|
125 |
1.1 2.2 3.3 |
|
132 |
1.1 2.2 3.3 |
|
136 |
1.1 2.2 |