How can I use the Java API to link RQM test case/results to RTC work items?
Accepted answer
the solution I found for this with the RTC Java API looks as follows:
private static class LinkURIOperation extends WorkItemOperation {
private URI fURI;
private IEndPointDescriptor fEndpointDescriptor;
public LinkURIOperation( IEndPointDescriptor endpointDescriptor,URI uri) {
super("Linking URL", IWorkItem.FULL_PROFILE);
fURI = uri;
fEndpointDescriptor=endpointDescriptor;
}
@Override
protected void execute(WorkItemWorkingCopy workingCopy,
IProgressMonitor monitor) throws TeamRepositoryException {
IReference reference;
reference = IReferenceFactory.INSTANCE.createReferenceFromURI(fURI);
workingCopy.getReferences().add(fEndpointDescriptor,reference);
}
}
The example is based on the https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation operation.
It requires to have the URI for the other element and the call would look like:
URI uri=new URI("https://clm.example.com:9448/qm/oslc_qm/contexts/_Lm2UIACBEeGZqMjM3RLKTw/resources/com.ibm.rqm.planning.VersionedTestCase/_dJzNgQCBEeGZqMjM3RLKTw");
IEndPointDescriptor endpoint = ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.TESTED_BY_TEST_CASE).getTargetEndPointDescriptor();
LinkURIOperation linkOp = new LinkURIOperation(endpoint,uri);
linkOp.run(workItem, monitor);
Or for other Link types:
IEndPointDescriptor endpoint = ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.AFFECTS_EXECUTION_RESULT).getTargetEndPointDescriptor();
LinkURIOperation linkOp = new LinkURIOperation(endpoint,uri);
linkOp.run(workItem, monitor);
Or
IEndPointDescriptor endpoint = ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.AFFECTED_BY_DEFECT).getTargetEndPointDescriptor();
LinkURIOperation linkOp = new LinkURIOperation(endpoint,uri);
linkOp.run(workItem, monitor);
Or any matching link type.
3 other answers
Comments
Hi Ralph, We are able to attach the test case to defect by using this. Thanks for that. But it was really hard coded URI. If I want to attach different test cases to different defects then at run time we need to get URI of these test cases. Is there any method where we can get this URI of the test case by using test case id / some other means? Sorry we are coming from ground level, so need your low level explanation.
you could build your test case-associated URIs by using the following pattern :
https://hostname:port/context_root/service/com.ibm.rqm.integration.service.IIntegrationService/resources/project_area_name/testcase/urn:com.ibm.rqm:testcase:test_case_ID
Regards,
Stephane Leroy
Jazz Jumpstart
Comments
Hi, I created defect and this defect is linked to test case pragmatically.. but from RQM test case results, defect section does not contain this actual defect. here I am not able to establish backward traceability. How can achieve this.?
Hi,
I'm not sure what you're exactly trying to do... but wonder if there is kind of mixing between the links to : - 1 - the development W.I. associated to the test case (CLM link "Tested by test case" ) and - 2 - a defect that would be created by a tester as a result of the execution of a test execution record ("Affect test result" link) ? These are very different stories.
If that's the case, you'd certainly go for programatically adding the defect at the test case execution level (versus your current linking to the Test Case) and then, you should now find your defect listed.
Unless I missed you scenario.
Stéphane
Hi, We are trying to create defects in RTC for test case failures in RQM. We are able to create the defects and mark the test case links for traceability. Now we want to link this defect in RQM test case results also. How can we achieve this pragmatically. we want both from RTC defect--> RQM test case and RQM test case results-->RTC defect. hope it clarifies.
Using the Plain Java Client Libraries/Java API you can create all link endpoint types available in RTC. So if the endpoint you want is available, you can do that. I would suggest to create this linkage to an RTC work item and then analyze the relationships. You can also determine the endpoint available from the WorkItemLinkTypes as shown above.
Can we add defects in "defects" section of RQM test case execution record? This is because when we link RQM test case in RTC defect, its not creating defect in "defects" section of RQM test case execution record where as if I add defects from RQM, it creates both forward and backward links..
Your question "Can we add defects in "defects" section of RQM test case execution record? This is because when we link RQM test case in RTC defect, its not creating defect in "defects" section of RQM test case execution record where as if I add defects from RQM, it creates both forward and backward links.."
My assumption would be that RQM shows data based on link types on the work item. I would check which links are available in a work item that shows up where you want it and to create the required links on the work item. Then it should show up where it needs to.
Comments
I tried all the link types available.. still its creating links on work item only but not on RQM execution result.
The Plain Java Client Libraries are for RTC, as far as I can tell. So you can use it to create links on RTC Work Items to any linkable URI type. But you can probably not use it to create links on RQM artifacts to other RQM artifacts. What are you trying?
See https://rsjazz.wordpress.com/2012/09/19/the-rtc-workitem-link-api-linking-workitems-to-other-elements/ for examples. You can create links on work items to test results and test execution results by providing the URI to said elements. This will create the back link on the QM artifact.
Best approach would be to create the links you want and then read the work item to figure the link type out.
I have created work Item in RTC. I want to link this work item to RQM Test Case execution result in "defect" section.
I am not able to open the link "https://rsjazz.wordpress.com/2012/09/19/the-rtc-workitem-link-api-linking-workitems-to-other-elements/"..
Please suggest.
See https://rsjazz.wordpress.com/2012/09/19/the-rtc-workitem-link-api-linking-workitems-to-other-elements/ for examples.
these are some of the endpoints. IEndPointDescriptor endpoint = ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.TESTED_BY_TEST_CASE).getTargetEndPointDescriptor(); IEndPointDescriptor endpoint1 = ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.AFFECTS_EXECUTION_RESULT).getTargetEndPointDescriptor(); IEndPointDescriptor endpoint3 = ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.AFFECTED_BY_DEFECT).getTargetEndPointDescriptor(); IEndPointDescriptor endpoint4 = ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.BLOCKS_EXECUTION_RECORD).getTargetEndPointDescriptor(); IEndPointDescriptor endpoint5 = ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.RELATED_EXECUTION_RECORD).getTargetEndPointDescriptor();
However, it does not seem to create the backlink in the QM item.
I tried all of these link types but does not create back linkage....Any idea how to create back link in RQM? do we have any other approach?
I think I remember I took some time to explore this and also had issues with the back links. I however did not have the time to take a closer look in the Eclipse client, how it is implemented there. I would suggest to plug-in spy the dialog in the Eclipse client and try to understand how it does the back linking. I am out of other ideas at this time.