CommentHook.java

1
package pro.verron.officestamper.core;
2
3
import pro.verron.officestamper.api.Comment;
4
import pro.verron.officestamper.api.DocxPart;
5
import pro.verron.officestamper.api.ProcessorContext;
6
import pro.verron.officestamper.utils.wml.WmlUtils;
7
8
/// A hook that processes comments in a document.
9
public class CommentHook
10
        implements DocxHook {
11
    private final DocxPart part;
12
    private final Tag tag;
13
    private final Comment comment;
14
15
    CommentHook(DocxPart part, Tag tag, Comment comment) {
16
        this.part = part;
17
        this.tag = tag;
18
        this.comment = comment;
19
    }
20
21
    @Override
22
    public boolean run(
23
            EngineFactory engineFactory,
24
            ContextRoot contextRoot,
25
            OfficeStamperEvaluationContextFactory evaluationContextFactory
26
    ) {
27 2 1. run : replaced boolean return with true for pro/verron/officestamper/core/CommentHook::run → TIMED_OUT
2. run : negated conditional → KILLED
        if (WmlUtils.hasTagAttribute(tag.tag(), "status", "executed")) return false;
28
        var paragraph = tag.getParagraph();
29
        var expression = comment.expression();
30
        var contextKey = tag.getContextKey();
31
        var contextStack = contextRoot.find(contextKey);
32
        var processorContext = new ProcessorContext(part, paragraph, comment, expression, contextStack);
33
        var evaluationContext = evaluationContextFactory.create(processorContext, contextStack);
34
        var engine = engineFactory.create(processorContext);
35
        var processed = engine.process(evaluationContext);
36 1 1. run : removed call to pro/verron/officestamper/utils/wml/WmlUtils::setTagAttribute → TIMED_OUT
        WmlUtils.setTagAttribute(tag.tag(), "status", "executed");
37 2 1. run : replaced boolean return with true for pro/verron/officestamper/core/CommentHook::run → TIMED_OUT
2. run : replaced boolean return with false for pro/verron/officestamper/core/CommentHook::run → KILLED
        return processed;
38
    }
39
40
    @Override
41
    public void setContextKey(String contextKey) {
42
        var smartTag = tag.tag();
43
        var attributeKey = "context";
44
        var attributeValue = contextKey;
45 1 1. setContextKey : removed call to pro/verron/officestamper/utils/wml/WmlUtils::setTagAttribute → NO_COVERAGE
        WmlUtils.setTagAttribute(smartTag, attributeKey, attributeValue);
46
    }
47
48
}

Mutations

27

1.1
Location : run
Killed by : none
replaced boolean return with true for pro/verron/officestamper/core/CommentHook::run → TIMED_OUT

2.2
Location : run
Killed by : pro.verron.officestamper.test.FailOnUnresolvedPlaceholderTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.FailOnUnresolvedPlaceholderTest]/[test-template:fails(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
negated conditional → KILLED

36

1.1
Location : run
Killed by : none
removed call to pro/verron/officestamper/utils/wml/WmlUtils::setTagAttribute → TIMED_OUT

37

1.1
Location : run
Killed by : pro.verron.officestamper.test.RegressionTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.RegressionTests]/[test-template:test52(pro.verron.officestamper.test.RegressionTests$Conditions, java.lang.String)]/[test-template-invocation:#1]
replaced boolean return with false for pro/verron/officestamper/core/CommentHook::run → KILLED

2.2
Location : run
Killed by : none
replaced boolean return with true for pro/verron/officestamper/core/CommentHook::run → TIMED_OUT

45

1.1
Location : setContextKey
Killed by : none
removed call to pro/verron/officestamper/utils/wml/WmlUtils::setTagAttribute → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.22.0