Ask a Question

JSON Project

Mis3
Frequent Contributor

JSON Project

Now that my Groovy script is working, I am working to add the script to other projects.  Most of my projects are XML so they are straight forward.  I am one project which is JSON and I am not sure how to create testStep for it.

 

In this JSON, the working API has the following attributes:

1.  Method: PUT

2.  Endpoint: https://10.14.151.51:8443

3.  Resource: /rem/sentinel/api/hssdata/subscriberdata/sip:+13313140097@ims.mnc130.mcc302.3gppnetwork.org

4.  Parameters: ?selectionKey=Metaswitch::::&rhinoInstanceId=Local

 

Screenshot is attached.   Tel-Number is the only input parameter to put in the Resource and the JSON body.  So, my plan is to create a Groovy to read a file of Tel-number and then execute the testStep one by one.

Can I create a Groovy for JSON?   I tried and somehow I cannot using property for Tel-Number in the Resource field.

Any help is appreciated.

 

 

 

13 REPLIES 13
nmrao
Community Hero

- Where is Telephone number? Is it in the url? or is it in the request body?
- I see it xml payload. Where is the json?

- Are the both query parameters fixed always?



Regards,
Rao.
Mis3
Frequent Contributor

- Where is Telephone number? Is it in the url? or is it in the request body?

The Tel number is in both the Resource line and in the request body.  It is the same value in both places.


- I see it xml payload. Where is the json?

The payload (request body attached).  It is in JSON, right?

 

- Are the both query parameters fixed always?

Yes, this is the only variable.  The Groovy script will read and inserts it into the teststep. 

nmrao
Community Hero

- Indeed it is xml, no json
- Not sure where do you need groovy and why?
- You can change the resource from
sip:-13313140097
to
sip:${#TestCase#PHONE_NUMBER}
- And add the PHONE_NUMBER in test case custom property with value. Change each time if you want to send for different number. Use the same way in the pay load as well
- Even for query parameters, change the values to use custom properties as suggested in the above.


Regards,
Rao.
Mis3
Frequent Contributor

I input the TAS project and renamed it to TAS-Groovy.   I then created the TestSuite and TestCase.  I then copied a working request (PT-TAS-PUT-CFU) as the first TestStep (PT-TAS-PUT-CFU-1).  

Somehow the screen of PT-AS-PUT-CFU-1 is different than PT-TAS-PUT-CFU.  I wanted to modify the Resource field to a custom property but it would not let me edit the filed.   Also, Method field is different as well.   Please refer to the attached screenshot (please zoom in, there are 2 API displayed in SoapUI).  

Not sure how to proceed now.  Maybe I should not copy in the create-testcase.  

 

nmrao
Community Hero

What are you trying to achieve?
Just renaming a project, doesn't make any difference.
Sorry, Not sure what is the issue here?


Regards,
Rao.
nmrao
Community Hero

@Mis3 

Here is what I was suggesting previously

 

nmrao_0-1625222304696.png

 



Regards,
Rao.
nmrao
Community Hero

Here is project which you can take a look if needed.
https://gist.github.com/nmrao/3e001382bc107751bddeb84bf641cdc4


Regards,
Rao.
nmrao
Community Hero

Now you should be able to replace different values for PHONE_NUMBER and other properties defined at custom properties at test case. And run multiple tests.


Regards,
Rao.
Mis3
Frequent Contributor

Somehow my screen (screen-1 below) is not the same as yours.  

In your screen and in my working API (screen-2 below), there is a Endpoint and in my screen, it is called Request URL.

There is a Resource filed in your screen, in my screen there is no Resource field.

Also, the property table has different number of columns.

When I created the teststep, I chose http.  Is this right?   If I can get a screen like screen-2, I can replace the Tel-Number by $(#TestCase#Tel-Number).

 

Mis3_1-1625241319325.png

 

Mis3_2-1625242019815.png

 

cancel
Showing results for 
Search instead for 
Did you mean: