1 | package com.github.dakusui.actionunit.actions.cmd; | |
2 | ||
3 | import com.github.dakusui.actionunit.actions.cmd.unix.SshOptions; | |
4 | import com.github.dakusui.actionunit.actions.cmd.unix.SshShell; | |
5 | import com.github.dakusui.processstreamer.core.process.Shell; | |
6 | ||
7 | import java.util.function.Function; | |
8 | ||
9 | import static java.util.Objects.requireNonNull; | |
10 | ||
11 | public interface ShellManager { | |
12 | Shell shellFor(String host); | |
13 | ||
14 | String userForRemote(String host); | |
15 | ||
16 | SshOptions sshOptionsFor(String host); | |
17 | ||
18 | interface Default extends ShellManager { | |
19 | @Override | |
20 | default Shell shellFor(String host) { | |
21 |
1
1. shellFor : negated conditional → KILLED |
if (isLocal(host)) |
22 |
1
1. shellFor : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default::shellFor → KILLED |
return Shell.LOCAL_SHELL; |
23 | ||
24 |
1
1. shellFor : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default::shellFor → KILLED |
return new SshShell.Builder(host, sshOptionsFor(host)) |
25 | .user(userForRemote(host)) | |
26 | .program("ssh") | |
27 | .build(); | |
28 | } | |
29 | ||
30 | default SshOptions sshOptionsFor(String host) { | |
31 |
1
1. sshOptionsFor : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default::sshOptionsFor → KILLED |
return sshOptionForRemote(host); |
32 | } | |
33 | ||
34 | SshOptions sshOptionForRemote(String remoteHost); | |
35 | ||
36 | ||
37 | default boolean isLocal(String host) { | |
38 |
4
1. isLocal : negated conditional → KILLED 2. isLocal : negated conditional → KILLED 3. isLocal : negated conditional → KILLED 4. isLocal : replaced boolean return with true for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default::isLocal → KILLED |
return "localhost".equals(host) || "127.0.0.1".equals(host) || "::1".equals(host); |
39 | } | |
40 | ||
41 | class Builder { | |
42 | private Function<String, SshOptions> sshOptionsResolver; | |
43 | private Function<String, String> userNameResolver; | |
44 | ||
45 | public Builder() { | |
46 |
1
1. lambda$new$0 : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default$Builder::lambda$new$0 → NO_COVERAGE |
this.sshOptionsResolver(h -> new SshOptions.Builder() |
47 | .disablePasswordAuthentication() | |
48 | .disableStrictHostkeyChecking() | |
49 | .build()) | |
50 |
1
1. lambda$new$1 : replaced return value with "" for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default$Builder::lambda$new$1 → NO_COVERAGE |
.userNameResolver(h -> System.getProperty("user.name")); |
51 | } | |
52 | ||
53 | public Builder userNameResolver(Function<String, String> resolver) { | |
54 | this.userNameResolver = requireNonNull(resolver); | |
55 |
1
1. userNameResolver : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default$Builder::userNameResolver → KILLED |
return this; |
56 | } | |
57 | ||
58 | public Builder sshOptionsResolver(Function<String, SshOptions> resolver) { | |
59 | this.sshOptionsResolver = requireNonNull(resolver); | |
60 |
1
1. sshOptionsResolver : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default$Builder::sshOptionsResolver → KILLED |
return this; |
61 | } | |
62 | ||
63 | public ShellManager build() { | |
64 |
1
1. build : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default$Builder::build → KILLED |
return new ShellManager.Default() { |
65 | final Function<String, SshOptions> sshOptionsResolver = Builder.this.sshOptionsResolver; | |
66 | final Function<String, String> userNameResolver = Builder.this.userNameResolver; | |
67 | ||
68 | @Override | |
69 | public SshOptions sshOptionForRemote(String remoteHost) { | |
70 |
1
1. sshOptionForRemote : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default$Builder$1::sshOptionForRemote → KILLED |
return sshOptionsResolver.apply(remoteHost); |
71 | } | |
72 | ||
73 | @Override | |
74 | public String userForRemote(String remoteHost) { | |
75 |
1
1. userForRemote : replaced return value with "" for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default$Builder$1::userForRemote → KILLED |
return userNameResolver.apply(remoteHost); |
76 | } | |
77 | }; | |
78 | } | |
79 | } | |
80 | } | |
81 | ||
82 | static ShellManager createShellManager() { | |
83 |
1
1. createShellManager : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager::createShellManager → KILLED |
return createShellManager(SshOptions.emptySshOptions()); |
84 | } | |
85 | ||
86 | static ShellManager createShellManager(SshOptions sshOptions) { | |
87 |
2
1. lambda$createShellManager$0 : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager::lambda$createShellManager$0 → NO_COVERAGE 2. createShellManager : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager::createShellManager → KILLED |
return createShellManager(h -> sshOptions); |
88 | } | |
89 | ||
90 | static ShellManager createShellManager(Function<String, SshOptions> sshOptionsResolver) { | |
91 |
1
1. createShellManager : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager::createShellManager → KILLED |
return new ShellManager.Default.Builder() |
92 |
1
1. lambda$createShellManager$1 : replaced return value with "" for com/github/dakusui/actionunit/actions/cmd/ShellManager::lambda$createShellManager$1 → KILLED |
.userNameResolver(h -> System.getProperty("user.name")) |
93 | .sshOptionsResolver(sshOptionsResolver) | |
94 | .build(); | |
95 | } | |
96 | } | |
Mutations | ||
21 |
1.1 |
|
22 |
1.1 |
|
24 |
1.1 |
|
31 |
1.1 |
|
38 |
1.1 2.2 3.3 4.4 |
|
46 |
1.1 |
|
50 |
1.1 |
|
55 |
1.1 |
|
60 |
1.1 |
|
64 |
1.1 |
|
70 |
1.1 |
|
75 |
1.1 |
|
83 |
1.1 |
|
87 |
1.1 2.2 |
|
91 |
1.1 |
|
92 |
1.1 |