Wrong assertion type is picked for Iterables

without this change in the generated test when SpringCloudContractAssertions are used, we're casting the read element of the JSON to a Collection class whereas we should be casting to an Iterable.

fixes #381
This commit is contained in:
Marcin Grzejszczak
2017-08-28 15:38:51 +02:00
parent 7b144df594
commit 8d2549fecf
3 changed files with 17 additions and 17 deletions

View File

@@ -548,15 +548,15 @@ assertions and the one from matchers with an `and` section):
assertThat(parsedJson.read("$.time", String.class)).matches("(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])");
assertThat((Object) parsedJson.read("$.valueWithTypeMatch")).isInstanceOf(java.lang.String.class);
assertThat((Object) parsedJson.read("$.valueWithMin")).isInstanceOf(java.util.List.class);
assertThat(parsedJson.read("$.valueWithMin", java.util.Collection.class)).hasSizeGreaterThanOrEqualTo(1);
assertThat(parsedJson.read("$.valueWithMin", java.lang.Iterable.class)).hasSizeGreaterThanOrEqualTo(1);
assertThat((Object) parsedJson.read("$.valueWithMax")).isInstanceOf(java.util.List.class);
assertThat(parsedJson.read("$.valueWithMax", java.util.Collection.class)).hasSizeLessThanOrEqualTo(3);
assertThat(parsedJson.read("$.valueWithMax", java.lang.Iterable.class)).hasSizeLessThanOrEqualTo(3);
assertThat((Object) parsedJson.read("$.valueWithMinMax")).isInstanceOf(java.util.List.class);
assertThat(parsedJson.read("$.valueWithMinMax", java.util.Collection.class)).hasSizeBetween(1, 3);
assertThat(parsedJson.read("$.valueWithMinMax", java.lang.Iterable.class)).hasSizeBetween(1, 3);
assertThat((Object) parsedJson.read("$.valueWithMinEmpty")).isInstanceOf(java.util.List.class);
assertThat(parsedJson.read("$.valueWithMinEmpty", java.util.Collection.class)).hasSizeGreaterThanOrEqualTo(0);
assertThat(parsedJson.read("$.valueWithMinEmpty", java.lang.Iterable.class)).hasSizeGreaterThanOrEqualTo(0);
assertThat((Object) parsedJson.read("$.valueWithMaxEmpty")).isInstanceOf(java.util.List.class);
assertThat(parsedJson.read("$.valueWithMaxEmpty", java.util.Collection.class)).hasSizeLessThanOrEqualTo(0);
assertThat(parsedJson.read("$.valueWithMaxEmpty", java.lang.Iterable.class)).hasSizeLessThanOrEqualTo(0);
assertThatValueIsANumber(parsedJson.read("$.duck"));
----