| 1 | package com.github.dakusui.actionunit.actions.cmd; | |
| 2 | ||
| 3 | import com.github.dakusui.actionunit.actions.ContextVariable; | |
| 4 | import com.github.dakusui.actionunit.actions.RetryOption; | |
| 5 | import com.github.dakusui.actionunit.actions.cmd.unix.SshOptions; | |
| 6 | import com.github.dakusui.processstreamer.core.process.ProcessStreamer; | |
| 7 | ||
| 8 | import java.util.function.BiFunction; | |
| 9 | import java.util.function.Function; | |
| 10 | import java.util.function.IntFunction; | |
| 11 | ||
| 12 | import static com.github.dakusui.actionunit.actions.cmd.unix.SshOptions.emptySshOptions; | |
| 13 | import static com.github.dakusui.processstreamer.core.process.ProcessStreamer.Checker.createCheckerForExitCode; | |
| 14 | import static java.util.Objects.requireNonNull; | |
| 15 | ||
| 16 | /** | |
| 17 | * An instance of this interface can be created by {@link CommanderConfig.Builder}. | |
| 18 | * | |
| 19 | * @see CommanderConfig.Builder | |
| 20 | */ | |
| 21 | public interface CommanderConfig { | |
| 22 | ||
| 23 | CommanderConfig DEFAULT = CommanderConfig.builder() | |
| 24 |
1
1. lambda$static$0 : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/CommanderConfig::lambda$static$0 → KILLED |
.shellManager(ShellManager.createShellManager(h -> new SshOptions.Builder() |
| 25 | .disableStrictHostkeyChecking() | |
| 26 | .disablePasswordAuthentication() | |
| 27 | .build())) | |
| 28 | .programNameResolver(ProgramNameResolver.createForUnix()) | |
| 29 | .placeHolderFormatter(PlaceHolderFormatter.DEFAULT_PLACE_HOLDER_FORMATTER) | |
| 30 | .build(); | |
| 31 | ||
| 32 | ShellManager shellManager(); | |
| 33 | ||
| 34 | BiFunction<String, String, String> programNameResolver(); | |
| 35 | ||
| 36 | /** | |
| 37 | * Returns a function that resolves an appropriate {@link SshOptions} object from a given host name. | |
| 38 | * | |
| 39 | * @return An ssh options resolver function. | |
| 40 | */ | |
| 41 | Function<String, SshOptions> sshOptionsResolver(); | |
| 42 | ||
| 43 | /** | |
| 44 | * Note that the returned objecc is only used by {@link Commander#toAction()} method, | |
| 45 | * not by other builder methods such as {@link Commander#toContextPredicate()}, {@link Commander#toContextFunction()}, etc. | |
| 46 | * | |
| 47 | * @return A retry option object. | |
| 48 | * @see Commander | |
| 49 | */ | |
| 50 | RetryOption retryOption(); | |
| 51 | ||
| 52 | Function<ContextVariable[], IntFunction<String>> variablePlaceHolderFormatter(); | |
| 53 | ||
| 54 | ProcessStreamer.Checker checker(); | |
| 55 | ||
| 56 | static Builder builder() { | |
| 57 |
1
1. builder : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/CommanderConfig::builder → KILLED |
return new Builder(); |
| 58 | } | |
| 59 | ||
| 60 | class Impl implements CommanderConfig { | |
| 61 | final ShellManager shellManager; | |
| 62 | final RetryOption retryOption; | |
| 63 | final ProcessStreamer.Checker processStreamerChecker; | |
| 64 | ||
| 65 | final Function<ContextVariable[], IntFunction<String>> placeHolderFormatter; | |
| 66 | ||
| 67 | final Function<String, SshOptions> sshOptionsResolver; | |
| 68 | final BiFunction<String, String, String> programNameResolver; | |
| 69 | ||
| 70 | public Impl( | |
| 71 | ShellManager shellManager, | |
| 72 | BiFunction<String, String, String> programNameResolver, | |
| 73 | Function<String, SshOptions> sshOptionsResolver, | |
| 74 | RetryOption retryOption, | |
| 75 | ProcessStreamer.Checker processStreamerChecker, | |
| 76 | Function<ContextVariable[], IntFunction<String>> placeHolderFormatter) { | |
| 77 | this.shellManager = requireNonNull(shellManager); | |
| 78 | this.programNameResolver = requireNonNull(programNameResolver); | |
| 79 | this.retryOption = requireNonNull(retryOption); | |
| 80 | this.processStreamerChecker = requireNonNull(processStreamerChecker); | |
| 81 | this.placeHolderFormatter = requireNonNull(placeHolderFormatter); | |
| 82 | this.sshOptionsResolver = requireNonNull(sshOptionsResolver); | |
| 83 | } | |
| 84 | ||
| 85 | @Override | |
| 86 | public ShellManager shellManager() { | |
| 87 |
1
1. shellManager : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/CommanderConfig$Impl::shellManager → KILLED |
return this.shellManager; |
| 88 | } | |
| 89 | ||
| 90 | @Override | |
| 91 | public Function<String, SshOptions> sshOptionsResolver() { | |
| 92 |
1
1. sshOptionsResolver : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/CommanderConfig$Impl::sshOptionsResolver → KILLED |
return this.sshOptionsResolver; |
| 93 | } | |
| 94 | ||
| 95 | @Override | |
| 96 | public RetryOption retryOption() { | |
| 97 |
1
1. retryOption : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/CommanderConfig$Impl::retryOption → KILLED |
return this.retryOption; |
| 98 | } | |
| 99 | ||
| 100 | @Override | |
| 101 | public Function<ContextVariable[], IntFunction<String>> variablePlaceHolderFormatter() { | |
| 102 |
1
1. variablePlaceHolderFormatter : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/CommanderConfig$Impl::variablePlaceHolderFormatter → KILLED |
return this.placeHolderFormatter; |
| 103 | } | |
| 104 | ||
| 105 | @Override | |
| 106 | public ProcessStreamer.Checker checker() { | |
| 107 |
1
1. checker : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/CommanderConfig$Impl::checker → KILLED |
return this.processStreamerChecker; |
| 108 | } | |
| 109 | ||
| 110 | @Override | |
| 111 | public BiFunction<String, String, String> programNameResolver() { | |
| 112 |
1
1. programNameResolver : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/CommanderConfig$Impl::programNameResolver → KILLED |
return this.programNameResolver; |
| 113 | } | |
| 114 | } | |
| 115 | ||
| 116 | class Builder { | |
| 117 | ShellManager shellManager; | |
| 118 | ||
| 119 | BiFunction<String, String, String> programNameResolver; | |
| 120 | ||
| 121 | Function<String, SshOptions> sshOptionsResolver; | |
| 122 | ||
| 123 | RetryOption retryOption; | |
| 124 | ProcessStreamer.Checker processStreamerChecker; | |
| 125 | Function<ContextVariable[], IntFunction<String>> placeHolderFormatter; | |
| 126 | ||
| 127 | public Builder() { | |
| 128 | this.processStreamerChecker(createCheckerForExitCode(0)) | |
| 129 | .shellManager(ShellManager.createShellManager()) | |
| 130 | .programNameResolver(ProgramNameResolver.createForUnix()) | |
| 131 | .retryOption(RetryOption.none()) | |
| 132 |
1
1. lambda$new$0 : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/CommanderConfig$Builder::lambda$new$0 → NO_COVERAGE |
.sshOptionsResolver(h -> emptySshOptions()) |
| 133 | .placeHolderFormatter(PlaceHolderFormatter.DEFAULT_PLACE_HOLDER_FORMATTER); | |
| 134 | } | |
| 135 | ||
| 136 | public Builder programNameResolver(BiFunction<String, String, String> programNameResolver) { | |
| 137 | this.programNameResolver = requireNonNull(programNameResolver); | |
| 138 |
1
1. programNameResolver : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/CommanderConfig$Builder::programNameResolver → KILLED |
return this; |
| 139 | } | |
| 140 | ||
| 141 | public Builder shellManager(ShellManager shellManager) { | |
| 142 | this.shellManager = requireNonNull(shellManager); | |
| 143 |
2
1. lambda$shellManager$1 : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/CommanderConfig$Builder::lambda$shellManager$1 → KILLED 2. shellManager : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/CommanderConfig$Builder::shellManager → KILLED |
return this.sshOptionsResolver(h -> this.shellManager.sshOptionsFor(h)); |
| 144 | } | |
| 145 | ||
| 146 | public Builder sshOptionsResolver(Function<String, SshOptions> sshOptionsResolver) { | |
| 147 | this.sshOptionsResolver = requireNonNull(sshOptionsResolver); | |
| 148 |
1
1. sshOptionsResolver : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/CommanderConfig$Builder::sshOptionsResolver → KILLED |
return this; |
| 149 | } | |
| 150 | ||
| 151 | public Builder retryOption(RetryOption retryOption) { | |
| 152 | this.retryOption = retryOption; | |
| 153 |
1
1. retryOption : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/CommanderConfig$Builder::retryOption → KILLED |
return this; |
| 154 | } | |
| 155 | ||
| 156 | public Builder processStreamerChecker(ProcessStreamer.Checker processStreamerChecker) { | |
| 157 | this.processStreamerChecker = requireNonNull(processStreamerChecker); | |
| 158 |
1
1. processStreamerChecker : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/CommanderConfig$Builder::processStreamerChecker → KILLED |
return this; |
| 159 | } | |
| 160 | ||
| 161 | public Builder placeHolderFormatter(Function<ContextVariable[], IntFunction<String>> placeHolderFormatter) { | |
| 162 | this.placeHolderFormatter = placeHolderFormatter; | |
| 163 |
1
1. placeHolderFormatter : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/CommanderConfig$Builder::placeHolderFormatter → KILLED |
return this; |
| 164 | } | |
| 165 | ||
| 166 | public CommanderConfig build() { | |
| 167 |
1
1. build : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/CommanderConfig$Builder::build → KILLED |
return new CommanderConfig.Impl(shellManager, programNameResolver, sshOptionsResolver, retryOption, processStreamerChecker, placeHolderFormatter); |
| 168 | } | |
| 169 | } | |
| 170 | } | |
Mutations | ||
| 24 |
1.1 |
|
| 57 |
1.1 |
|
| 87 |
1.1 |
|
| 92 |
1.1 |
|
| 97 |
1.1 |
|
| 102 |
1.1 |
|
| 107 |
1.1 |
|
| 112 |
1.1 |
|
| 132 |
1.1 |
|
| 138 |
1.1 |
|
| 143 |
1.1 2.2 |
|
| 148 |
1.1 |
|
| 153 |
1.1 |
|
| 158 |
1.1 |
|
| 163 |
1.1 |
|
| 167 |
1.1 |