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

devonfw / IDEasy / 19789527581

29 Nov 2025 09:25PM UTC coverage: 69.431% (-0.06%) from 69.489%
19789527581

push

github

web-flow
#1615: prevent to ask CVE questions if tool already installed (#1618)

3696 of 5853 branches covered (63.15%)

Branch coverage included in aggregate %.

9618 of 13323 relevant lines covered (72.19%)

3.14 hits per line

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

72.22
cli/src/main/java/com/devonfw/tools/ide/tool/ToolInstallRequest.java
1
package com.devonfw.tools.ide.tool;
2

3
import com.devonfw.tools.ide.process.ProcessContext;
4
import com.devonfw.tools.ide.step.Step;
5
import com.devonfw.tools.ide.version.GenericVersionRange;
6
import com.devonfw.tools.ide.version.VersionIdentifier;
7
import com.devonfw.tools.ide.version.VersionRange;
8

9
/**
10
 * Container for data related to a tool installation.
11
 */
12
public final class ToolInstallRequest {
1✔
13

14
  private final boolean silent;
15

16
  private final boolean direct;
17

18
  private boolean cveCheckDone;
19

20
  private ToolEditionAndVersion requested;
21

22
  private ToolEditionAndVersion installed;
23

24
  private ProcessContext processContext;
25

26
  private Step step;
27

28
  /**
29
   * The constructor.
30
   *
31
   * @param silent the {@link #isSilent() silent} flag.
32
   */
33
  public ToolInstallRequest(boolean silent) {
34
    this(silent, false);
4✔
35
  }
1✔
36

37
  /**
38
   * The constructor.
39
   *
40
   * @param parent the parent {@link ToolInstallRequest} (in case of a dependency).
41
   */
42
  public ToolInstallRequest(ToolInstallRequest parent) {
43
    this(parent.silent, false);
5✔
44
    this.processContext = parent.processContext;
4✔
45
  }
1✔
46

47
  /**
48
   * The constructor.
49
   *
50
   * @param silent the {@link #isSilent() silent} flag.
51
   * @param direct the {@link #isDirect() direct} flag.
52
   */
53
  private ToolInstallRequest(boolean silent, boolean direct) {
54
    super();
2✔
55
    this.silent = silent;
3✔
56
    this.direct = direct;
3✔
57
  }
1✔
58

59
  /**
60
   * @return {@code true} if this installation should be silent and log information like "tool already installed" only on debug level to avoid spam,
61
   *     {@code false} otherwise. A {@link #isDirect() direct} installation should never be silent.
62
   */
63
  public boolean isSilent() {
64

65
    return this.silent;
3✔
66
  }
67

68
  /**
69
   * @return {@code true} if the user directly triggered this tool installation (via "ide install tool"), {@code false} otherwise (indirect installation e.g. as
70
   *     dependency or via "ide create" or "ide update").
71
   */
72
  public boolean isDirect() {
73

74
    return this.direct;
×
75
  }
76

77
  /**
78
   * @return {@code true} if CVEs have already been checked, {@code false} otherwise.
79
   */
80
  public boolean isCveCheckDone() {
81

82
    return this.cveCheckDone;
3✔
83
  }
84

85
  void setCveCheckDone() {
86

87
    assert !this.cveCheckDone;
4!
88
    this.cveCheckDone = true;
3✔
89
  }
1✔
90

91
  /**
92
   * @return the {@link ToolEditionAndVersion} that is requested to be installed.
93
   */
94
  public ToolEditionAndVersion getRequested() {
95

96
    return this.requested;
3✔
97
  }
98

99
  /**
100
   * @param requested new value of {@link #getRequested()}.
101
   */
102
  public void setRequested(ToolEditionAndVersion requested) {
103
    if (this.requested != null) {
3!
104
      throw new IllegalStateException();
×
105
    }
106
    this.requested = requested;
3✔
107
  }
1✔
108

109
  /**
110
   * @return the {@link ToolEditionAndVersion} that is currently installed or {@code null} if the tool is not installed yet.
111
   */
112
  public ToolEditionAndVersion getInstalled() {
113

114
    return this.installed;
3✔
115
  }
116

117
  /**
118
   * @param installed new value of {@link #getInstalled()}.
119
   */
120
  public void setInstalled(ToolEditionAndVersion installed) {
121

122
    if (this.installed != null) {
3!
123
      throw new IllegalStateException();
×
124
    }
125
    this.installed = installed;
3✔
126
  }
1✔
127

128
  /**
129
   * @return the {@link ProcessContext} to use for executing the tool. Will also be configured during the installation (variables set, PATH extended).
130
   */
131
  public ProcessContext getProcessContext() {
132
    return this.processContext;
3✔
133
  }
134

135
  /**
136
   * @param processContext new value of {@link #getProcessContext()}.
137
   */
138
  public void setProcessContext(ProcessContext processContext) {
139

140
    if (this.processContext != null) {
3!
141
      throw new IllegalStateException();
×
142
    }
143
    this.processContext = processContext;
3✔
144
  }
1✔
145

146
  /**
147
   * @return the {@link Step} for the installation.
148
   */
149
  public Step getStep() {
150

151
    return this.step;
3✔
152
  }
153

154
  /**
155
   * @param step new value of {@link #getStep()}.
156
   */
157
  public void setStep(Step step) {
158

159
    if (this.step != null) {
×
160
      throw new IllegalStateException();
×
161
    }
162
    this.step = step;
×
163
  }
×
164

165
  /**
166
   * @return {@code true} if an additional installation is required not linked to the project's software folder (e.g. because of a transitive installation from
167
   *     a dependency that is incompatible with the project version), {@code false} otherwise.
168
   */
169
  public boolean isAdditionalInstallation() {
170
    if (this.requested != null) {
3!
171
      GenericVersionRange versionToInstall = this.requested.getVersion();
4✔
172
      return (versionToInstall instanceof VersionRange);
3✔
173
    }
174
    return false;
×
175
  }
176

177
  /**
178
   * @return {@code true} if the {@link #getRequested() requested edition and version} matches the {@link #getInstalled() installed edition and version}
179
   */
180
  public boolean isAlreadyInstalled() {
181

182
    if (this.installed == null) {
3!
183
      return false;
×
184
    }
185
    VersionIdentifier installedVersion = this.installed.getResolvedVersion();
4✔
186
    if (installedVersion == null) {
2✔
187
      return false;
2✔
188
    }
189
    ToolEdition installedEdition = this.installed.getEdition();
4✔
190
    if (installedEdition == null) {
2!
191
      return false; // should actually never happen
×
192
    }
193
    if (!this.requested.getEdition().equals(installedEdition)) {
6✔
194
      return false;
2✔
195
    }
196
    return installedVersion.equals(this.requested.getResolvedVersion());
6✔
197
  }
198

199
  /**
200
   * @return a new {@link #isDirect() direct} {@link ToolInstallRequest}.
201
   */
202
  public static ToolInstallRequest ofDirect() {
203

204
    return new ToolInstallRequest(false, true);
6✔
205
  }
206
}
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

© 2026 Coveralls, Inc