ShellManager.java

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
Location : shellFor
Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2.composeLocalEchoCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2)
negated conditional → KILLED

22

1.1
Location : shellFor
Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2.composeLocalEchoCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2)
replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default::shellFor → KILLED

24

1.1
Location : shellFor
Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithoutUsername.composeRemoteEchoCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithoutUsername)
replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default::shellFor → KILLED

31

1.1
Location : sshOptionsFor
Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithoutUsername.composeRemoteEchoCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithoutUsername)
replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default::sshOptionsFor → KILLED

38

1.1
Location : isLocal
Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2.composeLocalEchoCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2)
negated conditional → KILLED

2.2
Location : isLocal
Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithoutUsername.composeRemoteEchoCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithoutUsername)
negated conditional → KILLED

3.3
Location : isLocal
Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithoutUsername.composeRemoteEchoCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithoutUsername)
negated conditional → KILLED

4.4
Location : isLocal
Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithoutUsername.composeRemoteEchoCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithoutUsername)
replaced boolean return with true for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default::isLocal → KILLED

46

1.1
Location : lambda$new$0
Killed by : none
replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default$Builder::lambda$new$0 → NO_COVERAGE

50

1.1
Location : lambda$new$1
Killed by : none
replaced return value with "" for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default$Builder::lambda$new$1 → NO_COVERAGE

55

1.1
Location : userNameResolver
Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2.composeLocalEchoCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2)
replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default$Builder::userNameResolver → KILLED

60

1.1
Location : sshOptionsResolver
Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2.composeLocalEchoCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2)
replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default$Builder::sshOptionsResolver → KILLED

64

1.1
Location : build
Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2.composeLocalEchoCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2)
replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default$Builder::build → KILLED

70

1.1
Location : sshOptionForRemote
Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithoutUsername.composeRemoteEchoCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithoutUsername)
replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default$Builder$1::sshOptionForRemote → KILLED

75

1.1
Location : userForRemote
Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2.composeRemoteEchoCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2)
replaced return value with "" for com/github/dakusui/actionunit/actions/cmd/ShellManager$Default$Builder$1::userForRemote → KILLED

83

1.1
Location : createShellManager
Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2.composeLocalEchoCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2)
replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager::createShellManager → KILLED

87

1.1
Location : createShellManager
Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2.composeLocalEchoCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2)
replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager::createShellManager → KILLED

2.2
Location : lambda$createShellManager$0
Killed by : none
replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager::lambda$createShellManager$0 → NO_COVERAGE

91

1.1
Location : createShellManager
Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2.composeLocalEchoCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2)
replaced return value with null for com/github/dakusui/actionunit/actions/cmd/ShellManager::createShellManager → KILLED

92

1.1
Location : lambda$createShellManager$1
Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithoutUsername.composeRemoteEchoCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithoutUsername)
replaced return value with "" for com/github/dakusui/actionunit/actions/cmd/ShellManager::lambda$createShellManager$1 → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3