Hi guys,
I want to draft an automation test code to test a plugin in vRO via rest api call to mock the GUI including Presentation. I know there is a class called PresentationService, but could not find some sample codes, anyone can help?
Another question is that I know the customer validation works when send rest api call, but how about other constrains? Do they still work? Like if the PreDefinedList is 1,2,3, how about sending the rest call using 4?
And curious that will GetAction run when using presentation via rest api call?
Thank you so much! I really appreciate it!
I wanted to automate form testing but found it too time consuming. Here is the thread Form test - automation
In the last response I listed the URLs I found wrt. the form data using Chrome developer tools. I don't think these API calls are exposed via vCACCAFE plugin so you need to make REST API calls.
Here is how to use vRA API via REST. I have a simple XaaS with two inputs: arg_in_0 and myList. If you add values to the POST data (props) you can see the updated values (if you have bindings between the form elements):
vrahost = vCACCAFEEntitiesFinder.getHost("0d0e47c0-94d9-4b11-892c-983a005fd6b0");
restClient = vrahost.createRestClient("com.vmware.csp.core.cafe.catalog.api");
props = new Properties({"headers":{"entries":[]}, "formValues":{"entries":[{"key":"description", "value":{"type":"string", "value":""}},{"key":"provider-arg_in_0"},{"key":"provider-mylist"}]}, "affectedElements":["provider-__ASD_PRESENTATION_INSTANCE"]})
responseContent = restClient.post("consumer/catalogItems/043c48be-dfa5-4e76-bc68-ffc57c3c7841/forms/request/update/?subtenantId=5d88b947-7fa4-4f43-bd22-f41329fdb016", props).getBodyAsJson()
System.log(JSON.stringify(responseContent, null, 2));
Thank you so much for your reply! I tried to use presentation service in Java sdk, it could run actions for hidden parameters now, but still could not validate the constrains before sending api call to execute workflow.
Just tested my XaaS with an input constraint (on input min length) and it did not generate any new API request, probably handled on client side JS. What validation did you try to run, and on what form?
- Advanced Service Designer
- Advanced Service Designer with Custom Form
- XaaS
Constant constraints, external vRO action, or vRO presentation validation?
I tried to run validation on vRO presentation layer, no matter how to get the input constraints. For example, the predefined list of this field is array [1,2,3], then if we pass 4, do not know if it will find it is not in the range. Or get the predefined list via GetAction.
Well, according to Developer tools it is the very same request I've shown above:
POST consumer/catalogItems/043c48be-dfa5-4e76-bc68-ffc57c3c7841/forms/request/update/?subtenantId=5d88b947-7fa4-4f43-bd22-f41329fdb016
DATA: {"headers":{"entries":[]}, "formValues":{"entries":[{"key":"description", "value":{"type":"string", "value":""}},{"key":"provider-arg_in_0", "value":{"type":"string", "value":"11111111111111111111111111111"}},{"key":"provider-mylist", "value":{"type":"string", "value":"1"}},{"key":"provider-__ASD_PRESENTATION_INSTANCE", "value":{"type":"string", "value":"e463f703-cabb-405b-96fd-5e20d3383e33"}}]}, "affectedElements":["provider-arg_in_0"]}
Response:
{"elementUpdates":[{" ... "errors":["Too long!"]}]}"
(My validation action in vRO presentation was checking if the input is longer than 10 letters and gave the error above.)
For predefined lists of input this will not validate, I'm afraid (maybe I'm wrong...)
Is this a customer validation in your vRO presentation?
That is right, by a vRO action.
I can also see the XaaS predefined values in the response (these are not validated or defined in vRO presentation):
{
"id": "provider-mylist",
"detailLayout": null,
"facetValues": {
"facets": [
{
"type": "resetValue",
"value": {
"type": "string",
"value": "1"
}
},
{
"type": "editable",
"value": {
"type": "boolean",
"value": true
}
}
]
},
"extensionRendererContext": null,
"permissibleValues": [
{
"underlyingValue": {
"type": "string",
"value": "1"
},
"label": "first"
},
{
"underlyingValue": {
"type": "string",
"value": "2"
},
"label": "second"
}
],
"errors": null
},
Yeah, I tried in Java code, no matter if I use presentation service, customer validation has always been triggered . Read another thread here before secure string maximum string length validate issue , if we add X-Skip-Validation-Of parameters in header, will skip the validation.