It's all about the answers!

Ask a question

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


Catalin Morcan (132) | asked May 03 '23, 2:26 a.m.
closed May 04 '23, 7:09 a.m. by Ralph Schoon (63.5k33646)

 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.


Comments
Ralph Schoon commented May 03 '23, 2:51 a.m. | edited May 03 '23, 2:52 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 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.


Catalin Morcan commented May 03 '23, 9:35 a.m.

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


Ralph Schoon commented May 03 '23, 9:43 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


Catalin Morcan commented May 03 '23, 10:20 a.m.

 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?


Ralph Schoon commented May 03 '23, 10:26 a.m. | edited May 03 '23, 10:27 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.   


Catalin Morcan commented May 03 '23, 10:34 a.m.

I tried it with Postman and this is what I got


Catalin Morcan commented May 03 '23, 10:34 a.m.

 And these were the headers I used:


Configuration-Context:_xOWvEKfdEeur-Yd2h1oZug 


Ralph Schoon commented May 04 '23, 2:01 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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


Catalin Morcan commented May 04 '23, 2:26 a.m.

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


1
Ian Barnard commented May 04 '23, 4:05 a.m. | edited May 04 '23, 4:06 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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


Ralph Schoon commented May 04 '23, 4:34 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Catalin Morcan commented May 04 '23, 6:08 a.m.

 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
Ralph Schoon (63.5k33646) | answered May 04 '23, 7:09 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited May 04 '23, 7:19 a.m.

 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