| 1 | package com.github.dakusui.jcunitx.exceptions; | |
| 2 | ||
| 3 | import java.util.function.Function; | |
| 4 | import java.util.function.Predicate; | |
| 5 | import java.util.function.Supplier; | |
| 6 | ||
| 7 | /** | |
| 8 | * An exception that indicates a bug in JCUnit's framework. | |
| 9 | * | |
| 10 | * [ditaa] | |
| 11 | * ---- | |
| 12 | * +-----+ +-----+ | |
| 13 | * |hello|<>--->|world| | |
| 14 | * +-----+ +-----+ | |
| 15 | * ---- | |
| 16 | */ | |
| 17 | public class FrameworkException extends BaseException { | |
| 18 | protected FrameworkException(String format) { | |
| 19 | super(format); | |
| 20 | } | |
| 21 | ||
| 22 | protected FrameworkException(String format, Throwable t) { | |
| 23 | super(format, t); | |
| 24 | } | |
| 25 | ||
| 26 | @SuppressWarnings("WeakerAccess") | |
| 27 | public static void checkCondition(boolean b, Function<String, ? extends FrameworkException> exceptionFactory, Supplier<String> messageSupplier) { | |
| 28 |
1
1. checkCondition : negated conditional → KILLED |
if (!b) |
| 29 | throw exceptionFactory.apply(messageSupplier.get()); | |
| 30 | } | |
| 31 | ||
| 32 | public static <T> T check(T value, Predicate<T> check) { | |
| 33 |
1
1. check : negated conditional → KILLED |
if (check.test(value)) |
| 34 |
1
1. check : replaced return value with null for com/github/dakusui/jcunitx/exceptions/FrameworkException::check → SURVIVED |
return value; |
| 35 | throw new FrameworkException("Unexpected by design"); | |
| 36 | } | |
| 37 | ||
| 38 | public static <T> T check(T value, Predicate<T> check, Supplier<String> messageSupplier) { | |
| 39 |
1
1. check : negated conditional → NO_COVERAGE |
if (check.test(value)) |
| 40 |
1
1. check : replaced return value with null for com/github/dakusui/jcunitx/exceptions/FrameworkException::check → NO_COVERAGE |
return value; |
| 41 | throw new FrameworkException(messageSupplier.get()); | |
| 42 | } | |
| 43 | ||
| 44 | public static void checkCondition(boolean b, Function<String, ? extends FrameworkException> exceptionFactory) { | |
| 45 |
2
1. checkCondition : removed call to com/github/dakusui/jcunitx/exceptions/FrameworkException::checkCondition → SURVIVED 2. lambda$checkCondition$0 : replaced return value with "" for com/github/dakusui/jcunitx/exceptions/FrameworkException::lambda$checkCondition$0 → NO_COVERAGE |
checkCondition(b, exceptionFactory, () -> "Unexpected by design"); |
| 46 | } | |
| 47 | ||
| 48 | public static void checkCondition(boolean b) { | |
| 49 |
1
1. checkCondition : removed call to com/github/dakusui/jcunitx/exceptions/FrameworkException::checkCondition → SURVIVED |
checkCondition(b, FrameworkException::unexpectedByDesign); |
| 50 | } | |
| 51 | ||
| 52 | public static FrameworkException unexpectedByDesign() { | |
| 53 | throw new FrameworkException("Unexpected by design"); | |
| 54 | } | |
| 55 | ||
| 56 | public static FrameworkException unexpectedByDesign(Throwable t) { | |
| 57 |
1
1. unexpectedByDesign : negated conditional → KILLED |
if (t instanceof Error) |
| 58 | throw (Error) t; | |
| 59 |
1
1. unexpectedByDesign : negated conditional → SURVIVED |
if (t instanceof RuntimeException) |
| 60 | throw (RuntimeException) t; | |
| 61 | throw new FrameworkException(String.format("Unexpected by design:%s", t.getMessage()), t); | |
| 62 | } | |
| 63 | ||
| 64 | public static FrameworkException unexpectedByDesign(String message) { | |
| 65 | throw new FrameworkException(String.format("Unexpected by design:%s", message)); | |
| 66 | } | |
| 67 | } | |
Mutations | ||
| 28 |
1.1 |
|
| 33 |
1.1 |
|
| 34 |
1.1 |
|
| 39 |
1.1 |
|
| 40 |
1.1 |
|
| 45 |
1.1 2.2 |
|
| 49 |
1.1 |
|
| 57 |
1.1 |
|
| 59 |
1.1 |