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

devonfw / IDEasy / 20930596111

12 Jan 2026 06:30PM UTC coverage: 69.914% (+0.01%) from 69.902%
20930596111

Pull #1674

github

web-flow
Merge d8c5802f3 into ceb9ddcf7
Pull Request #1674: package refactoring for SoC

3982 of 6272 branches covered (63.49%)

Branch coverage included in aggregate %.

10193 of 14003 relevant lines covered (72.79%)

3.14 hits per line

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

92.31
cli/src/main/java/com/devonfw/tools/ide/tool/repository/ArtifactToolRepository.java
1
package com.devonfw.tools.ide.tool.repository;
2

3
import java.util.Comparator;
4
import java.util.HashMap;
5
import java.util.List;
6
import java.util.Map;
7

8
import com.devonfw.tools.ide.cache.CachedValue;
9
import com.devonfw.tools.ide.context.IdeContext;
10
import com.devonfw.tools.ide.tool.ToolCommandlet;
11
import com.devonfw.tools.ide.tool.mvn.MvnRepository;
12
import com.devonfw.tools.ide.tool.npm.NpmRepository;
13
import com.devonfw.tools.ide.url.model.file.UrlDownloadFileMetadata;
14
import com.devonfw.tools.ide.version.VersionIdentifier;
15

16
/**
17
 * Extends {@link AbstractToolRepository} for artifact repository like {@link MvnRepository} or {@link NpmRepository}.
18
 */
19
public abstract class ArtifactToolRepository<A extends SoftwareArtifact, M extends UrlDownloadFileMetadata> extends AbstractToolRepository {
20

21
  private final Map<A, CachedValue<List<VersionIdentifier>>> versionCache;
22

23
  /**
24
   * The constructor.
25
   *
26
   * @param context the owning {@link IdeContext}.
27
   */
28
  public ArtifactToolRepository(IdeContext context) {
29

30
    super(context);
3✔
31
    this.versionCache = new HashMap<>();
5✔
32
  }
1✔
33

34
  @Override
35
  public List<String> getSortedEditions(String tool) {
36

37
    return List.of(tool);
×
38
  }
39

40
  @Override
41
  public List<VersionIdentifier> getSortedVersions(String tool, String edition, ToolCommandlet toolCommandlet) {
42

43
    A artifact = resolveArtifact(tool, edition, null, toolCommandlet);
7✔
44
    CachedValue<List<VersionIdentifier>> cachedValue = this.versionCache.computeIfAbsent(artifact,
9✔
45
        a -> new CachedValue<>(() -> computeSortedVersions(artifact)));
11✔
46
    return cachedValue.get();
4✔
47
  }
48

49
  private List<VersionIdentifier> computeSortedVersions(A artifact) {
50

51
    List<VersionIdentifier> versions = fetchVersions(artifact);
4✔
52
    versions.sort(Comparator.reverseOrder());
3✔
53
    return versions;
2✔
54
  }
55

56
  /**
57
   * @param tool the {@link ToolCommandlet#getName() tool name}.
58
   * @param edition the {@link ToolCommandlet#getConfiguredEdition()  tool edition}.
59
   * @param version the {@link SoftwareArtifact#getVersion() tool version} or {@code null} if undefined.
60
   * @param toolCommandlet the {@link ToolCommandlet}.
61
   * @return the resolved {@link SoftwareArtifact}.
62
   */
63
  protected abstract A resolveArtifact(String tool, String edition, VersionIdentifier version, ToolCommandlet toolCommandlet);
64

65
  /**
66
   * @param artifact the {@link SoftwareArtifact}.
67
   * @return the list of {@link VersionIdentifier}s sorted in descending order.
68
   */
69
  protected abstract List<VersionIdentifier> fetchVersions(A artifact);
70

71
  @Override
72
  protected M getMetadata(String tool, String edition, VersionIdentifier version, ToolCommandlet toolCommandlet) {
73

74
    A artifact = resolveArtifact(tool, edition, version, toolCommandlet);
7✔
75
    return getMetadata(artifact, tool, edition);
6✔
76
  }
77

78
  /**
79
   * @param artifact the {@link SoftwareArtifact} to resolve.
80
   * @param tool the {@link ToolCommandlet#getName() tool name}.
81
   * @param edition the {@link ToolCommandlet#getConfiguredEdition()  tool edition}.
82
   * @return the resolved {@link UrlDownloadFileMetadata}.
83
   */
84
  public abstract M getMetadata(A artifact, String tool, String edition);
85

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