It's all about the answers!

Ask a question

Reading Test Case id from Test Result using OSLC


Vaibhav S (106348) | asked Dec 08 '17, 4:56 a.m.

Hi,
I am able to create TestResult object and retrive the values from it as

 TestResult testResult= response.getEntity(TestResult.class);
 testResult.getTitle()  and so on ...

Now i need to get the Test Case Dd from it which is not happening. From rest client i am able to view the ID in Short Identifier tag as :

<oslc_qm:TestResult rdf:about="https://rb-alm...................>
       <oslc:shortId rdf:datatype="http://www.w3.org/2001/XMLSchema#int">7292</oslc:shortId>
</oslc_qm:TestResult rdf:about="https://rb-alm...................>

but testResult.getShortIdentifier() method is not visible.

Is this method not exposed through OSLC.

Please let me know. If not then how do we read the TC IDs.

Thanks
Vaibhav

2 answers



permanent link
Vaibhav S (106348) | answered Dec 20 '17, 10:57 p.m.

Hi,

I used following code block for the same. it works fine:

response = client.getResource(resultsUrl[i], OSLCConstants.CT_RDF);
             
              ClientResponse tempResponseVar2 = clientTestCase.getResource(resultsUrl[i], OSLCConstants.CT_RDF);
             
             InputStream inputStream =  response.getEntity(InputStream.class);
             
             testCase= tempResponseVar2.getEntity(TestCase.class);
         
             InputSource inputSource = new InputSource(inputStream);
                      
             DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
             DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
             
             Document document = dBuilder.parse(inputSource);
             
             NodeList element = document.getElementsByTagName("rqm_qm:shortIdentifier");
                 
             String testCaseId = null ;
             for (int p = 0; p < element.getLength(); p++) {
                 
                 System.out.println("Short Identifier Value is : " + element.item(p).getTextContent());
                 testCaseId = element.item(p).getTextContent();
             }
                 
             response.consumeContent();


Thanks
Vaibhav


permanent link
abhishek gour (3812) | answered Dec 11 '17, 9:01 a.m.

A simple OSLC based GET on Test case would return a Test Case Shape. ( you can get a sample OSLC XML from following link - http://open-services.net/bin/view/Main/QmSpecificationV2Samples or http://open-services.net/bin/view/Main/QmSpecificationV2Shapes).

Based on that - I think you should have been looking for getIdentifier() routine ( because OSLC shape defines Identifier as per that specification).

You can try something like this - 
private static void printTestResultInfo(TestResult tr) {
//See the OSLC4J TestResult class for a full list of attributes you can access.
if (tr != null) {
System.out.println("ID: " + tr.getIdentifier() + ", Title: " + tr.getTitle() + ", Status: " + tr.getStatus());
}
}

I believe you may have been using some sort of ready to use SDk to perform these OSLC operation. Are you using Eclipse LYO?

Thanks,
Abhishek


Comments
Vaibhav S commented Dec 18 '17, 3:11 a.m. | edited Dec 18 '17, 3:12 a.m.

 Hi Abhishek,

getIdentifier() does not return the Test Case id but the URL.

I need to retrive the id. Any way of doing it please let me know

Thanks again
Vaibhav

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.