From e86add04aab923198fb5bce6ac93a4c05dfd8558 Mon Sep 17 00:00:00 2001 From: Mattes Mrzik Date: Mon, 11 Dec 2023 16:45:12 +0100 Subject: [PATCH 1/5] #139: fileaccess delete symlink fix (#134) --- .../main/java/com/devonfw/tools/ide/io/FileAccessImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 331f80bb0..e341ba43a 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 @@ -399,7 +399,9 @@ public void delete(Path path) { if (Files.isSymbolicLink(path)) { Files.delete(path); } - deleteRecursive(path); + else { + deleteRecursive(path); + } } catch (IOException e) { throw new IllegalStateException("Failed to delete " + path, e); } From d2d49204b60cb850c72ca2d887fd87c3092fa7eb Mon Sep 17 00:00:00 2001 From: Mattes Mrzik Date: Mon, 11 Dec 2023 17:16:39 +0100 Subject: [PATCH 2/5] #5: context question index bug fix (#133) --- .../java/com/devonfw/tools/ide/context/AbstractIdeContext.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java b/cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java index 941f7d025..8bda33623 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java +++ b/cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java @@ -667,8 +667,9 @@ public O question(String question, O... options) { assert (options.length >= 2); interaction(question); Map mapping = new HashMap<>(options.length); - int i = 1; + int i = 0; for (O option : options) { + i++; String key = "" + option; addMapping(mapping, key, option); String numericKey = Integer.toString(i); From a5f72022fbec06bc28fdefd9808780063c1e01ac Mon Sep 17 00:00:00 2001 From: moritzLanger <44358321+moritzLanger@users.noreply.github.com> Date: Tue, 12 Dec 2023 08:53:51 +0100 Subject: [PATCH 3/5] #127: Increase commandlet test coverage for EnvironmentCommandlet and ContextCommandlet (#144) --- .../ide/commandlet/ContextCommandletTest.java | 55 +++++++++++++++++++ .../commandlet/EnvironmentCommandletTest.java | 37 +++++++++++++ .../ide/commandlet/HelpCommandletTest.java | 2 +- 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 cli/src/test/java/com/devonfw/tools/ide/commandlet/ContextCommandletTest.java diff --git a/cli/src/test/java/com/devonfw/tools/ide/commandlet/ContextCommandletTest.java b/cli/src/test/java/com/devonfw/tools/ide/commandlet/ContextCommandletTest.java new file mode 100644 index 000000000..f1f02c21e --- /dev/null +++ b/cli/src/test/java/com/devonfw/tools/ide/commandlet/ContextCommandletTest.java @@ -0,0 +1,55 @@ +package com.devonfw.tools.ide.commandlet; + +import java.util.Locale; + +import org.junit.jupiter.api.Test; + +import com.devonfw.tools.ide.context.AbstractIdeContext; +import com.devonfw.tools.ide.context.AbstractIdeContextTest; +import com.devonfw.tools.ide.context.IdeContextConsole; + +public class ContextCommandletTest extends AbstractIdeContextTest { + + /** + * Test of {@link ContextCommandlet} has name context. + */ + @Test + public void testNameIsContext(){ + //arrange + ContextCommandlet cxt = new ContextCommandlet(); + //act & assert + assertThat(cxt.getName()).isEqualTo("context"); + } + + /** + * Test of {@link ContextCommandlet} does not require home. + */ + @Test + public void testThatHomeIsNotReqired() { + + // arrange + ContextCommandlet cxt = new ContextCommandlet(); + //act & assert + assertThat(cxt.isIdeHomeRequired()).isFalse(); + } + + /** + * Test of {@link ContextCommandlet} run. + */ + @Test + public void testRun() { + + // arrange + ContextCommandlet cxt = new ContextCommandlet(); + // act + cxt.run(); + // assert + assertThat(cxt.getIdeContext()).isInstanceOf(IdeContextConsole.class); + assertThat(cxt.getIdeContext().isForceMode()).isFalse(); + assertThat(cxt.getIdeContext().isBatchMode()).isFalse(); + assertThat(cxt.getIdeContext().isQuietMode()).isFalse(); + assertThat(cxt.getIdeContext().isOfflineMode()).isFalse(); + assertThat(cxt.getIdeContext().getLocale()).isEqualTo(Locale.getDefault()); + + } +} diff --git a/cli/src/test/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandletTest.java b/cli/src/test/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandletTest.java index 6defc9dfd..4d7a931ad 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandletTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandletTest.java @@ -1,10 +1,13 @@ package com.devonfw.tools.ide.commandlet; +import com.devonfw.tools.ide.context.IdeContext; import org.junit.jupiter.api.Test; import com.devonfw.tools.ide.context.AbstractIdeContextTest; +import com.devonfw.tools.ide.context.IdeTestContext; import com.devonfw.tools.ide.context.IdeTestContextMock; import com.devonfw.tools.ide.environment.VariableLine; +import com.devonfw.tools.ide.log.IdeLogLevel; /** * Test of {@link EnvironmentCommandlet}. @@ -64,4 +67,38 @@ public void testNormalizeWindowsLine() { assertThat(normalized.getName()).isEqualTo("MAGIC_PATH"); } + /** + * Test of {@link EnvironmentCommandlet} run. + */ + @Test + public void testRun() { + + // arrange + String path = "workspaces/foo-test/my-git-repo"; + IdeTestContext context = newContext("basic", path, false); + EnvironmentCommandlet env = context.getCommandletManager().getCommandlet(EnvironmentCommandlet.class); + // act + env.run(); + // assert + assertLogMessage(context, IdeLogLevel.INFO, "MVN_VERSION=3.9.*"); + assertLogMessage(context, IdeLogLevel.INFO, "SOME=some-${UNDEFINED}"); + assertLogMessage(context, IdeLogLevel.INFO, "BAR=bar-some-${UNDEFINED}"); + assertLogMessage(context, IdeLogLevel.INFO, "IDE_TOOLS=mvn,eclipse"); + assertLogMessage(context, IdeLogLevel.INFO, "ECLIPSE_VERSION=2023-03"); + assertLogMessage(context, IdeLogLevel.INFO, "FOO=foo-bar-some-${UNDEFINED}"); + assertLogMessage(context, IdeLogLevel.INFO, "JAVA_VERSION=17*"); + assertLogMessage(context, IdeLogLevel.INFO, "INTELLIJ_EDITION=ultimate"); + assertLogMessage(context, IdeLogLevel.INFO, "DOCKER_EDITION=docker"); + } + /** + * Test of {@link EnvironmentCommandlet} does not require home. + */ + @Test + public void testThatHomeIsNotReqired() { + + // arrange + EnvironmentCommandlet env = new EnvironmentCommandlet(IdeTestContextMock.get()); + // act & assert + assertThat(env.isIdeHomeRequired()).isFalse(); + } } diff --git a/cli/src/test/java/com/devonfw/tools/ide/commandlet/HelpCommandletTest.java b/cli/src/test/java/com/devonfw/tools/ide/commandlet/HelpCommandletTest.java index 30753d4f0..4d20eeb16 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/commandlet/HelpCommandletTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/commandlet/HelpCommandletTest.java @@ -24,7 +24,7 @@ public void testThatHomeIsNotReqired() { // act HelpCommandlet help = new HelpCommandlet(context); // assert - assertThat(help.isIdeHomeRequired()).isEqualTo(false); + assertThat(help.isIdeHomeRequired()).isFalse(); } /** From 4c46eb6f24a381613927096300e851bc8342788e Mon Sep 17 00:00:00 2001 From: moritzLanger <44358321+moritzLanger@users.noreply.github.com> Date: Fri, 15 Dec 2023 10:58:05 +0100 Subject: [PATCH 4/5] #146: Implement automated coverage tools (#152) --- .github/workflows/build-pr.yml | 2 ++ .github/workflows/build.yml | 2 ++ pom.xml | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 25b7560d8..451b0fbcf 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -14,3 +14,5 @@ jobs: java-version: '17' - name: Build project with Maven run: mvn -B -ntp -Dstyle.color=always install + - name: Coveralls GitHub Action + uses: coverallsapp/github-action@v2.2.3 \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3c98a4623..da7684b4f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,3 +23,5 @@ jobs: SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} run: mvn --settings .mvn/settings.xml -DskipTests=true -Darchetype.test.skip=true -Dmaven.install.skip=true -Dstyle.color=always -B -ntp deploy + - name: Coveralls GitHub Action + uses: coverallsapp/github-action@v2.2.3 \ No newline at end of file diff --git a/pom.xml b/pom.xml index 6fbd3dd2e..0a51732b8 100644 --- a/pom.xml +++ b/pom.xml @@ -49,6 +49,26 @@ true + + + org.jacoco + jacoco-maven-plugin + 0.8.11 + + + + prepare-agent + + + + report + prepare-package + + report + + + + From 1d60d9c17b954873d91e6fe84462744f139e7a7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Hohwiller?= Date: Fri, 15 Dec 2023 11:10:51 +0100 Subject: [PATCH 5/5] #146: added coverage badge (#152) --- README.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/README.adoc b/README.adoc index e64c75c8c..de1ef0d62 100644 --- a/README.adoc +++ b/README.adoc @@ -10,6 +10,7 @@ image:https://img.shields.io/github/license/devonfw/IDEasy.svg?label=License["Ap image:https://img.shields.io/maven-central/v/com.devonfw.tools.ide/ide-cli.svg?label=Maven%20Central["Maven Central",link=https://search.maven.org/search?q=g:com.devonfw.tools.ide] image:https://github.com/devonfw/IDEasy/actions/workflows/build.yml/badge.svg["Build Status",link="https://github.com/devonfw/IDEasy/actions/workflows/build.yml"] image:https://github.com/devonfw/IDEasy/actions/workflows/update-urls.yml/badge.svg["Update URLS Status",link="https://github.com/devonfw/IDEasy/actions/workflows/update-urls.yml"] +image:https://coveralls.io/repos/github/devonfw/IDEasy/badge.svg?branch=main["Coverage Status",link="https://coveralls.io/github/devonfw/IDEasy?branch=main"] toc::[]