diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 12ed4f6de..7e349003b 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -6,6 +6,7 @@ This file documents all notable changes to https://github.com/devonfw/IDEasy[IDE Release with new features and bugfixes: +* https://github.com/devonfw/IDEasy/issues/898[#898]: Improved feedback messages The full list of changes for this release can be found in https://github.com/devonfw/IDEasy/milestone/18?closed=1[milestone 2025.01.001]. diff --git a/cli/src/main/java/com/devonfw/tools/ide/commandlet/AbstractVersionOrEditionGetCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/commandlet/AbstractVersionOrEditionGetCommandlet.java new file mode 100644 index 000000000..5efed8c7a --- /dev/null +++ b/cli/src/main/java/com/devonfw/tools/ide/commandlet/AbstractVersionOrEditionGetCommandlet.java @@ -0,0 +1,119 @@ +package com.devonfw.tools.ide.commandlet; + +import java.util.Objects; + +import com.devonfw.tools.ide.context.IdeContext; +import com.devonfw.tools.ide.log.IdeLogLevel; +import com.devonfw.tools.ide.log.IdeSubLogger; +import com.devonfw.tools.ide.property.FlagProperty; +import com.devonfw.tools.ide.property.ToolProperty; +import com.devonfw.tools.ide.tool.ToolCommandlet; + +/** + * An internal {@link Commandlet} to get the installed version for a tool. + * + * @see ToolCommandlet#getInstalledVersion() + */ +public abstract class AbstractVersionOrEditionGetCommandlet extends Commandlet { + + /** The tool to get the version of. */ + public final ToolProperty tool; + + /** Flag to get the configured version. */ + public final FlagProperty configured; + + /** Flag to get the installed version. */ + public final FlagProperty installed; + + /** + * The constructor. + * + * @param context the {@link IdeContext}. + */ + public AbstractVersionOrEditionGetCommandlet(IdeContext context) { + + super(context); + addKeyword(getName()); + this.tool = add(new ToolProperty("", true, "tool")); + this.configured = add(new FlagProperty("--configured")); + this.installed = add(new FlagProperty("--installed")); + } + + @Override + public boolean isProcessableOutput() { + + return true; + } + + /** + * @return the property to get (e.g. "version" or "edition"). + */ + protected abstract String getPropertyToGet(); + + /** + * @param commandlet the {@link ToolCommandlet} to get the value from. + * @return the configured value. + * @see ToolCommandlet#getConfiguredVersion() + * @see ToolCommandlet#getConfiguredEdition() + */ + protected abstract Object getConfiguredValue(ToolCommandlet commandlet); + + /** + * @param commandlet the {@link ToolCommandlet} to get the value from. + * @return the installed value or {@code null} if the tool is not installed. + * @see ToolCommandlet#getInstalledVersion() + * @see ToolCommandlet#getInstalledEdition() + */ + protected abstract Object getInstalledValue(ToolCommandlet commandlet); + + @Override + public void run() { + + ToolCommandlet commandlet = this.tool.getValue(); + IdeSubLogger logger = this.context.level(IdeLogLevel.PROCESSABLE); + Object configuredValue = getConfiguredValue(commandlet); + Object installedValue = getInstalledValue(commandlet); + boolean getInstalledValue = this.installed.isTrue(); + boolean getConfiguredValue = this.configured.isTrue(); + if (getInstalledValue == getConfiguredValue) { + if (getInstalledValue) { // both --configured and --installed + logToolInfo(logger, commandlet, configuredValue, installedValue); + } else if (this.context.debug().isEnabled()) { + logToolInfo(logger, commandlet, configuredValue, installedValue); + } else { + if (installedValue == null) { + logger.log(configuredValue.toString()); + } else { + logger.log(installedValue.toString()); + } + } + } else { + if (getInstalledValue) { + if (installedValue == null) { + logToolInfo(logger, commandlet, configuredValue, null); + } else { + logger.log(installedValue.toString()); + } + } else { + logger.log(configuredValue.toString()); + } + } + } + + private void logToolInfo(IdeSubLogger logger, ToolCommandlet commandlet, Object configuredValue, Object installedValue) { + + String property = getPropertyToGet(); + String toolName = commandlet.getName(); + if (installedValue == null) { + logger.log("No installation of tool {} was found.", toolName); + } else { + logger.log("The installed {} for tool {} is {}", property, toolName, installedValue); + } + logger.log("The configured {} for tool {} is {}", property, toolName, configuredValue); + if (!Objects.equals(configuredValue, installedValue)) { + logger.log("To install that {} call the following command:", property); + logger.log("ide install {}", toolName); + } + } + +} diff --git a/cli/src/main/java/com/devonfw/tools/ide/commandlet/EditionGetCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/commandlet/EditionGetCommandlet.java index 52ae151a5..981e6f662 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/commandlet/EditionGetCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/commandlet/EditionGetCommandlet.java @@ -1,10 +1,6 @@ package com.devonfw.tools.ide.commandlet; import com.devonfw.tools.ide.context.IdeContext; -import com.devonfw.tools.ide.log.IdeLogLevel; -import com.devonfw.tools.ide.log.IdeSubLogger; -import com.devonfw.tools.ide.property.FlagProperty; -import com.devonfw.tools.ide.property.ToolProperty; import com.devonfw.tools.ide.tool.ToolCommandlet; /** @@ -12,16 +8,7 @@ * * @see ToolCommandlet#getInstalledEdition() */ -public class EditionGetCommandlet extends Commandlet { - - /** The tool to get the edition of. */ - public final ToolProperty tool; - - /** Flag to get the configured version. */ - public final FlagProperty configured; - - /** Flag to get the installed version. */ - public final FlagProperty installed; +public class EditionGetCommandlet extends AbstractVersionOrEditionGetCommandlet { /** * The constructor. @@ -31,10 +18,6 @@ public class EditionGetCommandlet extends Commandlet { public EditionGetCommandlet(IdeContext context) { super(context); - addKeyword(getName()); - this.tool = add(new ToolProperty("", true, "tool")); - this.configured = add(new FlagProperty("--configured")); - this.installed = add(new FlagProperty("--installed")); } @Override @@ -44,47 +27,20 @@ public String getName() { } @Override - public boolean isProcessableOutput() { + protected String getPropertyToGet() { - return true; + return "edition"; } @Override - public void run() { + protected Object getConfiguredValue(ToolCommandlet commandlet) { - ToolCommandlet commandlet = this.tool.getValue(); - String configuredEdition = commandlet.getConfiguredEdition(); - IdeSubLogger logger = this.context.level(IdeLogLevel.PROCESSABLE); - - if (this.installed.isTrue() && !this.configured.isTrue()) { // get installed edition - String installedEdition = commandlet.getInstalledEdition(); - if (commandlet.getInstalledVersion() == null) { - // note: getInstalledEdition() will fallback to configured edition and not return null, therefore we use getInstalledVersion() - toolInstallInfo(commandlet.getName(), configuredEdition, null, commandlet); - } else { - logger.log(installedEdition); - } - } else if (!this.installed.isTrue() && this.configured.isTrue()) { // get configured edition - logger.log(configuredEdition); - } else { // get both configured and installed edition - String installedEdition = commandlet.getInstalledEdition(); - if (configuredEdition.equals(installedEdition)) { - logger.log(installedEdition); - } else { - toolInstallInfo(commandlet.getName(), configuredEdition, installedEdition, commandlet); - } - } + return commandlet.getConfiguredEdition(); } - private void toolInstallInfo(String toolName, String configuredEdition, String installedEdition, ToolCommandlet commandlet) { + @Override + protected Object getInstalledValue(ToolCommandlet commandlet) { - if (installedEdition == null) { - this.context.warning("No installation of tool {} was found.", commandlet.getName()); - } else { - this.context.info("The installed edition for tool {} is {}", commandlet.getName(), installedEdition); - } - this.context.info("The configured edition for tool {} is {}", toolName, configuredEdition); - this.context.info("To install that edition call the following command:"); - this.context.info("ide install {}", toolName); + return commandlet.getInstalledEdition(); } } diff --git a/cli/src/main/java/com/devonfw/tools/ide/commandlet/UninstallCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/commandlet/UninstallCommandlet.java index 3b9a44cf3..c5fc77c0d 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/commandlet/UninstallCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/commandlet/UninstallCommandlet.java @@ -35,8 +35,11 @@ public void run() { for (int i = 0; i < this.tools.getValueCount(); i++) { ToolCommandlet toolCommandlet = this.tools.getValue(i); - - toolCommandlet.uninstall(); + if (toolCommandlet.getInstalledVersion() != null) { + toolCommandlet.uninstall(); + } else { + this.context.warning("Couldn't uninstall " + toolCommandlet.getName() + " because we could not find an installation"); + } } } diff --git a/cli/src/main/java/com/devonfw/tools/ide/commandlet/UninstallPluginCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/commandlet/UninstallPluginCommandlet.java index ba5b73eca..54055c87f 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/commandlet/UninstallPluginCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/commandlet/UninstallPluginCommandlet.java @@ -44,7 +44,11 @@ public void run() { String plugin = this.plugin.getValue(); if (commandlet instanceof PluginBasedCommandlet cmd) { - cmd.uninstallPlugin(cmd.getPlugin(plugin)); + if (cmd.uninstallPlugin(cmd.getPlugin(plugin)) == 0) { + context.info("Successfully uninstalled plugin " + plugin); + } else { + context.error("Could not uninstall plugin " + plugin + " because we could not find an installation"); + } } else { context.warning("Tool {} does not support plugins.", tool.getName()); } diff --git a/cli/src/main/java/com/devonfw/tools/ide/commandlet/VersionGetCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/commandlet/VersionGetCommandlet.java index 74b76ef67..8b9ddeea4 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/commandlet/VersionGetCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/commandlet/VersionGetCommandlet.java @@ -1,28 +1,14 @@ package com.devonfw.tools.ide.commandlet; import com.devonfw.tools.ide.context.IdeContext; -import com.devonfw.tools.ide.log.IdeLogLevel; -import com.devonfw.tools.ide.log.IdeSubLogger; -import com.devonfw.tools.ide.property.FlagProperty; -import com.devonfw.tools.ide.property.ToolProperty; import com.devonfw.tools.ide.tool.ToolCommandlet; -import com.devonfw.tools.ide.version.VersionIdentifier; /** * An internal {@link Commandlet} to get the installed version for a tool. * * @see ToolCommandlet#getInstalledVersion() */ -public class VersionGetCommandlet extends Commandlet { - - /** The tool to get the version of. */ - public final ToolProperty tool; - - /** Flag to get the configured version. */ - public final FlagProperty configured; - - /** Flag to get the installed version. */ - public final FlagProperty installed; +public class VersionGetCommandlet extends AbstractVersionOrEditionGetCommandlet { /** * The constructor. @@ -32,10 +18,6 @@ public class VersionGetCommandlet extends Commandlet { public VersionGetCommandlet(IdeContext context) { super(context); - addKeyword(getName()); - this.tool = add(new ToolProperty("", true, "tool")); - this.configured = add(new FlagProperty("--configured")); - this.installed = add(new FlagProperty("--installed")); } @Override @@ -45,47 +27,20 @@ public String getName() { } @Override - public boolean isProcessableOutput() { + protected String getPropertyToGet() { - return true; + return "version"; } @Override - public void run() { + protected Object getConfiguredValue(ToolCommandlet commandlet) { - ToolCommandlet commandlet = this.tool.getValue(); - VersionIdentifier configuredVersion = commandlet.getConfiguredVersion(); - IdeSubLogger logger = this.context.level(IdeLogLevel.PROCESSABLE); - if (this.installed.isTrue() && !this.configured.isTrue()) {// get installed version - VersionIdentifier installedVersion = commandlet.getInstalledVersion(); - if (installedVersion == null) { - toolInstallInfo(commandlet.getName(), configuredVersion, null, commandlet); - } else { - logger.log(installedVersion.toString()); - } - } else if (!this.installed.isTrue() && this.configured.isTrue()) {// get configured version - logger.log(configuredVersion.toString()); - } else { // get both configured and installed version - VersionIdentifier installedVersion = commandlet.getInstalledVersion(); - if (configuredVersion.matches(installedVersion)) { - logger.log(installedVersion.toString()); - } else { - toolInstallInfo(commandlet.getName(), configuredVersion, installedVersion, commandlet); - } - } + return commandlet.getConfiguredVersion(); } - private void toolInstallInfo(String toolName, VersionIdentifier configuredVersion, VersionIdentifier installedVersion, ToolCommandlet commandlet) { - - if (installedVersion == null) { - this.context.info("No installation of tool {} was found.", commandlet.getName()); - } else { - this.context.info("The installed version for tool {} is {}", commandlet.getName(), installedVersion); - } - this.context.info("The configured version for tool {} is {}", toolName, configuredVersion); - this.context.info("To install that version call the following command:"); - this.context.info("ide install {}", toolName); + @Override + protected Object getInstalledValue(ToolCommandlet commandlet) { + return commandlet.getInstalledVersion(); } - } diff --git a/cli/src/main/java/com/devonfw/tools/ide/io/FileAccess.java b/cli/src/main/java/com/devonfw/tools/ide/io/FileAccess.java index d3f46e900..5568bbebd 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/io/FileAccess.java +++ b/cli/src/main/java/com/devonfw/tools/ide/io/FileAccess.java @@ -271,4 +271,12 @@ default void extract(Path archiveFile, Path targetDir, Consumer postExtrac * @param filePath the {@link Path} to the file or folder. */ void touch(Path filePath); + + /** + * @param file the {@link Path} to the file to read. + * @return the content of the specified file (in UTF-8 encoding). + * @see java.nio.file.Files#readString(Path) + */ + String readFileContent(Path file); + } diff --git a/cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java b/cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java index 87a3896f3..be18c6fb5 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java +++ b/cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java @@ -952,4 +952,17 @@ public void touch(Path filePath) { } } } + + @Override + public String readFileContent(Path file) { + + this.context.trace("Reading content of file from {}", file); + try { + String content = Files.readString(file); + this.context.trace("Read content of file {} as {}", file, content); + return content; + } catch (IOException e) { + throw new IllegalStateException("Failed to read file " + file, e); + } + } } diff --git a/cli/src/main/java/com/devonfw/tools/ide/os/MacOsHelper.java b/cli/src/main/java/com/devonfw/tools/ide/os/MacOsHelper.java index 2f2b9b2ea..7f210b590 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/os/MacOsHelper.java +++ b/cli/src/main/java/com/devonfw/tools/ide/os/MacOsHelper.java @@ -94,7 +94,7 @@ public Path findLinkDir(Path rootDir, String tool) { */ public Path findRootToolPath(ToolCommandlet commandlet, IdeContext context) { return context.getSoftwareRepositoryPath().resolve(ToolRepository.ID_DEFAULT).resolve(commandlet.getName()) - .resolve(commandlet.getInstalledEdition().toString()) + .resolve(commandlet.getInstalledEdition()) .resolve(commandlet.getInstalledVersion().toString()); } diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/LocalToolCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/LocalToolCommandlet.java index 53f04d5c0..0f0c8dba5 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/LocalToolCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/LocalToolCommandlet.java @@ -312,20 +312,14 @@ protected VersionIdentifier getInstalledVersion(Path toolPath) { return null; } } - this.context.trace("Reading tool version from {}", toolVersionFile); - try { - String version = Files.readString(toolVersionFile).trim(); - this.context.trace("Read tool version {} from {}", version, toolVersionFile); - return VersionIdentifier.of(version); - } catch (IOException e) { - throw new IllegalStateException("Failed to read file " + toolVersionFile, e); - } + String version = this.context.getFileAccess().readFileContent(toolVersionFile).trim(); + return VersionIdentifier.of(version); } @Override public String getInstalledEdition() { - return getInstalledEdition(this.context.getSoftwarePath().resolve(getName())); + return getInstalledEdition(this.context.getSoftwarePath().resolve(this.tool)); } /** @@ -333,25 +327,43 @@ public String getInstalledEdition() { * to the passed {@link Path path} must be the name of the edition. * @return the installed edition of this tool or {@code null} if not installed. */ - public String getInstalledEdition(Path toolPath) { + private String getInstalledEdition(Path toolPath) { if (!Files.isDirectory(toolPath)) { - this.context.debug("Tool {} not installed in {}", getName(), toolPath); + this.context.debug("Tool {} not installed in {}", this.tool, toolPath); return null; } - try { - String edition = toolPath.toRealPath().getParent().getFileName().toString(); - if (!this.context.getUrls().getSortedEditions(getName()).contains(edition)) { - edition = getConfiguredEdition(); + Path realPath = this.context.getFileAccess().toRealPath(toolPath); + // if the realPath changed, a link has been resolved + if (realPath.equals(toolPath)) { + if (!isIgnoreSoftwareRepo()) { + this.context.warning("Tool {} is not installed via software repository (maybe from devonfw-ide). Please consider reinstalling it.", this.tool); } - return edition; - } catch (IOException e) { - throw new IllegalStateException( - "Couldn't determine the edition of " + getName() + " from the directory structure of its software path " - + toolPath - + ", assuming the name of the parent directory of the real path of the software path to be the edition " - + "of the tool.", e); + // I do not see any reliable way how we could determine the edition of a tool that does not use software repo or that was installed by devonfw-ide + return getConfiguredEdition(); + } + Path toolRepoFolder = context.getSoftwareRepositoryPath().resolve(ToolRepository.ID_DEFAULT).resolve(this.tool); + String edition = getEdition(toolRepoFolder, realPath); + if (!this.context.getUrls().getSortedEditions(this.tool).contains(edition)) { + this.context.warning("Undefined edition {} of tool {}", edition, this.tool); + } + return edition; + } + + private String getEdition(Path toolRepoFolder, Path toolInstallFolder) { + + int toolRepoNameCount = toolRepoFolder.getNameCount(); + int toolInstallNameCount = toolInstallFolder.getNameCount(); + if (toolRepoNameCount < toolInstallNameCount) { + // ensure toolInstallFolder starts with $IDE_ROOT/_ide/software/default/«tool» + for (int i = 0; i < toolRepoNameCount; i++) { + if (!toolRepoFolder.getName(i).toString().equals(toolInstallFolder.getName(i).toString())) { + return null; + } + } + return toolInstallFolder.getName(toolRepoNameCount).toString(); } + return null; } @Override diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/ToolCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/ToolCommandlet.java index a20bc0eb9..a2aef5d61 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/ToolCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/ToolCommandlet.java @@ -67,7 +67,7 @@ protected void initProperties() { * @return the name of the tool (e.g. "java", "mvn", "npm", "node"). */ @Override - public String getName() { + public final String getName() { return this.tool; } diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/plugin/PluginBasedCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/plugin/PluginBasedCommandlet.java index f91ced525..a81e89dd3 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/plugin/PluginBasedCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/plugin/PluginBasedCommandlet.java @@ -131,23 +131,25 @@ protected void installPlugins(Collection plugins) { /** * @param plugin the {@link ToolPluginDescriptor} to uninstall. + * @return 0 if the uninstallation was successfull and 1 if it failed */ - public void uninstallPlugin(ToolPluginDescriptor plugin) { + public int uninstallPlugin(ToolPluginDescriptor plugin) { Path pluginsPath = getPluginsInstallationPath(); if (!Files.isDirectory(pluginsPath)) { this.context.debug("Omitting to uninstall plugin {} ({}) as plugins folder does not exist at {}", plugin.name(), plugin.id(), pluginsPath); - return; + return 1; } FileAccess fileAccess = this.context.getFileAccess(); Path match = fileAccess.findFirst(pluginsPath, p -> p.getFileName().toString().startsWith(plugin.id()), false); if (match == null) { this.context.debug("Omitting to uninstall plugin {} ({}) as plugins folder does not contain a match at {}", plugin.name(), plugin.id(), pluginsPath); - return; + return 1; } fileAccess.delete(match); + return 0; } /** diff --git a/cli/src/test/java/com/devonfw/tools/ide/commandlet/EditionGetCommandletTest.java b/cli/src/test/java/com/devonfw/tools/ide/commandlet/EditionGetCommandletTest.java index bb0c3d53a..c84e95e9d 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/commandlet/EditionGetCommandletTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/commandlet/EditionGetCommandletTest.java @@ -72,10 +72,7 @@ public void testEditionGetCommandletToolNotInstalled() { editionGet.tool.setValueAsString("az", context); editionGet.run(); // assert - assertThat(context).log().hasEntries(IdeLogEntry.ofWarning("No installation of tool az was found."), - IdeLogEntry.ofInfo("The configured edition for tool az is az"), - IdeLogEntry.ofInfo("To install that edition call the following command:"), - IdeLogEntry.ofInfo("ide install az")); + assertThat(context).logAtProcessable().hasMessage("az"); } /** Test of {@link EditionGetCommandlet} run, with --installed flag, when Installed Version is null. */ @@ -90,10 +87,10 @@ public void testEditionGetCommandletInstalledEditionToolNotInstalled() { // act editionGet.run(); // assert - assertThat(context).log().hasEntries(IdeLogEntry.ofWarning("No installation of tool java was found."), - IdeLogEntry.ofInfo("The configured edition for tool java is java"), - IdeLogEntry.ofInfo("To install that edition call the following command:"), - IdeLogEntry.ofInfo("ide install java")); + assertThat(context).log().hasEntries(IdeLogEntry.ofProcessable("No installation of tool java was found."), + IdeLogEntry.ofProcessable("The configured edition for tool java is java"), + IdeLogEntry.ofProcessable("To install that edition call the following command:"), + IdeLogEntry.ofProcessable("ide install java")); } diff --git a/cli/src/test/java/com/devonfw/tools/ide/commandlet/UninstallCommandletTest.java b/cli/src/test/java/com/devonfw/tools/ide/commandlet/UninstallCommandletTest.java index 32cc3c091..ac4db997d 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/commandlet/UninstallCommandletTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/commandlet/UninstallCommandletTest.java @@ -48,7 +48,7 @@ public void testUninstallCommandletRun_WithExistingCommandlet() { uninstallCommandlet.run(); // assert assertThat(context).log().hasEntries(IdeLogEntry.ofSuccess("Successfully uninstalled " + npm), - IdeLogEntry.ofWarning("An installed version of " + dotnet + " does not exist")); + IdeLogEntry.ofWarning("Couldn't uninstall " + dotnet + " because we could not find an installation")); assertThat(context.getSoftwarePath().resolve(npm)).doesNotExist(); } @@ -65,7 +65,7 @@ public void testUninstallCommandletRun_WithNonExistingCommandlet() { // act uninstallCommandlet.run(); // assert - assertThat(context).logAtWarning().hasMessage("An installed version of " + eclipse + " does not exist"); + assertThat(context).logAtWarning().hasMessage("Couldn't uninstall " + eclipse + " because we could not find an installation"); assertThat(Files.notExists(context.getSoftwarePath().resolve(eclipse))); } diff --git a/cli/src/test/java/com/devonfw/tools/ide/commandlet/VersionGetCommandletTest.java b/cli/src/test/java/com/devonfw/tools/ide/commandlet/VersionGetCommandletTest.java index c09c09c1f..2129264e3 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/commandlet/VersionGetCommandletTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/commandlet/VersionGetCommandletTest.java @@ -26,10 +26,7 @@ public void testVersionGetCommandletNotInstalledRun() { // act versionGet.run(); // assert - assertThat(context).logAtInfo().hasEntries("No installation of tool java was found.", - "The configured version for tool java is 17*", - "To install that version call the following command:", - "ide install java"); + assertThat(context).logAtProcessable().hasMessage("17*"); } @Test @@ -43,7 +40,7 @@ public void testVersionGetCommandletNotInstalledRunInstalledFlag() { // act versionGet.run(); // assert - assertThat(context).logAtInfo().hasEntries("No installation of tool java was found.", + assertThat(context).logAtProcessable().hasEntries("No installation of tool java was found.", "The configured version for tool java is 17*", "To install that version call the following command:", "ide install java"); @@ -130,10 +127,7 @@ public void testVersionGetCommandletNeitherInstalledNorConfigured() { versionGet.tool.setValueAsString("java", context); versionGet.run(); // assert - assertThat(context).logAtInfo().hasEntries("No installation of tool java was found.", - "The configured version for tool java is *", - "To install that version call the following command:", - "ide install java"); + assertThat(context).logAtProcessable().hasMessage("*"); } } diff --git a/cli/src/test/java/com/devonfw/tools/ide/context/IdeTestContextAssertion.java b/cli/src/test/java/com/devonfw/tools/ide/context/IdeTestContextAssertion.java index af4457f5e..70761b643 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/context/IdeTestContextAssertion.java +++ b/cli/src/test/java/com/devonfw/tools/ide/context/IdeTestContextAssertion.java @@ -71,4 +71,8 @@ public IdeTestLoggerAssertion logAtError() { return log(IdeLogLevel.ERROR); } + public IdeTestLoggerAssertion logAtProcessable() { + return log(IdeLogLevel.PROCESSABLE); + } + } diff --git a/cli/src/test/resources/ide-projects/basic/project/software/npm/.ide.software.version b/cli/src/test/resources/ide-projects/basic/project/software/npm/.ide.software.version new file mode 100644 index 000000000..275283a18 --- /dev/null +++ b/cli/src/test/resources/ide-projects/basic/project/software/npm/.ide.software.version @@ -0,0 +1 @@ +11.0.0