ReflectionExecutor.java

1
package pro.verron.officestamper.core;
2
3
import org.springframework.expression.AccessException;
4
import org.springframework.expression.EvaluationContext;
5
import org.springframework.expression.MethodExecutor;
6
import org.springframework.expression.TypedValue;
7
import org.springframework.lang.NonNull;
8
9
import java.lang.reflect.InvocationTargetException;
10
import java.lang.reflect.Method;
11
import java.util.Arrays;
12
13
public record ReflectionExecutor(Object object, Method method)
14
        implements MethodExecutor {
15
16
    @Override @NonNull
17
    public TypedValue execute(
18
            @NonNull EvaluationContext context,
19
            @NonNull Object target,
20
            @NonNull Object... arguments
21
    )
22
            throws AccessException {
23
        try {
24
            var value = method.invoke(object, arguments);
25 1 1. execute : replaced return value with null for pro/verron/officestamper/core/ReflectionExecutor::execute → KILLED
            return new TypedValue(value);
26
        } catch (InvocationTargetException | IllegalAccessException e) {
27
            var message = "Failed to invoke method %s with arguments [%s] from object %s"
28
                    .formatted(method, Arrays.toString(arguments), object);
29
            throw new AccessException(message, e);
30
        }
31
    }
32
}

Mutations

25

1.1
Location : execute
Killed by : pro.verron.officestamper.test.RegressionTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.RegressionTests]/[method:test64()]
replaced return value with null for pro/verron/officestamper/core/ReflectionExecutor::execute → KILLED

Active mutators

Tests examined


Report generated by PIT 1.17.1