如何从 Rally Rest API 中读取集合 属性
How to read a collection property from Rally Rest API
使用 java Rally Rest API 2.0,当我读取 TestCase 的 TestSets 属性 时 returns:
{"_rallyAPIMajor":"2","_rallyAPIMinor":"0","_ref":"https://rally1.rallydev.com/slm/webservice/v2.0/TestCase/31169145174/TestSets",
"_type":"TestSet","Count":3}
计数是正确的,但如何获取测试集的 objectID 值? 31169145174是我的TestCase的对象ID。
假设您在名为 testCaseJsonObject
的 JsonObject
变量中拥有测试用例,类似于以下内容的内容应该可以轮询 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());
}
使用 java Rally Rest API 2.0,当我读取 TestCase 的 TestSets 属性 时 returns:
{"_rallyAPIMajor":"2","_rallyAPIMinor":"0","_ref":"https://rally1.rallydev.com/slm/webservice/v2.0/TestCase/31169145174/TestSets", "_type":"TestSet","Count":3}
计数是正确的,但如何获取测试集的 objectID 值? 31169145174是我的TestCase的对象ID。
假设您在名为 testCaseJsonObject
的 JsonObject
变量中拥有测试用例,类似于以下内容的内容应该可以轮询 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());
}