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

devonfw / IDEasy / 27652215079

16 Jun 2026 10:26PM UTC coverage: 71.202% (-0.08%) from 71.285%
27652215079

Pull #2018

github

web-flow
Merge fa9133a8c into ec9c73a45
Pull Request #2018: fixed pgAdmin macOS dmg installation

4688 of 7272 branches covered (64.47%)

Branch coverage included in aggregate %.

12078 of 16275 relevant lines covered (74.21%)

3.14 hits per line

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

22.92
cli/src/main/java/com/devonfw/tools/ide/tool/pgadmin/PgAdmin.java
1
package com.devonfw.tools.ide.tool.pgadmin;
2

3
import java.nio.file.Files;
4
import java.nio.file.Path;
5
import java.nio.file.Paths;
6
import java.util.ArrayList;
7
import java.util.Arrays;
8
import java.util.List;
9
import java.util.Set;
10

11
import com.devonfw.tools.ide.common.Tag;
12
import com.devonfw.tools.ide.context.IdeContext;
13
import com.devonfw.tools.ide.os.WindowsHelper;
14
import com.devonfw.tools.ide.tool.GlobalToolCommandlet;
15
import com.devonfw.tools.ide.tool.NativePackageManager;
16
import com.devonfw.tools.ide.tool.PackageManagerCommand;
17
import com.devonfw.tools.ide.tool.repository.ToolRepository;
18
import com.devonfw.tools.ide.version.VersionIdentifier;
19

20
/**
21
 * {@link GlobalToolCommandlet} for <a href="https://www.pgadmin.org/">pgadmin</a>
22
 */
23
public class PgAdmin extends GlobalToolCommandlet {
24

25
  private static final String PGADMIN_MAC_BINARY = "pgAdmin 4";
26

27
  /**
28
   * The constructor.
29
   *
30
   * @param context the {@link IdeContext}.
31
   */
32
  public PgAdmin(IdeContext context) {
33

34
    super(context, "pgadmin", Set.of(Tag.DB, Tag.ADMIN));
7✔
35
  }
1✔
36

37
  @Override
38
  protected List<PackageManagerCommand> getInstallPackageManagerCommands() {
39

40
    String edition = getConfiguredEdition();
×
41
    ToolRepository toolRepository = getToolRepository();
×
42
    VersionIdentifier configuredVersion = getConfiguredVersion();
×
43
    String resolvedVersion = toolRepository.resolveVersion(this.tool, edition, configuredVersion, this).toString();
×
44

45
    PackageManagerCommand packageManagerCommand = new PackageManagerCommand(NativePackageManager.APT, List.of(
×
46
        "curl -fsS https://www.pgadmin.org/static/packages_pgadmin_org.pub | "
47
            + "sudo gpg --yes --dearmor -o /usr/share/keyrings/packages-pgadmin-org.gpg",
48
        "sudo sh -c 'echo \"deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] "
49
            + "https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main\" "
50
            + "> /etc/apt/sources.list.d/pgadmin4.list && apt update'", String.format(
×
51
            "sudo apt install -y --allow-downgrades pgadmin4=%1$s pgadmin4-server=%1$s pgadmin4-desktop=%1$s pgadmin4-web=%1$s",
52
            resolvedVersion)));
53
    return List.of(packageManagerCommand);
×
54
  }
55

56
  @Override
57
  public void uninstall() {
58

59
    if (this.context.getSystemInfo().isLinux()) {
×
60
      runWithPackageManager(false, getPackageManagerCommandsUninstall());
×
61
    } else {
62
      super.uninstall();
×
63
    }
64
  }
×
65

66
  private List<PackageManagerCommand> getPackageManagerCommandsUninstall() {
67

68
    List<PackageManagerCommand> pmCommands = new ArrayList<>();
×
69

70
    pmCommands.add(new PackageManagerCommand(NativePackageManager.APT,
×
71
        Arrays.asList("sudo apt -y autoremove pgadmin4 pgadmin4-server pgadmin4-desktop pgadmin4-web")));
×
72

73
    return pmCommands;
×
74
  }
75

76
  @Override
77
  protected String getBinaryName() {
78

79
    if (this.context.getSystemInfo().isMac()) {
5✔
80
      return PGADMIN_MAC_BINARY;
2✔
81
    }
82
    return "pgadmin4";
2✔
83
  }
84

85
  @Override
86
  protected Path getInstallationPath(String edition, VersionIdentifier resolvedVersion) {
87

88
    Path installationPath = super.getInstallationPath(edition, resolvedVersion);
5✔
89
    if (installationPath != null) {
2!
90
      return installationPath;
2✔
91
    }
92
    if (this.context.getSystemInfo().isWindows()) {
×
93
      return getExecutableFolderFromWindowsRegistry();
×
94
    }
95
    return null;
×
96
  }
97

98
  private Path getExecutableFolderFromWindowsRegistry() {
99

100
    WindowsHelper windowsHelper = WindowsHelper.get(this.context);
×
101
    String registryPath = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\pgAdmin 4v9_is1";
×
102
    String displayIcon = windowsHelper.getRegistryValue(registryPath, "DisplayIcon");
×
103
    if (displayIcon != null) {
×
104
      Path executablePath = Paths.get(displayIcon);
×
105
      if (Files.isExecutable(executablePath)) {
×
106
        Path installationDir = executablePath.getParent();
×
107
        this.context.getPath().setPath(getName(), installationDir);
×
108
        return installationDir;
×
109
      }
110
    }
111
    return null;
×
112
  }
113
}
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