Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Reading Test Case id from Test Result using OSLC

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

0 votes



2 answers

Permanent link

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

1 vote


Permanent link

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

0 votes

Comments

 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 log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 11,051

Question asked: Dec 08 '17, 4:56 a.m.

Question was seen: 3,766 times

Last updated: Dec 20 '17, 10:57 p.m.

Confirmation Cancel Confirm