SshShell.java

1
package com.github.dakusui.actionunit.actions.cmd.unix;
2
3
import com.github.dakusui.processstreamer.core.process.Shell;
4
5
import java.util.LinkedList;
6
import java.util.List;
7
8
import static java.util.Objects.requireNonNull;
9
10
public interface SshShell extends Shell {
11
  class Impl implements SshShell {
12
    private final String       program;
13
    private final List<String> options;
14
15
    Impl(String program, List<String> options) {
16
      this.program = program;
17
      this.options = options;
18
    }
19
20
    @Override
21
    public String program() {
22 1 1. program : replaced return value with "" for com/github/dakusui/actionunit/actions/cmd/unix/SshShell$Impl::program → KILLED
      return program;
23
    }
24
25
    @Override
26
    public List<String> options() {
27 1 1. options : replaced return value with Collections.emptyList for com/github/dakusui/actionunit/actions/cmd/unix/SshShell$Impl::options → KILLED
      return options;
28
    }
29
30
    @Override
31
    public String toString() {
32 1 1. toString : replaced return value with "" for com/github/dakusui/actionunit/actions/cmd/unix/SshShell$Impl::toString → NO_COVERAGE
      return String.format("%s %s", program, String.join(" ", options));
33
    }
34
  }
35
36
  class Builder {
37
    /**
38
     * A name of ssh program. Usually just `ssh`.
39
     */
40
    private       String program;
41
    private       String user;
42
    private final String host;
43
44
    /**
45
     * Holds options specific to {@code ssh} command. That is, options supported
46
     * by {@code ssh} but not by {@code scp} should be stored in this field.
47
     */
48
    private final SshOptions options;
49
50
    public Builder(String host) {
51
      this(host, new SshOptions.Builder().build());
52
    }
53
54
    public Builder(String host, SshOptions options) {
55
      this.program("ssh");
56
      this.host = requireNonNull(host);
57
      this.options = requireNonNull(options);
58
    }
59
60
    public Builder program(String program) {
61
      this.program = requireNonNull(program);
62 1 1. program : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshShell$Builder::program → KILLED
      return this;
63
    }
64
65
    public Builder user(String user) {
66
      this.user = requireNonNull(user);
67 1 1. user : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshShell$Builder::user → KILLED
      return this;
68
    }
69
70
    public Shell build() {
71
      List<String> options = new LinkedList<String>() {{
72
        this.addAll(Builder.this.options.formatOptionsWith(SshOptions.Formatter.forSsh()));
73
        this.add(
74 1 1. <init> : negated conditional → KILLED
            user != null ?
75
                String.format("%s@%s", user, host) :
76
                host);
77
      }};
78 1 1. build : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/SshShell$Builder::build → KILLED
      return new Impl(program, options);
79
    }
80
  }
81
}

Mutations

22

1.1
Location : program
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/unix/SshShell$Impl::program → KILLED

27

1.1
Location : options
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 Collections.emptyList for com/github/dakusui/actionunit/actions/cmd/unix/SshShell$Impl::options → KILLED

32

1.1
Location : toString
Killed by : none
replaced return value with "" for com/github/dakusui/actionunit/actions/cmd/unix/SshShell$Impl::toString → NO_COVERAGE

62

1.1
Location : program
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/unix/SshShell$Builder::program → KILLED

67

1.1
Location : user
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/unix/SshShell$Builder::user → KILLED

74

1.1
Location : <init>
Killed by : com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2.composeRemoteEchoCommandLine(com.github.dakusui.actionunit.ut.actions.cmd.UnixCommanderFactoryTest$WithCustomSshOptions2)
negated conditional → KILLED

78

1.1
Location : build
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/unix/SshShell$Builder::build → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3