fix(测试用例): 未获取jira全部需求问题

Closes #5460
This commit is contained in:
shiziyuan9527 2021-08-18 15:33:58 +08:00 committed by 刘瑞斌
parent 0080615344
commit d46a4b9f46
1 changed files with 29 additions and 16 deletions

View File

@ -141,22 +141,35 @@ public class JiraPlatform extends AbstractIssuePlatform {
RestTemplate restTemplate = new RestTemplate();
//post
ResponseEntity<String> responseEntity = null;
responseEntity = restTemplate.exchange(url + "/rest/api/2/search?jql=project="+key+"+AND+issuetype="+type+"&fields=summary,issuetype",
HttpMethod.GET, requestEntity, String.class);
String body = responseEntity.getBody();
JSONObject jsonObject = JSONObject.parseObject(body);
JSONArray jsonArray = jsonObject.getJSONArray("issues");
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject o = jsonArray.getJSONObject(i);
String issueKey = o.getString("key");
JSONObject fields = o.getJSONObject("fields");
String summary = fields.getString("summary");
DemandDTO demandDTO = new DemandDTO();
demandDTO.setName(summary);
demandDTO.setId(issueKey);
demandDTO.setPlatform(IssuesManagePlatform.Jira.name());
list.add(demandDTO);
}
int maxResults = 50, startAt = 0, total = 0, currentStartAt = 0;
do {
String jql = url + "/rest/api/2/search?jql=project=" + key + "+AND+issuetype=" + type
+ "&maxResults=" + maxResults + "&startAt=" + startAt + "&fields=summary,issuetype";
responseEntity = restTemplate.exchange(jql,
HttpMethod.GET, requestEntity, String.class);
String body = responseEntity.getBody();
JSONObject jsonObject = JSONObject.parseObject(body);
JSONArray jsonArray = jsonObject.getJSONArray("issues");
if (jsonArray.size() == 0) {
break;
}
total = jsonObject.getInteger("total");
startAt = startAt + maxResults;
currentStartAt = jsonObject.getInteger("startAt");
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject o = jsonArray.getJSONObject(i);
String issueKey = o.getString("key");
JSONObject fields = o.getJSONObject("fields");
String summary = fields.getString("summary");
DemandDTO demandDTO = new DemandDTO();
demandDTO.setName(summary);
demandDTO.setId(issueKey);
demandDTO.setPlatform(IssuesManagePlatform.Jira.name());
list.add(demandDTO);
}
} while (currentStartAt + maxResults < total);
} catch (Exception e) {
LogUtil.error(e.getMessage(), e);
}