OfficeStampers.java

1
package pro.verron.officestamper.preset;
2
3
import org.docx4j.openpackaging.exceptions.Docx4JException;
4
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
5
import pro.verron.officestamper.api.OfficeStamperConfiguration;
6
import pro.verron.officestamper.api.OfficeStamperException;
7
import pro.verron.officestamper.api.StreamStamper;
8
import pro.verron.officestamper.core.DocxStamper;
9
10
import java.io.InputStream;
11
12
/**
13
 * Main class of the docx-stamper library.
14
 * <p>
15
 * This class can be used to create "stampers" that will open .docx templates
16
 * to create a .docx document filled with custom data at runtime.
17
 *
18
 * @author Joseph Verron
19
 * @version ${version}
20
 * @since 1.6.4
21
 */
22
public class OfficeStampers {
23
24
25
    private OfficeStampers() {
26
        throw new OfficeStamperException("OfficeStampers cannot be instantiated");
27
    }
28
29
    /**
30
     * Creates a new DocxStamper with the default configuration.
31
     * Also adds the {@link Preprocessors#removeLanguageProof()} and {@link Preprocessors#mergeSimilarRuns()}
32
     * preprocessors.
33
     *
34
     * @return a new DocxStamper
35
     */
36
    public static StreamStamper<WordprocessingMLPackage> docxStamper() {
37 1 1. docxStamper : replaced return value with null for pro/verron/officestamper/preset/OfficeStampers::docxStamper → NO_COVERAGE
        return docxStamper(OfficeStamperConfigurations.standardWithPreprocessing());
38
    }
39
40
    /**
41
     * Creates a new instance of the {@link DocxStamper} class with the specified {@link OfficeStamperConfiguration}.
42
     *
43
     * @param config the configuration for the docx stamper
44
     *
45
     * @return a new instance of the {@link DocxStamper} class
46
     */
47
    public static StreamStamper<WordprocessingMLPackage> docxStamper(
48
            OfficeStamperConfiguration config
49
    ) {
50 1 1. docxStamper : replaced return value with null for pro/verron/officestamper/preset/OfficeStampers::docxStamper → KILLED
        return new StreamStamper<>(
51
                OfficeStampers::loadWord,
52
                new DocxStamper(config)
53
        );
54
    }
55
56
    private static WordprocessingMLPackage loadWord(InputStream is) {
57
        try {
58 1 1. loadWord : replaced return value with null for pro/verron/officestamper/preset/OfficeStampers::loadWord → KILLED
            return WordprocessingMLPackage.load(is);
59
        } catch (Docx4JException e) {
60
            throw new OfficeStamperException(e);
61
        }
62
    }
63
64
}

Mutations

37

1.1
Location : docxStamper
Killed by : none
replaced return value with null for pro/verron/officestamper/preset/OfficeStampers::docxStamper → NO_COVERAGE

50

1.1
Location : docxStamper
Killed by : pro.verron.officestamper.test.ResolutionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ResolutionTest]/[test-template:testCustomResolution(java.lang.String, boolean, boolean, boolean, boolean, boolean, java.lang.String, boolean, java.lang.String)]/[test-template-invocation:#30]
replaced return value with null for pro/verron/officestamper/preset/OfficeStampers::docxStamper → KILLED

58

1.1
Location : loadWord
Killed by : pro.verron.officestamper.test.ResolutionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ResolutionTest]/[test-template:testCustomResolution(java.lang.String, boolean, boolean, boolean, boolean, boolean, java.lang.String, boolean, java.lang.String)]/[test-template-invocation:#30]
replaced return value with null for pro/verron/officestamper/preset/OfficeStampers::loadWord → KILLED

Active mutators

Tests examined


Report generated by PIT 1.17.1