Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,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/1552[#1552]: Add Commandlet to fix TLS issue
* https://github.com/devonfw/IDEasy/issues/1760[#1760]: Accept empty input for single option

The full list of changes for this release can be found in https://github.com/devonfw/IDEasy/milestone/43?closed=1[milestone 2026.04.002].

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,9 @@ private <O> O displayOptionsAndGetAnswer(O[] options) {
}
IdeLogLevel.INTERACTION.log(LOG, "Option {}: {}", numericKey, title);
}
if (options.length == 1) {
mapping.put("", options[0]);
}
O option = null;
Comment thread
ducminh02 marked this conversation as resolved.
if (isBatchMode()) {
if (isForceMode()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package com.devonfw.tools.ide.context;

import java.nio.file.Path;
import java.util.List;
import java.util.Properties;

import org.junit.jupiter.api.Test;
import com.devonfw.tools.ide.security.ToolVersionChoice;
import com.devonfw.tools.ide.tool.ToolEditionAndVersion;
import com.devonfw.tools.ide.security.ToolVulnerabilities;
import com.devonfw.tools.ide.version.VersionIdentifier;
import com.devonfw.tools.ide.version.VersionRange;
import com.devonfw.tools.ide.url.model.file.json.Cve;
import com.devonfw.tools.ide.tool.ToolEdition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -273,4 +281,36 @@ void testFindBashOnSystemPathOnWindowsWithInvalidBashPathSet() {
assertThat(bash).isEqualTo(bashExePath);
}

@Test
void testQuestionWithMultipleOptions() {
IdeTestContext context = newContext(PROJECT_BASIC, null, false);
String[] options = {"option1", "option2"};
context.setAnswers("option1");
String result = context.question(options, "Which option?");
assertThat(result).isEqualTo("option1");
}

@Test
void testQuestionWithSingleOptionAndEmptyAnswer() {
IdeTestContext context = newContext(PROJECT_BASIC, null, false);
String[] options = {"onlyOption"};
context.setAnswers(""); // Empty answer (Enter)
String result = context.question(options, "Which option?");
assertThat(result).isEqualTo("onlyOption");
}

@Test
void testQuestionWithSingleToolVersionChoiceAndEmptyAnswer() {
IdeTestContext context = newContext(PROJECT_BASIC, null, false);
ToolEdition edition = new ToolEdition("java", "oracle");
VersionIdentifier version = VersionIdentifier.of("17");
Cve cve = new Cve("CVE-2023-XXXX", 9.8, List.of(VersionRange.of("[17,18)")));
ToolVersionChoice choice = new ToolVersionChoice(new ToolEditionAndVersion(edition, version), "current", ToolVulnerabilities.of(List.of(cve)));
ToolVersionChoice[] options = {choice};

context.setAnswers(""); // Empty answer (Enter)
ToolVersionChoice result = context.question(options, "Which version?");
assertThat(result).isSameAs(choice);
}

}
Loading