1 | package com.github.dakusui.actionunit.actions; | |
2 | ||
3 | import com.github.dakusui.actionunit.core.Action; | |
4 | ||
5 | import java.util.Formatter; | |
6 | import java.util.concurrent.TimeUnit; | |
7 | ||
8 | import static com.github.dakusui.actionunit.utils.Checks.checkArgument; | |
9 | import static com.github.dakusui.actionunit.utils.InternalUtils.formatDuration; | |
10 | import static java.util.Objects.requireNonNull; | |
11 | import static java.util.concurrent.TimeUnit.SECONDS; | |
12 | ||
13 | public interface TimeOut extends Action { | |
14 | Action perform(); | |
15 | ||
16 | long durationInNanos(); | |
17 | ||
18 | @Override | |
19 | default void accept(Visitor visitor) { | |
20 |
1
1. accept : removed call to com/github/dakusui/actionunit/core/Action$Visitor::visit → KILLED |
visitor.visit(this); |
21 | } | |
22 | ||
23 | @Override | |
24 | default void formatTo(Formatter formatter, int flags, int width, int precision) { | |
25 | formatter.format("timeout in %s", formatDuration(durationInNanos())); | |
26 | } | |
27 | ||
28 | class Builder extends Action.Builder<TimeOut> { | |
29 | Action action; | |
30 | long duration = 10; | |
31 | private TimeUnit timeUnit = SECONDS; | |
32 | ||
33 | public Builder(Action action) { | |
34 | this.action = requireNonNull(action); | |
35 | } | |
36 | ||
37 | public Action in(long duration, TimeUnit timeUnit) { | |
38 |
3
1. in : changed conditional boundary → KILLED 2. in : negated conditional → KILLED 3. in : removed call to com/github/dakusui/actionunit/utils/Checks::checkArgument → KILLED |
checkArgument(duration > 0, |
39 | "Timeout duration must be positive but %d was given", | |
40 | duration | |
41 | ); | |
42 | requireNonNull(timeUnit); | |
43 | this.duration = duration; | |
44 | this.timeUnit = timeUnit; | |
45 |
1
1. in : replaced return value with null for com/github/dakusui/actionunit/actions/TimeOut$Builder::in → KILLED |
return this.$(); |
46 | } | |
47 | ||
48 | @Override | |
49 | public TimeOut build() { | |
50 |
1
1. build : replaced return value with null for com/github/dakusui/actionunit/actions/TimeOut$Builder::build → KILLED |
return new TimeOut() { |
51 | @Override | |
52 | public Action perform() { | |
53 |
1
1. perform : replaced return value with null for com/github/dakusui/actionunit/actions/TimeOut$Builder$1::perform → KILLED |
return Builder.this.action; |
54 | } | |
55 | ||
56 | @Override | |
57 | public long durationInNanos() { | |
58 |
1
1. durationInNanos : replaced long return with 0 for com/github/dakusui/actionunit/actions/TimeOut$Builder$1::durationInNanos → KILLED |
return Builder.this.timeUnit.toNanos(Builder.this.duration); |
59 | } | |
60 | }; | |
61 | } | |
62 | } | |
63 | ||
64 | } | |
Mutations | ||
20 |
1.1 |
|
38 |
1.1 2.2 3.3 |
|
45 |
1.1 |
|
50 |
1.1 |
|
53 |
1.1 |
|
58 |
1.1 |