fix(接口测试): 接口定义和场景用例添加标签后,变更历史中没有记录

--bug=1009037 --user=郭雨琦 【ID1009037】【接口测试】-接口定义和场景用例添加标签后,变更历史中没有记录
This commit is contained in:
guoyuqi 2021-12-22 20:48:01 +08:00 committed by xiaomeinvG
parent 9730124c36
commit 18cc316657
1 changed files with 17 additions and 6 deletions

View File

@ -153,16 +153,27 @@ public class ReflexObjectUtil {
GsonDiff diff = new GsonDiff();
Object originalValue = originalColumns.get(i).getOriginalValue();
Object newValue = newColumns.get(i).getOriginalValue();
String oldTags = null;
if (originalValue != null && !StringUtils.equals("null", originalValue.toString())) {
List<String> originalValueArray = JSON.parseArray(originalValue.toString(), String.class);
List<String> newValueArray = JSON.parseArray(newValue.toString(), String.class);
Collections.sort(originalValueArray);
Collections.sort(newValueArray);
Object originalObject = JSON.toJSON(originalValueArray);
oldTags = ApiDefinitionDiffUtil.JSON_START + ((originalColumns.get(i) != null && originalObject != null) ? originalObject.toString() : "\"\"") + ApiDefinitionDiffUtil.JSON_END;
}
List<String> newValueArray = JSON.parseArray(newValue.toString(), String.class);
Collections.sort(newValueArray);
Object newObject = JSON.toJSON(newValueArray);
String oldTags = ApiDefinitionDiffUtil.JSON_START + ((originalColumns.get(i) != null && originalObject != null) ? originalObject.toString() : "\"\"") + ApiDefinitionDiffUtil.JSON_END;
String newTags = ApiDefinitionDiffUtil.JSON_START + ((newColumns.get(i) != null && newObject != null) ? newObject.toString() : "\"\"") + ApiDefinitionDiffUtil.JSON_END;
String diffValue;
if (oldTags != null) {
String diffStr = diff.diff(oldTags, newTags);
String diffValue = diff.apply(newTags, diffStr);
diffValue = diff.apply(newTags, diffStr);
} else {
int indexAdd = newTags.indexOf("[");
String substring = newTags.substring(0, indexAdd + 2);
String substring1 = newTags.substring(indexAdd + 2);
diffValue = substring + "++" + substring1;
}
column.setDiffValue(diffValue);
}
// 深度对比