Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/devonfw/IDEasy into feature/d…
Browse files Browse the repository at this point in the history
…evonfw#139-feature-for-making-symlinks-relative

# Conflicts:
#	cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java
  • Loading branch information
MattesMrzik committed Dec 12, 2023
2 parents be24f11 + a5f7202 commit 985e964
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,9 @@ public <O> O question(String question, O... options) {
assert (options.length >= 2);
interaction(question);
Map<String, O> 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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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());

}
}
Original file line number Diff line number Diff line change
@@ -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}.
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void testThatHomeIsNotReqired() {
// act
HelpCommandlet help = new HelpCommandlet(context);
// assert
assertThat(help.isIdeHomeRequired()).isEqualTo(false);
assertThat(help.isIdeHomeRequired()).isFalse();
}

/**
Expand Down

0 comments on commit 985e964

Please sign in to comment.