Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#517 Fix get version throws exception when run on not-installed tool with installed flag #518

Merged
merged 3 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading