使用Java Rally Rest API 2.0,当我读取TestCase的TestSets属性时,它将返回:
{“ _rallyAPIMajor”:“ 2”,“ _ rallyAPIMinor”:“ 0”,“ _ ref”:“ https://rally1.rallydev.com/slm/webservice/v2.0/TestCase/31169145174/TestSets”,
“ _type”:“ TestSet”,“ Count”:3}
计数正确,但是如何获取TestSet的objectID值? 31169145174是我的TestCase的对象ID。
最佳答案
假设您在名为JsonObject
的testCaseJsonObject
变量中包含测试用例,则类似于以下内容的工作应可轮询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());
}