How to get TestSet ID using Rally Rest API in Java?

本小妞迷上赌 提交于 2019-12-24 05:31:25

问题


I am using following code to get TestSet ID. But it doesn't give any result

QueryRequest testsetRequest = new QueryRequest("Test Set");
testsetRequest.setFetch(new Fetch("FormattedID","Name"));
testsetRequest.setQueryFilter(new QueryFilter("TestSet.Name", "=", "TestSetName"));
QueryResponse testSetQueryResponse = restApi.query(testsetRequest);
System.out.println(String.format("\nTestSet:%d",testSetQueryResponse.getTotalResultCount()));
StringTestSetref=testSetQueryResponse.getResults().get(0).getAsJsonObject().get("_ref").toString();
System.out.println(TestSetref);

回答1:


You're probably getting an error in your query. Code like this should work. The else clause will also help you diagnose what errors you are getting if there is a problem with your query.

QueryRequest testsetRequest = new QueryRequest("TestSet"); //no spaces
testsetRequest.setFetch(new Fetch("FormattedID","Name"));     

//No need to specify type again 
testsetRequest.setQueryFilter(new QueryFilter("Name", "=", "TestSetName")); 
QueryResponse testSetQueryResponse = restApi.query(testsetRequest);

if(testSetQueryResponse.wasSuccessful()) {
    for (JsonElement result : testSetQueryResponse.getResults()) {
        //handle results
    }
} else {
    //See what error occurred
    for (String err : testSetQueryResponse.getErrors()) {
        System.err.println("\t" + err);
    }
}


来源:https://stackoverflow.com/questions/12819433/how-to-get-testset-id-using-rally-rest-api-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!