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 2 1. provide : negated conditional → RUN_ERROR
2. provide : negated conditional → RUN_ERROR
		if(content instanceof MayHaveStringContent && ((MayHaveStringContent) content).canProvideString()) {
23
			String stringContent = ((MayHaveStringContent) content).asString();
24 1 1. provide : negated conditional → RUN_ERROR
			if (HtmlUtils.isHtml(stringContent)) {
25 1 1. provide : replaced return value with "" for fr/sii/ogham/core/subject/provider/HtmlTitleSubjectProvider::provide → RUN_ERROR
				return HtmlUtils.getTitle(stringContent);
26
			}
27
		}
28 1 1. provide : replaced return value with "" for fr/sii/ogham/core/subject/provider/HtmlTitleSubjectProvider::provide → RUN_ERROR
		return null;
29
	}
30
31
}

Mutations

22

1.1
Location : provide
Killed by :
negated conditional → RUN_ERROR

2.2
Location : provide
Killed by :
negated conditional → RUN_ERROR

24

1.1
Location : provide
Killed by :
negated conditional → RUN_ERROR

25

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

28

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

Active mutators

Tests examined


Report generated by PIT 1.13.1