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(); String body = responseEntity.getBody();
JSONObject obj = JSONObject.parseObject(body); JSONObject obj = JSONObject.parseObject(body);
LogUtil.info("project story" + key + obj); LogUtil.info("project story: " + key + obj);
if (obj != null) { if (obj != null) {
JSONObject data = obj.getJSONObject("data"); String data = obj.getString("data");
String s = JSON.toJSONString(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>>(){}); Map<String, Object> map = JSONArray.parseObject(s, new TypeReference<Map<String, Object>>(){});
Collection<Object> values = map.values(); Collection<Object> values = map.values();
values.forEach(v -> { values.forEach(v -> {
@ -122,10 +140,10 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
demandDTO.setPlatform(IssuesManagePlatform.Zentao.name()); demandDTO.setPlatform(IssuesManagePlatform.Zentao.name());
list.add(demandDTO); list.add(demandDTO);
}); });
}
} }
} catch (Exception e) { } catch (Exception e) {
LogUtil.error("get zentao bug fail " + e.getMessage()); LogUtil.error("get zentao demand fail " + e.getMessage());
} }
return list; return list;
} }