FrameworkException.java

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
Location : checkCondition
Killed by : com.github.dakusui.jcunitx.tests.features.generators.IpoGplusTest$AllPossibleTuples.given3FactorsWithStrength2$whenAllPossibleTuples$thenAllCovered(com.github.dakusui.jcunitx.tests.features.generators.IpoGplusTest$AllPossibleTuples)
negated conditional → KILLED

33

1.1
Location : check
Killed by : com.github.dakusui.jcunitx.tests.features.pipeline.stages.EngineTest.givenOneFactorWithNoConstraint$whenEngine$thenTupleSetGenerated(com.github.dakusui.jcunitx.tests.features.pipeline.stages.EngineTest)
negated conditional → KILLED

34

1.1
Location : check
Killed by : none
replaced return value with null for com/github/dakusui/jcunitx/exceptions/FrameworkException::check → SURVIVED

39

1.1
Location : check
Killed by : none
negated conditional → NO_COVERAGE

40

1.1
Location : check
Killed by : none
replaced return value with null for com/github/dakusui/jcunitx/exceptions/FrameworkException::check → NO_COVERAGE

45

1.1
Location : checkCondition
Killed by : none
removed call to com/github/dakusui/jcunitx/exceptions/FrameworkException::checkCondition → SURVIVED

2.2
Location : lambda$checkCondition$0
Killed by : none
replaced return value with "" for com/github/dakusui/jcunitx/exceptions/FrameworkException::lambda$checkCondition$0 → NO_COVERAGE

49

1.1
Location : checkCondition
Killed by : none
removed call to com/github/dakusui/jcunitx/exceptions/FrameworkException::checkCondition → SURVIVED

57

1.1
Location : unexpectedByDesign
Killed by : com.github.dakusui.jcunitx.tests.errorhandling.ErrorHandlingTest.failOnParameterFactoryCreation(com.github.dakusui.jcunitx.tests.errorhandling.ErrorHandlingTest)
negated conditional → KILLED

59

1.1
Location : unexpectedByDesign
Killed by : none
negated conditional → SURVIVED

Active mutators

Tests examined


Report generated by PIT 1.7.3