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

devonfw / IDEasy / 8144002629

04 Mar 2024 04:56PM UTC coverage: 58.928% (+0.7%) from 58.254%
8144002629

push

github

web-flow
#208: improve test infrastructure # 219: fix wrong executable (#238)

* Add first implementation

* Add javadoc

* Add javadoc

* Using target path instead of ressource path to make sure one-to-one copy of set up folders is used

* Add JavaDoc and mac mock program

* Add support for multiple dependencies while testing

* Minor changes

* Modify mock programs for testing

* Refactored example JmcTest

* Add possibility to set execution path by using the context

* Reenable test after related issue 228 has been merged

* Replace ternary with regular if

* Add missing javadoc

* Add missing javadoc

* remove unnecessary semicolon

* Fix spelling typo

* Minor test changes

* Refactoring FileExtractor class for more modularity

* using const

* Add missing extensions

* Remove unnecessary execption declaration and minor rename

* Fix spelling

* Add javadoc

* Forget dot

* minor change

* Revert "minor change"

This reverts commit ec81c3ce6.

* Revert "Merge branch 'main' into feature/208-MockOutToolRepoRefactorTestInfra"

This reverts commit d58847230, reversing
changes made to f38b3105f.

* Revert "Revert "Merge branch 'main' into feature/208-MockOutToolRepoRefactorTestInfra""

This reverts commit 3e49a0b3d.

* Revert "Revert "minor change""

This reverts commit 2f7b94624.

* fix typo

* #208: review and complete rework

* #208: improved system path

* #208: found and fixed bug on windows

* #208: improve OS mocking

* #208: improve test logging

reveal logs/errors so the developer actually sees what is happening instead of leaving them in the dark

* #208: improve OS detection

* #208: fixed

found and fixed bug in MacOS app detection for JMC, fixed copy file to folder bug, moved !extract logic back to FileAccess, f... (continued)

1580 of 2930 branches covered (53.92%)

Branch coverage included in aggregate %.

4047 of 6619 relevant lines covered (61.14%)

2.65 hits per line

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

71.74
cli/src/main/java/com/devonfw/tools/ide/variable/AbstractVariableDefinition.java
1
package com.devonfw.tools.ide.variable;
2

3
import com.devonfw.tools.ide.context.IdeContext;
4

5
import java.util.Objects;
6
import java.util.function.Function;
7

8
/**
9
 * Abstract base implementation of {@link VariableDefinition}.
10
 *
11
 * @param <V> the {@link #getValueType() value type}.
12
 */
13
public abstract class AbstractVariableDefinition<V> implements VariableDefinition<V> {
14

15
  @SuppressWarnings("rawtypes")
16
  private static final Function NO_DEFAULT_VALUE = context -> null;
3✔
17

18
  private final String name;
19

20
  private final String legacyName;
21

22
  private final Function<IdeContext, V> defaultValueFactory;
23

24
  private final boolean forceDefaultValue;
25

26
  private final boolean export;
27

28
  /**
29
   * The constructor.
30
   *
31
   * @param name the {@link #getName() variable name}.
32
   */
33
  public AbstractVariableDefinition(String name) {
34

35
    this(name, null, NO_DEFAULT_VALUE, false);
×
36
  }
×
37

38
  /**
39
   * The constructor.
40
   *
41
   * @param name the {@link #getName() variable name}.
42
   * @param legacyName the {@link #getLegacyName() legacy name}.
43
   */
44
  public AbstractVariableDefinition(String name, String legacyName) {
45

46
    this(name, legacyName, NO_DEFAULT_VALUE, false);
6✔
47
  }
1✔
48

49
  /**
50
   * The constructor.
51
   *
52
   * @param name the {@link #getName() variable name}.
53
   * @param legacyName the {@link #getLegacyName() legacy name}.
54
   * @param defaultValueFactory the factory {@link Function} for the
55
   * {@link #getDefaultValue(IdeContext) default value}.
56
   * @param forceDefaultValue the {@link #isForceDefaultValue() forceDefaultValue} flag.
57
   */
58
  public AbstractVariableDefinition(String name, String legacyName, Function<IdeContext, V> defaultValueFactory,
59
      boolean forceDefaultValue) {
60

61
    this(name, legacyName, defaultValueFactory, forceDefaultValue, false);
7✔
62
  }
1✔
63

64
  /**
65
   * The constructor.
66
   *
67
   * @param name the {@link #getName() variable name}.
68
   * @param legacyName the {@link #getLegacyName() legacy name}.
69
   * @param defaultValueFactory the factory {@link Function} for the
70
   * {@link #getDefaultValue(IdeContext) default value}.
71
   */
72
  public AbstractVariableDefinition(String name, String legacyName, Function<IdeContext, V> defaultValueFactory) {
73

74
    this(name, legacyName, defaultValueFactory, false);
6✔
75
  }
1✔
76

77
  /**
78
   * The constructor.
79
   *
80
   * @param name the {@link #getName() variable name}.
81
   * @param legacyName the {@link #getLegacyName() legacy name}.
82
   * @param defaultValueFactory the factory {@link Function} for the
83
   * {@link #getDefaultValue(IdeContext) default value}.
84
   * @param forceDefaultValue the {@link #isForceDefaultValue() forceDefaultValue} flag.
85
   * @param export the {@link #isExport() export} flag.
86
   */
87
  public AbstractVariableDefinition(String name, String legacyName, Function<IdeContext, V> defaultValueFactory,
88
      boolean forceDefaultValue, boolean export) {
89

90
    super();
2✔
91
    this.name = name;
3✔
92
    this.legacyName = legacyName;
3✔
93
    this.defaultValueFactory = defaultValueFactory;
3✔
94
    this.forceDefaultValue = forceDefaultValue;
3✔
95
    this.export = export;
3✔
96
  }
1✔
97

98
  @Override
99
  public boolean isForceDefaultValue() {
100

101
    return this.forceDefaultValue;
3✔
102
  }
103

104
  @Override
105
  public String getName() {
106

107
    return this.name;
3✔
108
  }
109

110
  @Override
111
  public String getLegacyName() {
112

113
    return this.legacyName;
3✔
114
  }
115

116
  @Override
117
  public V getDefaultValue(IdeContext context) {
118

119
    return this.defaultValueFactory.apply(context);
5✔
120
  }
121

122
  @Override
123
  public V get(IdeContext context) {
124

125
    Objects.requireNonNull(context);
3✔
126
    String valueAsString = null;
2✔
127
    if (!this.forceDefaultValue) {
3✔
128
      valueAsString = context.getVariables().get(this.name);
6✔
129
      if (valueAsString == null) {
2!
130
        if (this.legacyName != null) {
×
131
          valueAsString = context.getVariables().get(this.legacyName);
×
132
        }
133
      }
134
    }
135
    V value;
136
    if (valueAsString == null) {
2✔
137
      value = getDefaultValue(context);
5✔
138
    } else {
139
      value = fromString(valueAsString, context);
5✔
140
    }
141
    return value;
2✔
142
  }
143

144
  @Override
145
  public boolean isExport() {
146

147
    return this.export;
3✔
148
  }
149

150
  @Override
151
  public String toString() {
152

153
    Class<V> valueType = getValueType();
×
154
    if (valueType == String.class) {
×
155
      return this.name;
×
156
    } else {
157
      return this.name + "[" + valueType.getSimpleName() + "]";
×
158
    }
159
  }
160

161
}
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