How do I change the state of a test case using the (rest or oslc) API?
Thanks
2 answers
For your issue, you can do it in two ways.
1. Create the test artifacts as usual, and move the state to the desired one according to the workflow - you may need to do multiple PUT operations against a test artifact to achieve this.
2. Only when you are the only one actively using the RQM project:
a. Change the starting state to the desired one in a workflow of a test artifact type.
b. Save the change.
c. Create test artifacts of that particular state and particular type.
d. Repeat a. - c. for each state.
e. Change the starting state back to Draft.
f. Repeat a. - e. for each test artifact type.
Comments
I need to make the change programmatically (option 1 in the response from Donald Nong), as other people may be using the product at the same time that I am (so option 2 is not a good choice).
The response does not answer the question of how to update the state attribute. How can I do either of:
- use the API to request an action that would trigger the state transition from one state to another
- use the API to update the data so that the state transitions from one state to another
I thought it's quite straightforward so I didn't put in the details. Sorry about that. You do not invoke an action at all, and you just update the test artifact with the target state directly. For example, from the workflow, you know that you can move an artifact from Draft to Ready For Review, and the ID for the said state is "com.ibm.rqm.planning.common.new" and "com.ibm.rqm.planning.common.underreview" respectively (you can find it out by querying the existing artifacts of the said state). Then for the artifact you need to update, do a GET operation, and you should get something like this in the response.
<ns5:state ns7:resource="https://clm:9443/qm/service/com.ibm.rqm.integration.service.IIntegrationService/process-info/_un7MMIPsEeSArJ5EtUYmDQ/workflowstate/com.ibm.rqm.process.testcase.workflow/com.ibm.rqm.planning.common.new">com.ibm.rqm.planning.common.new</ns5:state>Next you will replace the above line with this.
<ns5:state ns7:resource="https://clm:9443/qm/service/com.ibm.rqm.integration.service.IIntegrationService/process-info/_un7MMIPsEeSArJ5EtUYmDQ/workflowstate/com.ibm.rqm.process.testcase.workflow/com.ibm.rqm.planning.common.underreview">com.ibm.rqm.planning.common.underreview</ns5:state>And finally you will make this modified response body as the payload of the PUT(modify) operation against the same artifact. If everything goes to plan, you should get an HTTP 200 response code and the test artifact gets updated with the new state.
Thanks! The API documentation lead me to believe that with a testcase and a /state somewhere in the URI, I could just update the state! (see "https://www.ibm.com/support/knowledgecenter/SSYMRC_6.0.1/com.ibm.rational.test.qm.doc/topics/qm/Test-Case.html?lang=en" and the reference to "/content/qm:testcase/alm:state/@rdf:resource" lead me to think I could just update the state, rather than having to move around the whole resource.
But the technique you supplied works!
Thanks!
I did spend some time on finding a way to update the attribute itself only (as in the case of RTC), but did not have much luck.
P.S. The document that you linked is for the data warehouse, while the REST API is used against the RQM live database.