Composite.java

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

Mutations

20

1.1
Location : formatTo
Killed by : com.github.dakusui.actionunit.ut.ActionVisitorTest.givenCompositeAction$whenAccept$thenVisited(com.github.dakusui.actionunit.ut.ActionVisitorTest)
negated conditional → KILLED

37

1.1
Location : parallel
Killed by : com.github.dakusui.actionunit.ut.actions.CompositeTest.givenSequentialActionAndConcurrentAction$whenEquals$thenFalse(com.github.dakusui.actionunit.ut.actions.CompositeTest)
replaced return value with null for com/github/dakusui/actionunit/actions/Composite$Builder::parallel → KILLED

42

1.1
Location : sequential
Killed by : none
replaced return value with null for com/github/dakusui/actionunit/actions/Composite$Builder::sequential → SURVIVED

46

1.1
Location : build
Killed by : com.github.dakusui.actionunit.ut.actions.CompositeTest.givenSequentialActionAndNonCompositeAction$whenEquals$thenFalse(com.github.dakusui.actionunit.ut.actions.CompositeTest)
replaced return value with null for com/github/dakusui/actionunit/actions/Composite$Builder::build → KILLED

61

1.1
Location : children
Killed by : com.github.dakusui.actionunit.scenarios.CompatActionSupportTest.sequentialTest(com.github.dakusui.actionunit.scenarios.CompatActionSupportTest)
replaced return value with Collections.emptyList for com/github/dakusui/actionunit/actions/Composite$Impl::children → KILLED

66

1.1
Location : accept
Killed by : com.github.dakusui.actionunit.scenarios.CompatActionSupportTest.sequentialTest(com.github.dakusui.actionunit.scenarios.CompatActionSupportTest)
removed call to com/github/dakusui/actionunit/core/Action$Visitor::visit → KILLED

71

1.1
Location : isParallel
Killed by : com.github.dakusui.actionunit.ut.ReportingActionPerformerTest$ConcurrentAction.givenConcurrentAction$whenPerformed$thenWorksFine(com.github.dakusui.actionunit.ut.ReportingActionPerformerTest$ConcurrentAction)
replaced boolean return with false for com/github/dakusui/actionunit/actions/Composite$Impl::isParallel → KILLED

2.2
Location : isParallel
Killed by : com.github.dakusui.actionunit.scenarios.CompatActionSupportTest.sequentialTest(com.github.dakusui.actionunit.scenarios.CompatActionSupportTest)
replaced boolean return with true for com/github/dakusui/actionunit/actions/Composite$Impl::isParallel → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3