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 Location : lambda$null$0 Killed by : none replaced return value with "" for com/github/dakusui/actionunit/utils/Checks::lambda$null$0 → NO_COVERAGE 2.2 Location : lambda$requireState$1 Killed by : none replaced return value with null for com/github/dakusui/actionunit/utils/Checks::lambda$requireState$1 → NO_COVERAGE 3.3 Location : requireState Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2.composeLocalScpCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2) replaced return value with null for com/github/dakusui/actionunit/utils/Checks::requireState → KILLED
|
17 |
|
1.1 Location : requireState Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2.composeLocalScpCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2) negated conditional → KILLED
|
18 |
|
1.1 Location : requireState Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2.composeLocalScpCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2) replaced return value with null for com/github/dakusui/actionunit/utils/Checks::requireState → KILLED
|
23 |
|
1.1 Location : lambda$null$2 Killed by : none replaced return value with "" for com/github/dakusui/actionunit/utils/Checks::lambda$null$2 → SURVIVED 2.2 Location : lambda$requireArgument$3 Killed by : com.github.dakusui.actionunit.ut.actions.RetryTest.givenNegativeInterval$whenCreated$thenExceptionThrown(com.github.dakusui.actionunit.ut.actions.RetryTest) replaced return value with null for com/github/dakusui/actionunit/utils/Checks::lambda$requireArgument$3 → KILLED 3.3 Location : requireArgument Killed by : com.github.dakusui.actionunit.ut.actions.RetryTest.givenNegativeTimes$whenCreated$thenExceptionThrown(com.github.dakusui.actionunit.ut.actions.RetryTest) replaced return value with null for com/github/dakusui/actionunit/utils/Checks::requireArgument → KILLED
|
27 |
|
1.1 Location : requireArgument Killed by : com.github.dakusui.actionunit.scenarios.CompatActionSupportTest.givenRetryAction$whenDescribe$thenLooksNice(com.github.dakusui.actionunit.scenarios.CompatActionSupportTest) negated conditional → KILLED
|
28 |
|
1.1 Location : requireArgument Killed by : com.github.dakusui.actionunit.ut.actions.RetryTest.givenNegativeTimes$whenCreated$thenExceptionThrown(com.github.dakusui.actionunit.ut.actions.RetryTest) replaced return value with null for com/github/dakusui/actionunit/utils/Checks::requireArgument → KILLED
|
49 |
|
1.1 Location : checkNotNull Killed by : none replaced return value with null for com/github/dakusui/actionunit/utils/Checks::checkNotNull → NO_COVERAGE
|
53 |
|
1.1 Location : checkNotNull Killed by : com.github.dakusui.actionunit.scenarios.CompatActionSupportTest.retryTest$failForever(com.github.dakusui.actionunit.scenarios.CompatActionSupportTest) replaced return value with null for com/github/dakusui/actionunit/utils/Checks::checkNotNull → KILLED
|
57 |
|
1.1 Location : checkArgument Killed by : com.github.dakusui.actionunit.ut.actions.TimeoutTest.givenNegativeDuration$whenCreated$thenExceptionThrown(com.github.dakusui.actionunit.ut.actions.TimeoutTest) removed call to com/github/dakusui/actionunit/utils/Checks::checkArgument → KILLED
|
61 |
|
1.1 Location : checkArgument Killed by : com.github.dakusui.actionunit.ut.UtilsTest.givenNegativeStep$whenRangeIsInvoked$thenIllegalArgument(com.github.dakusui.actionunit.ut.UtilsTest) negated conditional → KILLED
|
66 |
|
1.1 Location : checkArgument Killed by : none removed call to com/github/dakusui/actionunit/utils/Checks::checkArgument → NO_COVERAGE
|