[closed] Setting Result Details of RQM Test Result using OSLC API
Catalin Morcan (13●2)
| asked May 03 '23, 2:26 a.m.
closed May 04 '23, 7:09 a.m. by Ralph Schoon (63.5k●3●36●46) 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.
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
Ralph Schoon (63.5k●3●36●46)
| 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.
Ralph Schoon selected this answer as the correct answer
|
Comments
I can not provide an example that would fit your example. I can only provide with approaches that have helped me.
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.
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.
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:
URL is missing. The return is an HTML page with a redirect. So something is wrong. Authenticated?
Yes. I am authenticated.
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
See https://rsjazz.wordpress.com/2019/05/13/using-a-rest-client-to-authenticate-to-elm-clm-applications/
The header was the issue, I thought I already had it, but I was wrong.