Null2PlaceholderResolver.java

1
package pro.verron.officestamper.preset.resolvers.nulls;
2
3
import org.docx4j.wml.R;
4
import org.springframework.lang.Nullable;
5
import pro.verron.officestamper.api.DocxPart;
6
import pro.verron.officestamper.api.ObjectResolver;
7
import pro.verron.officestamper.api.OfficeStamperException;
8
import pro.verron.officestamper.api.Placeholder;
9
10
import static pro.verron.officestamper.utils.WmlFactory.newRun;
11
12
/**
13
 * The {@link Null2PlaceholderResolver} class is an implementation of the ObjectResolver interface.
14
 * It provides a way to resolve null objects by not replacing their expression.
15
 *
16
 * @author Joseph Verron
17
 * @version ${version}
18
 * @since 1.6.7
19
 */
20
public class Null2PlaceholderResolver
21
        implements ObjectResolver {
22
23
    /* package */
24
    public Null2PlaceholderResolver() {
25
        //DO NOTHING
26
    }
27
28
    @Override
29
    public R resolve(
30
            DocxPart document,
31
            Placeholder placeholder,
32
            Object object
33
    ) {
34 1 1. resolve : replaced return value with null for pro/verron/officestamper/preset/resolvers/nulls/Null2PlaceholderResolver::resolve → KILLED
        return newRun(placeholder.expression());
35
    }
36
37
    @Override
38
    public boolean canResolve(@Nullable Object object) {
39 2 1. canResolve : replaced boolean return with true for pro/verron/officestamper/preset/resolvers/nulls/Null2PlaceholderResolver::canResolve → SURVIVED
2. canResolve : negated conditional → KILLED
        return object == null;
40
    }
41
42
    @Override
43
    public R resolve(
44
            DocxPart document,
45
            String expression,
46
            Object object
47
    ) {
48
        throw new OfficeStamperException("Should not be called");
49
    }
50
}

Mutations

34

1.1
Location : resolve
Killed by : pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, java.io.InputStream, java.lang.String)]/[test-template-invocation:#5]
replaced return value with null for pro/verron/officestamper/preset/resolvers/nulls/Null2PlaceholderResolver::resolve → KILLED

39

1.1
Location : canResolve
Killed by : pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, java.io.InputStream, java.lang.String)]/[test-template-invocation:#5]
negated conditional → KILLED

2.2
Location : canResolve
Killed by : none
replaced boolean return with true for pro/verron/officestamper/preset/resolvers/nulls/Null2PlaceholderResolver::canResolve → SURVIVED
Covering tests

Active mutators

Tests examined


Report generated by PIT 1.17.1