ParsedContent.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.template.context.Context;
5
import fr.sii.ogham.core.util.EqualsBuilder;
6
import fr.sii.ogham.core.util.HashCodeBuilder;
7
8
/**
9
 * Represent a content that original content comes from a template.
10
 * 
11
 * This is a decorator. It also implements several interfaces to delegate to decorated contents.
12
 * 
13
 * @author Aurélien Baudet
14
 *
15
 */
16
public class ParsedContent implements MayHaveStringContent, UpdatableStringContent, HasResourcePath {
17
	/**
18
	 * The template content used to generate the {@link Content}
19
	 */
20
	private final TemplateContent source;
21
	/**
22
	 * The content that has been generated
23
	 */
24
	private final Content generated;
25
26
	/**
27
	 * Initializes the content with template source and the generated content.
28
	 * 
29
	 * @param source
30
	 *            the source that has been processed
31
	 * @param generated
32
	 *            the generated output
33
	 */
34
	public ParsedContent(TemplateContent source, Content generated) {
35
		super();
36
		this.source = source;
37
		this.generated = generated;
38
	}
39
40
	/**
41
	 * Initializes the content with template source and the generated content.
42
	 * 
43
	 * @param sourcePath
44
	 *            the source path that has been processed
45
	 * @param sourceContext
46
	 *            the evaluation context
47
	 * @param generated
48
	 *            the generated output as string
49
	 */
50
	public ParsedContent(ResourcePath sourcePath, Context sourceContext, String generated) {
51
		super();
52
		this.source = new TemplateContent(sourcePath, sourceContext);
53
		this.generated = new StringContent(generated);
54
	}
55
56
	@Override
57
	public String toString() {
58 6 1. toString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::toString → NO_COVERAGE
2. toString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::toString → TIMED_OUT
3. toString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::toString → KILLED
4. toString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::toString → KILLED
5. toString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::toString → KILLED
6. toString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::toString → KILLED
		return asString();
59
	}
60
61
	@Override
62
	public boolean canProvideString() {
63 9 1. canProvideString : replaced boolean return with true for fr/sii/ogham/core/message/content/ParsedContent::canProvideString → NO_COVERAGE
2. canProvideString : replaced boolean return with true for fr/sii/ogham/core/message/content/ParsedContent::canProvideString → SURVIVED
3. canProvideString : negated conditional → NO_COVERAGE
4. canProvideString : negated conditional → NO_COVERAGE
5. canProvideString : replaced boolean return with true for fr/sii/ogham/core/message/content/ParsedContent::canProvideString → TIMED_OUT
6. canProvideString : negated conditional → TIMED_OUT
7. canProvideString : negated conditional → TIMED_OUT
8. canProvideString : negated conditional → KILLED
9. canProvideString : negated conditional → KILLED
		return generated instanceof MayHaveStringContent && ((MayHaveStringContent) generated).canProvideString();
64
	}
65
66
	@Override
67
	public String asString() {
68 12 1. asString : negated conditional → NO_COVERAGE
2. asString : negated conditional → NO_COVERAGE
3. asString : negated conditional → TIMED_OUT
4. asString : negated conditional → TIMED_OUT
5. asString : negated conditional → KILLED
6. asString : negated conditional → KILLED
7. asString : negated conditional → KILLED
8. asString : negated conditional → KILLED
9. asString : negated conditional → KILLED
10. asString : negated conditional → KILLED
11. asString : negated conditional → KILLED
12. asString : negated conditional → KILLED
		if(generated instanceof MayHaveStringContent && ((MayHaveStringContent) generated).canProvideString()) {
69 6 1. asString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → NO_COVERAGE
2. asString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → TIMED_OUT
3. asString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → KILLED
4. asString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → KILLED
5. asString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → KILLED
6. asString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → KILLED
			return ((MayHaveStringContent) generated).asString();
70
		}
71 1 1. asString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → NO_COVERAGE
		return null;
72
	}
73
74
	@Override
75
	public void setStringContent(String content) {
76 2 1. setStringContent : negated conditional → NO_COVERAGE
2. setStringContent : negated conditional → KILLED
		if(generated instanceof UpdatableStringContent) {
77 2 1. setStringContent : removed call to fr/sii/ogham/core/message/content/UpdatableStringContent::setStringContent → NO_COVERAGE
2. setStringContent : removed call to fr/sii/ogham/core/message/content/UpdatableStringContent::setStringContent → KILLED
			((UpdatableStringContent) generated).setStringContent(content);
78
		}
79
	}
80
81
	@Override
82
	public int hashCode() {
83 1 1. hashCode : replaced int return with 0 for fr/sii/ogham/core/message/content/ParsedContent::hashCode → NO_COVERAGE
		return new HashCodeBuilder().append(source).append(generated).hashCode();
84
	}
85
86
	@Override
87
	public boolean equals(Object obj) {
88 2 1. equals : replaced boolean return with false for fr/sii/ogham/core/message/content/ParsedContent::equals → NO_COVERAGE
2. equals : replaced boolean return with true for fr/sii/ogham/core/message/content/ParsedContent::equals → NO_COVERAGE
		return new EqualsBuilder(this, obj).appendFields("source", "generated").isEqual();
89
	}
90
91
	@Override
92
	public ResourcePath getPath() {
93 2 1. getPath : replaced return value with null for fr/sii/ogham/core/message/content/ParsedContent::getPath → NO_COVERAGE
2. getPath : replaced return value with null for fr/sii/ogham/core/message/content/ParsedContent::getPath → KILLED
		return source.getPath();
94
	}
95
96
	public TemplateContent getSource() {
97 1 1. getSource : replaced return value with null for fr/sii/ogham/core/message/content/ParsedContent::getSource → NO_COVERAGE
		return source;
98
	}
99
100
	public Content getGenerated() {
101 1 1. getGenerated : replaced return value with null for fr/sii/ogham/core/message/content/ParsedContent::getGenerated → NO_COVERAGE
		return generated;
102
	}
103
	
104
}

Mutations

58

1.1
Location : toString
Killed by : oghamthymeleafv3.it.resolver.StringResourceResolverTest.text(oghamthymeleafv3.it.resolver.StringResourceResolverTest)
replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::toString → KILLED

2.2
Location : toString
Killed by : oghamall.it.freemarker.StaticMethodAccessTest.smsUsingFreemarkerTemplateShouldBeAbleToCallStaticMethods(oghamall.it.freemarker.StaticMethodAccessTest)
replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::toString → KILLED

3.3
Location : toString
Killed by : oghamthymeleafv2.it.resolver.StringResourceResolverTest.text(oghamthymeleafv2.it.resolver.StringResourceResolverTest)
replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::toString → KILLED

4.4
Location : toString
Killed by : oghamfremarker.it.FreeMarkerParserTest.nested(oghamfremarker.it.FreeMarkerParserTest)
replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::toString → KILLED

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

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

63

1.1
Location : canProvideString
Killed by : none
replaced boolean return with true for fr/sii/ogham/core/message/content/ParsedContent::canProvideString → NO_COVERAGE

2.2
Location : canProvideString
Killed by : none
replaced boolean return with true for fr/sii/ogham/core/message/content/ParsedContent::canProvideString → SURVIVED

3.3
Location : canProvideString
Killed by : none
replaced boolean return with true for fr/sii/ogham/core/message/content/ParsedContent::canProvideString → TIMED_OUT

4.4
Location : canProvideString
Killed by : oghamall.it.email.EmailMultiTemplateTest.withThymeleafOneVariantWithInvalidResourcePath(oghamall.it.email.EmailMultiTemplateTest)
negated conditional → KILLED

5.5
Location : canProvideString
Killed by : none
negated conditional → NO_COVERAGE

6.6
Location : canProvideString
Killed by : none
negated conditional → TIMED_OUT

7.7
Location : canProvideString
Killed by : oghamall.it.email.EmailMultiTemplateTest.withThymeleafOneVariantWithInvalidResourcePath(oghamall.it.email.EmailMultiTemplateTest)
negated conditional → KILLED

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

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

68

1.1
Location : asString
Killed by : oghamthymeleafv3.it.resolver.StringResourceResolverTest.text(oghamthymeleafv3.it.resolver.StringResourceResolverTest)
negated conditional → KILLED

2.2
Location : asString
Killed by : oghamall.it.email.EmailMultiTemplateTest.withThymeleafOneVariantWithParsingError(oghamall.it.email.EmailMultiTemplateTest)
negated conditional → KILLED

3.3
Location : asString
Killed by : oghamthymeleafv2.it.resolver.StringResourceResolverTest.text(oghamthymeleafv2.it.resolver.StringResourceResolverTest)
negated conditional → KILLED

4.4
Location : asString
Killed by : oghamfremarker.it.FreeMarkerParserTest.nested(oghamfremarker.it.FreeMarkerParserTest)
negated conditional → KILLED

5.5
Location : asString
Killed by : none
negated conditional → TIMED_OUT

6.6
Location : asString
Killed by : none
negated conditional → NO_COVERAGE

7.7
Location : asString
Killed by : oghamfremarker.it.FreeMarkerParserTest.nested(oghamfremarker.it.FreeMarkerParserTest)
negated conditional → KILLED

8.8
Location : asString
Killed by : oghamthymeleafv3.it.resolver.StringResourceResolverTest.text(oghamthymeleafv3.it.resolver.StringResourceResolverTest)
negated conditional → KILLED

9.9
Location : asString
Killed by : oghamthymeleafv2.it.resolver.StringResourceResolverTest.text(oghamthymeleafv2.it.resolver.StringResourceResolverTest)
negated conditional → KILLED

10.10
Location : asString
Killed by : none
negated conditional → TIMED_OUT

11.11
Location : asString
Killed by : oghamall.it.email.EmailMultiTemplateTest.withThymeleafOneVariantWithParsingError(oghamall.it.email.EmailMultiTemplateTest)
negated conditional → KILLED

12.12
Location : asString
Killed by : none
negated conditional → NO_COVERAGE

69

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

2.2
Location : asString
Killed by : oghamthymeleafv3.it.resolver.StringResourceResolverTest.text(oghamthymeleafv3.it.resolver.StringResourceResolverTest)
replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → KILLED

3.3
Location : asString
Killed by : oghamthymeleafv2.it.resolver.StringResourceResolverTest.text(oghamthymeleafv2.it.resolver.StringResourceResolverTest)
replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → KILLED

4.4
Location : asString
Killed by : none
replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → TIMED_OUT

5.5
Location : asString
Killed by : oghamfremarker.it.FreeMarkerParserTest.nested(oghamfremarker.it.FreeMarkerParserTest)
replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → KILLED

6.6
Location : asString
Killed by : oghamall.it.email.EmailMultiTemplateTest.withThymeleafOneVariantWithInvalidResourcePath(oghamall.it.email.EmailMultiTemplateTest)
replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → KILLED

71

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

76

1.1
Location : setStringContent
Killed by : oghamall.it.email.EmailSMTPDefaultsTest.subjectInTextTemplate(oghamall.it.email.EmailSMTPDefaultsTest)
negated conditional → KILLED

2.2
Location : setStringContent
Killed by : none
negated conditional → NO_COVERAGE

77

1.1
Location : setStringContent
Killed by : none
removed call to fr/sii/ogham/core/message/content/UpdatableStringContent::setStringContent → NO_COVERAGE

2.2
Location : setStringContent
Killed by : oghamall.it.email.EmailSMTPDefaultsTest.subjectInTextTemplate(oghamall.it.email.EmailSMTPDefaultsTest)
removed call to fr/sii/ogham/core/message/content/UpdatableStringContent::setStringContent → KILLED

83

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

88

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

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

93

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

2.2
Location : getPath
Killed by : oghamall.it.email.EmailMultiTemplateTest.withThymeleafOneVariantWithInvalidResourcePath(oghamall.it.email.EmailMultiTemplateTest)
replaced return value with null for fr/sii/ogham/core/message/content/ParsedContent::getPath → KILLED

97

1.1
Location : getSource
Killed by : none
replaced return value with null for fr/sii/ogham/core/message/content/ParsedContent::getSource → NO_COVERAGE

101

1.1
Location : getGenerated
Killed by : none
replaced return value with null for fr/sii/ogham/core/message/content/ParsedContent::getGenerated → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT OGHAM