Hooks.java

1
package pro.verron.officestamper.api;
2
3
import org.docx4j.wml.CTSmartTagRun;
4
import org.docx4j.wml.ContentAccessor;
5
import pro.verron.officestamper.utils.iterator.ResetableIterator;
6
import pro.verron.officestamper.utils.wml.DocxIterator;
7
import pro.verron.officestamper.utils.wml.WmlUtils;
8
9
/// Provides utility methods for working with [Hook] instances in the context of a WordprocessingML-based document. The
10
/// [Hooks] class contains static methods to create and manage [ResetableIterator] instances of hooks for a given
11
/// document part. These hooks allow the customization or extension of document processing behavior in a flexible and
12
/// context-driven manner.
13
public class Hooks {
14
15
    private Hooks() {
16
        throw new IllegalStateException("Utility class");
17
    }
18
19
    /// Creates a [ResetableIterator] of Hook instances for a specific document part, based on the provided content
20
    /// accessor. This method filters potential hooks from the content and maps them to Hook instances associated with
21
    /// the given document part.
22
    ///
23
    /// @param contentAccessor the content accessor providing access to the document's content
24
    /// @return a [ResetableIterator] of Hook instances for the specified document part
25
    public static ResetableIterator<Hook> ofHooks(ContentAccessor contentAccessor) {
26 1 1. ofHooks : replaced return value with null for pro/verron/officestamper/api/Hooks::ofHooks → KILLED
        return new DocxIterator(contentAccessor).filter(Hooks::isHook)
27
                                                .map(Hooks::asHook);
28
    }
29
30
    private static boolean isHook(Object o) {
31 3 1. isHook : negated conditional → KILLED
2. isHook : negated conditional → KILLED
3. isHook : replaced boolean return with true for pro/verron/officestamper/api/Hooks::isHook → KILLED
        return o instanceof CTSmartTagRun tag && WmlUtils.isTagElement(tag, "officestamper");
32
    }
33
34
    private static Hook asHook(Object o) {
35 2 1. asHook : negated conditional → KILLED
2. asHook : negated conditional → KILLED
        if (o instanceof CTSmartTagRun tag && WmlUtils.isTagElement(tag, "officestamper"))
36 2 1. lambda$asHook$0 : removed call to pro/verron/officestamper/utils/wml/WmlUtils::setTagAttribute → KILLED
2. asHook : replaced return value with null for pro/verron/officestamper/api/Hooks::asHook → KILLED
            return contextKey -> WmlUtils.setTagAttribute(tag, "context", contextKey);
37
        throw new IllegalArgumentException("Unexpected value: " + o);
38
    }
39
}

Mutations

26

1.1
Location : ofHooks
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:#3]
replaced return value with null for pro/verron/officestamper/api/Hooks::ofHooks → KILLED

31

1.1
Location : isHook
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:#3]
negated conditional → KILLED

2.2
Location : isHook
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:#3]
negated conditional → KILLED

3.3
Location : isHook
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:#3]
replaced boolean return with true for pro/verron/officestamper/api/Hooks::isHook → KILLED

35

1.1
Location : asHook
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:#3]
negated conditional → KILLED

2.2
Location : asHook
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:#3]
negated conditional → KILLED

36

1.1
Location : lambda$asHook$0
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:#3]
removed call to pro/verron/officestamper/utils/wml/WmlUtils::setTagAttribute → KILLED

2.2
Location : asHook
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:#3]
replaced return value with null for pro/verron/officestamper/api/Hooks::asHook → KILLED

Active mutators

Tests examined


Report generated by PIT 1.25.5 support