Retrieve linked test cases from a Work Item
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
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.
Comments
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?
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.