QueryRequest testCaseResultsRequest = new QueryRequest("TestCaseResult"); testCaseResultsRequest.setFetch(new Fetch("Build","TestCase","TestSet", "Verdict","FormattedID")); testCaseResultsRequest.setQueryFilter(new QueryFilter("TestCase.FormattedID", "=", "TC8147").and( new QueryFilter("TestSet.FormattedID", "=", "TS363"))); QueryResponse testCaseResultResponse = restApi.query(testCaseResultsRequest); int numberTestCaseResults = testCaseResultResponse.getTotalResultCount(); System.out.println(numberTestCaseResults); if(numberTestCaseResults >0) System.out.println(testCaseResultResponse.getResults().get(0).getAsJsonObject().get("Verdict").getAsString()); else System.out.println("Not executed");
System.out.println("Size: " + testSetQueryResponse.getTotalResultCount()); for (int i=0; i<testSetQueryResponse.getResults().size();i++){ JsonObject testSetJsonObject = testSetQueryResponse.getResults().get(i).getAsJsonObject();
System.out.println("Size: " + storyQueryResponse.getTotalResultCount()); for (int i=0; i<storyQueryResponse.getTotalResultCount();i++){ JsonObject storyJsonObject = storyQueryResponse.getResults().get(i).getAsJsonObject(); System.out.println("Name: " + storyJsonObject.get("Name") + " FormattedID: " + storyJsonObject.get("FormattedID"));
int numberOfResults = taskQueryResponse.getTotalResultCount(); System.out.println(numberOfResults);
tsRequest.setQueryFilter(new QueryFilter("FormattedID", "=", setID)); QueryResponse tsQueryResponse = restApi.query(tsRequest); if(tsQueryResponse.getTotalResultCount() == 0){ System.out.println("Cannot find tag: " + setID); return; QueryResponse testCaseQueryResponse = restApi.query(testCaseRequest);; if (testCaseQueryResponse.getTotalResultCount() == 0) { System.out.println("Cannot find test case : " + testid); return;
buildRequest.setProject(projectRef); QueryResponse buildResponse = restApi.query(buildRequest); for (int i=0; i<buildResponse.getTotalResultCount();i++){ JsonObject buildObj = buildResponse.getResults().get(i).getAsJsonObject(); System.out.println("Build Status: " + buildObj.get("Status") + changesetsRequest.setLimit(1000); QueryResponse changesetsResponse = restApi.query(changesetsRequest); for (int j=0; j<changesetsResponse.getTotalResultCount();j++) { JsonObject changesetObj = changesetsResponse.getResults().get(j).getAsJsonObject(); System.out.println("\nChangeset Revision: " + changesetObj.get("Revision")); artifactsRequest.setFetch(new Fetch("FormattedID")); QueryResponse artifactsResponse = restApi.query(artifactsRequest); for (int k=0; k<artifactsResponse.getTotalResultCount();k++) { JsonObject artifactObj = artifactsResponse.getResults().get(k).getAsJsonObject(); System.out.println("\nArtifact FormattedID: " + artifactObj.get("FormattedID")); changesRequest.setFetch(new Fetch("PathAndFilename")); QueryResponse changesResponse = restApi.query(changesRequest); for (int l=0; l<changesResponse.getTotalResultCount();l++) { JsonObject changeObj = changesResponse.getResults().get(l).getAsJsonObject(); System.out.println("Change PathAndFilename: " + changeObj.get("PathAndFilename"));
tagRequest.setQueryFilter(new QueryFilter("Name", "=", tagname)); QueryResponse tagQueryResponse = restApi.query(tagRequest); if(tagQueryResponse.getTotalResultCount() == 0){ System.out.println("Cannot find tag: " + tagname); return; QueryResponse testCaseQueryResponse = restApi.query(testCaseRequest);; if (testCaseQueryResponse.getTotalResultCount() == 0) { System.out.println("Cannot find test case : " + testid); return;
System.out.println("Size: " + testCaseResponse.getTotalResultCount()); int totalResults = 0; for (int i=0; i<testCaseResponse.getResults().size();i++){
tsRequest.setQueryFilter(new QueryFilter("FormattedID", "=", setID)); QueryResponse tsQueryResponse = restApi.query(tsRequest); if(tsQueryResponse.getTotalResultCount() == 0){ System.out.println("Cannot find tag: " + setID); return; QueryResponse testCaseQueryResponse = restApi.query(testCaseRequest);; if (testCaseQueryResponse.getTotalResultCount() == 0) { System.out.println("Cannot find test case : " + testid); return;
QueryResponse storyQueryResponse = restApi.query(storyRequest); System.out.println("Successful: " + storyQueryResponse.wasSuccessful()); System.out.println("Size: " + storyQueryResponse.getTotalResultCount()); System.out.println("Results Size: " + storyQueryResponse.getResults().size()); for (int i=0; i<storyQueryResponse.getResults().size();i++){
RallyRestApi restApi = new RallyRestApi(new URI("https://rally.rallydev.com/"), "_apogjlfdkjglfjlksr23rfdlj"); String wsapiVersion = "v2.0"; String workspaceRef = "/workspace/01245"; String projectRef = "/project/6757552"; if(restApi!=null){ restApi.setWsapiVersion(wsapiVersion); QueryRequest queryRequest = new QueryRequest("TestFolders"); queryRequest.setFetch(new Fetch(new String[] { "Name","FormattedID","TestFolder"})); queryRequest.setWorkspace(workspaceRef); queryRequest.setProject(projectRef); queryRequest.setScopedDown(true); queryRequest.setLimit(Integer.MAX_VALUE); queryRequest.setPageSize(Integer.MAX_VALUE); QueryResponse queryResponse = null; JsonArray jsonarr = new JsonArray(); queryResponse = restApi.query(queryRequest); int responseTotalResultsCount = queryResponse.getTotalResultCount(); jsonarr.addAll(queryResponse.getResults()); int jsonArrSize = jsonarr.size(); for (int i=0; i<queryResponse.getResults().size();i++){ JsonObject testCaseJsonObject = queryResponse.getResults().get(i).getAsJsonObject(); System.out.println(testCaseJsonObject.getAsJsonObject().get("FormattedID")+": "+testCaseJsonObject.getAsJsonObject().get("Name")); } }
public static void main(String[] args) throws Exception { String host = "https://rally1.rallydev.com"; String apiKey = "_abc123"; String applicationName = "Find TestCase by ObjectID"; String workspaceRef = "/workspace/12345"; RallyRestApi restApi = null; try { restApi = new RallyRestApi(new URI(host),apiKey); QueryRequest request = new QueryRequest("TestCase"); request.setWorkspace(workspaceRef); restApi.setApplicationName(applicationName); request.setFetch(new Fetch("FormattedID")); request.setQueryFilter(new QueryFilter("ObjectID", "=", "14226025324")); QueryResponse response = restApi.query(request); if(response.wasSuccessful()){ System.out.println("Number of results: " + response.getResults().size()); for (int i=0; i<response.getTotalResultCount();i++){ JsonObject jsonObject = response.getResults().get(i).getAsJsonObject(); System.out.println("FormattedID: " + jsonObject.get("FormattedID")); } } else{ System.out.println("false? " + response.wasSuccessful()); } } finally { if (restApi != null) { restApi.close(); } } }
int numberOfReleasesInProject = releaseQueryResponse.getTotalResultCount(); System.out.println(numberOfReleasesInProject); JsonObject releaseJsonObject = releaseQueryResponse.getResults().get(0).getAsJsonObject(); int numberOfIteraitons = iterationQueryResponse.getTotalResultCount(); System.out.println("numberOfIteraitons " + numberOfIteraitons); if(numberOfIteraitons >0){ System.out.println("Number of stories in " + iterationName + " :" + storyQueryResponse.getTotalResultCount());
responseTotalResultsCount = queryResponse.getTotalResultCount();// Set to correct value here
// Query for Test Case to which we want to add results QueryRequest testCaseRequest = new QueryRequest("TestCase"); testCaseRequest.setFetch(new Fetch("FormattedID","Name")); testCaseRequest.setQueryFilter(new QueryFilter("FormattedID", "=", "TC4")); QueryResponse testCaseQueryResponse = restApi.query(testCaseRequest); JsonObject testCaseJsonObject = testCaseQueryResponse.getResults().get(0).getAsJsonObject(); String testCaseRef = testCaseQueryResponse.getResults().get(0).getAsJsonObject().get("_ref").toString(); String testCaseFormattedID = testCaseQueryResponse.getResults().get(0).getAsJsonObject.get("FormattedID").toString(); // Query for Test Case Results that are associated to this particular Test Case QueryRequest testCaseResultsRequest = new QueryRequest("TestCaseResult"); testCaseResultsRequest.setFetch(new Fetch("Build","TestCase","Verdict","FormattedID")); testCaseResultsRequest.setQueryFilter(new QueryFilter("TestCase.FormattedID", "=", testCaseFormattedID)); QueryResponse testCaseResultResponse = restApi.query(testCaseResultsRequest); int numberTestCaseResults = testCaseResultResponse.getTotalResultCount();