【问题标题】:How to read a collection property from Rally Rest API如何从 Rally Rest API 读取集合属性
【发布时间】:2015-04-29 14:13:45
【问题描述】:
【问题讨论】:
标签:
java
api
rest
collections
rally
【解决方案1】:
假设您在名为 testCaseJsonObject 的 JsonObject 变量中有 testCase,类似于以下内容的内容应该可以轮询 TestSets 集合:
QueryRequest testSetRequest = new QueryRequest(testCaseJsonObject.getAsJsonObject("TestSets"));
testSetRequest.setFetch(new Fetch("Name", "FormattedID"));
// Load the TestSet collection
JsonArray testSetsOfTestCase = restApi.query(testSetRequest).getResults();
for (int i=0; i<testSetsOfTestCase.length(); i++) {
System.out.println("Name: " + testSetsOfTestCase.get(i).getAsJsonObject().get("Name") + testSetsOfTestCase.get(i).getAsJsonObject().get("FormattedID").getAsString());
}