CommentProcessors.java

1
package pro.verron.officestamper.core;
2
3
import pro.verron.officestamper.api.CommentProcessor;
4
import pro.verron.officestamper.api.DocxPart;
5
import pro.verron.officestamper.api.ProcessorContext;
6
7
import java.util.AbstractMap;
8
import java.util.Map;
9
import java.util.Set;
10
11
/// The CommentProcessors class is a specialized extension of [AbstractMap] that serves as a registry
12
/// for associating [CommentProcessor] instances with their corresponding [Class] types.
13
/// This class facilitates the management and execution of multiple [CommentProcessor] objects by
14
/// coordinating their lifecycle operations, such as setting contexts and committing changes.
15
public class CommentProcessors
16
        extends AbstractMap<Class<?>, CommentProcessor> {
17
    private final Map<Class<?>, CommentProcessor> processors;
18
19
    /// Constructs a new CommentProcessors instance with the specified map of processors.
20
    ///
21
    /// @param processors a map associating [Class] types with their corresponding [CommentProcessor]
22
    ///                   instances; this map serves as the registry for managing and executing the processors
23
    public CommentProcessors(Map<Class<?>, CommentProcessor> processors) {
24
        this.processors = processors;
25
    }
26
27
    /// Sets the context for all registered [CommentProcessor] instances.
28
    /// This method delegates the provided [ProcessorContext] to each processor in the registry,
29
    /// enabling them to operate within the specified context.
30
    ///
31
    /// @param context the context in which the processors will operate, containing details about
32
    ///                the paragraph, run, comment, and placeholder being processed
33
    void setContext(ProcessorContext context) {
34
        for (var processor : processors.values()) {
35 1 1. setContext : removed call to pro/verron/officestamper/api/CommentProcessor::setProcessorContext → KILLED
            processor.setProcessorContext(context);
36
        }
37
    }
38
39
    /// Commits all changes made to the provided [DocxPart] across all registered [CommentProcessor] instances.
40
    /// This method ensures that each processor finalizes its processing for the given document part and resets its
41
    /// internal state to prepare for subsequent operations.
42
    ///
43
    /// @param source the [DocxPart] instance representing the part of the document that is being processed;
44
    ///               used as input for committing changes and finalizing the processing tasks of the comment processors
45
    void commitChanges(DocxPart source) {
46
        for (var processor : processors.values()) {
47 1 1. commitChanges : removed call to pro/verron/officestamper/api/CommentProcessor::commitChanges → KILLED
            processor.commitChanges(source);
48 1 1. commitChanges : removed call to pro/verron/officestamper/api/CommentProcessor::reset → KILLED
            processor.reset();
49
        }
50
    }
51
52
    /// Returns a set view of the mappings contained in this map.
53
    /// Each entry in the set is a mapping between a `Class<?>` key and its associated
54
    /// `CommentProcessor` value.
55
    ///
56
    /// @return a set of map entries representing the associations between `Class<?>` keys
57
    ///         and their corresponding `CommentProcessor` values in this map
58
    @Override public Set<Entry<Class<?>, CommentProcessor>> entrySet() {
59 1 1. entrySet : replaced return value with Collections.emptySet for pro/verron/officestamper/core/CommentProcessors::entrySet → KILLED
        return processors.entrySet();
60
    }
61
62
    @Override
63
    public int hashCode() {
64 1 1. hashCode : replaced int return with 0 for pro/verron/officestamper/core/CommentProcessors::hashCode → NO_COVERAGE
        return super.hashCode();
65
    }
66
67
    @Override
68
    public boolean equals(Object o) {
69 2 1. equals : replaced boolean return with true for pro/verron/officestamper/core/CommentProcessors::equals → NO_COVERAGE
2. equals : replaced boolean return with false for pro/verron/officestamper/core/CommentProcessors::equals → NO_COVERAGE
        return super.equals(o);
70
    }
71
}

Mutations

35

1.1
Location : setContext
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfTableRowsTest(pro.verron.officestamper.test.ContextFactory)]/[test-template-invocation:#2]
removed call to pro/verron/officestamper/api/CommentProcessor::setProcessorContext → KILLED

47

1.1
Location : commitChanges
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfTableRowsTest(pro.verron.officestamper.test.ContextFactory)]/[test-template-invocation:#2]
removed call to pro/verron/officestamper/api/CommentProcessor::commitChanges → KILLED

48

1.1
Location : commitChanges
Killed by : pro.verron.officestamper.test.ProcessorRepeatParagraphTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorRepeatParagraphTest]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, java.io.InputStream, java.lang.String)]/[test-template-invocation:#4]
removed call to pro/verron/officestamper/api/CommentProcessor::reset → KILLED

59

1.1
Location : entrySet
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfTableRowsTest(pro.verron.officestamper.test.ContextFactory)]/[test-template-invocation:#2]
replaced return value with Collections.emptySet for pro/verron/officestamper/core/CommentProcessors::entrySet → KILLED

64

1.1
Location : hashCode
Killed by : none
replaced int return with 0 for pro/verron/officestamper/core/CommentProcessors::hashCode → NO_COVERAGE

69

1.1
Location : equals
Killed by : none
replaced boolean return with true for pro/verron/officestamper/core/CommentProcessors::equals → NO_COVERAGE

2.2
Location : equals
Killed by : none
replaced boolean return with false for pro/verron/officestamper/core/CommentProcessors::equals → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.21.0