Skip to content

#1731: Fixed Solar Install returning NPE#1734

Merged
hohwille merged 3 commits intodevonfw:mainfrom
tmukh:SonarNPE_Fix
Mar 12, 2026
Merged

#1731: Fixed Solar Install returning NPE#1734
hohwille merged 3 commits intodevonfw:mainfrom
tmukh:SonarNPE_Fix

Conversation

@tmukh
Copy link
Contributor

@tmukh tmukh commented Mar 10, 2026

This PR fixes #1731

Implemented changes:

  • Changed relative path to absolute path for resolution, in order to run Sonar installation
  • created comprehensive Sonar tests following the Commandlet test patterns.
  • SonarTest.java with three test methods:
    • testSonarStartCommand - Tests the Sonar commandlet with START command
    • testSonarStopCommand - Tests the Sonar commandlet with STOP command
    • testSonarAnalyzeCommand - Tests the Sonar commandlet with ANALYZE command
  • Each test:
    • Creates an IDE test context for the sonar project
    • Retrieves the Sonar commandlet from the commandlet manager
    • Sets the appropriate command using the enum
    • Validates that the commandlet is properly initialized with the correct command
      Structure Created:
src/test/resources/ide-projects/sonar/
├── project/
│   ├── home/.ide/ide.properties
│   ├── settings/ide.properties
│   └── workspaces/
├── repository/sonar/sonar/default/
│   ├── .ide.software.version
│   ├── bin/
│   │   ├── windows-x86-64/
│   │   │   ├── StartSonar.bat
│   │   │   └── SonarService.bat
│   │   ├── linux-x86-64/sonar.sh
│   │   └── macosx-universal-64/sonar.sh
│   └── conf/sonar.properties
└── _ide/urls/sonar/sonar/26.3.0.120487/urls

The tests follow the same pattern as the other tests, using the @wiremocktest annotation and AbstractIdeContextTest
base class for proper test isolation and context management.


Checklist for this PR

  • 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

@coveralls
Copy link
Collaborator

coveralls commented Mar 10, 2026

Pull Request Test Coverage Report for Build 22949388609

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 20 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.05%) to 70.337%

Files with Coverage Reduction New Missed Lines %
com/devonfw/tools/ide/tool/ide/IdeToolCommandlet.java 1 78.33%
com/devonfw/tools/ide/tool/sonar/Sonar.java 19 36.51%
Totals Coverage Status
Change from base Build 22895024827: 0.05%
Covered Lines: 10617
Relevant Lines: 14500

💛 - Coveralls

@CLAassistant
Copy link

CLAassistant commented Mar 10, 2026

CLA assistant check
All committers have signed the CLA.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR targets issue #1731 by adjusting SonarQube tool execution/installation behavior (path/binary resolution) and adding a dedicated test fixture plus JUnit tests for the Sonar commandlet.

Changes:

  • Updated Sonar commandlet binary/path resolution (including an override to use an absolute executable path).
  • Added a new WireMock-based SonarTest and a full sonar test project fixture under src/test/resources/ide-projects/sonar/.
  • Added a changelog entry for #1731.

Reviewed changes

Copilot reviewed 7 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
cli/src/main/java/com/devonfw/tools/ide/tool/sonar/Sonar.java Adjusts binary selection and configures the process executable using an absolute path.
cli/src/test/java/com/devonfw/tools/ide/sonar/SonarTest.java Adds tests for parsing/initializing Sonar commands (START/STOP/ANALYZE).
cli/src/test/resources/ide-projects/sonar/repository/sonar/sonar/default/conf/sonar.properties Adds minimal SonarQube config used by the fixture.
cli/src/test/resources/ide-projects/sonar/repository/sonar/sonar/default/bin/windows-x86-64/StartSonar.bat Adds mocked Windows start script for tests.
cli/src/test/resources/ide-projects/sonar/repository/sonar/sonar/default/bin/windows-x86-64/SonarService.bat Adds mocked Windows service script for tests.
cli/src/test/resources/ide-projects/sonar/repository/sonar/sonar/default/bin/linux-x86-64/sonar.sh Adds mocked Linux script for tests.
cli/src/test/resources/ide-projects/sonar/repository/sonar/sonar/default/bin/macosx-universal-64/sonar.sh Adds mocked macOS script for tests.
cli/src/test/resources/ide-projects/sonar/repository/sonar/sonar/default/.ide.software.version Adds pinned sonar version file for the fixture.
cli/src/test/resources/ide-projects/sonar/project/settings/ide.properties Adds SONAR_VERSION setting for fixture project.
cli/src/test/resources/ide-projects/sonar/_ide/urls/sonar/sonar/26.3.0.120487/urls Adds mocked download URL for ToolRepositoryMock usage.
CHANGELOG.adoc Adds release note entry for #1731.

Copy link
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.

@tmukh thanks for finding the bug, creating the issue, creating PR, fixing the NPE and especially adding the missing JUnit test. 👍This is really great work and surprised me since you just on-boarded to our team 🚀

I did my usual picky review and left you various constructive review comments.
Please note that if you auto-apply them (e.g. in batch) there will be some import statements missing in the SonarTest causing compile errors. You can still do that and pull the result, add the imports and commit + push, or do not accept the suggestions adding @ParameterizedTest and address them manually.
FYI: The SonarTest will still not run the run() method of the commandlet what is typically the most valuable thing to test. If you ever consider to add this in this PR or later after merge, please consider that *.bat files cannot be executed on OS other than windows. You could fake them by technically putting a bash script into such .bat file what is a little hack but could do the trick. Otherwise you would need to run that test method only for the current OS.

@hohwille hohwille self-assigned this Mar 10, 2026
@hohwille hohwille moved this from 🆕 New to 👀 In review in IDEasy board Mar 10, 2026
@hohwille hohwille added this to the release:2026.03.001 milestone Mar 10, 2026
@tmukh
Copy link
Contributor Author

tmukh commented Mar 11, 2026

Thanks for the comments @hohwille , I implemented the changes and hope that it's up to what you wanted.

Side note: I ended up rebasing on my old local main branch, and had to figure out for 30 minutes hwo to undo a rebase.
This comic accurately describes how git sometimes makes me feel:

image

Copy link
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.

@tmukh thanks for your excellent rework. All perfect now and ready for merge 👍

@hohwille hohwille merged commit a965db6 into devonfw:main Mar 12, 2026
4 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in IDEasy board Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Sonar Installation leads to NPE

5 participants