• 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

80.0
cli/src/main/java/com/devonfw/tools/ide/variable/VariableDefinition.java
1
package com.devonfw.tools.ide.variable;
2

3
import com.devonfw.tools.ide.context.IdeContext;
4
import com.devonfw.tools.ide.environment.EnvironmentVariables;
5
import com.devonfw.tools.ide.environment.VariableLine;
6

7
import java.nio.file.Path;
8

9
/**
10
 * Interface for a definition of a variable.
11
 *
12
 * @param <V> the {@link #getValueType() value type}.
13
 */
14
public interface VariableDefinition<V> {
15

16
  /**
17
   * @return the name of the variable.
18
   */
19
  String getName();
20

21
  /**
22
   * @return the optional legacy name that is still supported for downward compatibility. May be {@code null} if
23
   * undefined (no legacy support).
24
   */
25
  String getLegacyName();
26

27
  /**
28
   * @return the {@link Class} reflecting the type of the variable value.
29
   */
30
  Class<V> getValueType();
31

32
  /**
33
   * @param context the {@link IdeContext}.
34
   * @return the default value. May be {@code null}.
35
   */
36
  V getDefaultValue(IdeContext context);
37

38
  /**
39
   * @param context the {@link IdeContext}.
40
   * @return the default value as {@link String}. May be {@code null}.
41
   * @see #getDefaultValue(IdeContext)
42
   * @see #toString(Object)
43
   */
44
  default String getDefaultValueAsString(IdeContext context) {
45

46
    V value = getDefaultValue(context);
4✔
47
    if (value == null) {
2!
48
      return null;
×
49
    }
50
    return toString(value);
4✔
51
  }
52

53
  /**
54
   * @return {@code true} if the {@link #getDefaultValue(IdeContext) default value} shall be used without any
55
   * {@link EnvironmentVariables#get(String) variable lookup} (to prevent odd overriding of build in variables like
56
   * IDE_HOME), {@code false} otherwise (overriding of default value is allowed and intended).
57
   */
58
  boolean isForceDefaultValue();
59

60
  /**
61
   * @param value the value as {@link String}. May NOT be {@code null}.
62
   * @param context the {@link IdeContext}.
63
   * @return the value converted to the {@link #getValueType() value type}.
64
   */
65
  V fromString(String value, IdeContext context);
66

67
  /**
68
   * @return {@code true} if the variable needs to be exported, {@code false} otherwise.
69
   */
70
  boolean isExport();
71

72
  /**
73
   * @param value the typed value.
74
   * @return the value converted to {@link String}.
75
   */
76
  default String toString(V value) {
77

78
    if (value == null) {
2!
79
      return "";
×
80
    } else if (value instanceof Path) {
3✔
81
      return value.toString().replace('\\', '/');
6✔
82
    }
83
    return value.toString();
3✔
84
  }
85

86
  /**
87
   * @param context the {@link IdeContext}.
88
   * @return the value of the variable of this {@link VariableDefinition}.
89
   */
90
  V get(IdeContext context);
91

92
  /**
93
   * @param line the {@link VariableLine} that potentially needs to be migrated.
94
   * @return the original {@link VariableLine} or a migrated copy of it.
95
   */
96
  default VariableLine migrateLine(VariableLine line) {
97

98
    String name = line.getName();
3✔
99
    if (name != null) {
2!
100
      String newName = getName();
3✔
101
      if (!name.equals(newName)) {
4✔
102
        return line.withName(newName);
4✔
103
      }
104
    }
105
    return line;
2✔
106
  }
107

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