TagHook.java

1
package pro.verron.officestamper.core;
2
3
import pro.verron.officestamper.api.DocxPart;
4
import pro.verron.officestamper.api.ProcessorContext;
5
import pro.verron.officestamper.utils.wml.WmlUtils;
6
7
/// Hook for processing tags.
8
public class TagHook
9
        implements DocxHook {
10
    private final Tag tag;
11
    private final DocxPart part;
12
13
    TagHook(DocxPart part, Tag tag) {
14
        this.tag = tag;
15
        this.part = part;
16
    }
17
18
    @Override
19
    public boolean run(
20
            EngineFactory engineFactory,
21
            ContextRoot contextRoot,
22
            OfficeStamperEvaluationContextFactory evaluationContextFactory
23
    ) {
24 2 1. run : replaced boolean return with true for pro/verron/officestamper/core/TagHook::run → TIMED_OUT
2. run : negated conditional → KILLED
        if (WmlUtils.hasTagAttribute(tag.tag(), "status", "executed")) return false;
25
        var comment = tag.asComment();
26
        var paragraph = tag.getParagraph();
27
        var expression = tag.expression();
28
        var contextKey = tag.getContextKey();
29
        var contextStack = contextRoot.find(contextKey);
30
        var processorContext = new ProcessorContext(part, paragraph, comment, expression, contextStack);
31
        var evaluationContext = evaluationContextFactory.create(processorContext, contextStack);
32
        var engine = engineFactory.create(processorContext);
33
        var tagType = tag.type()
34
                         .orElse(null);
35
        boolean processed = false;
36 1 1. run : negated conditional → KILLED
        if ("inlineProcessor".equals(tagType)) {
37 1 1. run : negated conditional → SURVIVED
            if (engine.process(evaluationContext)) processed = true;
38 1 1. run : removed call to pro/verron/officestamper/core/Tag::remove → KILLED
            tag.remove();
39
        }
40 1 1. run : negated conditional → KILLED
        else if ("placeholder".equals(tagType)) {
41
            var insert = engine.resolve(evaluationContext);
42
            processed = true;
43 1 1. run : removed call to pro/verron/officestamper/core/Tag::replace → KILLED
            tag.replace(insert);
44
        }
45 1 1. run : removed call to pro/verron/officestamper/utils/wml/WmlUtils::setTagAttribute → KILLED
        WmlUtils.setTagAttribute(tag.tag(), "status", "executed");
46 2 1. run : replaced boolean return with true for pro/verron/officestamper/core/TagHook::run → SURVIVED
2. run : replaced boolean return with false for pro/verron/officestamper/core/TagHook::run → SURVIVED
        return processed;
47
    }
48
49
    @Override
50
    public void setContextKey(String contextKey) {
51 1 1. setContextKey : removed call to pro/verron/officestamper/utils/wml/WmlUtils::setTagAttribute → NO_COVERAGE
        WmlUtils.setTagAttribute(tag.tag(), "context", contextKey);
52
    }
53
54
}

Mutations

24

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

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

36

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

37

1.1
Location : run
Killed by : none
negated conditional → SURVIVED
Covering tests

38

1.1
Location : run
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfParagraphsTest_unresolvedInlineProcessorExpressionsAreRemoved(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
removed call to pro/verron/officestamper/core/Tag::remove → KILLED

40

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

43

1.1
Location : run
Killed by : pro.verron.officestamper.test.CustomFunctionTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.CustomFunctionTests]/[test-template:trifunctions(pro.verron.officestamper.test.utils.ContextFactory, java.lang.String, java.lang.String)]/[test-template-invocation:#12]
removed call to pro/verron/officestamper/core/Tag::replace → KILLED

45

1.1
Location : run
Killed by : pro.verron.officestamper.test.CustomFunctionTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.CustomFunctionTests]/[test-template:trifunctions(pro.verron.officestamper.test.utils.ContextFactory, java.lang.String, java.lang.String)]/[test-template-invocation:#12]
removed call to pro/verron/officestamper/utils/wml/WmlUtils::setTagAttribute → KILLED

46

1.1
Location : run
Killed by : none
replaced boolean return with true for pro/verron/officestamper/core/TagHook::run → SURVIVED
Covering tests

2.2
Location : run
Killed by : none
replaced boolean return with false for pro/verron/officestamper/core/TagHook::run → SURVIVED Covering tests

51

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.23.1 support