It's all about the answers!

Ask a question

Retrieve linked test cases from a Work Item


Antonio Dionisio (175) | asked Nov 16 '16, 7:18 a.m.
edited Nov 16 '16, 7:19 a.m.
I have to retrieve information about the Test Cases that are linked to a given Work Item. I am using RTC 5.0.1 and Java API.

Thanks to other questions and blogposts I have managed to get throught the links of a Work Item, but I am stuck on how to retrieve the TestCase itself. Is there any way to get the Test Cases?
private void getLinks(ITeamRepository repo, IWorkItem wi) throws TeamRepositoryException{

        ILinkManager linkManager = (ILinkManager) repo.getClientLibrary(ILinkManager.class);

        IItemReference itemReference = linkManager.referenceFactory().createReferenceToItem(wi);

        ILinkCollection linkCollection = linkManager.findLinksBySource(itemReference, null).getAllLinksFromHereOn();

        System.out.println("\tWorkItem has " + linkCollection.size() + " links");

        for (ILink link: linkCollection) {

            IItemHandle linkHandle = (IItemHandle) link.getTargetRef().resolve();

            System.out.println("\t" + link.getThisEndpointDescriptor(link.getTargetRef()).getDisplayName() + " " + link.getTargetRef().getClass());

        }

    }


This method currently outputs:

	Work Item has 1 links
	Tested By Test Case class com.ibm.team.links.internal.links.impl.ReferenceImpl

Accepted answer


permanent link
Miguel Tomico (5001123) | answered Nov 16 '16, 8:16 a.m.
Unfortunately, RQM does not have a Java API like RTC.
You will need to make OSLC calls to retrieve the detail of the Test Cases.
If you need this for reporting purposes, I would consider JRS.
Antonio Dionisio selected this answer as the correct answer

Comments
Antonio Dionisio commented Nov 16 '16, 10:13 a.m. | edited Nov 16 '16, 10:24 a.m.

Miguel, thanks for you answer. So I have the url to the linked test (something like this: https://localhost:9443/qm/oslc_qm/contexts/_ueOOYKgQEeaPaoGRbbL1BA/resources/com.ibm.rqm.planning.VersionedTestCase/_LsP4sKqLEeaPaoGRbbL1BA).  If I want to call for this specific test case in a REST call how do I know what is this test case id? As I have read the REST call would be like this:
https://localhost:9443/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/[PROJECT]/testcase/urn:com.ibm.rqm:testcase:32
How can I know the test case id with the retrieved link?


Miguel Tomico commented Nov 21 '16, 4:03 a.m. | edited Nov 21 '16, 4:05 a.m.

Apologies for the late response.

In your example, the external UUID of the Test Case is:

_LsP4sKqLEeaPaoGRbbL1BA

Therefore, the REST call to GET the resource using this external ID would be as follows:

https://<jazz server>:<port>/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/_ueOOYKgQEeaPaoGRbbL1BA/testcase/_LsP4sKqLEeaPaoGRbbL1BA

Have a look at this article about retrieving RQM resources using Internal or External IDs.

https://www.ibm.com/developerworks/community/blogs/e4210f90-a515-41c9-a487-8fc7d79d7f61/entry/rqm_rest_api?lang=en

Your answer


Register or to post your answer.