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