fix(测试用例): 集成禅道11.5版本获取需求失败

This commit is contained in:
shiziyuan9527 2021-08-31 16:08:00 +08:00 committed by 刘瑞斌
parent 333e71394f
commit 8c6a0fa75b
1 changed files with 33 additions and 15 deletions

View File

@ -107,11 +107,29 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
String body = responseEntity.getBody();
JSONObject obj = JSONObject.parseObject(body);
LogUtil.info("project story" + key + obj);
LogUtil.info("project story: " + key + obj);
if (obj != null) {
JSONObject data = obj.getJSONObject("data");
String s = JSON.toJSONString(data);
String data = obj.getString("data");
if (StringUtils.isBlank(data)) {
return list;
}
// 兼容处理11.5版本格式 [{obj},{obj}]
if (data.charAt(0) == '[') {
JSONArray array = obj.getJSONArray("data");
for (int i = 0; i < array.size(); i++) {
JSONObject o = array.getJSONObject(i);
DemandDTO demandDTO = new DemandDTO();
demandDTO.setId(o.getString("id"));
demandDTO.setName(o.getString("title"));
demandDTO.setPlatform(IssuesManagePlatform.Zentao.name());
list.add(demandDTO);
}
}
// 处理格式 {{"id": {obj}},{"id",{obj}}}
else if (data.charAt(0) == '{') {
JSONObject dataObject = obj.getJSONObject("data");
String s = JSON.toJSONString(dataObject);
Map<String, Object> map = JSONArray.parseObject(s, new TypeReference<Map<String, Object>>(){});
Collection<Object> values = map.values();
values.forEach(v -> {
@ -122,10 +140,10 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
demandDTO.setPlatform(IssuesManagePlatform.Zentao.name());
list.add(demandDTO);
});
}
}
} catch (Exception e) {
LogUtil.error("get zentao bug fail " + e.getMessage());
LogUtil.error("get zentao demand fail " + e.getMessage());
}
return list;
}