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
        var comment = this.comment;
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 1 1. run : negated conditional → KILLED
        if (engine.process(evaluationContext)) {
36 1 1. run : removed call to pro/verron/officestamper/core/CommentUtil::deleteComment → TIMED_OUT
            CommentUtil.deleteComment(comment);
37 1 1. run : replaced boolean return with false for pro/verron/officestamper/core/CommentHook::run → KILLED
            return true;
38
        }
39 1 1. run : replaced boolean return with true for pro/verron/officestamper/core/CommentHook::run → TIMED_OUT
        return false;
40
    }
41
42
    @Override
43
    public void setContextKey(String contextKey) {
44 1 1. setContextKey : removed call to pro/verron/officestamper/utils/wml/WmlUtils::setTagAttribute → NO_COVERAGE
        WmlUtils.setTagAttribute(tag.tag(), "context", contextKey);
45
    }
46
47
}

Mutations

35

1.1
Location : run
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfTableRowsTest(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/core/CommentUtil::deleteComment → TIMED_OUT

37

1.1
Location : run
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfTableRowsTest(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
replaced boolean return with false for pro/verron/officestamper/core/CommentHook::run → KILLED

39

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

44

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