From 52daa7853deb3f4d840b35ea1532231a9960f27b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Hohwiller?= Date: Sat, 6 Jul 2024 13:10:59 +0200 Subject: [PATCH] #451: fixed EditionSetCommandletTest --- .../tools/ide/tool/LocalToolCommandlet.java | 3 ++- .../devonfw/tools/ide/tool/ToolCommandlet.java | 1 + .../ide/commandlet/EditionSetCommandletTest.java | 15 +++++++-------- .../_ide/urls/docker/docker/latest/mac_arm64.urls | 1 + .../_ide/urls/docker/docker/latest/mac_x64.urls | 1 + .../urls/docker/docker/latest/windows_x64.urls | 1 + .../urls/docker/rancher/1.14.2/linux_x64.urls | 1 + .../docker/rancher/1.14.2/linux_x64.urls.sha256 | 1 + .../urls/docker/rancher/1.14.2/mac_arm64.urls | 1 + .../docker/rancher/1.14.2/mac_arm64.urls.sha256 | 1 + .../_ide/urls/docker/rancher/1.14.2/mac_x64.urls | 1 + .../docker/rancher/1.14.2/mac_x64.urls.sha256 | 1 + .../urls/docker/rancher/1.14.2/windows_x64.urls | 1 + .../docker/rancher/1.14.2/windows_x64.urls.sha256 | 1 + 14 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 cli/src/test/resources/ide-projects/basic/_ide/urls/docker/docker/latest/mac_arm64.urls create mode 100644 cli/src/test/resources/ide-projects/basic/_ide/urls/docker/docker/latest/mac_x64.urls create mode 100644 cli/src/test/resources/ide-projects/basic/_ide/urls/docker/docker/latest/windows_x64.urls create mode 100644 cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/linux_x64.urls create mode 100644 cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/linux_x64.urls.sha256 create mode 100644 cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/mac_arm64.urls create mode 100644 cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/mac_arm64.urls.sha256 create mode 100644 cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/mac_x64.urls create mode 100644 cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/mac_x64.urls.sha256 create mode 100644 cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/windows_x64.urls create mode 100644 cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/windows_x64.urls.sha256 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 417c70384..11ab36236 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 @@ -1,6 +1,7 @@ package com.devonfw.tools.ide.tool; import com.devonfw.tools.ide.common.Tag; +import com.devonfw.tools.ide.context.AbstractIdeContext; import com.devonfw.tools.ide.context.IdeContext; import com.devonfw.tools.ide.io.FileAccess; import com.devonfw.tools.ide.io.FileCopyMode; @@ -291,7 +292,7 @@ private ToolInstallation createToolInstallation(Path rootDir, VersionIdentifier if (newInstallation && (linkDir != rootDir)) { assert (!linkDir.equals(rootDir)); this.context.getFileAccess().copy(toolVersionFile, linkDir, FileCopyMode.COPY_FILE_OVERRIDE); - if (this.context.getSystemInfo().isMac()) { + if (this.context.getSystemInfo().isMac() && !((AbstractIdeContext) this.context).isTest()) { Path macApp = findMacApp(linkDir); if (macApp != null) { ProcessContext pc = this.context.newProcess(); 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 da8aa64b0..79585c88f 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 @@ -12,6 +12,7 @@ import com.devonfw.tools.ide.process.ProcessErrorHandling; import com.devonfw.tools.ide.process.ProcessMode; import com.devonfw.tools.ide.property.StringProperty; +import com.devonfw.tools.ide.url.model.folder.UrlEdition; import com.devonfw.tools.ide.version.VersionIdentifier; import java.nio.file.Files; diff --git a/cli/src/test/java/com/devonfw/tools/ide/commandlet/EditionSetCommandletTest.java b/cli/src/test/java/com/devonfw/tools/ide/commandlet/EditionSetCommandletTest.java index 15f51e614..5686a6719 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/commandlet/EditionSetCommandletTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/commandlet/EditionSetCommandletTest.java @@ -1,13 +1,11 @@ package com.devonfw.tools.ide.commandlet; import com.devonfw.tools.ide.context.AbstractIdeContextTest; -import com.devonfw.tools.ide.context.IdeContext; import com.devonfw.tools.ide.context.IdeTestContext; import com.devonfw.tools.ide.log.IdeLogLevel; import org.junit.jupiter.api.Test; import java.nio.file.Path; -import java.util.List; /** Integration test of {@link EditionSetCommandlet}. */ public class EditionSetCommandletTest extends AbstractIdeContextTest { @@ -17,17 +15,18 @@ public class EditionSetCommandletTest extends AbstractIdeContextTest { public void testEditionSetCommandletRun() { // arrange - IdeContext context = newContext(PROJECT_BASIC); + IdeTestContext context = newContext(PROJECT_BASIC); EditionSetCommandlet editionSet = context.getCommandletManager().getCommandlet(EditionSetCommandlet.class); - editionSet.tool.setValueAsString("mvn", context); - editionSet.edition.setValueAsString("setEdition", context); + editionSet.tool.setValueAsString("docker", context); + editionSet.edition.setValueAsString("rancher", context); + assertThat(context.getVariables().getToolEdition("docker")).isEqualTo("docker"); // act editionSet.run(); // assert - List logs = ((IdeTestContext) context).level(IdeLogLevel.WARNING).getMessages(); - assertThat(logs).containsExactly("Edition setEdition seems to be invalid"); + assertThat(context.getVariables().getToolEdition("docker")).isEqualTo("rancher"); + assertLogMessage(context, IdeLogLevel.INFO, "DOCKER_EDITION=rancher has been set in SETTINGS@", true); Path settingsIdeProperties = context.getSettingsPath().resolve("ide.properties"); assertThat(settingsIdeProperties).hasContent(""" #******************************************************************************** @@ -52,6 +51,6 @@ public void testEditionSetCommandletRun() { TEST_ARGS9=settings9 TEST_ARGSb=${TEST_ARGS10} settingsb ${TEST_ARGSa} ${TEST_ARGSb} TEST_ARGSc=${TEST_ARGSc} settingsc - MVN_EDITION=setEdition"""); + DOCKER_EDITION=rancher"""); } } \ No newline at end of file diff --git a/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/docker/latest/mac_arm64.urls b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/docker/latest/mac_arm64.urls new file mode 100644 index 000000000..f67fd2cb5 --- /dev/null +++ b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/docker/latest/mac_arm64.urls @@ -0,0 +1 @@ +https://desktop.docker.com/mac/main/arm64/Docker.dmg diff --git a/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/docker/latest/mac_x64.urls b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/docker/latest/mac_x64.urls new file mode 100644 index 000000000..ddc76f03e --- /dev/null +++ b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/docker/latest/mac_x64.urls @@ -0,0 +1 @@ +https://desktop.docker.com/mac/main/amd64/Docker.dmg diff --git a/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/docker/latest/windows_x64.urls b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/docker/latest/windows_x64.urls new file mode 100644 index 000000000..a91514e91 --- /dev/null +++ b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/docker/latest/windows_x64.urls @@ -0,0 +1 @@ +https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe diff --git a/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/linux_x64.urls b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/linux_x64.urls new file mode 100644 index 000000000..3745edf9c --- /dev/null +++ b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/linux_x64.urls @@ -0,0 +1 @@ +https://github.com/rancher-sandbox/rancher-desktop/releases/download/v1.14.2/rancher-desktop-linux-v1.14.2.zip diff --git a/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/linux_x64.urls.sha256 b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/linux_x64.urls.sha256 new file mode 100644 index 000000000..8410df2f8 --- /dev/null +++ b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/linux_x64.urls.sha256 @@ -0,0 +1 @@ +2d304d3fe0dbf5efe987c2d583feeb607ce9ef507753fcf0a6b1a6b9b2128d1e diff --git a/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/mac_arm64.urls b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/mac_arm64.urls new file mode 100644 index 000000000..e3511f683 --- /dev/null +++ b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/mac_arm64.urls @@ -0,0 +1 @@ +https://github.com/rancher-sandbox/rancher-desktop/releases/download/v1.14.2/Rancher.Desktop-1.14.2-mac.aarch64.zip diff --git a/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/mac_arm64.urls.sha256 b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/mac_arm64.urls.sha256 new file mode 100644 index 000000000..92ed70df7 --- /dev/null +++ b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/mac_arm64.urls.sha256 @@ -0,0 +1 @@ +0ce7cf58fecbf4ea99541f51401f95ba70053b390b51ae98b16265d1a450a517 diff --git a/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/mac_x64.urls b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/mac_x64.urls new file mode 100644 index 000000000..e37045888 --- /dev/null +++ b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/mac_x64.urls @@ -0,0 +1 @@ +https://github.com/rancher-sandbox/rancher-desktop/releases/download/v1.14.2/Rancher.Desktop-1.14.2.x86_64.dmg diff --git a/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/mac_x64.urls.sha256 b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/mac_x64.urls.sha256 new file mode 100644 index 000000000..cf87a9ec6 --- /dev/null +++ b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/mac_x64.urls.sha256 @@ -0,0 +1 @@ +e764e335d1475f8bceb3fb6d1d1892b09d3c2bee3f34355ddab8a7e157c87452 diff --git a/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/windows_x64.urls b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/windows_x64.urls new file mode 100644 index 000000000..cf9728f8a --- /dev/null +++ b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/windows_x64.urls @@ -0,0 +1 @@ +https://github.com/rancher-sandbox/rancher-desktop/releases/download/v1.14.2/Rancher.Desktop.Setup.1.14.2.msi diff --git a/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/windows_x64.urls.sha256 b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/windows_x64.urls.sha256 new file mode 100644 index 000000000..f22248aa2 --- /dev/null +++ b/cli/src/test/resources/ide-projects/basic/_ide/urls/docker/rancher/1.14.2/windows_x64.urls.sha256 @@ -0,0 +1 @@ +01f52b7a1ebcddeda01b6979ce3505b895fdcde2c5b57f18e4f8c4a593618f3f