While.java

1
package com.github.dakusui.actionunit.actions;
2
3
import com.github.dakusui.actionunit.core.Action;
4
import com.github.dakusui.actionunit.core.Context;
5
6
import java.util.Formatter;
7
import java.util.function.Predicate;
8
9
import static java.util.Objects.requireNonNull;
10
11
public interface While extends Action {
12
  Predicate<Context> condition();
13
14
  Action perform();
15
16
  @Override
17
  default void formatTo(Formatter formatter, int flags, int width, int precision) {
18
    formatter.format("while (%s)", this.condition());
19
  }
20
21
  default void accept(Visitor visitor) {
22 1 1. accept : removed call to com/github/dakusui/actionunit/core/Action$Visitor::visit → KILLED
    visitor.visit(this);
23
  }
24
25
  class Impl implements While {
26
27
    private final Action             action;
28
    private final Predicate<Context> condition;
29
30
    public Impl(Predicate<Context> condition, Action action) {
31
      this.action = requireNonNull(action);
32
      this.condition = requireNonNull(condition);
33
    }
34
35
    @Override
36
    public Predicate<Context> condition() {
37 1 1. condition : replaced return value with null for com/github/dakusui/actionunit/actions/While$Impl::condition → KILLED
      return this.condition;
38
    }
39
40
    @Override
41
    public Action perform() {
42 1 1. perform : replaced return value with null for com/github/dakusui/actionunit/actions/While$Impl::perform → KILLED
      return this.action;
43
    }
44
45
    @Override
46
    public String toString() {
47 1 1. toString : replaced return value with "" for com/github/dakusui/actionunit/actions/While$Impl::toString → NO_COVERAGE
      return String.format("%s", this);
48
    }
49
  }
50
51
  class Builder {
52
    private final Predicate<Context> predicate;
53
    private       Action             action;
54
55
    public Builder(Predicate<Context> predicate) {
56
      this.predicate = requireNonNull(predicate);
57
    }
58
59
    public Builder action(Action action) {
60
      this.action = requireNonNull(action);
61 1 1. action : replaced return value with null for com/github/dakusui/actionunit/actions/While$Builder::action → KILLED
      return this;
62
    }
63
64
    public While perform(Action action) {
65 1 1. perform : replaced return value with null for com/github/dakusui/actionunit/actions/While$Builder::perform → KILLED
      return this.action(action).build();
66
    }
67
68
    public While build() {
69 1 1. build : replaced return value with null for com/github/dakusui/actionunit/actions/While$Builder::build → KILLED
      return new Impl(this.predicate, this.action);
70
    }
71
  }
72
}

Mutations

22

1.1
Location : accept
Killed by : com.github.dakusui.actionunit.ut.actions.WhileTest.givenWhileAction_whenPerform_thenRepeatsWhileConditionIsTrue(com.github.dakusui.actionunit.ut.actions.WhileTest)
removed call to com/github/dakusui/actionunit/core/Action$Visitor::visit → KILLED

37

1.1
Location : condition
Killed by : com.github.dakusui.actionunit.ut.actions.WhileTest.givenWhileActionWithConditionNeverMet_whenPerform_thenNothingHappens(com.github.dakusui.actionunit.ut.actions.WhileTest)
replaced return value with null for com/github/dakusui/actionunit/actions/While$Impl::condition → KILLED

42

1.1
Location : perform
Killed by : com.github.dakusui.actionunit.ut.actions.WhileTest.givenWhileActionWithConditionNeverMet_whenPerform_thenNothingHappens(com.github.dakusui.actionunit.ut.actions.WhileTest)
replaced return value with null for com/github/dakusui/actionunit/actions/While$Impl::perform → KILLED

47

1.1
Location : toString
Killed by : none
replaced return value with "" for com/github/dakusui/actionunit/actions/While$Impl::toString → NO_COVERAGE

61

1.1
Location : action
Killed by : com.github.dakusui.actionunit.ut.actions.WhileTest.givenWhileActionWithConditionNeverMet_whenPerform_thenNothingHappens(com.github.dakusui.actionunit.ut.actions.WhileTest)
replaced return value with null for com/github/dakusui/actionunit/actions/While$Builder::action → KILLED

65

1.1
Location : perform
Killed by : com.github.dakusui.actionunit.ut.actions.ForEachTest.printActionTree_6(com.github.dakusui.actionunit.ut.actions.ForEachTest)
replaced return value with null for com/github/dakusui/actionunit/actions/While$Builder::perform → KILLED

69

1.1
Location : build
Killed by : com.github.dakusui.actionunit.ut.actions.WhileTest.givenWhileActionWithConditionNeverMet_whenPerform_thenNothingHappens(com.github.dakusui.actionunit.ut.actions.WhileTest)
replaced return value with null for com/github/dakusui/actionunit/actions/While$Builder::build → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3