fix(接口测试): 修复被禁用的引用场景仍可以开启的缺陷

This commit is contained in:
wxg0103 2022-11-16 17:13:55 +08:00 committed by wxg0103
parent 44a323a802
commit a8b2d280a9
2 changed files with 5 additions and 4 deletions

View File

@ -26,7 +26,6 @@ import io.metersphere.service.MsHashTreeService;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.config.Arguments; import org.apache.jmeter.config.Arguments;
import org.apache.jorphan.collections.HashTree; import org.apache.jorphan.collections.HashTree;
@ -230,7 +229,7 @@ public class MsScenario extends MsTestElement {
if (JSONObject.NULL.equals(orgElement) || targetElement == null) { if (JSONObject.NULL.equals(orgElement) || targetElement == null) {
return orgElement; return orgElement;
} }
if (BooleanUtils.isFalse(orgElement.optBoolean(MsHashTreeService.ENABLE))) { if (!orgElement.optBoolean(MsHashTreeService.ENABLE)) {
orgElement.put(MsHashTreeService.ENABLE, false); orgElement.put(MsHashTreeService.ENABLE, false);
} else { } else {
orgElement.put(MsHashTreeService.ENABLE, targetElement.isEnable()); orgElement.put(MsHashTreeService.ENABLE, targetElement.isEnable());

View File

@ -19,7 +19,6 @@ import io.metersphere.commons.utils.LogUtil;
import io.metersphere.service.definition.ApiDefinitionService; import io.metersphere.service.definition.ApiDefinitionService;
import io.metersphere.service.definition.ApiTestCaseService; import io.metersphere.service.definition.ApiTestCaseService;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
@ -229,12 +228,15 @@ public class MsHashTreeService {
if (orgElement == null || targetElement == null) { if (orgElement == null || targetElement == null) {
return orgElement; return orgElement;
} }
if (BooleanUtils.isFalse(orgElement.optBoolean(ENABLE))) { if (!orgElement.optBoolean(ENABLE)) {
orgElement.put(ENABLE, false); orgElement.put(ENABLE, false);
orgElement.put(REF_ENABLE, true); orgElement.put(REF_ENABLE, true);
} else { } else {
orgElement.put(ENABLE, targetElement.optBoolean(ENABLE)); orgElement.put(ENABLE, targetElement.optBoolean(ENABLE));
} }
if (targetElement.optBoolean(REF_ENABLE)) {
orgElement.put(REF_ENABLE, targetElement.optBoolean(REF_ENABLE));
}
try { try {
if (orgElement.has(HASH_TREE)) { if (orgElement.has(HASH_TREE)) {
JSONArray orgJSONArray = orgElement.optJSONArray(HASH_TREE); JSONArray orgJSONArray = orgElement.optJSONArray(HASH_TREE);