|
1
|
|
package com.github.dakusui.symfonion.compat.exceptions; |
|
2
|
|
|
|
3
|
|
import java.io.Closeable; |
|
4
|
|
import java.util.HashMap; |
|
5
|
|
|
|
6
|
|
import static com.github.valid8j.fluent.Expectations.*; |
|
7
|
|
|
|
8
|
|
public class ExceptionContext implements Closeable { |
|
9
|
|
private final ExceptionContext parent; |
|
10
|
|
private final HashMap<CompatExceptionThrower.ContextKey, Object> values = HashMap.newHashMap(100); |
|
11
|
|
|
|
12
|
|
private ExceptionContext(ExceptionContext parent) { |
|
13
|
|
this.parent = parent; |
|
14
|
|
} |
|
15
|
|
|
|
16
|
|
public ExceptionContext() { |
|
17
|
|
this.parent = null; |
|
18
|
|
} |
|
19
|
|
|
|
20
|
|
public static ExceptionContextEntry entry(CompatExceptionThrower.ContextKey key, Object value) { |
|
21
|
|
assert preconditions(value(key).then().notNull().$(), |
|
22
|
|
value(value).then().notNull().instanceOf(CompatExceptionThrower.classOfValueFor(key)).$()); |
|
23
|
1
1. entry : replaced return value with null for com/github/dakusui/symfonion/compat/exceptions/ExceptionContext::entry → KILLED
|
return new ExceptionContextEntry(key, value); |
|
24
|
|
} |
|
25
|
|
|
|
26
|
|
public ExceptionContext set(CompatExceptionThrower.ContextKey key, Object value) { |
|
27
|
|
assert preconditions( |
|
28
|
|
value(key).then().notNull().$(), |
|
29
|
|
value(value).then().notNull().instanceOf(key.type()).$()); |
|
30
|
|
this.values.put(key, value); |
|
31
|
1
1. set : replaced return value with null for com/github/dakusui/symfonion/compat/exceptions/ExceptionContext::set → SURVIVED
|
return this; |
|
32
|
|
} |
|
33
|
|
|
|
34
|
|
public ExceptionContext parent() { |
|
35
|
1
1. parent : replaced return value with null for com/github/dakusui/symfonion/compat/exceptions/ExceptionContext::parent → KILLED
|
return this.parent; |
|
36
|
|
} |
|
37
|
|
|
|
38
|
|
/** |
|
39
|
|
* |
|
40
|
|
*/ |
|
41
|
|
@SuppressWarnings({"unchecked"}) |
|
42
|
|
<T> T get(CompatExceptionThrower.ContextKey key) { |
|
43
|
|
assert preconditions(value(key).then().notNull().$()); |
|
44
|
|
// In production, we do not want to produce a NullPointerException, even if the key is null. |
|
45
|
|
// Just return null in such a situation. |
|
46
|
1
1. get : negated conditional → KILLED
|
if (key == null) |
|
47
|
|
return null; |
|
48
|
1
1. get : negated conditional → KILLED
|
if (!this.values.containsKey(key)) { |
|
49
|
|
assert invariant(value(this).invoke("parent").then().notNull()); |
|
50
|
|
// In production, we do not want to produce a NullPointerException, even if a value associated with the key doesn't exist. |
|
51
|
|
// Just return null, in such a situation. |
|
52
|
1
1. get : negated conditional → KILLED
|
if (this.parent() == null) |
|
53
|
|
return null; |
|
54
|
1
1. get : replaced return value with null for com/github/dakusui/symfonion/compat/exceptions/ExceptionContext::get → KILLED
|
return this.parent().get(key); |
|
55
|
|
} |
|
56
|
1
1. get : replaced return value with null for com/github/dakusui/symfonion/compat/exceptions/ExceptionContext::get → KILLED
|
return (T) this.values.get(key); |
|
57
|
|
} |
|
58
|
|
|
|
59
|
|
|
|
60
|
|
@Override |
|
61
|
|
public void close() { |
|
62
|
1
1. close : removed call to java/lang/ThreadLocal::set → SURVIVED
|
CompatExceptionThrower.context.set(this.parent); |
|
63
|
|
} |
|
64
|
|
|
|
65
|
|
ExceptionContext createChild() { |
|
66
|
1
1. createChild : replaced return value with null for com/github/dakusui/symfonion/compat/exceptions/ExceptionContext::createChild → KILLED
|
return new ExceptionContext(this); |
|
67
|
|
} |
|
68
|
|
} |
| | Mutations |
| 23 |
|
1.1 Location : entry Killed by : com.github.dakusui.symfonion.tests.InvalidJsonErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidJsonErrorTest]/[method:invalid_array()] replaced return value with null for com/github/dakusui/symfonion/compat/exceptions/ExceptionContext::entry → KILLED
|
| 31 |
|
1.1 Location : set Killed by : none replaced return value with null for com/github/dakusui/symfonion/compat/exceptions/ExceptionContext::set → SURVIVED
Covering tests
Covered by tests:
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#14]
- com.github.dakusui.symfonion.tests.InvalidJsonErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidJsonErrorTest]/[method:invalid_array()]
- com.github.dakusui.symfonion.tests.MalformedTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MalformedTest]/[method:givenMalformed_emptyFile()]
- com.github.dakusui.symfonion.tests.MalformedTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MalformedTest]/[method:givenMalformed_brokenObject()]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#2]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#3]
- com.github.dakusui.symfonion.tests.InvalidJsonErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidJsonErrorTest]/[method:invalid_01()]
- com.github.dakusui.symfonion.tests.InvalidJsonErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidJsonErrorTest]/[method:missingSection_sequence()]
- com.github.dakusui.symfonion.tests.InvalidJsonErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidJsonErrorTest]/[method:missingSection_groove()]
- com.github.dakusui.symfonion.tests.InvalidDataErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidDataErrorTest]/[method:illegalFraction()]
- com.github.dakusui.symfonion.tests.ReferenceErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.ReferenceErrorTest]/[method:missingNoteMap()]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#1]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#4]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#8]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#13]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#10]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#9]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#11]
- com.github.dakusui.symfonion.tests.InvalidDataErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidDataErrorTest]/[method:illegalNoteLength_02()]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#12]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[method:pickupNotation_noteOnAtCorrectTick()]
- com.github.dakusui.symfonion.tests.ReferenceErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.ReferenceErrorTest]/[method:missingNote()]
- com.github.dakusui.symfonion.tests.ReferenceErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.ReferenceErrorTest]/[method:missingGroove()]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#7]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#6]
- com.github.dakusui.symfonion.tests.InvalidJsonErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidJsonErrorTest]/[method:missingSection_parts()]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#5]
- com.github.dakusui.symfonion.tests.InvalidDataErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidDataErrorTest]/[method:illegalNoteLength_03()]
- com.github.dakusui.symfonion.tests.cli.subcommands.CompatCompileTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.cli.subcommands.CompatCompileTest]/[method:test()]
- com.github.dakusui.symfonion.tests.InvalidDataErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidDataErrorTest]/[method:illegalNoteLength_01()]
- com.github.dakusui.symfonion.tests.ReferenceErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.ReferenceErrorTest]/[method:missingPart()]
- com.github.dakusui.symfonion.tests.cli.subcommands.PatchBayTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.cli.subcommands.PatchBayTest]/[method:whenPatchBay_thenOutputLooksOk()]
|
| 35 |
|
1.1 Location : parent Killed by : com.github.dakusui.symfonion.tests.InvalidJsonErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidJsonErrorTest]/[method:missingSection_groove()] replaced return value with null for com/github/dakusui/symfonion/compat/exceptions/ExceptionContext::parent → KILLED
|
| 46 |
|
1.1 Location : get Killed by : com.github.dakusui.symfonion.tests.MalformedTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MalformedTest]/[method:givenMalformed_emptyFile()] negated conditional → KILLED
|
| 48 |
|
1.1 Location : get Killed by : com.github.dakusui.symfonion.tests.MalformedTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MalformedTest]/[method:givenMalformed_emptyFile()] negated conditional → KILLED
|
| 52 |
|
1.1 Location : get Killed by : com.github.dakusui.symfonion.tests.InvalidDataErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidDataErrorTest]/[method:illegalFraction()] negated conditional → KILLED
|
| 54 |
|
1.1 Location : get Killed by : com.github.dakusui.symfonion.tests.InvalidDataErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidDataErrorTest]/[method:illegalFraction()] replaced return value with null for com/github/dakusui/symfonion/compat/exceptions/ExceptionContext::get → KILLED
|
| 56 |
|
1.1 Location : get Killed by : com.github.dakusui.symfonion.tests.MalformedTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MalformedTest]/[method:givenMalformed_emptyFile()] replaced return value with null for com/github/dakusui/symfonion/compat/exceptions/ExceptionContext::get → KILLED
|
| 62 |
|
1.1 Location : close Killed by : none removed call to java/lang/ThreadLocal::set → SURVIVED
Covering tests
Covered by tests:
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#14]
- com.github.dakusui.symfonion.tests.InvalidJsonErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidJsonErrorTest]/[method:invalid_array()]
- com.github.dakusui.symfonion.tests.MalformedTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MalformedTest]/[method:givenMalformed_emptyFile()]
- com.github.dakusui.symfonion.tests.MalformedTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MalformedTest]/[method:givenMalformed_brokenObject()]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#2]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#3]
- com.github.dakusui.symfonion.tests.InvalidJsonErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidJsonErrorTest]/[method:invalid_01()]
- com.github.dakusui.symfonion.tests.InvalidJsonErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidJsonErrorTest]/[method:missingSection_sequence()]
- com.github.dakusui.symfonion.tests.InvalidJsonErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidJsonErrorTest]/[method:missingSection_groove()]
- com.github.dakusui.symfonion.tests.InvalidDataErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidDataErrorTest]/[method:illegalFraction()]
- com.github.dakusui.symfonion.tests.ReferenceErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.ReferenceErrorTest]/[method:missingNoteMap()]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#1]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#4]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#8]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#13]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#10]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#9]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#11]
- com.github.dakusui.symfonion.tests.InvalidDataErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidDataErrorTest]/[method:illegalNoteLength_02()]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#12]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[method:pickupNotation_noteOnAtCorrectTick()]
- com.github.dakusui.symfonion.tests.ReferenceErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.ReferenceErrorTest]/[method:missingNote()]
- com.github.dakusui.symfonion.tests.ReferenceErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.ReferenceErrorTest]/[method:missingGroove()]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#7]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#6]
- com.github.dakusui.symfonion.tests.InvalidJsonErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidJsonErrorTest]/[method:missingSection_parts()]
- com.github.dakusui.symfonion.tests.MidiCompilerTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.MidiCompilerTest]/[test-template:exercise(com.github.dakusui.symfonion.testutils.SymfonionTestCase)]/[test-template-invocation:#5]
- com.github.dakusui.symfonion.tests.InvalidDataErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidDataErrorTest]/[method:illegalNoteLength_03()]
- com.github.dakusui.symfonion.tests.cli.subcommands.CompatCompileTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.cli.subcommands.CompatCompileTest]/[method:test()]
- com.github.dakusui.symfonion.tests.InvalidDataErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidDataErrorTest]/[method:illegalNoteLength_01()]
- com.github.dakusui.symfonion.tests.ReferenceErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.ReferenceErrorTest]/[method:missingPart()]
- com.github.dakusui.symfonion.tests.cli.subcommands.PatchBayTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.cli.subcommands.PatchBayTest]/[method:whenPatchBay_thenOutputLooksOk()]
|
| 66 |
|
1.1 Location : createChild Killed by : com.github.dakusui.symfonion.tests.InvalidJsonErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidJsonErrorTest]/[method:invalid_array()] replaced return value with null for com/github/dakusui/symfonion/compat/exceptions/ExceptionContext::createChild → KILLED
|