Forum Discussion

freaky007's avatar
freaky007
New Contributor
11 years ago

Pass complex json object from teststep to teststep

hi

i am wondering if there is a way to pass complex json objects, loaded via a GroovyDataSource to test steps.
it seems that storing the json in the test step custom attributes is not working.

small json example, the real ones are 3-5 times bigger.
each main attributes should be used by single test step calling a restful webservice composed out of the data from the json.
>>>>>>
{
"CPEDefaultATAGroup": [
{
"CFS": "AXS-005-xxxxxx",
"Description": "CPEDescription",
"DeviceType": "Media5-Mediatrix4102",
"ForcePIN": "12345678",
"LocationServiceId": "AXS-004-xxxxxx"
},
{
"CFS": "AXS-005-xxxxxx",
"Description": "CPEDescription",
"DeviceType": "Media5-Mediatrix4102",
"ForcePIN": "12345678",
"LocationServiceId": "AXS-004-xxxxxx"
},
{
"CFS": "AXS-005-xxxxxx",
"Description": "CPEDescription",
"DeviceType": "Media5-Mediatrix4102",
"ForcePIN": "12345678",
"LocationServiceId": "AXS-004-xxxxxx"
}
],
"DDI": {
"CFS": "AXS-021-xxxxxx",
"EnterpriseID": 200020,
"PhoneNumberStart": "+41993550310",
"RangeLength": 20
},
"Enterprise": {
"CFS": "AXS-001-xxxxxx",
"City": "Gallizia",
"EnterpriseID": 200020,
"HouseNumber": "42a",
"Name": "Hinkelstein GmbH",
"Street": "Gallierstrasse",
"Zip": "6666"
},
"FirmenIndex": 880088060,
"Groups": [
{
"CFS": "AXS-004-xxxxxx",
"City": "Berlin",
"EnterpriseServiceID": "AXS-001-xxxxxx",
"GroupID": 200021,
"GroupName": "Berlin",
"HouseNumber": "102",
"Scn": 200021,
"Street": "Werkgasse",
"Zip": "12345"
},
{
"CFS": "AXS-004-xxxxxx",
"City": "Biel",
"EnterpriseServiceID": "AXS-001-xxxxxx",
"GroupID": 200022,
"GroupName": "Munich",
"HouseNumber": "10",
"Scn": 200022,
"Street": "Seeweg",
"Zip": "67890"
}
],
"VLAN": {
"CFS": "AXS-003-xxxxxx",
"CVLanID": 403,
"EnterpriseServiceID": "AXS-001-xxxxxx"
},
"tpVoipNrStatus-StammnrGroup": [
{
"EnterpriseServiceId": "AXS-001-K00001",
"PhoneNumber": "+490123456789"
},
{
"EnterpriseServiceId": "AXS-001-K00001",
"PhoneNumber": "+490123456789"
}
],
"User": [
{
"CFS": "AXS-006-xxxxxx",
"Firstname": "Asterix",
"Lastname": "der Gallier",
"ExtensionReservationId": "AXS-004-xxxxxx:311",
"LocationServiceId": "AXS-004-xxxxxx",
"Language": "de"
,"UserCpeRelation": "AXS-005-K00008"
},
{
"CFS": "AXS-006-xxxxxx",
"Firstname": "Obelix",
"Lastname": "der Gallier",
"ExtensionReservationId": "AXS-004-xxxxxx:312",
"LocationServiceId": "AXS-004-xxxxxx",
"Language": "fr"
}
]
,"tpUserCpeRelation-G1U1": [{"CpeServiceId": "AXS-005-K00008", "UserServiceId": "AXS-006-K00007"}, {"CpeServiceId": "AXS-005-K00008", "UserServiceId": "AXS-006-K00007"}]
}
<<<<<<

any idea?

thanks
salids reto
  • Hi,

    Are you not able to return the property (JSON string)? The DataSource property will be a string.
    Please check that is what your DataSource is returning and if you have any error in the log, please include it.

    Thanks,

    Giscard
    SmartBear Support
  • freaky007's avatar
    freaky007
    New Contributor
    hi, just added a little test project to show what i have in mind.
    somehow the toString method is not creating a proper json object.

    any idea of how i could pass / axess the parts of the json in the teststeps?

    thanks
  • Hi,

    You would have to create a property in the Groovy datasource that has the value of exactly what you want to access in the JSON, or create a Groovy test step that will parse the property in the Groovy datasource and set it to a new property to use in another request test step. You could use the property transfer test step with JsonPath to use it in a Request test step, however, the JSON being returned from the toString method with JsonSlurper is invalid. Therefore you can not use the JsonPath on invalid JSON content. You can check by copying the JSON that is being logged and validate in http://jsonlint.com/.


    Regards,
    Marcus
    SmartBear Support