ThymeleafAssertions.java

1
package fr.sii.ogham.testing.assertion.internal;
2
3
import static fr.sii.ogham.testing.assertion.internal.helper.ImplementationFinder.findParsers;
4
import static java.util.stream.Collectors.toSet;
5
6
import java.util.Set;
7
8
import org.thymeleaf.TemplateEngine;
9
10
import fr.sii.ogham.core.service.MessagingService;
11
import fr.sii.ogham.email.message.Email;
12
import fr.sii.ogham.sms.message.Sms;
13
import fr.sii.ogham.template.thymeleaf.common.ThymeleafParser;
14
import fr.sii.ogham.testing.assertion.internal.helper.FoundParser;
15
import fr.sii.ogham.testing.util.HasParent;
16
17
/**
18
 * Helper class to make assertions on Thymealf instances created by Ogham.
19
 * 
20
 * For example, to ensure that particular engine is used for emails:
21
 * 
22
 * <pre>
23
* {@code
24
* email()
25
*   .engine(isA(SpringTemplateEngine.class))
26
* }
27
 * </pre>
28
 * 
29
 * @author Aurélien Baudet
30
 *
31
 */
32
public class ThymeleafAssertions extends HasParent<MessagingServiceAssertions> {
33
	private final Set<FoundParser<ThymeleafParser>> thymeleafParsers;
34
35
	public ThymeleafAssertions(MessagingServiceAssertions parent, Set<FoundParser<ThymeleafParser>> thymeleafParsers) {
36
		super(parent);
37
		this.thymeleafParsers = thymeleafParsers;
38
	}
39
40
	/**
41
	 * Make assertions on {@link ThymeleafParser} instantiated for both emails
42
	 * and sms.
43
	 * 
44
	 * For example, to ensure that all {@link ThymeleafParser}s use the right
45
	 * {@link TemplateEngine} instance:
46
	 * 
47
	 * <pre>
48
	 * {@code
49
	 * all()
50
	 *   .engine(isA(SpringTemplateEngine.class))
51
	 * }
52
	 * </pre>
53
	 * 
54
	 * @return builder for fluent chaining
55
	 */
56
	public ThymeleafParserAssertions all() {
57 3 1. all : replaced return value with null for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::all → NO_COVERAGE
2. all : replaced return value with null for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::all → TIMED_OUT
3. all : replaced return value with null for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::all → KILLED
		return new ThymeleafParserAssertions(this, thymeleafParsers.stream().map(FoundParser::getParser).collect(toSet()));
58
	}
59
60
	/**
61
	 * Make assertions on {@link ThymeleafParser} instantiated for sending
62
	 * emails only.
63
	 * 
64
	 * For example, to ensure that {@link ThymeleafParser} used for sending
65
	 * emails uses the right {@link TemplateEngine} instance:
66
	 * 
67
	 * <pre>
68
	 * {@code
69
	 * email()
70
	 *   .engine(isA(SpringTemplateEngine.class))
71
	 * }
72
	 * </pre>
73
	 * 
74
	 * @return builder for fluent chaining
75
	 */
76
	public ThymeleafParserAssertions email() {
77 3 1. email : replaced return value with null for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::email → NO_COVERAGE
2. lambda$email$0 : replaced boolean return with false for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::lambda$email$0 → NO_COVERAGE
3. lambda$email$0 : replaced boolean return with true for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::lambda$email$0 → NO_COVERAGE
		return new ThymeleafParserAssertions(this, thymeleafParsers.stream().filter(f -> f.getMessageType().equals(Email.class)).map(FoundParser::getParser).collect(toSet()));
78
	}
79
80
	/**
81
	 * Make assertions on {@link ThymeleafParser} instantiated for sending sms
82
	 * only.
83
	 * 
84
	 * For example, to ensure that {@link ThymeleafParser} used for sending sms
85
	 * uses the right {@link TemplateEngine} instance:
86
	 * 
87
	 * <pre>
88
	 * {@code
89
	 * sms()
90
	 *   .engine(isA(SpringTemplateEngine.class))
91
	 * }
92
	 * </pre>
93
	 * 
94
	 * @return builder for fluent chaining
95
	 */
96
	public ThymeleafParserAssertions sms() {
97 3 1. lambda$sms$1 : replaced boolean return with false for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::lambda$sms$1 → NO_COVERAGE
2. lambda$sms$1 : replaced boolean return with true for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::lambda$sms$1 → NO_COVERAGE
3. sms : replaced return value with null for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::sms → NO_COVERAGE
		return new ThymeleafParserAssertions(this, thymeleafParsers.stream().filter(f -> f.getMessageType().equals(Sms.class)).map(FoundParser::getParser).collect(toSet()));
98
	}
99
100
	/**
101
	 * Find instances of {@link ThymeleafParser}
102
	 * 
103
	 * @param messagingService
104
	 *            the messaging service
105
	 * @return the found instances
106
	 */
107
	public static Set<FoundParser<ThymeleafParser>> getThymeleafParsers(MessagingService messagingService) {
108 3 1. getThymeleafParsers : replaced return value with Collections.emptyList for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::getThymeleafParsers → SURVIVED
2. getThymeleafParsers : replaced return value with Collections.emptyList for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::getThymeleafParsers → NO_COVERAGE
3. getThymeleafParsers : replaced return value with Collections.emptyList for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::getThymeleafParsers → TIMED_OUT
		return findParsers(messagingService, ThymeleafParser.class);
109
	}
110
111
}

Mutations

57

1.1
Location : all
Killed by : oghamall.it.configuration.ThymeleafConfigurationTest.asDeveloperIDefineCustomPathPrefixInMyOwnCode(oghamall.it.configuration.ThymeleafConfigurationTest)
replaced return value with null for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::all → KILLED

2.2
Location : all
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::all → TIMED_OUT

3.3
Location : all
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::all → NO_COVERAGE

77

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

2.2
Location : lambda$email$0
Killed by : none
replaced boolean return with false for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::lambda$email$0 → NO_COVERAGE

3.3
Location : lambda$email$0
Killed by : none
replaced boolean return with true for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::lambda$email$0 → NO_COVERAGE

97

1.1
Location : lambda$sms$1
Killed by : none
replaced boolean return with false for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::lambda$sms$1 → NO_COVERAGE

2.2
Location : lambda$sms$1
Killed by : none
replaced boolean return with true for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::lambda$sms$1 → NO_COVERAGE

3.3
Location : sms
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::sms → NO_COVERAGE

108

1.1
Location : getThymeleafParsers
Killed by : none
replaced return value with Collections.emptyList for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::getThymeleafParsers → TIMED_OUT

2.2
Location : getThymeleafParsers
Killed by : none
replaced return value with Collections.emptyList for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::getThymeleafParsers → SURVIVED

3.3
Location : getThymeleafParsers
Killed by : none
replaced return value with Collections.emptyList for fr/sii/ogham/testing/assertion/internal/ThymeleafAssertions::getThymeleafParsers → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT OGHAM