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(); } /**