MergeSameStyleRuns.java

1
package pro.verron.officestamper.preset.preprocessors.similarrun;
2
3
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
4
import org.docx4j.wml.ContentAccessor;
5
import org.docx4j.wml.R;
6
import pro.verron.officestamper.api.PreProcessor;
7
import pro.verron.officestamper.core.DocumentUtil;
8
9
import java.util.LinkedHashSet;
10
import java.util.List;
11
12
public class MergeSameStyleRuns
13
        implements PreProcessor {
14
15
    /// {@inheritDoc}
16
    @Override
17
    public void process(WordprocessingMLPackage document) {
18
        var visitor = new SimilarRunVisitor();
19 1 1. process : removed call to pro/verron/officestamper/core/DocumentUtil::visitDocument → SURVIVED
        DocumentUtil.visitDocument(document, visitor);
20
        for (List<R> similarStyleRuns : visitor.getSimilarStyleRuns()) {
21
            R firstRun = similarStyleRuns.getFirst();
22
            var runContent = firstRun.getContent();
23
            var firstRunContent = new LinkedHashSet<>(runContent);
24
            var firstRunParentContent = ((ContentAccessor) firstRun.getParent()).getContent();
25
            for (R r : similarStyleRuns.subList(1, similarStyleRuns.size())) {
26
                firstRunParentContent.remove(r);
27
                firstRunContent.addAll(r.getContent());
28
            }
29 1 1. process : removed call to java/util/List::clear → KILLED
            runContent.clear();
30
            runContent.addAll(firstRunContent);
31
        }
32
    }
33
}

Mutations

19

1.1
Location : process
Killed by : none
removed call to pro/verron/officestamper/core/DocumentUtil::visitDocument → SURVIVED
Covering tests

29

1.1
Location : process
Killed by : pro.verron.officestamper.test.SpelInstantiationTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.SpelInstantiationTest]/[test-template:testDateInstantiationAndResolution(pro.verron.officestamper.test.ContextFactory)]/[test-template-invocation:#2]
removed call to java/util/List::clear → KILLED

Active mutators

Tests examined


Report generated by PIT 1.21.0