Forum Discussion

Mis3's avatar
Mis3
Frequent Contributor
4 years ago

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.

 

 

 

  • nmrao's avatar
    nmrao
    Champion Level 3

    - 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?

    • Mis3's avatar
      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's avatar
    nmrao
    Champion Level 3
    - 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.
    • Mis3's avatar
      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's avatar
        nmrao
        Champion Level 3
        What are you trying to achieve?
        Just renaming a project, doesn't make any difference.
        Sorry, Not sure what is the issue here?
    • nmrao's avatar
      nmrao
      Champion Level 3

      Mis3 

      Here is what I was suggesting previously