From a6d7d24c2432bd1e96aa8d20d35f4ac5b6927787 Mon Sep 17 00:00:00 2001
From: buildmaster byType can take a closure where you can set minOccurrence and maxOccurrence.
That way you can assert on the size of the collection.
byCommand(…) - the value taken from the response via the provided JSON Path will be
+passed as an input to the custom method that you’re providing. E.g. byCommand('foo($it)')
+will result in calling a foo method to which the value matching the JSON Path will get
+ passed.
and section):
assertThat((Object) parsedJson.read("$.valueWithMax")).isInstanceOf(java.util.List.class);
assertThat(parsedJson.read("$.valueWithMax", java.util.Collection.class).size()).isLessThanOrEqualTo(3);
assertThat((Object) parsedJson.read("$.valueWithMinMax")).isInstanceOf(java.util.List.class);
- assertThat(parsedJson.read("$.valueWithMinMax", java.util.Collection.class).size()).isBetween(1, 3);
+ assertThat(parsedJson.read("$.valueWithMinMax", java.util.Collection.class).size()).isBetween(1, 3);
+ assertThat((Object) parsedJson.read("$.valueWithMinEmpty")).isInstanceOf(java.util.List.class);
+ assertThat(parsedJson.read("$.valueWithMinEmpty", java.util.Collection.class).size()).isGreaterThanOrEqualTo(0);
+ assertThat((Object) parsedJson.read("$.valueWithMaxEmpty")).isInstanceOf(java.util.List.class);
+ assertThat(parsedJson.read("$.valueWithMaxEmpty", java.util.Collection.class).size()).isLessThanOrEqualTo(0);
+ assertThatValueIsANumber(parsedJson.read("$.duck"));