0

I'm trying to write a parameterized test using a csv file as the data source. I would like to check the json node for a number if keys, if the are present. Here my first attempt:

@ParameterizedTest(name = "{index} => name={0}")
@CsvFileSource(resources = "fields.csv", numLinesToSkip = 0)
void verifyFields(String name) {
    Response response = getResponse(); // rest - assured query response
    response
            .then()
            .assertThat()
            .body("components.any { it.containsKey('" + name + "') }", is(true));

But I keep getting the following error when trying to verify that the key xzy is present:

 Caused by: groovy.lang.MissingMethodException: No signature of method: java.util.HashMap$Node.containsKey() is applicable for argument types: (String) values: [xyz]

I'm not sure I'm using the groovy statement correctly. I'm just trying to use the parameters from the file.

Shejo284
  • 4,541
  • 6
  • 32
  • 44
  • 1
    Maybe this GPath can help `components.keySet().contains('fieldName')` – bhusak Oct 08 '19 at 23:53
  • 1
    Also take a look at https://stackoverflow.com/questions/54089850/using-rest-assured-how-can-i-check-if-a-field-is-present-or-not-in-an-array-of/54093698#54093698 – bhusak Oct 09 '19 at 01:10

0 Answers0