FluentEmailsAssert.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.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
Location : count
Killed by : none
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → SURVIVED

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

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

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

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

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

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

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

46

1.1
Location : count
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentEmailsAssert::count → SURVIVED

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

3.3
Location : count
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentEmailsAssert::count → TIMED_OUT

4.4
Location : count
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentEmailsAssert::count → NO_COVERAGE

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

71

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

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

3.3
Location : lambda$message$1
Killed by : none
removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → SURVIVED

4.4
Location : lambda$message$1
Killed by : none
removed call to fr/sii/ogham/testing/assertion/util/AssertionHelper::assertThat → TIMED_OUT

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

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

7.7
Location : message
Killed by : none
removed call to fr/sii/ogham/testing/assertion/util/AssertionRegistry::register → TIMED_OUT

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

72

1.1
Location : message
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : message
Killed by : none
changed conditional boundary → TIMED_OUT

3.3
Location : message
Killed by : oghamtesting.it.assertion.FluentEmailAssertionsSpec
changed conditional boundary → KILLED

4.4
Location : message
Killed by : none
changed conditional boundary → SURVIVED

5.5
Location : message
Killed by : oghamjavamail.it.JavaMailSmtpTest.simple(oghamjavamail.it.JavaMailSmtpTest)
negated conditional → KILLED

6.6
Location : message
Killed by : oghamall.it.configuration.EmptyBuilderTest.manualJavaMailConfigurationCanSendEmail(oghamall.it.configuration.EmptyBuilderTest)
negated conditional → KILLED

7.7
Location : message
Killed by : oghamtesting.it.assertion.FluentEmailAssertionsSpec
negated conditional → KILLED

8.8
Location : message
Killed by : none
negated conditional → TIMED_OUT

9.9
Location : message
Killed by : none
negated conditional → NO_COVERAGE

10.10
Location : message
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentEmailsAssert::message → TIMED_OUT

11.11
Location : message
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentEmailsAssert::message → NO_COVERAGE

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

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

14.14
Location : message
Killed by : oghamtesting.it.assertion.FluentEmailAssertionsSpec
replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentEmailsAssert::message → KILLED

101

1.1
Location : every
Killed by : oghamall.it.email.EmailPropertiesTest.simple(oghamall.it.email.EmailPropertiesTest)
replaced return value with null for fr/sii/ogham/testing/assertion/email/FluentEmailsAssert::every → KILLED

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

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

Active mutators

Tests examined


Report generated by PIT OGHAM