OslcQueryResult .getMembers() and .getMembersUrls() return null

Hello,

I’m trying to query Test Cases from Jazz based on the examples provided in:
https://github.com/OSLC/lyo-samples/blob/master/oslc4j-client-samples/src/main/java/org/eclipse/lyo/oslc4j/client/samples/ETMSample.java

I tried to use .getMembers() and .getMembersUrls() functions but they return null. Using .getRawResponse() I managed to make it work, but this solution does not support pagination and I want to cover this case as well.

My code looks like this:

    String serviceProviderUrl = oslcClient.lookupServiceProviderUrl(catalogUrl, projectAreaName);
    String queryCapability = oslcClient.lookupQueryCapability(
            serviceProviderUrl, OSLCConstants.OSLC_QM_V2,
            OSLCConstants.QM_TEST_CASE_QUERY);

    OslcQueryParameters queryParams = new OslcQueryParameters();
    if(conditions != null){
        queryParams.setWhere(conditions);
    }
    if(testCaseProperties != null){
        queryParams.setSelect(testCaseProperties);
    }

    OslcQuery query = new OslcQuery(oslcClient, queryCapability, queryParams);
    OslcQueryResult result = query.submit();

    testCases = processPagedQueryResult(result);

and processPagedQueryResult function:

private static List<TestCase> processPagedQueryResult(OslcQueryResult result){
    List<TestCase> testCases = new ArrayList<>();

    int page = 1;
    do {

        for (TestCase testCase : result.getMembers(TestCase.class)) {
            testCases.add(testCase);
        }

        if (result.hasNext()) {
            result = result.next();
            page++;
        } else {
            break;
        }
    } while(true);

    return testCases;
}

Did I miss something?

I am also experiencing something similar when I want to get the Related Change Requests (using .getRelatedChangeRequests()) from a Test Plan (it also returns a null list even though in the Jazz interface I can see the links in the Test Plan)

Thank you,
Ana

1 Like

Hello Ana,

Did you run https://github.com/OSLC/lyo-samples/blob/master/oslc4j-client-samples/src/main/java/org/eclipse/lyo/oslc4j/client/samples/ETMSample.java exactly or change it in some way?

I just tried it just now with a debugger and it seems to return some valid values for both methods:

You may need to check the configuration of your server and the code of the org.eclipse.lyo.client.query.OslcQueryResult#getMembersUrls method where you can see that it will uses org.eclipse.lyo.client.query.OslcQueryResult#getMemberSelector to select a membership property (org.eclipse.lyo.client.query.OslcQueryResult#DEFAULT_MEMBER_PROPERTY by default).

–Andrew

1 Like