{
    "$schema": "https://files-apicasystem-com.s3-eu-west-1.amazonaws.com/schemas/url-xi-schema-v1-0.json",
    "name": "Ticket Monster Get Event",
    "description": "Test case for ticket monster",
    "flowControl": "Chained Flow",
    "message":"Assert Test={{assertTest}}",
    
    "baseURL": "http://ticketmonster.apicasystem.com",
    "config": {},
    "includes": [
      
        {
            "name": "testdata",
            "scope": "project",
            "type": "data",
            "src": "my_test_data.json"
        },
        {
            "name": "defaultVariables",
            "scope": "project", 
            "type": "vars",
            "src": "default_test_vars.json"
        }
    ],
    "variables": [
        {
            "key": "assertTest",
            "type": "string",
            "usage": "input",
            "value": "ok",
            "description": "Assert test must be ok to pass"
        },
        
        {
            "key": "defIdleTime",
            "type": "number",
            "usage": "input",
            "value": 500,
            "validation": "value > 499 && value <= 15000"
        },
        {
            "key": "requestIdleTime",
            "type": "number",
            "usage": "input",
            "value": 500,
            "validation": "value > 499 && value <= 15000"
        },
        {
            "key": "sections",
            "type": "number",
            "usage": "inResponse",
            "value": 0
        },
        {
            "key": "capacity",
            "type": "number",
            "usage": "returnValue",
            "value": 0,
            "unit": "seats"
        },
        {
            "key": "venueName",
            "type": "string",
            "usage": "inResponse",
            "value": ""
        }
    ],
    "scripts": [
        {
            "scope": "before",
            "name":"Before test script",
            "script": [
                "var os=require('os')"
            ],
            "options": {
                "builtin": ["os"]
            }
        }

    ],
    "steps": [
        {
            "name": "Get Events",
            "idleBetweenRequests": "{{requestIdleTime}}",
            "scripts": [
                {
                    "scope": "before",
                    "name":"Set vars before",
                    "script": [
                        "let dummy=1",
                        "uxs.setVar('var1', new Date())",
                        "uxs.assert('foo' !== 'bar', 'foo is not bar')"
                    ]
                },
                {
                    "scope": "beforeEach",
                    "name":"Set vars before each",
                    "script": [
                        "let var1=uxs.getVar('var1')",
                        "logger.debug('var1',var1)"
                    ]
                },
                {
                    "scope": "afterEach",
                    "name":"Assert test",
                    "script": [
                        "let assertTest= uxs.getVar('assertTest')",
                        "uxs.expect(assertTest).to.equal('ok','Assert test variable should contain ok')"
                    ]
                }
            ],
            "requests": [
                {
                    "config": {
                        "method": "get",
                        "url": "/ticket-monster/rest/events/",
                        "params": {
                            "_": "{{$timestamp}}",
                            "mySecret":"{{mySecret}}"
                        }
                    },
                    "extractors": [
                        {
                            "type": "header",
                            "expression": "x-powered-by",
                            "variable": "xPoweredBy"
                        }
                    ],
                    "scripts": [
                        {
                            "scope": "after",
                            "name":"Get random event id",
                            "script": "getRandomEvent.js"
                            
                        }
                    ]
                }
            ]
        },
        {
            "name": "Get Shows",
            "requests": [
                {
                    "alwaysSaveResponse":true,
                    "config": {
                        "method": "get",
                        "url": "/ticket-monster/rest/shows",
                        "params": {
                            "_": "{{$timestamp}}",
                            "event": "{{eventId}}"
                        }
                    },
                    "extractors": [
                        {
                            "type": "jsonpath",
                            "expression": "$..venue.name",
                            "variable": "venueName"
                        },
                        {
                            "type": "jsonpath",
                            "expression": "$..venue.capacity",
                            "variable": "capacity"
                        },
                        {
                            "type": "jsonpath",
                            "expression": "$..venue.sections[*].id",
                            "variable": "sections",
                            "counter": true
                        }
                    ]
                }
            ]
        }
    ]
}