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

devonfw / IDEasy / 9907372175

12 Jul 2024 11:49AM UTC coverage: 61.142% (-0.02%) from 61.162%
9907372175

push

github

hohwille
fixed tests

1997 of 3595 branches covered (55.55%)

Branch coverage included in aggregate %.

5296 of 8333 relevant lines covered (63.55%)

2.8 hits per line

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

65.38
cli/src/main/java/com/devonfw/tools/ide/property/RepositoryProperty.java
1
package com.devonfw.tools.ide.property;
2

3
import java.nio.file.Files;
4
import java.nio.file.Path;
5
import java.util.Arrays;
6
import java.util.function.Consumer;
7

8
import com.devonfw.tools.ide.context.IdeContext;
9

10
/**
11
 * Extends {@link FileProperty} for repository properties config file with auto-completion.
12
 */
13
public class RepositoryProperty extends FileProperty {
14

15
  /**
16
   * The constructor.
17
   *
18
   * @param name the {@link #getName() property name}.
19
   * @param required the {@link #isRequired() required flag}.
20
   * @param alias the {@link #getAlias() property alias}.
21
   */
22
  public RepositoryProperty(String name, boolean required, String alias) {
23

24
    super(name, required, alias, true);
6✔
25
  }
1✔
26

27
  /**
28
   * The constructor.
29
   *
30
   * @param name the {@link #getName() property name}.
31
   * @param required the {@link #isRequired() required flag}.
32
   * @param alias the {@link #getAlias() property alias}.
33
   * @param validator the {@link Consumer} used to {@link #validate() validate} the {@link #getValue() value}.
34
   */
35
  public RepositoryProperty(String name, boolean required, String alias, Consumer<Path> validator) {
36

37
    super(name, required, alias, true, validator);
×
38
  }
×
39

40
  @Override
41
  public Path parse(String valueAsString, IdeContext context) {
42

43
    if (valueAsString == null) {
2!
44
      return null;
×
45
    }
46

47
    Path repositoryFile = Path.of(valueAsString);
5✔
48
    if (!Files.exists(repositoryFile)) {
5!
49
      Path repositoriesPath = context.getSettingsPath().resolve(IdeContext.FOLDER_REPOSITORIES);
5✔
50
      Path legacyRepositoriesPath = context.getSettingsPath().resolve(IdeContext.FOLDER_LEGACY_REPOSITORIES);
5✔
51
      String propertiesFileName = valueAsString;
2✔
52
      if (!valueAsString.endsWith(".properties")) {
4!
53
        propertiesFileName += ".properties";
×
54
      }
55
      repositoryFile = context.getFileAccess().findExistingFile(propertiesFileName,
15✔
56
          Arrays.asList(repositoriesPath, legacyRepositoriesPath));
1✔
57
    }
58
    if (repositoryFile == null) {
2!
59
      throw new IllegalStateException("Could not find properties file: " + valueAsString);
×
60
    }
61
    return repositoryFile;
2✔
62
  }
63

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