InvocationContext.java

1
package com.github.dakusui.osynth.core;
2
3
import java.lang.reflect.Method;
4
5
import static java.util.Objects.requireNonNull;
6
7
public interface InvocationContext {
8
  ThreadLocal<InvocationContext> CONTEXT_THREAD_LOCAL = new ThreadLocal<>();
9
10
  Method invokedMethod();
11
12
  static InvocationContext forCurrentThread() {
13 1 1. forCurrentThread : replaced return value with null for com/github/dakusui/osynth/core/InvocationContext::forCurrentThread → KILLED
    return requireNonNull(CONTEXT_THREAD_LOCAL.get());
14
  }
15
16
  class Impl implements InvocationContext {
17
    private static void forCurrentThreadOrNewOneWith(Method invokedMethod) {
18 1 1. forCurrentThreadOrNewOneWith : removed call to com/github/dakusui/osynth/core/InvocationContext$Impl::invokedMethod → KILLED
      createContextIfNotYet().invokedMethod(invokedMethod);
19
    }
20
21
    static void contextWith(Method invokedMethod) {
22 1 1. contextWith : removed call to com/github/dakusui/osynth/core/InvocationContext$Impl::forCurrentThreadOrNewOneWith → KILLED
      Impl.forCurrentThreadOrNewOneWith(invokedMethod);
23
    }
24
25
    private static Impl createContextIfNotYet() {
26
      Impl ret = (Impl) CONTEXT_THREAD_LOCAL.get();
27 1 1. createContextIfNotYet : negated conditional → KILLED
      if (ret == null) {
28
        ret = new Impl();
29 1 1. createContextIfNotYet : removed call to java/lang/ThreadLocal::set → SURVIVED
        CONTEXT_THREAD_LOCAL.set(ret);
30
      }
31 1 1. createContextIfNotYet : replaced return value with null for com/github/dakusui/osynth/core/InvocationContext$Impl::createContextIfNotYet → KILLED
      return ret;
32
    }
33
34
    private Method invokedMethod;
35
36
    void invokedMethod(Method invokedMethod) {
37
      this.invokedMethod = invokedMethod;
38
    }
39
40
    @Override
41
    public Method invokedMethod() {
42 1 1. invokedMethod : replaced return value with null for com/github/dakusui/osynth/core/InvocationContext$Impl::invokedMethod → KILLED
      return this.invokedMethod;
43
    }
44
  }
45
}

Mutations

13

1.1
Location : forCurrentThread
Killed by : com.github.dakusui.osynth.ut.DelegationTest.whenDoDelegation$thenDelegatedObjectTakesControl(com.github.dakusui.osynth.ut.DelegationTest)
replaced return value with null for com/github/dakusui/osynth/core/InvocationContext::forCurrentThread → KILLED

18

1.1
Location : forCurrentThreadOrNewOneWith
Killed by : com.github.dakusui.osynth.ut.DelegationTest.whenDoDelegation$thenDelegatedObjectTakesControl(com.github.dakusui.osynth.ut.DelegationTest)
removed call to com/github/dakusui/osynth/core/InvocationContext$Impl::invokedMethod → KILLED

22

1.1
Location : contextWith
Killed by : com.github.dakusui.osynth.ut.DelegationTest.whenDoDelegation$thenDelegatedObjectTakesControl(com.github.dakusui.osynth.ut.DelegationTest)
removed call to com/github/dakusui/osynth/core/InvocationContext$Impl::forCurrentThreadOrNewOneWith → KILLED

27

1.1
Location : createContextIfNotYet
Killed by : com.github.dakusui.osynth.ut.core.SynthesizedObjectTest.descriptorSameReference(com.github.dakusui.osynth.ut.core.SynthesizedObjectTest)
negated conditional → KILLED

29

1.1
Location : createContextIfNotYet
Killed by : none
removed call to java/lang/ThreadLocal::set → SURVIVED

31

1.1
Location : createContextIfNotYet
Killed by : com.github.dakusui.osynth.ut.core.SynthesizedObjectTest.descriptorSameReference(com.github.dakusui.osynth.ut.core.SynthesizedObjectTest)
replaced return value with null for com/github/dakusui/osynth/core/InvocationContext$Impl::createContextIfNotYet → KILLED

42

1.1
Location : invokedMethod
Killed by : com.github.dakusui.osynth.ut.DelegationTest.whenDoDelegation$thenDelegatedObjectTakesControl(com.github.dakusui.osynth.ut.DelegationTest)
replaced return value with null for com/github/dakusui/osynth/core/InvocationContext$Impl::invokedMethod → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3