Skip to content

Commit

Permalink
devonfw#517: Fix get version throws exception when run on not-install…
Browse files Browse the repository at this point in the history
…ed tool with installed flag (devonfw#518)
  • Loading branch information
slskiba authored Aug 6, 2024
1 parent 1ef551c commit 86e258c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ public void run() {
if (installedVersion == null) {
this.context.info("No installation of tool {} was found.", commandlet.getName());
toolInstallInfo(commandlet.getName(), configuredVersion);
} else {
this.context.info(installedVersion.toString());
}
this.context.info(installedVersion.toString());

} else if (!this.installed.isTrue() && this.configured.isTrue()) {// get configured version

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class VersionGetCommandletTest extends AbstractIdeContextTest {
* Test of {@link VersionGetCommandlet} run, when Installed Version is null.
*/
@Test
public void testVersionGetCommandletRunThrowsCliException() {
public void testVersionGetCommandletNotInstalledRun() {

// arrange
IdeTestContext context = newContext(PROJECT_BASIC, null, false);
Expand All @@ -27,6 +27,23 @@ public void testVersionGetCommandletRunThrowsCliException() {
"To install that version call the following command:", "ide install java");
}

@Test
public void testVersionGetCommandletNotInstalledRunInstalledFlag() {

// arrange
IdeTestContext context = newContext(PROJECT_BASIC, null, false);
VersionGetCommandlet versionGet = context.getCommandletManager().getCommandlet(VersionGetCommandlet.class);
versionGet.tool.setValueAsString("java", context);
versionGet.installed.setValue(true);
// act
versionGet.run();
// assert
assertThat(context).logAtInfo().hasMessage("No installation of tool java was found.");
assertThat(context).logAtInfo().hasMessage("The configured version for tool java is 17*");
assertThat(context).logAtInfo().hasMessage("To install that version call the following command:");
assertThat(context).logAtInfo().hasMessage("ide install java");
}

/**
* Test of {@link VersionGetCommandlet} run.
*/
Expand Down

0 comments on commit 86e258c

Please sign in to comment.