/** * Add a fetch to the profile. * * @param association The association to be fetched * @param style The style to apply */ public void addFetch(Association association, Fetch.Style style) { addFetch( new Fetch( association, style ) ); }
defectRequest.setFetch(new Fetch("Project", "LastUpdateDate", "FormattedId", "Owner", "SubmittedBy"));
storyRequest.setFetch(new Fetch("Name","Owner","UserName", "EmailAddress"));
//TestCases is an object with a Count and a ref to load the collection int numberOfTestCases = testSetJsonObject.getAsJsonObject("TestCases").get("Count").getAsInt(); if(numberOfTestCases > 0) { QueryRequest testCaseRequest = new QueryRequest(testSetJsonObject.getAsJsonObject("TestCases")); testCaseRequest.setFetch(new Fetch("FormattedID")); //load the collection JsonArray testCases = restApi.query(testCaseRequest).getResults(); for (int j=0;j<numberOfTestCases;j++){ System.out.println(testCases.get(j).getAsJsonObject().get("FormattedID").getAsString()); } }
//TestCases is an object with a Count and a ref to load the collection int numberOfTestCases = testSetJsonObject.getAsJsonObject("TestCases").get("Count").getAsInt(); if(numberOfTestCases > 0) { QueryRequest testCaseRequest = new QueryRequest(testSetJsonObject.getAsJsonObject("TestCases")); testCaseRequest.setFetch(new Fetch("FormattedID")); //load the collection JsonArray testCases = restApi.query(testCaseRequest).getResults(); for (int j=0;j<numberOfTestCases;j++){ System.out.println(testCases.get(j).getAsJsonObject().get("FormattedID").getAsString()); } }
//Build the array of tags to add JsonArray tagRefs = new JsonArray(); JsonObject tagRef = new JsonObject(); tagRef.addProperty("_ref", "/tag/12345"); tagRefs.add(tagRef); //Update the collection CollectionUpdateRequest testCaseTagCollectionAddRequest = new CollectionUpdateRequest("/testcase/23456", tagRefs, true); testCaseTagCollectionAddRequest.setFetch(new Fetch("Name")); CollectionUpdateResponse testCaseTagCollectionAddResponse = restApi.updateCollection(testCaseTagCollectionAddRequest);
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()); }
/** * Add a fetch to the profile. * * @param association The association to be fetched * @param style The style to apply */ public void addFetch(Association association, Fetch.Style style) { addFetch( new Fetch( association, style ) ); }
/** * Add a fetch to the profile. * * @param association The association to be fetched * @param style The style to apply */ public void addFetch(Association association, Fetch.Style style) { addFetch( new Fetch( association, style ) ); }
/** * Add a fetch to the profile. * * @param association The association to be fetched * @param style The style to apply */ public void addFetch(Association association, Fetch.Style style) { addFetch( new Fetch( association, style ) ); }
QueryRequest userRequest = new QueryRequest("User"); userRequest.setFetch(new Fetch("UserName", "Subscription", "DisplayName", "SubscriptionAdmin")); userRequest.setQueryFilter(new QueryFilter("UserName", "=", "someuser@co.com")); QueryResponse userQueryResponse = restApi.query(userRequest); JsonArray userQueryResults = userQueryResponse.getResults(); JsonElement userQueryElement = userQueryResults.get(0); JsonObject userQueryObject = userQueryElement.getAsJsonObject(); String userRef = userQueryObject.get("_ref").getAsString(); System.out.println(userRef); if (userQueryObject.get("SubscriptionAdmin").getAsBoolean() == false){ System.out.println(userQueryObject.get("SubscriptionAdmin")); }
// Query for Story to associate with Defect String storyFormattedID = "US20142"; QueryRequest storyRequest = new QueryRequest("HierarchicalRequirement"); storyRequest.setFetch(new Fetch("FormattedID","Name","Changesets")); storyRequest.setQueryFilter(new QueryFilter("FormattedID", "=", storyFormattedID)); QueryResponse storyQueryResponse = restApi.query(storyRequest); JsonObject storyJsonObject = storyQueryResponse.getResults().get(0).getAsJsonObject(); String storyRef = storyJsonObject.get("_ref").toString(); JsonObject newDefect = new JsonObject(); newDefect.addProperty("Name", "Test Defect"); newDefect.addProperty("Priority", "High Attention"); newDefect.addProperty("Severity", "Major Problem"); newDefect.addProperty("Requirement", storyRef); CreateRequest storyCreateRequest = new CreateRequest("defect", newDefect); CreateResponse storyCreateResponse = restApi.create(storyCreateRequest);
try{ QueryRequest c = new QueryRequest("testcaseresult"); c.setFetch(new Fetch("testcase")); c.setQueryFilter(new QueryFilter("testcase", "=", testCaseRef)); QueryResponse cc = r.query(c); String testresultRef = cc.getResults().get(0).getAsJsonObject().get("_ref").toString(); } catch(IndexOutOfBoundsException e){ //Create a testcaseresult here. }
QueryRequest ustore = new QueryRequest("hierarchicalrequirement"); ustore.setLimit(Integer.MAX_VALUE); ustore.setFetch(new Fetch("FormattedID","Name","Parent","Feature","Blocked","PlanEstimate","ScheduleState","Release","Iteration","Owner","Project")); ustore.setQueryFilter(new QueryFilter("Feature.Name","=",feature.getName())); QueryResponse usResp = restApi.query(ustore);
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");
QueryRequest defectRequest = new QueryRequest("defect"); defectRequest.setFetch(new Fetch("Project", "LastUpdateDate", "FormattedId", "SubmittedBy", "Owner")); defectRequest.setProject("/project/12345"); //The project oid for your project defectRequest.setScopedDown(true); QueryResponse projectDefects = rallyApi.query(defectRequest);
QueryRequest defectTypeRequest = new QueryRequest("typedefinition"); defectTypeRequest.setFetch(new Fetch("Attributes,Name,AllowedValues,StringValue")); defectTypeRequest.setQueryFilter(new QueryFilter("TypePath", "=", "defect")); QueryResponse queryResponse = restApi.query(defectTypeRequest);
QueryRequest testSetRequest = new QueryRequest("TestCases"); testSetRequest.setFetch(new Fetch(new String[] { "Name","FormattedID"})); testSetRequest.setQueryFilter(new QueryFilter("TestFolder.Parent.Name", "=", "TestFolderParent1"));
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); } }
// 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();