1 | package com.github.dakusui.actionunit.utils; | |
2 | ||
3 | import java.util.Objects; | |
4 | import java.util.function.Function; | |
5 | import java.util.function.Predicate; | |
6 | ||
7 | import static java.lang.String.format; | |
8 | ||
9 | public enum Checks { | |
10 | ; | |
11 | ||
12 | public static <T> T requireState(Predicate<T> condition, T value) { | |
13 |
3
1. lambda$null$0 : replaced return value with "" for com/github/dakusui/actionunit/utils/Checks::lambda$null$0 → NO_COVERAGE 2. lambda$requireState$1 : replaced return value with null for com/github/dakusui/actionunit/utils/Checks::lambda$requireState$1 → NO_COVERAGE 3. requireState : replaced return value with null for com/github/dakusui/actionunit/utils/Checks::requireState → KILLED |
return requireState(condition, value, c -> v -> format("'%s' did not not satisfy '%s'", v, c)); |
14 | } | |
15 | ||
16 | public static <T> T requireState(Predicate<T> condition, T value, Function<Predicate<T>, Function<T, String>> messageComposer) { | |
17 |
1
1. requireState : negated conditional → KILLED |
if (condition.test(value)) |
18 |
1
1. requireState : replaced return value with null for com/github/dakusui/actionunit/utils/Checks::requireState → KILLED |
return value; |
19 | throw exceptionForIllegaState(messageComposer.apply(condition).apply(value)); | |
20 | } | |
21 | ||
22 | public static <T> T requireArgument(Predicate<T> condition, T value) { | |
23 |
3
1. lambda$null$2 : replaced return value with "" for com/github/dakusui/actionunit/utils/Checks::lambda$null$2 → SURVIVED 2. lambda$requireArgument$3 : replaced return value with null for com/github/dakusui/actionunit/utils/Checks::lambda$requireArgument$3 → KILLED 3. requireArgument : replaced return value with null for com/github/dakusui/actionunit/utils/Checks::requireArgument → KILLED |
return requireArgument(condition, value, c -> v -> format("'%s' did not not satisfy '%s'", v, c)); |
24 | } | |
25 | ||
26 | public static <T> T requireArgument(Predicate<T> condition, T value, Function<Predicate<T>, Function<T, String>> messageComposer) { | |
27 |
1
1. requireArgument : negated conditional → KILLED |
if (condition.test(value)) |
28 |
1
1. requireArgument : replaced return value with null for com/github/dakusui/actionunit/utils/Checks::requireArgument → KILLED |
return value; |
29 | throw exceptionForIllegalValue(messageComposer.apply(condition).apply(value)); | |
30 | } | |
31 | ||
32 | private static RuntimeException exceptionForIllegaState(String message) { | |
33 | throw new IllegalStateException(message); | |
34 | } | |
35 | ||
36 | private static RuntimeException exceptionForIllegalValue(String message) { | |
37 | throw new IllegalArgumentException(message); | |
38 | } | |
39 | ||
40 | public static RuntimeException impossibleLineReached(String message, Throwable t) { | |
41 | throw exceptionForImpossibleLine(message, t); | |
42 | } | |
43 | ||
44 | private static RuntimeException exceptionForImpossibleLine(String message, Throwable t) { | |
45 | throw new AssertionError(message, t); | |
46 | } | |
47 | ||
48 | public static <T> T checkNotNull(T value, String message) { | |
49 |
1
1. checkNotNull : replaced return value with null for com/github/dakusui/actionunit/utils/Checks::checkNotNull → NO_COVERAGE |
return Objects.requireNonNull(value, message); |
50 | } | |
51 | ||
52 | public static <T> T checkNotNull(T value) { | |
53 |
1
1. checkNotNull : replaced return value with null for com/github/dakusui/actionunit/utils/Checks::checkNotNull → KILLED |
return Objects.requireNonNull(value); |
54 | } | |
55 | ||
56 | public static void checkArgument(boolean cond, String message, Object... args) { | |
57 |
1
1. checkArgument : removed call to com/github/dakusui/actionunit/utils/Checks::checkArgument → KILLED |
checkArgument(cond, format(message, args)); |
58 | } | |
59 | ||
60 | public static void checkArgument(boolean cond, String message) { | |
61 |
1
1. checkArgument : negated conditional → KILLED |
if (!cond) |
62 | throw new IllegalArgumentException(message); | |
63 | } | |
64 | ||
65 | public static void checkArgument(boolean cond) { | |
66 |
1
1. checkArgument : removed call to com/github/dakusui/actionunit/utils/Checks::checkArgument → NO_COVERAGE |
checkArgument(cond, null); |
67 | } | |
68 | } | |
Mutations | ||
13 |
1.1 2.2 3.3 |
|
17 |
1.1 |
|
18 |
1.1 |
|
23 |
1.1 2.2 3.3 |
|
27 |
1.1 |
|
28 |
1.1 |
|
49 |
1.1 |
|
53 |
1.1 |
|
57 |
1.1 |
|
61 |
1.1 |
|
66 |
1.1 |