• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 14462897556

15 Apr 2025 06:35AM UTC coverage: 67.461% (+0.1%) from 67.315%
14462897556

Pull #1241

github

web-flow
Merge 6bd21c956 into 1823d2ec6
Pull Request #1241: #1205 : Fix Git implementation

3055 of 4930 branches covered (61.97%)

Branch coverage included in aggregate %.

7879 of 11278 relevant lines covered (69.86%)

3.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
cli/src/main/java/com/devonfw/tools/ide/process/ProcessResultImpl.java
1
package com.devonfw.tools.ide.process;
2

3
import java.util.Collections;
4
import java.util.List;
5
import java.util.Objects;
6

7
import com.devonfw.tools.ide.cli.CliProcessException;
8
import com.devonfw.tools.ide.context.IdeContext;
9
import com.devonfw.tools.ide.log.IdeLogLevel;
10

11
/**
12
 * Implementation of {@link ProcessResult}.
13
 */
14
public class ProcessResultImpl implements ProcessResult {
15

16
  private final String executable;
17

18
  private final String command;
19

20
  private final int exitCode;
21

22
  private final List<OutputMessage> outputMessages;
23

24
  /**
25
   * The constructor.
26
   *
27
   * @param executable the {@link #getExecutable() executable}.
28
   * @param command the {@link #getCommand() command}.
29
   * @param exitCode the {@link #getExitCode() exit code}.
30
   * @param outputMessages {@link #getOutputMessages() output Messages}.
31
   */
32
  public ProcessResultImpl(String executable, String command, int exitCode, List<OutputMessage> outputMessages) {
33

34
    super();
2✔
35
    this.executable = executable;
3✔
36
    this.command = command;
3✔
37
    this.exitCode = exitCode;
3✔
38
    this.outputMessages = Objects.requireNonNullElse(outputMessages, Collections.emptyList());
6✔
39
  }
1✔
40

41
  @Override
42
  public String getExecutable() {
43

44
    return this.executable;
×
45
  }
46

47
  @Override
48
  public String getCommand() {
49

50
    return this.command;
×
51
  }
52

53
  @Override
54
  public int getExitCode() {
55

56
    return this.exitCode;
3✔
57
  }
58

59
  @Override
60
  public List<String> getOut() {
61

62
    return this.outputMessages.stream().filter(outputMessage -> !outputMessage.error()).map(OutputMessage::message).toList();
16✔
63
  }
64

65
  @Override
66
  public List<String> getErr() {
67

68
    return this.outputMessages.stream().filter(OutputMessage::error).map(OutputMessage::message).toList();
9✔
69
  }
70

71
  @Override
72
  public List<OutputMessage> getOutputMessages() {
73

74
    return this.outputMessages;
×
75

76
  }
77

78
  @Override
79
  public void log(IdeLogLevel level, IdeContext context) {
80
    log(level, context, level);
5✔
81
  }
1✔
82

83
  @Override
84
  public void log(IdeLogLevel outLevel, IdeContext context, IdeLogLevel errorLevel) {
85

86
    if (!this.outputMessages.isEmpty()) {
4✔
87
      for (OutputMessage outputMessage : this.outputMessages) {
11✔
88
        if (outputMessage.error()) {
3✔
89
          doLog(errorLevel, outputMessage.message(), context);
7✔
90
        } else {
91
          doLog(outLevel, outputMessage.message(), context);
6✔
92
        }
93
      }
1✔
94
    }
95
  }
1✔
96

97
  private void doLog(IdeLogLevel level, String message, IdeContext context) {
98
    // remove !MESSAGE from log message
99
    if (message.startsWith("!MESSAGE ")) {
4!
100
      message = message.substring(9);
×
101
    }
102
    context.level(level).log(message);
5✔
103
  }
1✔
104

105
  @Override
106
  public void failOnError() throws CliProcessException {
107

108
    if (!isSuccessful()) {
×
109
      throw new CliProcessException(this);
×
110
    }
111
  }
×
112
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc