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

[closed] Setting Result Details of RQM Test Result using OSLC API

 Hello.


Can someone provide an example of how to write inside the Result Details of the Test Result section using the OSLC API?
 I tried to recreate the structure of extended Properties I have seen inside a Test Result I fetched from ETM using the API, but something might be missing.
I am trying with this code and when I check in ETM the Test Result is created and it looks ok but the Result Details section is empty.

Dictionary<QName, object> extProp = new Dictionary<QName, object>();
QName qName = new QName("http://jazz.net/ns/qm/rqm", "richTextSession","rqm_qm");
List<AnyResource> anyResources= new List<AnyResource>();

AnyResource anyResource = new AnyResource();
                
IDictionary<QName, object> insideExtProp = new Dictionary<QName, object>();
QName detailsContent = new QName("http://jazz.net/ns/qm/rqm", "content", "rqm_qm");
string content = "Details Content";
QName detailsTitle = new QName("http://purl.org/dc/terms/", "title", "dcterms");
string dTitle = "Notes";

QName detailsIdentifier = new QName("http://purl.org/dc/terms/", "identifier", "dcterms");
string identifier = "com.ibm.rqm.execution.editor.section.tcResultNotes";
insideExtProp.Add(detailsContent, content);
insideExtProp.Add(detailsIdentifier, identifier);
insideExtProp.Add(detailsTitle, dTitle);

anyResource.SetExtendedProperties(insideExtProp);
anyResource.SetTypes(new List<Uri>() { new Uri("http://jazz.net/ns/qm/rqm#RichTextSection") });
anyResources.Add(anyResource);
extProp.Add(qName, anyResources);
testResult.SetExtendedProperties(extProp);

String testResultCreation = client.LookupCreationFactory(
                    serviceProviderUrl, OSLCConstants.OSLC_QM_V2,
                    testResult.GetRdfTypes()[0].ToString());
HttpResponseMessage testResultCreationResponse = client.CreateResource(
                    testResultCreation, testResult,
                    OslcMediaType.APPLICATION_RDF_XML);


I would be amazingly grateful for any advice.

0 votes

Comments

 I can not provide an example that would fit your example. I can only provide with approaches that have helped me.

  1. Use RESTClient or Postman. 
  2. Authenticate
  3. Get the creation factory and the resource shape for the item.
  4. Get a minimal example.
  5. Use the minimal example to create an item.
  6. Remove unnecessary attributes to get the minimal data needed.

To create a test case I had to provide the title, the description, the RDF.type and the suspect state. Once you can do it there, you can write an app for it.

Thank you for responding. 

I understand your point of view but I also have no idea of how to use Postman to set it.

I know the richTextSession is associated with the Result Details, but if I query for Test Results the richTextSection only contains something like this:


I can't see here the text that I see inside the Result Details in the ALM when I open it in my browser

You assume that the API has to directly return the same data you see in the UI. I can assure you here and right now, that this is definitely a wrong assumption. Dependent on which API and which part of the API, you might only get links/references to other stuff. If you need the details about the linked element, you need to do another GET to get it. 

OSLC (assuming this is the OSLC API) works based on resources and links between resources. The resource contains its attributes. Basic attributes such as text strings are directly returned in the resource. Complex items like links to other items or enumerations, you would have to GET to get at the values.

 Ok. And then if I understand it right I should try a GET operation on the link that I pasted in the comment above.


But, the "<rqm_qm" type of resources cannot be accessed by OSLC API. Or am I wrong?

I would try to GET that resource. I do not know if OSLC would or would not consider this as an OSLC resource or not. I am not an ETM OSLC expert, I just did some examples.

Without further investigation I can even not say if you are using OSLC QM API. You send the headers, that is for sure, but the URI'S are not exposed so I couldn't tell if I wanted. 

If you used RESTClient in Firefox and authenticated against the RM, you could just paste the reference URI in there, add the headers and try to GET the resources.

Note POST is different and requires additional headers e.g. X-Jazz-CSRF-Prevent.   

I tried it with Postman and this is what I got

 And these were the headers I used:


Configuration-Context:_xOWvEKfdEeur-Yd2h1oZug 

 URL is missing. The return is an HTML page with a redirect. So something is wrong. Authenticated?

Yes. I am authenticated. 

I thought it might be because the OSLC API might not support this operation. But I can't find this information in the wiki

In the browser you're using RESTClient, make sure you are logged in to your server. Also the response is HTML - you probably need to add header Accept: application/rdf+xml to your GET so the result is XML RDF

1 vote

 The header was the issue, I thought I already had it, but I was wrong. 

I got the resource.
Thank you 

showing 5 of 12 show 7 more comments

The question has been closed for the following reason: "The question is answered, right answer was accepted" by rschoon May 04 '23, 7:09 a.m.

Accepted answer

Permanent link

 The missing issue was - see Ians Comment.


Also the response is HTML - you probably need to add header Accept: application/rdf+xml to your GET so the result is XML RDF 

Ralph Schoon selected this answer as the correct answer

0 votes

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
× 10,938

Question asked: May 03 '23, 2:26 a.m.

Question was seen: 803 times

Last updated: May 04 '23, 7:19 a.m.

Confirmation Cancel Confirm