UnionEvaluationContext.java

1
package pro.verron.officestamper.core;
2
3
import org.jspecify.annotations.Nullable;
4
import org.springframework.expression.*;
5
6
import java.util.ArrayList;
7
import java.util.List;
8
import java.util.Objects;
9
10
/// An {@link EvaluationContext} that combines multiple contexts.
11
public class UnionEvaluationContext
12
        implements EvaluationContext {
13
    private final EvaluationContext evaluationContext;
14
    private final Invokers invokers;
15
16
    UnionEvaluationContext(EvaluationContext evaluationContext, Invokers invokers) {
17
        this.evaluationContext = evaluationContext;
18
        this.invokers = invokers;
19
    }
20
21
    @Override
22
    public TypedValue getRootObject() {
23 1 1. getRootObject : replaced return value with null for pro/verron/officestamper/core/UnionEvaluationContext::getRootObject → KILLED
        return evaluationContext.getRootObject();
24
    }
25
26
    @Override
27
    public List<PropertyAccessor> getPropertyAccessors() {
28
        var accessors = evaluationContext.getPropertyAccessors();
29
        var unionAccessors = new ArrayList<>(accessors);
30 1 1. getPropertyAccessors : removed call to java/util/ArrayList::addFirst → SURVIVED
        unionAccessors.addFirst(new UnionPropertyAccessor(accessors));
31 1 1. getPropertyAccessors : replaced return value with Collections.emptyList for pro/verron/officestamper/core/UnionEvaluationContext::getPropertyAccessors → KILLED
        return unionAccessors;
32
    }
33
34
    @Override
35
    public List<IndexAccessor> getIndexAccessors() {
36
        var accessors = evaluationContext.getIndexAccessors();
37
        var unionAccessors = new ArrayList<>(accessors);
38 1 1. getIndexAccessors : removed call to java/util/ArrayList::addFirst → NO_COVERAGE
        unionAccessors.addFirst(new UnionIndexAccessor(accessors));
39 1 1. getIndexAccessors : replaced return value with Collections.emptyList for pro/verron/officestamper/core/UnionEvaluationContext::getIndexAccessors → NO_COVERAGE
        return unionAccessors;
40
    }
41
42
    @Override
43
    public List<ConstructorResolver> getConstructorResolvers() {
44 1 1. getConstructorResolvers : replaced return value with Collections.emptyList for pro/verron/officestamper/core/UnionEvaluationContext::getConstructorResolvers → KILLED
        return evaluationContext.getConstructorResolvers();
45
    }
46
47
    @Override
48
    public List<MethodResolver> getMethodResolvers() {
49
        var resolvers = evaluationContext.getMethodResolvers();
50
        var unionResolvers = new ArrayList<>(resolvers);
51 1 1. getMethodResolvers : removed call to java/util/ArrayList::addFirst → SURVIVED
        unionResolvers.addFirst(new UnionMethodResolver(resolvers));
52
        unionResolvers.add(invokers);
53 1 1. getMethodResolvers : replaced return value with Collections.emptyList for pro/verron/officestamper/core/UnionEvaluationContext::getMethodResolvers → KILLED
        return unionResolvers;
54
    }
55
56
    @Override
57
    @Nullable
58
    public BeanResolver getBeanResolver() {
59 1 1. getBeanResolver : replaced return value with null for pro/verron/officestamper/core/UnionEvaluationContext::getBeanResolver → NO_COVERAGE
        return evaluationContext.getBeanResolver();
60
    }
61
62
    @Override
63
    public TypeLocator getTypeLocator() {
64 1 1. getTypeLocator : replaced return value with null for pro/verron/officestamper/core/UnionEvaluationContext::getTypeLocator → KILLED
        return evaluationContext.getTypeLocator();
65
    }
66
67
    @Override
68
    public TypeConverter getTypeConverter() {
69 1 1. getTypeConverter : replaced return value with null for pro/verron/officestamper/core/UnionEvaluationContext::getTypeConverter → KILLED
        return evaluationContext.getTypeConverter();
70
    }
71
72
    @Override
73
    public TypeComparator getTypeComparator() {
74 1 1. getTypeComparator : replaced return value with null for pro/verron/officestamper/core/UnionEvaluationContext::getTypeComparator → NO_COVERAGE
        return evaluationContext.getTypeComparator();
75
    }
76
77
    @Override
78
    public OperatorOverloader getOperatorOverloader() {
79 1 1. getOperatorOverloader : replaced return value with null for pro/verron/officestamper/core/UnionEvaluationContext::getOperatorOverloader → NO_COVERAGE
        return evaluationContext.getOperatorOverloader();
80
    }
81
82
    @Override
83
    public void setVariable(String name, @Nullable Object value) {
84 1 1. setVariable : removed call to org/springframework/expression/EvaluationContext::setVariable → NO_COVERAGE
        evaluationContext.setVariable(name, value);
85
    }
86
87
    @Override
88
    @Nullable
89
    public Object lookupVariable(String name) {
90 1 1. lookupVariable : replaced return value with null for pro/verron/officestamper/core/UnionEvaluationContext::lookupVariable → NO_COVERAGE
        return evaluationContext.lookupVariable(name);
91
    }
92
93
    @Override
94
    public int hashCode() {
95 1 1. hashCode : replaced int return with 0 for pro/verron/officestamper/core/UnionEvaluationContext::hashCode → NO_COVERAGE
        return Objects.hash(evaluationContext, invokers);
96
    }
97
98
    @Override
99
    public boolean equals(Object obj) {
100 2 1. equals : replaced boolean return with false for pro/verron/officestamper/core/UnionEvaluationContext::equals → NO_COVERAGE
2. equals : negated conditional → NO_COVERAGE
        if (obj == this) return true;
101 3 1. equals : negated conditional → NO_COVERAGE
2. equals : negated conditional → NO_COVERAGE
3. equals : replaced boolean return with true for pro/verron/officestamper/core/UnionEvaluationContext::equals → NO_COVERAGE
        if (obj == null || obj.getClass() != this.getClass()) return false;
102
        var that = (UnionEvaluationContext) obj;
103 3 1. equals : negated conditional → NO_COVERAGE
2. equals : replaced boolean return with true for pro/verron/officestamper/core/UnionEvaluationContext::equals → NO_COVERAGE
3. equals : negated conditional → NO_COVERAGE
        return Objects.equals(this.evaluationContext, that.evaluationContext) && Objects.equals(this.invokers,
104
                that.invokers);
105
    }
106
107
    @Override
108
    public String toString() {
109 1 1. toString : replaced return value with "" for pro/verron/officestamper/core/UnionEvaluationContext::toString → SURVIVED
        return "UnionEvaluationContext[evaluationContext=%s, invokers=%s]".formatted(evaluationContext, invokers);
110
    }
111
}

Mutations

23

1.1
Location : getRootObject
Killed by : pro.verron.officestamper.test.SpelInjectionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.SpelInjectionTest]/[test-template:spelInjectionTest(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
replaced return value with null for pro/verron/officestamper/core/UnionEvaluationContext::getRootObject → KILLED

30

1.1
Location : getPropertyAccessors
Killed by : none
removed call to java/util/ArrayList::addFirst → SURVIVED
Covering tests

31

1.1
Location : getPropertyAccessors
Killed by : pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, org.docx4j.openpackaging.packages.WordprocessingMLPackage, java.lang.String)]/[test-template-invocation:#35]
replaced return value with Collections.emptyList for pro/verron/officestamper/core/UnionEvaluationContext::getPropertyAccessors → KILLED

38

1.1
Location : getIndexAccessors
Killed by : none
removed call to java/util/ArrayList::addFirst → NO_COVERAGE

39

1.1
Location : getIndexAccessors
Killed by : none
replaced return value with Collections.emptyList for pro/verron/officestamper/core/UnionEvaluationContext::getIndexAccessors → NO_COVERAGE

44

1.1
Location : getConstructorResolvers
Killed by : pro.verron.officestamper.test.SpelInstantiationTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.SpelInstantiationTest]/[test-template:testDateInstantiationAndResolution(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
replaced return value with Collections.emptyList for pro/verron/officestamper/core/UnionEvaluationContext::getConstructorResolvers → KILLED

51

1.1
Location : getMethodResolvers
Killed by : none
removed call to java/util/ArrayList::addFirst → SURVIVED
Covering tests

53

1.1
Location : getMethodResolvers
Killed by : pro.verron.officestamper.test.CustomProcessorTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.CustomProcessorTests]/[test-template:should_allow_custom_processors_injection(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
replaced return value with Collections.emptyList for pro/verron/officestamper/core/UnionEvaluationContext::getMethodResolvers → KILLED

59

1.1
Location : getBeanResolver
Killed by : none
replaced return value with null for pro/verron/officestamper/core/UnionEvaluationContext::getBeanResolver → NO_COVERAGE

64

1.1
Location : getTypeLocator
Killed by : pro.verron.officestamper.test.SpelInjectionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.SpelInjectionTest]/[test-template:spelInjectionTest(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
replaced return value with null for pro/verron/officestamper/core/UnionEvaluationContext::getTypeLocator → KILLED

69

1.1
Location : getTypeConverter
Killed by : pro.verron.officestamper.test.NullPointerResolutionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.NullPointerResolutionTest]/[test-template:nullPointerResolutionTest_testThrowingCase(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
replaced return value with null for pro/verron/officestamper/core/UnionEvaluationContext::getTypeConverter → KILLED

74

1.1
Location : getTypeComparator
Killed by : none
replaced return value with null for pro/verron/officestamper/core/UnionEvaluationContext::getTypeComparator → NO_COVERAGE

79

1.1
Location : getOperatorOverloader
Killed by : none
replaced return value with null for pro/verron/officestamper/core/UnionEvaluationContext::getOperatorOverloader → NO_COVERAGE

84

1.1
Location : setVariable
Killed by : none
removed call to org/springframework/expression/EvaluationContext::setVariable → NO_COVERAGE

90

1.1
Location : lookupVariable
Killed by : none
replaced return value with null for pro/verron/officestamper/core/UnionEvaluationContext::lookupVariable → NO_COVERAGE

95

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

100

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

2.2
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

101

1.1
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

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

103

1.1
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

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

3.3
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

109

1.1
Location : toString
Killed by : none
replaced return value with "" for pro/verron/officestamper/core/UnionEvaluationContext::toString → SURVIVED
Covering tests

Active mutators

Tests examined


Report generated by PIT 1.22.1