Uh oh!
There was an error while loading. Please reload this page.
forked from nmusaelian-rally/rally-java-rest-apps
- Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathAddStepsToTestCase.java
More file actions
Latest commit
61 lines (55 loc) · 2.78 KB
/
Copy pathAddStepsToTestCase.java
File metadata and controls
61 lines (55 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
importjava.io.IOException;
importjava.net.URI;
importjava.net.URISyntaxException;
importcom.google.gson.JsonArray;
importcom.google.gson.JsonObject;
importcom.rallydev.rest.RallyRestApi;
importcom.rallydev.rest.request.QueryRequest;
importcom.rallydev.rest.request.UpdateRequest;
importcom.rallydev.rest.response.QueryResponse;
importcom.rallydev.rest.response.UpdateResponse;
importcom.rallydev.rest.util.Fetch;
importcom.rallydev.rest.util.QueryFilter;
publicclassAddStepsToTestCase {
publicstaticvoidmain(String[] args) throwsException {
Stringhost = "https://rally1.rallydev.com";
StringapiKey = "_abc123";
StringapplicationName = "Add Steps To TC";
StringworkspaceRef = "/workspace/12343";
RallyRestApirestApi = null;
try {
restApi = newRallyRestApi(newURI(host), apiKey);
restApi.setApplicationName(applicationName);
QueryRequestrequest = newQueryRequest("TestCase");
request.setFetch(newFetch("FormattedID", "Name", "Steps"));
request.setWorkspace(workspaceRef);
request.setQueryFilter(newQueryFilter("FormattedID", "=", "TC18"));
QueryResponseresponse = restApi.query(request);
JsonObjecttestCaseJsonObject = response.getResults().get(0).getAsJsonObject();
StringtestCaseRef = testCaseJsonObject.get("_ref").getAsString();
intnumberOfSteps = testCaseJsonObject.getAsJsonObject("Steps").get("Count").getAsInt();
System.out.println(testCaseJsonObject.get("Name") + " ref: " + testCaseRef + "number of steps: " + numberOfSteps + " " + testCaseJsonObject.get("Steps"));
if (response.wasSuccessful()) {
JsonObjectstepOne = newJsonObject();
JsonObjectstepTwo = newJsonObject();
stepOne.addProperty("Input", "Open Database Connection");
stepOne.addProperty("StepIndex", 1);
stepOne.addProperty("StepIndex", 2);
stepOne.addProperty("TestCase", testCaseRef);
stepTwo.addProperty("Input", "2+2");
stepTwo.addProperty("ExpectedResult", "4");
stepTwo.addProperty("TestCase", testCaseRef);
CreateRequestcreateRequest = newCreateRequest("testcasestep", stepOne);
CreateResponsecreateResponse = restApi.create(createRequest);
CreateRequestcreateRequest2 = newCreateRequest("testcasestep", stepTwo);
CreateResponsecreateResponse2 = restApi.create(createRequest2);
}else {
System.out.println("false? " + response.wasSuccessful());
}
} finally {
if (restApi != null) {
restApi.close();
}
}
}
}