From 91688f09dc57ac879a0b9e15faa88016ee69dbc7 Mon Sep 17 00:00:00 2001 From: buildmaster Date: Fri, 10 Feb 2017 15:18:24 +0000 Subject: [PATCH] Sync docs from master to gh-pages --- spring-cloud-contract.html | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/spring-cloud-contract.html b/spring-cloud-contract.html index aa5b292da7..fb249757bd 100644 --- a/spring-cloud-contract.html +++ b/spring-cloud-contract.html @@ -6851,6 +6851,12 @@ be of the same type as the type defined in the body of the response in the contr 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.

    +
  • @@ -6949,6 +6955,8 @@ That way you can assert on the size of the collection.

    // results in verification of size of array (max 0) maxOccurrence(0) }) + // will execute a method `assertThatValueIsANumber` + jsonPath('$.duck', byCommand('assertThatValueIsANumber($it)')) } headers { contentType(applicationJson()) @@ -7019,11 +7027,16 @@ 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).size()).isGreaterThanOrEqualTo(1); + assertThat(parsedJson.read("$.valueWithMin", java.util.Collection.class)).hasSizeGreaterThanOrEqualTo(1); assertThat((Object) parsedJson.read("$.valueWithMax")).isInstanceOf(java.util.List.class); - assertThat(parsedJson.read("$.valueWithMax", java.util.Collection.class).size()).isLessThanOrEqualTo(3); + assertThat(parsedJson.read("$.valueWithMax", java.util.Collection.class)).hasSizeLessThanOrEqualTo(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)).hasSizeBetween(1, 3); + assertThat((Object) parsedJson.read("$.valueWithMinEmpty")).isInstanceOf(java.util.List.class); + assertThat(parsedJson.read("$.valueWithMinEmpty", java.util.Collection.class)).hasSizeGreaterThanOrEqualTo(0); + assertThat((Object) parsedJson.read("$.valueWithMaxEmpty")).isInstanceOf(java.util.List.class); + assertThat(parsedJson.read("$.valueWithMaxEmpty", java.util.Collection.class)).hasSizeLessThanOrEqualTo(0); + assertThatValueIsANumber(parsedJson.read("$.duck"));