FluentAddressListAssert.java

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.usingContext;
5
6
import java.util.ArrayList;
7
import java.util.List;
8
9
import javax.mail.internet.InternetAddress;
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 FluentAddressListAssert<P> extends HasParent<P> {
17
	/**
18
	 * The list of addresses that will be used for assertions
19
	 */
20
	private List<AddressesWithContext> actual;
21
	/**
22
	 * Registry to register assertions
23
	 */
24
	private final AssertionRegistry registry;
25
26
	public FluentAddressListAssert(List<AddressesWithContext> actual, P parent, AssertionRegistry registry) {
27
		super(parent);
28
		this.actual = actual;
29
		this.registry = registry;
30
	}
31
32
	/**
33
	 * Make assertions on the email addresses (without personal).
34
	 * 
35
	 * <p>
36
	 * Email address parts can be checked independently:
37
	 * <ul>
38
	 * <li>address: "recipient@sii.fr"</li>
39
	 * <li>personal: "Recipient Name"</li>
40
	 * <li>textual: {@code "Recipient Name <recipient@sii.fr>"}</li>
41
	 * </ul>
42
	 * 
43
	 * <pre>
44
	 * .receivedMessages().message(0).to()
45
	 *    .address(hasItems("recipient@sii.fr"))
46
	 * </pre>
47
	 * 
48
	 * Will check if the list of recipient email addresses of the first message
49
	 * contains exactly "recipient@sii.fr".
50
	 * 
51
	 * <pre>
52
	 * .receivedMessages().every().to()
53
	 *    .address(hasItems("recipient@sii.fr"))
54
	 * </pre>
55
	 * 
56
	 * Will check if the list of recipient email addresses of every message
57
	 * contains exactly "recipient@sii.fr".
58
	 * 
59
	 * @param matcher
60
	 *            the assertion to apply on the email addresses
61
	 * @return the fluent API for chaining assertions on received message(s)
62
	 */
63
	public FluentAddressListAssert<P> address(Matcher<? super Iterable<String>> matcher) {
64
		String desc = "email addresses of '${fieldName}' field of message ${messageIndex}";
65
		for (AddressesWithContext addresses : actual) {
66
			List<String> addressesStr = new ArrayList<>();
67
			for (InternetAddress address : addresses.getAddresses()) {
68
				addressesStr.add(address.getAddress());
69
			}
70 6 1. address : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → SURVIVED
2. address : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE
3. lambda$address$0 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → SURVIVED
4. lambda$address$0 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → NO_COVERAGE
5. address : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED
6. lambda$address$0 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → KILLED
			registry.register(() -> assertThat(addressesStr, usingContext(desc, addresses, matcher)));
71
		}
72 4 1. address : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentAddressListAssert::address → NO_COVERAGE
2. address : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentAddressListAssert::address → KILLED
3. address : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentAddressListAssert::address → KILLED
4. address : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentAddressListAssert::address → KILLED
		return this;
73
	}
74
75
	/**
76
	 * Make assertions on the email addresses (textual form).
77
	 * 
78
	 * <p>
79
	 * Email address parts can be checked independently:
80
	 * <ul>
81
	 * <li>address: "recipient@sii.fr"</li>
82
	 * <li>personal: "Recipient Name"</li>
83
	 * <li>textual: {@code "Recipient Name <recipient@sii.fr>"}</li>
84
	 * </ul>
85
	 * 
86
	 * <pre>
87
	 * .receivedMessages().message(0).to()
88
	 *    .textual(hasItems("Recipient Name &lt;recipient@sii.fr&gt;"))
89
	 * </pre>
90
	 * 
91
	 * Will check if the list of recipient email addresses (personal with
92
	 * address) of the first message contains exactly {@code "Recipient Name
93
	 * <recipient@sii.fr>"}.
94
	 * 
95
	 * <pre>
96
	 * .receivedMessages().every().to()
97
	 *    .textual(hasItems("Recipient Name &lt;recipient@sii.fr&gt;"))
98
	 * </pre>
99
	 * 
100
	 * Will check if the list of recipient email addresses (personal with
101
	 * address) of every message contains exactly {@code "Recipient Name
102
	 * <recipient@sii.fr>"}.
103
	 * 
104
	 * @param matcher
105
	 *            the assertion to apply on the email addresses
106
	 * @return the fluent API for chaining assertions on received message(s)
107
	 */
108
	public FluentAddressListAssert<P> textual(Matcher<? super Iterable<String>> matcher) {
109
		String desc = "textual addresses of '${fieldName}' field of message ${messageIndex}";
110
		for (AddressesWithContext addresses : actual) {
111
			List<String> addressesStr = new ArrayList<>();
112
			for (InternetAddress address : addresses.getAddresses()) {
113
				addressesStr.add(address.toString());
114
			}
115 4 1. lambda$textual$1 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → NO_COVERAGE
2. textual : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE
3. lambda$textual$1 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → KILLED
4. textual : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED
			registry.register(() -> assertThat(addressesStr, usingContext(desc, addresses, matcher)));
116
		}
117 2 1. textual : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentAddressListAssert::textual → NO_COVERAGE
2. textual : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentAddressListAssert::textual → KILLED
		return this;
118
	}
119
120
	/**
121
	 * Make assertions on the email address types.
122
	 * 
123
	 * <pre>
124
	 * .receivedMessages().message(0).to()
125
	 *    .type(hasItems("rfc822"))
126
	 * </pre>
127
	 * 
128
	 * Will check if the list of recipient email address types of the first
129
	 * message contains exactly "rfc822".
130
	 * 
131
	 * <pre>
132
	 * .receivedMessages().every().to()
133
	 *    .type(hasItems("rfc822"))
134
	 * </pre>
135
	 * 
136
	 * Will check if the list of recipient email address types of every message
137
	 * contains exactly "rfc822".
138
	 * 
139
	 * @param matcher
140
	 *            the assertion to apply on the email addresses
141
	 * @return the fluent API for chaining assertions on received message(s)
142
	 */
143
	public FluentAddressListAssert<P> type(Matcher<? super Iterable<String>> matcher) {
144
		String desc = "address types of '${fieldName}' field of message ${messageIndex}";
145
		for (AddressesWithContext addresses : actual) {
146
			List<String> addressesStr = new ArrayList<>();
147
			for (InternetAddress address : addresses.getAddresses()) {
148
				addressesStr.add(address.getType());
149
			}
150 4 1. lambda$type$2 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → NO_COVERAGE
2. type : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE
3. lambda$type$2 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → KILLED
4. type : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED
			registry.register(() -> assertThat(addressesStr, usingContext(desc, addresses, matcher)));
151
		}
152 2 1. type : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentAddressListAssert::type → NO_COVERAGE
2. type : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentAddressListAssert::type → KILLED
		return this;
153
	}
154
155
	/**
156
	 * Make assertions on the email addresses (personal information only).
157
	 * 
158
	 * <p>
159
	 * Email address parts can be checked independently:
160
	 * <ul>
161
	 * <li>address: "recipient@sii.fr"</li>
162
	 * <li>personal: "Recipient Name"</li>
163
	 * <li>textual: {@code "Recipient Name <recipient@sii.fr>"}</li>
164
	 * </ul>
165
	 * 
166
	 * <pre>
167
	 * .receivedMessages().message(0).to()
168
	 *    .personal(hasItems("Recipient Name"))
169
	 * </pre>
170
	 * 
171
	 * Will check if the list of recipient email addresses (personal
172
	 * information) of the first message contains exactly "Recipient Name".
173
	 * 
174
	 * <pre>
175
	 * .receivedMessages().every().to()
176
	 *    .personal(hasItems("Recipient Name"))
177
	 * </pre>
178
	 * 
179
	 * Will check if the list of recipient email addresses (personal
180
	 * information) of every message contains exactly "Recipient Name".
181
	 * 
182
	 * @param matcher
183
	 *            the assertion to apply on the email addresses
184
	 * @return the fluent API for chaining assertions on received message(s)
185
	 */
186
	public FluentAddressListAssert<P> personal(Matcher<? super Iterable<String>> matcher) {
187
		String desc = "personal of '${fieldName}' field of message ${messageIndex}";
188
		for (AddressesWithContext addresses : actual) {
189
			List<String> addressesStr = new ArrayList<>();
190
			for (InternetAddress address : addresses.getAddresses()) {
191
				addressesStr.add(address.getPersonal());
192
			}
193 6 1. lambda$personal$3 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → NO_COVERAGE
2. lambda$personal$3 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → SURVIVED
3. personal : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → SURVIVED
4. personal : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE
5. lambda$personal$3 : removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → KILLED
6. personal : removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED
			registry.register(() -> assertThat(addressesStr, usingContext(desc, addresses, matcher)));
194
		}
195 3 1. personal : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentAddressListAssert::personal → NO_COVERAGE
2. personal : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentAddressListAssert::personal → KILLED
3. personal : replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentAddressListAssert::personal → KILLED
		return this;
196
	}
197
198
}

Mutations

70

1.1
Location : address
Killed by : oghamtesting.it.assertion.FluentEmailAssertionsSpec
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED

2.2
Location : address
Killed by : none
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → SURVIVED

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

4.4
Location : lambda$address$0
Killed by : oghamtesting.it.assertion.FluentEmailAssertionsSpec
removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → KILLED

5.5
Location : lambda$address$0
Killed by : none
removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → SURVIVED

6.6
Location : lambda$address$0
Killed by : none
removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → NO_COVERAGE

72

1.1
Location : address
Killed by : oghamall.it.configuration.EmptyBuilderTest.manualJavaMailConfigurationCanSendEmail(oghamall.it.configuration.EmptyBuilderTest)
replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentAddressListAssert::address → KILLED

2.2
Location : address
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentAddressListAssert::address → NO_COVERAGE

3.3
Location : address
Killed by : oghamtesting.it.assertion.FluentEmailAssertionsSpec
replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentAddressListAssert::address → KILLED

4.4
Location : address
Killed by : oghamjavamail.it.JavaMailSmtpTest.simple(oghamjavamail.it.JavaMailSmtpTest)
replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentAddressListAssert::address → KILLED

115

1.1
Location : lambda$textual$1
Killed by : oghamtesting.it.assertion.FluentEmailAssertionsSpec
removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → KILLED

2.2
Location : lambda$textual$1
Killed by : none
removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → NO_COVERAGE

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

4.4
Location : textual
Killed by : oghamtesting.it.assertion.FluentEmailAssertionsSpec
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED

117

1.1
Location : textual
Killed by : oghamtesting.it.assertion.FluentEmailAssertionsSpec
replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentAddressListAssert::textual → KILLED

2.2
Location : textual
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentAddressListAssert::textual → NO_COVERAGE

150

1.1
Location : lambda$type$2
Killed by : oghamtesting.it.assertion.FluentEmailAssertionsSpec
removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → KILLED

2.2
Location : lambda$type$2
Killed by : none
removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → NO_COVERAGE

3.3
Location : type
Killed by : oghamtesting.it.assertion.FluentEmailAssertionsSpec
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED

4.4
Location : type
Killed by : none
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

152

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

2.2
Location : type
Killed by : oghamtesting.it.assertion.FluentEmailAssertionsSpec
replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentAddressListAssert::type → KILLED

193

1.1
Location : lambda$personal$3
Killed by : none
removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → NO_COVERAGE

2.2
Location : lambda$personal$3
Killed by : none
removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → SURVIVED

3.3
Location : lambda$personal$3
Killed by : oghamtesting.it.assertion.FluentEmailAssertionsSpec
removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → KILLED

4.4
Location : personal
Killed by : none
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → SURVIVED

5.5
Location : personal
Killed by : none
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → NO_COVERAGE

6.6
Location : personal
Killed by : oghamtesting.it.assertion.FluentEmailAssertionsSpec
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → KILLED

195

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

2.2
Location : personal
Killed by : oghamtesting.it.assertion.FluentEmailAssertionsSpec
replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentAddressListAssert::personal → KILLED

3.3
Location : personal
Killed by : oghamall.it.email.EmailSMTPAuthenticationTest.authenticated(oghamall.it.email.EmailSMTPAuthenticationTest)
replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentAddressListAssert::personal → KILLED

Active mutators

Tests examined


Report generated by PIT OGHAM