ContextConsumer.java

1
package com.github.dakusui.actionunit.core.context;
2
3
import com.github.dakusui.actionunit.core.Context;
4
import com.github.dakusui.printables.PrintableConsumer;
5
6
import java.util.Formatter;
7
import java.util.Objects;
8
import java.util.function.Consumer;
9
import java.util.function.Supplier;
10
11
import static com.github.dakusui.actionunit.utils.InternalUtils.toStringIfOverriddenOrNoname;
12
import static java.util.Objects.requireNonNull;
13
14
/**
15
 * This interface is intended to be used with multi-parameter functions.
16
 * You do not need to use an instance of this interface to create a simple action.
17
 *
18
 */
19
@FunctionalInterface
20
public interface ContextConsumer extends FormattableConsumer<Context> {
21
  ContextConsumer NOP_CONSUMER = new ContextConsumer() {
22
    @Override
23
    public void accept(Context context) {
24
    }
25
26
    @Override
27
    public void formatTo(Formatter formatter, int flags, int width, int precision) {
28
      formatter.format("(nop)");
29
    }
30
31
    public String toString() {
32 1 1. toString : replaced return value with "" for com/github/dakusui/actionunit/core/context/ContextConsumer$1::toString → KILLED
      return "(nop)";
33
    }
34
  };
35
36
  @Override
37
  default void formatTo(Formatter formatter, int flags, int width, int precision) {
38
    formatter.format(toStringIfOverriddenOrNoname(this));
39
  }
40
41
  @Override
42
  default ContextConsumer andThen(Consumer<? super Context> after) {
43
    Objects.requireNonNull(after);
44 1 1. andThen : replaced return value with null for com/github/dakusui/actionunit/core/context/ContextConsumer::andThen → NO_COVERAGE
    return (t) -> {
45 1 1. lambda$andThen$0 : removed call to com/github/dakusui/actionunit/core/context/ContextConsumer::accept → NO_COVERAGE
      accept(t);
46 1 1. lambda$andThen$0 : removed call to java/util/function/Consumer::accept → NO_COVERAGE
      after.accept(t);
47
    };
48
  }
49
50
  static ContextConsumer of(Supplier<String> formatter, Consumer<Context> consumer) {
51 1 1. of : replaced return value with null for com/github/dakusui/actionunit/core/context/ContextConsumer::of → KILLED
    return new Impl(formatter, consumer);
52
  }
53
54
  class Impl extends PrintableConsumer<Context> implements ContextConsumer {
55
56
    public Impl(Supplier<String> formatter, Consumer<Context> consumer) {
57
      super(formatter, consumer);
58
    }
59
60
    @Override
61
    public ContextConsumer andThen(Consumer<? super Context> after) {
62
      requireNonNull(after);
63 1 1. andThen : replaced return value with null for com/github/dakusui/actionunit/core/context/ContextConsumer$Impl::andThen → KILLED
      return (ContextConsumer) super.andThen(after);
64
    }
65
66
    @SuppressWarnings("unchecked")
67
    @Override
68
    protected ContextConsumer.Impl createConsumer(Supplier<String> formatter, Consumer<? super Context> consumer) {
69 1 1. createConsumer : replaced return value with null for com/github/dakusui/actionunit/core/context/ContextConsumer$Impl::createConsumer → KILLED
      return new ContextConsumer.Impl(formatter, (Consumer<Context>) consumer);
70
    }
71
  }
72
73
}

Mutations

32

1.1
Location : toString
Killed by : com.github.dakusui.actionunit.ut.ReportingActionPerformerTest$AttemptAction.givenPassingAttemptAction$whenPerformed$thenWorksFine(com.github.dakusui.actionunit.ut.ReportingActionPerformerTest$AttemptAction)
replaced return value with "" for com/github/dakusui/actionunit/core/context/ContextConsumer$1::toString → KILLED

44

1.1
Location : andThen
Killed by : none
replaced return value with null for com/github/dakusui/actionunit/core/context/ContextConsumer::andThen → NO_COVERAGE

45

1.1
Location : lambda$andThen$0
Killed by : none
removed call to com/github/dakusui/actionunit/core/context/ContextConsumer::accept → NO_COVERAGE

46

1.1
Location : lambda$andThen$0
Killed by : none
removed call to java/util/function/Consumer::accept → NO_COVERAGE

51

1.1
Location : of
Killed by : com.github.dakusui.actionunit.ut.actions.AttemptTest.givenAttemptAction$whenPerform$thenWorksFine(com.github.dakusui.actionunit.ut.actions.AttemptTest)
replaced return value with null for com/github/dakusui/actionunit/core/context/ContextConsumer::of → KILLED

63

1.1
Location : andThen
Killed by : com.github.dakusui.actionunit.ut.actions.AttemptTest.givenAttemptAction$whenPerform$thenWorksFine(com.github.dakusui.actionunit.ut.actions.AttemptTest)
replaced return value with null for com/github/dakusui/actionunit/core/context/ContextConsumer$Impl::andThen → KILLED

69

1.1
Location : createConsumer
Killed by : com.github.dakusui.actionunit.ut.actions.AttemptTest.givenAttemptAction$whenPerform$thenWorksFine(com.github.dakusui.actionunit.ut.actions.AttemptTest)
replaced return value with null for com/github/dakusui/actionunit/core/context/ContextConsumer$Impl::createConsumer → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3