• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In
Build has been canceled!

devonfw / IDEasy / 20241902872

15 Dec 2025 05:44PM UTC coverage: 70.138% (-0.002%) from 70.14%
20241902872

push

github

web-flow
#1644: added JSON deserialization tests, implement + registered custom deserializer (#1656)

3970 of 6225 branches covered (63.78%)

Branch coverage included in aggregate %.

10160 of 13921 relevant lines covered (72.98%)

3.15 hits per line

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

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

3
import java.util.List;
4

5
import com.devonfw.tools.ide.context.IdeContext;
6
import com.devonfw.tools.ide.json.JsonMapping;
7
import com.devonfw.tools.ide.tool.ToolCommandlet;
8
import com.devonfw.tools.ide.tool.pip.Pip;
9
import com.devonfw.tools.ide.tool.pip.PipArtifact;
10
import com.devonfw.tools.ide.tool.pip.PipArtifactMetadata;
11
import com.devonfw.tools.ide.tool.pip.PypiObject;
12
import com.devonfw.tools.ide.version.VersionIdentifier;
13
import com.fasterxml.jackson.core.JsonProcessingException;
14
import com.fasterxml.jackson.databind.ObjectMapper;
15

16
/**
17
 * Implementation of {@link AbstractToolRepository} for pip/PyPI artifacts.
18
 */
19
public class PipRepository extends ArtifactToolRepository<PipArtifact, PipArtifactMetadata> {
20

21
  /** The base URL of the PyPI registry. */
22
  public static final String REGISTRY_URL = "https://pypi.org/pypi/";
23

24
  private static final ObjectMapper MAPPER = JsonMapping.create();
3✔
25

26
  /** The {@link #getId() repository ID}. */
27
  public static final String ID = "pip";
28

29
  /**
30
   * The constructor.
31
   *
32
   * @param context the {@link IdeContext}.
33
   */
34
  public PipRepository(IdeContext context) {
35
    super(context);
3✔
36
  }
1✔
37

38
  @Override
39
  public String getId() {
40

41
    return ID;
×
42
  }
43

44
  @Override
45
  protected PipArtifact resolveArtifact(String tool, String edition, VersionIdentifier version, ToolCommandlet toolCommandlet) {
46

47
    if (toolCommandlet instanceof Pip pip) {
6!
48
      String name = pip.getPackageName();
3✔
49
      if (version == null) {
2!
50
        version = VersionIdentifier.LATEST;
2✔
51
      }
52
      return new PipArtifact(name, version.toString());
7✔
53
    }
54
    throw new UnsupportedOperationException("Tool '" + tool + "' is not supported by pip repository.");
×
55
  }
56

57
  @Override
58
  protected List<VersionIdentifier> fetchVersions(PipArtifact artifact) {
59

60
    String url = getRegistryUrl() + artifact.getName() + "/json";
6✔
61
    String json = this.context.getFileAccess().download(url);
6✔
62
    try {
63
      PypiObject pypiObject = MAPPER.readValue(json, PypiObject.class);
6✔
64
      return pypiObject.releases();
3✔
65
    } catch (JsonProcessingException e) {
×
66
      throw new RuntimeException("Failed to process JSON from " + url, e);
×
67
    }
68
  }
69

70
  /**
71
   * @return the registry URL.
72
   */
73
  public String getRegistryUrl() {
74
    return REGISTRY_URL;
×
75
  }
76

77
  @Override
78
  public PipArtifactMetadata getMetadata(PipArtifact artifact, String tool, String edition) {
79

80
    return new PipArtifactMetadata(artifact, tool, edition);
×
81
  }
82

83
  @Override
84
  public List<String> getSortedEditions(String tool) {
85

86
    if ("pip".equals(tool)) {
×
87
      return Pip.EDITIONS;
×
88
    }
89
    return super.getSortedEditions(tool);
×
90
  }
91
}
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