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
    /**
16
     * {@inheritDoc}
17
     */
18
    @Override
19
    public void process(WordprocessingMLPackage document) {
20
        var visitor = new SimilarRunVisitor();
21 1 1. process : removed call to pro/verron/officestamper/core/DocumentUtil::visitDocument → SURVIVED
        DocumentUtil.visitDocument(document, visitor);
22
        for (List<R> similarStyleRuns : visitor.getSimilarStyleRuns()) {
23
            R firstRun = similarStyleRuns.getFirst();
24
            var runContent = firstRun.getContent();
25
            var firstRunContent = new LinkedHashSet<>(runContent);
26
            var firstRunParentContent = ((ContentAccessor) firstRun.getParent()).getContent();
27
            for (R r : similarStyleRuns.subList(1, similarStyleRuns.size())) {
28
                firstRunParentContent.remove(r);
29
                firstRunContent.addAll(r.getContent());
30
            }
31 1 1. process : removed call to java/util/List::clear → KILLED
            runContent.clear();
32
            runContent.addAll(firstRunContent);
33
        }
34
    }
35
}

Mutations

21

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

31

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.20.0