TemplateContent.java

1
package fr.sii.ogham.core.message.content;
2
3
import fr.sii.ogham.core.resource.path.ResourcePath;
4
import fr.sii.ogham.core.resource.path.UnresolvedPath;
5
import fr.sii.ogham.core.template.context.BeanContext;
6
import fr.sii.ogham.core.template.context.Context;
7
import fr.sii.ogham.core.template.context.NullContext;
8
import fr.sii.ogham.core.util.EqualsBuilder;
9
import fr.sii.ogham.core.util.HashCodeBuilder;
10
11
/**
12
 * Content that points to a template. The template contains variables. The
13
 * template will be evaluated with the provided context (variable values).
14
 * 
15
 * @author Aurélien Baudet
16
 *
17
 */
18
public class TemplateContent implements Content, HasResourcePath {
19
	/**
20
	 * The path to the template
21
	 */
22
	private ResourcePath path;
23
24
	/**
25
	 * The context (variable values)
26
	 */
27
	private Context context;
28
29
	
30
	/**
31
	 * Initialize the content with the path to the template and the context.
32
	 * 
33
	 * @param path
34
	 *            the path to the template
35
	 * @param context
36
	 *            the context (variable values)
37
	 */
38
	public TemplateContent(ResourcePath path, Context context) {
39
		super();
40
		this.path = path;
41 4 1. <init> : negated conditional → NO_COVERAGE
2. <init> : negated conditional → SURVIVED
3. <init> : negated conditional → TIMED_OUT
4. <init> : negated conditional → KILLED
		this.context = context != null ? context : new NullContext();
42
	}
43
44
	/**
45
	 * Initialize the content with the path to the template and the context.
46
	 * 
47
	 * @param path
48
	 *            the path to the template as string
49
	 * @param context
50
	 *            the context (variable values)
51
	 */
52
	public TemplateContent(String path, Context context) {
53
		this(new UnresolvedPath(path), context);
54
	}
55
56
	/**
57
	 * Shortcut for directly using any object as source for variable
58
	 * substitutions.
59
	 * 
60
	 * @param path
61
	 *            the path to the template
62
	 * @param bean
63
	 *            the object that contains the variable values
64
	 */
65
	public TemplateContent(ResourcePath path, Object bean) {
66 2 1. <init> : negated conditional → NO_COVERAGE
2. <init> : negated conditional → KILLED
		this(path, bean != null ? new BeanContext(bean) : new NullContext());
67
	}
68
69
	/**
70
	 * Shortcut for directly using any object as source for variable
71
	 * substitutions.
72
	 * 
73
	 * @param path
74
	 *            the path to the template
75
	 * @param bean
76
	 *            the object that contains the variable values
77
	 */
78
	public TemplateContent(String path, Object bean) {
79 3 1. <init> : negated conditional → NO_COVERAGE
2. <init> : negated conditional → TIMED_OUT
3. <init> : negated conditional → KILLED
		this(path, bean != null ? new BeanContext(bean) : new NullContext());
80
	}
81
82
	@Override
83
	public ResourcePath getPath() {
84 4 1. getPath : replaced return value with null for fr/sii/ogham/core/message/content/TemplateContent::getPath → NO_COVERAGE
2. getPath : replaced return value with null for fr/sii/ogham/core/message/content/TemplateContent::getPath → TIMED_OUT
3. getPath : replaced return value with null for fr/sii/ogham/core/message/content/TemplateContent::getPath → KILLED
4. getPath : replaced return value with null for fr/sii/ogham/core/message/content/TemplateContent::getPath → KILLED
		return path;
85
	}
86
87
	public Context getContext() {
88 4 1. getContext : replaced return value with null for fr/sii/ogham/core/message/content/TemplateContent::getContext → NO_COVERAGE
2. getContext : replaced return value with null for fr/sii/ogham/core/message/content/TemplateContent::getContext → TIMED_OUT
3. getContext : replaced return value with null for fr/sii/ogham/core/message/content/TemplateContent::getContext → KILLED
4. getContext : replaced return value with null for fr/sii/ogham/core/message/content/TemplateContent::getContext → KILLED
		return context;
89
	}
90
91
	@Override
92
	public String toString() {
93
		StringBuilder builder = new StringBuilder();
94
		builder.append("TemplateContent [path=").append(path).append(", context=").append(context).append("]");
95 3 1. toString : replaced return value with "" for fr/sii/ogham/core/message/content/TemplateContent::toString → NO_COVERAGE
2. toString : replaced return value with "" for fr/sii/ogham/core/message/content/TemplateContent::toString → SURVIVED
3. toString : replaced return value with "" for fr/sii/ogham/core/message/content/TemplateContent::toString → TIMED_OUT
		return builder.toString();
96
	}
97
98
	@Override
99
	public int hashCode() {
100 2 1. hashCode : replaced int return with 0 for fr/sii/ogham/core/message/content/TemplateContent::hashCode → NO_COVERAGE
2. hashCode : replaced int return with 0 for fr/sii/ogham/core/message/content/TemplateContent::hashCode → KILLED
		return new HashCodeBuilder().append(path, context).hashCode();
101
	}
102
103
	@Override
104
	public boolean equals(Object obj) {
105 4 1. equals : replaced boolean return with false for fr/sii/ogham/core/message/content/TemplateContent::equals → NO_COVERAGE
2. equals : replaced boolean return with true for fr/sii/ogham/core/message/content/TemplateContent::equals → NO_COVERAGE
3. equals : replaced boolean return with false for fr/sii/ogham/core/message/content/TemplateContent::equals → KILLED
4. equals : replaced boolean return with true for fr/sii/ogham/core/message/content/TemplateContent::equals → KILLED
		return new EqualsBuilder(this, obj).appendFields("path", "context").isEqual();
106
	}
107
}

Mutations

41

1.1
Location : <init>
Killed by : none
negated conditional → TIMED_OUT

2.2
Location : <init>
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : <init>
Killed by : none
negated conditional → SURVIVED

4.4
Location : <init>
Killed by : oghamall.it.retry.AutoRetryTest.doNotResendEmailIfParsingFailed(oghamall.it.retry.AutoRetryTest)
negated conditional → KILLED

66

1.1
Location : <init>
Killed by : oghamall.it.email.FluentEmailTest.bodyTemplateString(oghamall.it.email.FluentEmailTest)
negated conditional → KILLED

2.2
Location : <init>
Killed by : none
negated conditional → NO_COVERAGE

79

1.1
Location : <init>
Killed by : none
negated conditional → TIMED_OUT

2.2
Location : <init>
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : <init>
Killed by : oghamall.it.email.FluentEmailTest.textTemplateOnly(oghamall.it.email.FluentEmailTest)
negated conditional → KILLED

84

1.1
Location : getPath
Killed by : none
replaced return value with null for fr/sii/ogham/core/message/content/TemplateContent::getPath → TIMED_OUT

2.2
Location : getPath
Killed by : none
replaced return value with null for fr/sii/ogham/core/message/content/TemplateContent::getPath → NO_COVERAGE

3.3
Location : getPath
Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredAndTemplateParsersOnlyRegisteredCantHandleTemplateContentDueToResourceResolutionNotConfigured(oghamall.it.configuration.EmptyBuilderTest)
replaced return value with null for fr/sii/ogham/core/message/content/TemplateContent::getPath → KILLED

4.4
Location : getPath
Killed by : oghamcore.ut.core.EqualsTest.templateContent(oghamcore.ut.core.EqualsTest)
replaced return value with null for fr/sii/ogham/core/message/content/TemplateContent::getPath → KILLED

88

1.1
Location : getContext
Killed by : oghamcore.ut.core.EqualsTest.templateContent(oghamcore.ut.core.EqualsTest)
replaced return value with null for fr/sii/ogham/core/message/content/TemplateContent::getContext → KILLED

2.2
Location : getContext
Killed by : oghamall.it.email.EmailSMTPDefaultsTest.invalidTemplate(oghamall.it.email.EmailSMTPDefaultsTest)
replaced return value with null for fr/sii/ogham/core/message/content/TemplateContent::getContext → KILLED

3.3
Location : getContext
Killed by : none
replaced return value with null for fr/sii/ogham/core/message/content/TemplateContent::getContext → NO_COVERAGE

4.4
Location : getContext
Killed by : none
replaced return value with null for fr/sii/ogham/core/message/content/TemplateContent::getContext → TIMED_OUT

95

1.1
Location : toString
Killed by : none
replaced return value with "" for fr/sii/ogham/core/message/content/TemplateContent::toString → NO_COVERAGE

2.2
Location : toString
Killed by : none
replaced return value with "" for fr/sii/ogham/core/message/content/TemplateContent::toString → TIMED_OUT

3.3
Location : toString
Killed by : none
replaced return value with "" for fr/sii/ogham/core/message/content/TemplateContent::toString → SURVIVED

100

1.1
Location : hashCode
Killed by : oghamcore.ut.core.EqualsTest.templateContent(oghamcore.ut.core.EqualsTest)
replaced int return with 0 for fr/sii/ogham/core/message/content/TemplateContent::hashCode → KILLED

2.2
Location : hashCode
Killed by : none
replaced int return with 0 for fr/sii/ogham/core/message/content/TemplateContent::hashCode → NO_COVERAGE

105

1.1
Location : equals
Killed by : oghamcore.ut.core.EqualsTest.templateContent(oghamcore.ut.core.EqualsTest)
replaced boolean return with false for fr/sii/ogham/core/message/content/TemplateContent::equals → KILLED

2.2
Location : equals
Killed by : none
replaced boolean return with false for fr/sii/ogham/core/message/content/TemplateContent::equals → NO_COVERAGE

3.3
Location : equals
Killed by : oghamcore.ut.core.EqualsTest.templateContent(oghamcore.ut.core.EqualsTest)
replaced boolean return with true for fr/sii/ogham/core/message/content/TemplateContent::equals → KILLED

4.4
Location : equals
Killed by : none
replaced boolean return with true for fr/sii/ogham/core/message/content/TemplateContent::equals → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT OGHAM