1

Іssue in the next.

I have a feature response which I check according to schema validation

   {
    "name": "#string",
    "director_first_name": "##string",
    "director_last_name": "##string",
    "director_phone": "##string",
    "director_email": "##string",
    "language": {
        "id": "#uuid",
        "name": "#string",
        "code": "#string? _.length == 2"
    }
   }

Also I have additional feature, which has list of languages

[
    {
        "id": "fde1312f-2ab2-4fdf-a4f3-a7095dd89a4d",
        "name": "English",
        "code": "EN"
    },
    {
        "id": "0d4c6626-1010-4dda-8721-665071ec3b28",
        "name": "Swedish",
        "code": "SV"
    }
] 

And I need to check the next

  1. Need to take response.language.id from first response and check if this id is represented in the second response. In this case I need to call this second feature.
  2. If it is represented, need to match if id, name, code which belong to first reponse the same as in the second response.
Holgar
  • 91
  • 5
  • Done @PeterThomas. Sorry for this, I'm a newbie. Could you help me with my problem above, pls? – Holgar May 18 '22 at 10:50

1 Answers1

0

You can do this in one line. I leave it as an exercise to you to get the data from a second feature file if you wish.

* def data =
"""
[
    {
        "id": "fde1312f-2ab2-4fdf-a4f3-a7095dd89a4d",
        "name": "English",
        "code": "EN"
    },
    {
        "id": "0d4c6626-1010-4dda-8721-665071ec3b28",
        "name": "Swedish",
        "code": "SV"
    }
]
"""
* def response =
"""
{
    "language": {
        "id": "fde1312f-2ab2-4fdf-a4f3-a7095dd89a4d",
        "name": "English",
        "code": "EN"
    }
}
"""
* match response.language == data.find(x => x.code == response.language.code)

Take some time to read other answers (and follow the links) for ideas: https://stackoverflow.com/a/70055035/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248