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

TestCase querying issue

 Hi,

Based on the  ETMSample from Lyo's OSLC-client lyo-samples/ETMSample.java at master · OSLC/lyo-samples (github.com), I wrote a query that should retrieve all the test cases of a given project area.

The result of this query is always an empty array, although there is actually 3 test cases in this project area.

Did I missed something ?

String catalogUrl = new RootServicesHelper( <My QM URL> , OSLCConstants.OSLC_QM_V2, client).getCatalogUrl();
String serviceProviderUrl = client.lookupServiceProviderUrl(catalogUrl,  <My QM project area> );
String queryCapability = client.lookupQueryCapability(serviceProviderUrl, OSLCConstants.OSLC_QM_V2, OSLCConstants.QM_TEST_CASE_QUERY);
OslcQueryParameters queryParams = new OslcQueryParameters();
queryParams.setPrefix("rdf=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>");
queryParams.setWhere("rdf:type=<http://open-services.net/ns/qm#TestCase>");
OslcQuery query = new OslcQuery(client, queryCapability, -1, queryParams);
OslcQueryResult result = query.submit();
Assertions.assertNotNull(result);
Assertions.assertEquals(3, result.getMembersUrls().length);

0 votes

Comments

The corresponding request that is actually generated is :

"https://<myhost>/qm/oslc_qm/contexts/_kMlv4BoCEey2zPn1rSWp-Q/resources/com.ibm.rqm.planning.VersionedTestCase?oslc.where=rdf%3Atype%3D%3Chttp%3A%2F%2Fopen-services.net%2Fns%2Fqm%23TestCase%3E&oslc.prefix=rdf%3D%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%3E"
The resulting status is "200 / OK" but the returned array is empty.



5 answers

Permanent link

 Hi


Since you are looking up a query for testcases (line3), I don't believe that you need to set the where & prefix parameters. (lines 5 & 6)

But this is a detail. 

Can you try this request from Postman (or some other tool) ? What response do you get? 
This will help us work out if the problem is on the Server or Client side.

I also wonder if you need any authentication to get access to this information. I don't see it in your code, and suspect that your target application expects it.

0 votes

Comments

Hi, thanks for answering.

Here is the content of the returned rdf data (had to remove the ns urls, comment was too long...)

<rdf:RDF><rdf:Description rdf:about="https://<host>/qm/oslc_qm/contexts/_kMlv4BoCEey2zPn1rSWp-Q/resources/com.ibm.rqm.planning.VersionedTestCase?oslc.where=rdf%3Atype%3D%3Chttp%3A%2F%2Fopen-services.net%2Fns%2Fqm%23TestCase%3E"><dcterms:title>QM V2 Test Case Query Results</dcterms:title><oslc:totalCount>0</oslc:totalCount<bp:containerSortPredicates>rqm_qm:orderIndex</bp:containerSortPredicates><dcterms:description>Results of a QM V2 Test Case query.</dcterms:description><rdf:type rdf:resource="http://open-services.net/ns/core#ResponseInfo"/></rdf:Description><rdf:Description rdf:about="https://<host>/qm/oslc_qm/contexts/_kMlv4BoCEey2zPn1rSWp-Q/resources/com.ibm.rqm.planning.VersionedTestCase"><rdf:type rdf:resource="http://open-services.net/ns/qm#TestCaseQuery"/></rdf:Description></rdf:RDF>

 

For the authentication, I used the same code as the ERMSample from Lyo samples (i.e OslcClient / JEEFormAuthenticator / SSLContextBuilder).

You will definitely require authentication, Jad. I think the Lyo samples perform the authentication in the beginning. You need to authenticate to find the project areas and to access any protected resource other than the rootservices.

I trust authentication is working, since the call client.lookupServiceProviderUrl() is working as expected. 


Permanent link

I see <oslc:totalCount>0</oslc:totalCount>. So the question is why is the server returning 0 entries. We can (for now) conclude that it is not a problem with your client/Lyo. It's either on the server side, or in your query.

 
Try removing the oslc.where and oslc.prefix paramemters. Will that give more answers? 

0 votes


Permanent link

 Hi Joao


As you're querying the query Capability specifically for test cases you don't need to add an oslc.where expression to find test cases, i.e. just the bare query URL will return all test cases in that context.

I thought that your oslc.where expression might have been the problem but when I use the exact same expression I get the same results as when not using oslc.where, so there may be something else not quite right with your query. 

Are you specifying the correct configuration (which specifies the component) where these three test cases exist -  usa a parameter like &oslc_config.context=https://SErVER:PORT/qm/oslc_config/resources/com.ibm.team.vvc.Configuration/_tS6zI0B1Eeus6Zk4qsm_Cw

This configuration URL can alternatively be specified using a header Configuration-Context

What version+ifix is your qm environment?

HTH
Ian

0 votes


Permanent link
Actually, keeping or removing the "prefix"/"where" from the query parameters didn't had any effect.

However, I added the following code, and now it works :
result.setMemberProperty(OSLCConstants.OSLC_QM_V2 + "testCase");

Thank you all for your answers.

Best regards,
Joao

0 votes

Comments

Strangely, I have (almost) the same code to retrieve all requirements from a "RM" project area and, in this case, I didn't have to set this "memberProperty"...

That must affect something about the query GET if it changes what ETM returns, perhaps it adds a needed header like OSLC-Core-Version: 2.0 - can you compare with/without it?

I'm not sure about that : the "memberProperty" is applied on the result after the query has been submitted


Permanent link

 @joao!


You added the "memberProperty" after the query has been submitted? Strange, because I thought the result from ETM was already empty upon submission. 

0 votes

Comments
the OslcQueryResult is the result of the "submit" method, I cannot set the "memberProperty" before retrieving the result.

but I agree, it's strange indeed.


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,074

Question asked: Sep 21 '21, 11:34 a.m.

Question was seen: 1,889 times

Last updated: Oct 07 '21, 4:27 a.m.

Confirmation Cancel Confirm