HtmlTitleSubjectProvider.java

1
package fr.sii.ogham.core.subject.provider;
2
3
import fr.sii.ogham.core.message.Message;
4
import fr.sii.ogham.core.message.content.Content;
5
import fr.sii.ogham.core.message.content.MayHaveStringContent;
6
import fr.sii.ogham.core.util.HtmlUtils;
7
8
/**
9
 * Provider that analyzes the content of the message. It the content is HTML,
10
 * then the subject is extracted from the title node. The extracted subject is
11
 * trimmed. If the extracted subject is empty then the final subject is empty
12
 * string. If the HTML doesn't contain the title node, then the subject is null.
13
 * 
14
 * @author Aurélien Baudet
15
 *
16
 */
17
public class HtmlTitleSubjectProvider implements SubjectProvider {
18
19
	@Override
20
	public String provide(Message message) {
21
		Content content = message.getContent();
22 8 1. provide : negated conditional → NO_COVERAGE
2. provide : negated conditional → NO_COVERAGE
3. provide : negated conditional → TIMED_OUT
4. provide : negated conditional → TIMED_OUT
5. provide : negated conditional → KILLED
6. provide : negated conditional → KILLED
7. provide : negated conditional → KILLED
8. provide : negated conditional → KILLED
		if(content instanceof MayHaveStringContent && ((MayHaveStringContent) content).canProvideString()) {
23
			String stringContent = ((MayHaveStringContent) content).asString();
24 4 1. provide : negated conditional → NO_COVERAGE
2. provide : negated conditional → TIMED_OUT
3. provide : negated conditional → KILLED
4. provide : negated conditional → KILLED
			if (HtmlUtils.isHtml(stringContent)) {
25 4 1. provide : replaced return value with "" for fr/sii/ogham/core/subject/provider/HtmlTitleSubjectProvider::provide → NO_COVERAGE
2. provide : replaced return value with "" for fr/sii/ogham/core/subject/provider/HtmlTitleSubjectProvider::provide → TIMED_OUT
3. provide : replaced return value with "" for fr/sii/ogham/core/subject/provider/HtmlTitleSubjectProvider::provide → KILLED
4. provide : replaced return value with "" for fr/sii/ogham/core/subject/provider/HtmlTitleSubjectProvider::provide → KILLED
				return HtmlUtils.getTitle(stringContent);
26
			}
27
		}
28 3 1. provide : replaced return value with "" for fr/sii/ogham/core/subject/provider/HtmlTitleSubjectProvider::provide → SURVIVED
2. provide : replaced return value with "" for fr/sii/ogham/core/subject/provider/HtmlTitleSubjectProvider::provide → NO_COVERAGE
3. provide : replaced return value with "" for fr/sii/ogham/core/subject/provider/HtmlTitleSubjectProvider::provide → KILLED
		return null;
29
	}
30
31
}

Mutations

22

1.1
Location : provide
Killed by : none
negated conditional → TIMED_OUT

2.2
Location : provide
Killed by : oghamcore.ut.email.subject.provider.HtmlTitleSubjectProviderTest.withTitle(oghamcore.ut.email.subject.provider.HtmlTitleSubjectProviderTest)
negated conditional → KILLED

3.3
Location : provide
Killed by : none
negated conditional → NO_COVERAGE

4.4
Location : provide
Killed by : oghamall.it.email.EmailExtractSubjectTest.subjectExtractedFromTextWithDefaultSubjectShouldSendWithSubjectExtractedFromText(oghamall.it.email.EmailExtractSubjectTest)
negated conditional → KILLED

5.5
Location : provide
Killed by : oghamcore.ut.email.subject.provider.HtmlTitleSubjectProviderTest.withTitle(oghamcore.ut.email.subject.provider.HtmlTitleSubjectProviderTest)
negated conditional → KILLED

6.6
Location : provide
Killed by : oghamall.it.email.EmailExtractSubjectTest.subjectExtractedFromHtmlWithoutDefaultSubjectShouldSendWithHtmlTitle(oghamall.it.email.EmailExtractSubjectTest)
negated conditional → KILLED

7.7
Location : provide
Killed by : none
negated conditional → NO_COVERAGE

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

24

1.1
Location : provide
Killed by : oghamcore.ut.email.subject.provider.HtmlTitleSubjectProviderTest.withTitle(oghamcore.ut.email.subject.provider.HtmlTitleSubjectProviderTest)
negated conditional → KILLED

2.2
Location : provide
Killed by : none
negated conditional → TIMED_OUT

3.3
Location : provide
Killed by : none
negated conditional → NO_COVERAGE

4.4
Location : provide
Killed by : oghamall.it.email.EmailExtractSubjectTest.subjectExtractedFromHtmlWithoutDefaultSubjectShouldSendWithHtmlTitle(oghamall.it.email.EmailExtractSubjectTest)
negated conditional → KILLED

25

1.1
Location : provide
Killed by : oghamcore.ut.email.subject.provider.HtmlTitleSubjectProviderTest.withTitle(oghamcore.ut.email.subject.provider.HtmlTitleSubjectProviderTest)
replaced return value with "" for fr/sii/ogham/core/subject/provider/HtmlTitleSubjectProvider::provide → KILLED

2.2
Location : provide
Killed by : none
replaced return value with "" for fr/sii/ogham/core/subject/provider/HtmlTitleSubjectProvider::provide → TIMED_OUT

3.3
Location : provide
Killed by : oghamall.it.email.EmailExtractSubjectTest.noSubjectInContentsWithoutDefaultSubjectShouldSendWithoutSubject(oghamall.it.email.EmailExtractSubjectTest)
replaced return value with "" for fr/sii/ogham/core/subject/provider/HtmlTitleSubjectProvider::provide → KILLED

4.4
Location : provide
Killed by : none
replaced return value with "" for fr/sii/ogham/core/subject/provider/HtmlTitleSubjectProvider::provide → NO_COVERAGE

28

1.1
Location : provide
Killed by : none
replaced return value with "" for fr/sii/ogham/core/subject/provider/HtmlTitleSubjectProvider::provide → SURVIVED

2.2
Location : provide
Killed by : none
replaced return value with "" for fr/sii/ogham/core/subject/provider/HtmlTitleSubjectProvider::provide → NO_COVERAGE

3.3
Location : provide
Killed by : oghamall.it.email.EmailExtractSubjectTest.subjectExtractedFromTextWithDefaultSubjectShouldSendWithSubjectExtractedFromText(oghamall.it.email.EmailExtractSubjectTest)
replaced return value with "" for fr/sii/ogham/core/subject/provider/HtmlTitleSubjectProvider::provide → KILLED

Active mutators

Tests examined


Report generated by PIT OGHAM