Skip to content

#1869: Improve windows helper to search windows registry#1876

Open
jakozian wants to merge 13 commits into
devonfw:mainfrom
jakozian:feature/#1869-improve-windows-helper-to-search-windows-registry
Open

#1869: Improve windows helper to search windows registry#1876
jakozian wants to merge 13 commits into
devonfw:mainfrom
jakozian:feature/#1869-improve-windows-helper-to-search-windows-registry

Conversation

@jakozian
Copy link
Copy Markdown
Contributor

@jakozian jakozian commented Apr 29, 2026

This PR fixes #1869

Implemented changes:

  • Add methods to search for DisplayVersion, DisplayIcon, InstallLocation and UninstallString in common registry paths for an application.
  • Add tests

Checklist for this PR

Make sure everything is checked before merging this PR. For further info please also see
our DoD.

  • When running mvn clean test locally all tests pass and build is successful
  • PR title is of the form #«issue-id»: «brief summary» (e.g. #921: fixed setup.bat). If no issue ID exists, title only.
  • PR top-level comment summarizes what has been done and contains link to addressed issue(s)
  • PR and issue(s) have suitable labels
  • Issue is set to In Progress and assigned to you or there is no issue (might happen for very small PRs)
  • You followed all coding conventions
  • You have added the issue implemented by your PR in CHANGELOG.adoc unless issue is labeled
    with internal

@github-project-automation github-project-automation Bot moved this to 🆕 New in IDEasy board Apr 29, 2026
@jakozian jakozian self-assigned this Apr 29, 2026
@jakozian jakozian added internal Nothing to be added to CHANGELOG, only internal story windows specific for Microsoft Windows OS labels Apr 29, 2026
@jakozian jakozian moved this from 🆕 New to 🏗 In progress in IDEasy board Apr 29, 2026
@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Apr 29, 2026

Coverage Report for CI Build 25717685842

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage decreased (-0.09%) to 70.643%

Details

  • Coverage decreased (-0.09%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 285 coverage regressions across 13 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

285 previously-covered lines in 13 files lost coverage.

Top 10 Files by Coverage Loss Lines Losing Coverage Coverage
com/devonfw/tools/ide/io/FileAccessImpl.java 98 66.72%
com/devonfw/tools/ide/tool/IdeasyCommandlet.java 62 72.78%
com/devonfw/tools/ide/tool/pgadmin/PgAdmin.java 27 4.76%
com/devonfw/tools/ide/os/WindowsHelperImpl.java 19 61.76%
com/devonfw/tools/ide/tool/docker/Docker.java 18 6.02%
com/devonfw/tools/ide/process/ProcessContextImpl.java 14 81.21%
com/devonfw/tools/ide/url/updater/UpdateManager.java 13 0.0%
com/devonfw/tools/ide/tool/gui/Gui.java 10 20.83%
com/devonfw/tools/ide/tool/plugin/PluginBasedCommandlet.java 9 86.29%
com/devonfw/tools/ide/tool/GlobalToolCommandlet.java 6 2.34%

Coverage Stats

Coverage Status
Relevant Lines: 15499
Covered Lines: 11411
Line Coverage: 73.62%
Relevant Branches: 6932
Covered Branches: 4435
Branch Coverage: 63.98%
Branches in Coverage %: Yes
Coverage Strength: 3.12 hits per line

💛 - Coveralls

@hohwille hohwille moved this from 🏗 In progress to Team Review in IDEasy board Apr 30, 2026
Copy link
Copy Markdown
Contributor

@MarvMa MarvMa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats a really easy to read PR following the KISS principle, which I personally appreciate a lot 👍 I left some comments regarding minor changes. I have been more critical since that has been the desired task. But the coments are just related to minor changes in code-style regarding the coding-conventions of IDEasy.

Comment thread cli/src/main/java/com/devonfw/tools/ide/os/WindowsHelper.java
Comment thread cli/src/main/java/com/devonfw/tools/ide/os/WindowsHelperImpl.java Outdated
Comment thread cli/src/test/java/com/devonfw/tools/ide/os/WindowsHelperMock.java Outdated
@jakozian jakozian moved this from Team Review to 👀 In review in IDEasy board May 7, 2026
@jakozian jakozian requested a review from hohwille May 7, 2026 13:36
Copy link
Copy Markdown
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jakozian thanks for your PR. Nice improvement and isolation incl. testing of this feature. 👍
I left some review comments for rework.
@MarvMa since you did the Team-Review and @jakozian already left, could you have a look at my review comments so we can get this completed together?

}
for (String line : out) {
line = line.trim();
if (line.startsWith("HKEY_")) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if registryBasePath was "HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall" this will never be true? So it that entry in the constant array pointless then?
Should this rather be like this:

Suggested change
if (line.startsWith("HKEY_")) {
if (line.startsWith(registryBasePath)) {

Copy link
Copy Markdown
Contributor Author

@jakozian jakozian May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output of reg query <path> /s looks something like this:
image

That means the HKCU of the path is written out in the output and in this case HK = HKEY and CU=Current User. For that reason i did not check for line.startsWith(registryBasePath).
And the goal is to find the path to the tool and every path (doesn't matter which base path, LM or CU) begins with HKEY_ so that seemed to be the right decision in my opinion.

Comment thread cli/src/main/java/com/devonfw/tools/ide/os/WindowsHelperImpl.java
Comment thread cli/src/main/java/com/devonfw/tools/ide/os/WindowsHelperImpl.java Outdated
Comment on lines +15 to +24
private static final String MOCK_APP_NAME = "TestApp";

private static final String MOCK_DISPLAY_VERSION = "1.1.1";

private static final String MOCK_INSTALL_LOCATION = "C:\\Program Files\\TestApp";

private static final String MOCK_DISPLAY_ICON =
"C:\\Program Files\\TestApp\\testapp.exe,0";
private static final String MOCK_UNINSTALL_STRING =
"\"C:\\Program Files\\TestApp\\uninstall.exe\"";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for mocking we should use a Map where mock data for tests can be registered instead of hard-coding random values.
Assuming you want to test PGAdmin now with mocked Windows on any OS then you could first register for the key pgadmin some object (Java record) containing the displayIcon, appName, and displayVersion, etc.

Co-authored-by: Jörg Hohwiller <hohwille@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Nothing to be added to CHANGELOG, only internal story windows specific for Microsoft Windows OS

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

Improve WindowsHelper to search in windows registry

4 participants