Fix switch task will throw exception when there is not parameters (#15594)

This commit is contained in:
Wenjun Ruan 2024-02-19 11:12:22 +08:00 committed by GitHub
parent d77bbccdf2
commit 8a35e8b2f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 4 deletions

View File

@ -66,7 +66,7 @@ public class SwitchTaskUtils {
Map<String, Property> varParams) {
String content = condition.replaceAll("'", "\"");
if (MapUtils.isEmpty(globalParams) && MapUtils.isEmpty(varParams)) {
throw new IllegalArgumentException("globalParams and varParams are both empty, please check it.");
return content;
}
Map<String, Property> params = Maps.newHashMap();
if (MapUtils.isNotEmpty(globalParams)) {

View File

@ -34,9 +34,8 @@ public class SwitchTaskUtilsTest {
String content = "${test}==1";
Map<String, Property> globalParams = new HashMap<>();
Map<String, Property> varParams = new HashMap<>();
Assertions.assertThrowsExactly(IllegalArgumentException.class, () -> {
SwitchTaskUtils.generateContentWithTaskParams(content, globalParams, varParams);
});
Assertions.assertDoesNotThrow(
() -> SwitchTaskUtils.generateContentWithTaskParams(content, globalParams, varParams));
globalParams.put("test", new Property("test", Direct.IN, DataType.INTEGER, "1"));
String result = SwitchTaskUtils.generateContentWithTaskParams(content, globalParams, varParams);