swangkkb / rest-assured

Automatically exported from code.google.com/p/rest-assured
0 stars 0 forks source link

Incorrect path evaluation that converted String to Long #333

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. REST response payload contains the following:
        "items": [
            {
                "createdTime": 1400539383298,
                "lastUpdatedTime": 1400539383298,
                "objectKey": {
                    "keyMap": {
                        "GUID": "20140519154303298"  <== String
                    }
                }
            },
            {
                "createdTime": 1400539383330,
                "lastUpdatedTime": 1400539383330,
                "objectKey": {
                    "keyMap": {
                        "GUID": "20140519154303330"  <== String
                    }
                }
            },
            {
                "createdTime": 1400539383359,
                "lastUpdatedTime": 1400539383359,
                "objectKey": {
                    "keyMap": {
                        "GUID": "20140519154303359"  <== String
                    }
                }
            }
        }

2. Using below to check:
      assertThat().
        body("items.objectKey.keyMap.GUID", arrayContaining(myItems));

3. myItems is of String[]:["20140519154303298", "20140519154303330", 
"20140519154303359"]

What is the expected output? What do you see instead?
expected output should be "true".
But the path evaluation produced an array of Long instead of String:
>>  Expected: ["20140519154303298", "20140519154303330", "20140519154303359"]
>>  Actual: [20140519154303298, 20140519154303330, 20140519154303359]

What version of the product are you using? On what operating system?
version 2.3.1

Please provide any additional information below.

Original issue reported on code.google.com by danielch...@gmail.com on 19 May 2014 at 11:03

GoogleCodeExporter commented 9 years ago
That's (probably) because you're using "arrayContaining". What's returned from 
JsonPath is not an array but a list so change it to "hasItems" and it ought to 
work.

Original comment by johan.ha...@gmail.com on 20 May 2014 at 9:01