diff --git a/compatibility-suite/pact-compatibility-suite/features/V3/generators.feature b/compatibility-suite/pact-compatibility-suite/features/V3/generators.feature index 96c51ba32..13aa7bb20 100644 --- a/compatibility-suite/pact-compatibility-suite/features/V3/generators.feature +++ b/compatibility-suite/pact-compatibility-suite/features/V3/generators.feature @@ -69,21 +69,3 @@ Feature: V3 era Generators | file: basic.json | boolean-generator.json | When the request is prepared for use Then the body value for "$.one" will have been replaced with a "boolean" - - Scenario: Supports a Provider State generator - Given a request configured with the following generators: - | body | generators | - | file: basic.json | providerstate-generator.json | - And the generator test mode is set as "Provider" - When the request is prepared for use with a "providerState" context: - | { "id": 1000 } | - Then the body value for "$.one" will have been replaced with "1000" - - Scenario: Supports a Mock server URL generator - Given a request configured with the following generators: - | body | generators | - | file: basic.json | mockserver-generator.json | - And the generator test mode is set as "Consumer" - When the request is prepared for use with a "mockServer" context: - | { "href": "http://somewhere.world" } | - Then the body value for "$.one" will have been replaced with "http://somewhere.world/a" diff --git a/compatibility-suite/pact-compatibility-suite/features/V4/generators.feature b/compatibility-suite/pact-compatibility-suite/features/V4/generators.feature new file mode 100644 index 000000000..d9abdbf54 --- /dev/null +++ b/compatibility-suite/pact-compatibility-suite/features/V4/generators.feature @@ -0,0 +1,47 @@ +Feature: V4 era Generators + + Scenario: Supports a Provider State generator + Given a request configured with the following generators: + | body | generators | + | file: basic.json | providerstate-generator.json | + And the generator test mode is set as "Provider" + When the request is prepared for use with a "providerState" context: + | { "id": 1000 } | + Then the body value for "$.one" will have been replaced with "1000" + + Scenario: Supports a Mock server URL generator + Given a request configured with the following generators: + | body | generators | + | file: basic.json | mockserver-generator.json | + And the generator test mode is set as "Consumer" + When the request is prepared for use with a "mockServer" context: + | { "href": "http://somewhere.world" } | + Then the body value for "$.one" will have been replaced with "http://somewhere.world/a" + + Scenario: Supports a simple UUID generator + Given a request configured with the following generators: + | body | generators | + | file: basic.json | uuid-generator-simple.json | + When the request is prepared for use + Then the body value for "$.one" will have been replaced with a "simple UUID" + + Scenario: Supports a lower-case-hyphenated UUID generator + Given a request configured with the following generators: + | body | generators | + | file: basic.json | uuid-generator-lower-case-hyphenated.json | + When the request is prepared for use + Then the body value for "$.one" will have been replaced with a "lower-case-hyphenated UUID" + + Scenario: Supports a upper-case-hyphenated UUID generator + Given a request configured with the following generators: + | body | generators | + | file: basic.json | uuid-generator-upper-case-hyphenated.json | + When the request is prepared for use + Then the body value for "$.one" will have been replaced with a "upper-case-hyphenated UUID" + + Scenario: Supports a URN UUID generator + Given a request configured with the following generators: + | body | generators | + | file: basic.json | uuid-generator-urn.json | + When the request is prepared for use + Then the body value for "$.one" will have been replaced with a "URN UUID" diff --git a/compatibility-suite/pact-compatibility-suite/features/V4/matching_rules.feature b/compatibility-suite/pact-compatibility-suite/features/V4/matching_rules.feature index 839c0ef09..60cdde92a 100644 --- a/compatibility-suite/pact-compatibility-suite/features/V4/matching_rules.feature +++ b/compatibility-suite/pact-compatibility-suite/features/V4/matching_rules.feature @@ -92,3 +92,66 @@ Feature: V4 era Matching Rules Then the comparison should NOT be OK And the mismatches will contain a mismatch with error "$.one" -> "Expected '1.0' (String) to be a semantic version" And the mismatches will contain a mismatch with error "$.two" -> "Expected '1.0abc' (String) to be a semantic version" + + Scenario: Supports an EachKey matcher (positive case) + Given an expected request configured with the following: + | body | matching rules | + | file: basic.json | eachkey-matcher-v4.json | + And a request is received with the following: + | body | + | JSON: { "one": "a", "two": "b", "three": "c", "four": "d" } | + When the request is compared to the expected one + Then the comparison should be OK + + Scenario: Supports an EachKey matcher (negative case) + Given an expected request configured with the following: + | body | matching rules | + | file: basic.json | eachkey-matcher-v4.json | + And a request is received with the following: + | body | + | JSON: { "one": "a", "two": "b", "three": "c", "100": "d" } | + When the request is compared to the expected one + Then the comparison should NOT be OK + And the mismatches will contain a mismatch with error "$[100]" -> "Expected '100' to match '[a-z]+" + + Scenario: Supports an EachValue matcher (positive case) + Given an expected request configured with the following: + | body | matching rules | + | file: basic.json | eachvalue-matcher-v4.json | + And a request is received with the following: + | body | + | JSON: { "one": "a", "three": "b", "four": "c", "five": "d" } | + When the request is compared to the expected one + Then the comparison should be OK + + Scenario: Supports a EachValue matcher (negative case) + Given an expected request configured with the following: + | body | matching rules | + | file: basic.json | eachvalue-matcher-v4.json | + And a request is received with the following: + | body | + | JSON: { "one": "", "two": "b", "three": "c", "four": "100" } | + When the request is compared to the expected one + Then the comparison should NOT be OK + And the mismatches will contain a mismatch with error "$.four" -> "Expected '100' to match '[a-z]+" + + Scenario: Supports an ArrayContains matcher (positive case) + Given an expected request configured with the following: + | content type | body | matching rules | + | application/vnd.siren+json | file: siren.json | arraycontains-matcher-v4.json | + And a request is received with the following: + | content type | body | + | application/vnd.siren+json | file: siren2.json | + When the request is compared to the expected one + Then the comparison should be OK + + Scenario: Supports a ArrayContains matcher (negative case) + Given an expected request configured with the following: + | content type | body | matching rules | + | application/vnd.siren+json | file: siren.json | arraycontains-matcher-v4.json | + And a request is received with the following: + | content type | body | + | application/vnd.siren+json | file: siren3.json | + When the request is compared to the expected one + Then the comparison should NOT be OK + And the mismatches will contain a mismatch with error "$.actions" -> "Variant at index 1 ({\"href\":\"http://api.x.io/orders/42/items\",\"method\":\"DELETE\",\"name\":\"delete-item\",\"title\":\"Delete Item\"}) was not found in the actual list" diff --git a/compatibility-suite/pact-compatibility-suite/fixtures/arraycontains-matcher-v4.json b/compatibility-suite/pact-compatibility-suite/fixtures/arraycontains-matcher-v4.json new file mode 100644 index 000000000..662b46484 --- /dev/null +++ b/compatibility-suite/pact-compatibility-suite/fixtures/arraycontains-matcher-v4.json @@ -0,0 +1,78 @@ +{ + "body": { + "$.actions": { + "combine": "AND", + "matchers": [ + { + "match": "arrayContains", + "variants": [ + { + "generators": {}, + "index": 0, + "rules": { + "$.name": { + "combine": "AND", + "matchers": [ + { + "match": "regex", + "regex": "add\\-item" + } + ] + }, + "$.method": { + "combine": "AND", + "matchers": [ + { + "match": "regex", + "regex": "POST" + } + ] + }, + "$.*": { + "combine": "AND", + "matchers": [ + { + "match": "type" + } + ] + } + } + }, + { + "generators": { }, + "index": 1, + "rules": { + "$.name": { + "combine": "AND", + "matchers": [ + { + "match": "regex", + "regex": "delete\\-item" + } + ] + }, + "$.method": { + "combine": "AND", + "matchers": [ + { + "match": "regex", + "regex": "DELETE" + } + ] + }, + "$.*": { + "combine": "AND", + "matchers": [ + { + "match": "type" + } + ] + } + } + } + ] + } + ] + } + } +} diff --git a/compatibility-suite/pact-compatibility-suite/fixtures/eachkey-matcher-v4.json b/compatibility-suite/pact-compatibility-suite/fixtures/eachkey-matcher-v4.json new file mode 100644 index 000000000..4a0a3c9a7 --- /dev/null +++ b/compatibility-suite/pact-compatibility-suite/fixtures/eachkey-matcher-v4.json @@ -0,0 +1,19 @@ +{ + "body": { + "$": { + "combine": "AND", + "matchers": [ + { + "match": "eachKey", + "rules": [ + { + "match": "regex", + "regex": "[a-z]+" + } + ], + "value": "one" + } + ] + } + } +} diff --git a/compatibility-suite/pact-compatibility-suite/fixtures/eachvalue-matcher-v4.json b/compatibility-suite/pact-compatibility-suite/fixtures/eachvalue-matcher-v4.json new file mode 100644 index 000000000..e56c933a6 --- /dev/null +++ b/compatibility-suite/pact-compatibility-suite/fixtures/eachvalue-matcher-v4.json @@ -0,0 +1,19 @@ +{ + "body": { + "$": { + "combine": "AND", + "matchers": [ + { + "match": "eachValue", + "rules": [ + { + "match": "regex", + "regex": "[a-z]+" + } + ], + "value": "one" + } + ] + } + } +} diff --git a/compatibility-suite/pact-compatibility-suite/fixtures/siren.json b/compatibility-suite/pact-compatibility-suite/fixtures/siren.json new file mode 100644 index 000000000..d2d5fccdf --- /dev/null +++ b/compatibility-suite/pact-compatibility-suite/fixtures/siren.json @@ -0,0 +1,65 @@ +{ + "class": [ + "order" + ], + "properties": { + "orderNumber": 42, + "itemCount": 3, + "status": "pending" + }, + "entities": [ + { + "class": [ + "items", + "collection" + ], + "rel": [ "http://x.io/rels/order-items" ], + "href": "http://api.x.io/orders/42/items" + }, + { + "class": [ + "info", + "customer" + ], + "rel": [ "http://x.io/rels/customer" ], + "properties": { + "customerId": "pj123", + "name": "Peter Joseph" + }, + "links": [ + { + "rel": [ "self" ], + "href": "http://api.x.io/customers/pj123" + } + ] + } + ], + "actions": [ + { + "name": "add-item", + "title": "Add Item", + "method": "POST", + "href": "http://api.x.io/orders/42/items" + }, + { + "name": "delete-item", + "title": "Delete Item", + "method": "DELETE", + "href": "http://api.x.io/orders/42/items" + } + ], + "links": [ + { + "rel": [ "self" ], + "href": "http://api.x.io/orders/42" + }, + { + "rel": [ "previous" ], + "href": "http://api.x.io/orders/41" + }, + { + "rel": [ "next" ], + "href": "http://api.x.io/orders/43" + } + ] +} diff --git a/compatibility-suite/pact-compatibility-suite/fixtures/siren2.json b/compatibility-suite/pact-compatibility-suite/fixtures/siren2.json new file mode 100644 index 000000000..e367e0d10 --- /dev/null +++ b/compatibility-suite/pact-compatibility-suite/fixtures/siren2.json @@ -0,0 +1,71 @@ +{ + "class": [ + "order" + ], + "properties": { + "orderNumber": 42, + "itemCount": 3, + "status": "pending" + }, + "entities": [ + { + "class": [ + "items", + "collection" + ], + "rel": [ "http://x.io/rels/order-items" ], + "href": "http://api.x.io/orders/42/items" + }, + { + "class": [ + "info", + "customer" + ], + "rel": [ "http://x.io/rels/customer" ], + "properties": { + "customerId": "pj123", + "name": "Peter Joseph" + }, + "links": [ + { + "rel": [ "self" ], + "href": "http://api.x.io/customers/pj123" + } + ] + } + ], + "actions": [ + { + "name": "delete-item", + "title": "Delete Item", + "method": "DELETE", + "href": "http://api.x.io/orders/42/items" + }, + { + "name": "add-item", + "title": "Add Item", + "method": "POST", + "href": "http://api.x.io/orders/42/items" + }, + { + "name": "update-item", + "title": "Update Item", + "method": "PUT", + "href": "http://api.x.io/orders/42/items" + } + ], + "links": [ + { + "rel": [ "self" ], + "href": "http://api.x.io/orders/42" + }, + { + "rel": [ "previous" ], + "href": "http://api.x.io/orders/41" + }, + { + "rel": [ "next" ], + "href": "http://api.x.io/orders/43" + } + ] +} diff --git a/compatibility-suite/pact-compatibility-suite/fixtures/siren3.json b/compatibility-suite/pact-compatibility-suite/fixtures/siren3.json new file mode 100644 index 000000000..9be0f11ad --- /dev/null +++ b/compatibility-suite/pact-compatibility-suite/fixtures/siren3.json @@ -0,0 +1,65 @@ +{ + "class": [ + "order" + ], + "properties": { + "orderNumber": 42, + "itemCount": 3, + "status": "pending" + }, + "entities": [ + { + "class": [ + "items", + "collection" + ], + "rel": [ "http://x.io/rels/order-items" ], + "href": "http://api.x.io/orders/42/items" + }, + { + "class": [ + "info", + "customer" + ], + "rel": [ "http://x.io/rels/customer" ], + "properties": { + "customerId": "pj123", + "name": "Peter Joseph" + }, + "links": [ + { + "rel": [ "self" ], + "href": "http://api.x.io/customers/pj123" + } + ] + } + ], + "actions": [ + { + "name": "add-item", + "title": "Add Item", + "method": "POST", + "href": "http://api.x.io/orders/42/items" + }, + { + "name": "update-item", + "title": "Update Item", + "method": "PUT", + "href": "http://api.x.io/orders/42/items" + } + ], + "links": [ + { + "rel": [ "self" ], + "href": "http://api.x.io/orders/42" + }, + { + "rel": [ "previous" ], + "href": "http://api.x.io/orders/41" + }, + { + "rel": [ "next" ], + "href": "http://api.x.io/orders/43" + } + ] +} diff --git a/compatibility-suite/pact-compatibility-suite/fixtures/uuid-generator-lower-case-hyphenated.json b/compatibility-suite/pact-compatibility-suite/fixtures/uuid-generator-lower-case-hyphenated.json new file mode 100644 index 000000000..a340be1f2 --- /dev/null +++ b/compatibility-suite/pact-compatibility-suite/fixtures/uuid-generator-lower-case-hyphenated.json @@ -0,0 +1,5 @@ +{ + "body": { + "$.one": { "type": "Uuid", "format": "lower-case-hyphenated" } + } +} diff --git a/compatibility-suite/pact-compatibility-suite/fixtures/uuid-generator-simple.json b/compatibility-suite/pact-compatibility-suite/fixtures/uuid-generator-simple.json new file mode 100644 index 000000000..0b38e158e --- /dev/null +++ b/compatibility-suite/pact-compatibility-suite/fixtures/uuid-generator-simple.json @@ -0,0 +1,5 @@ +{ + "body": { + "$.one": { "type": "Uuid", "format": "simple" } + } +} diff --git a/compatibility-suite/pact-compatibility-suite/fixtures/uuid-generator-upper-case-hyphenated.json b/compatibility-suite/pact-compatibility-suite/fixtures/uuid-generator-upper-case-hyphenated.json new file mode 100644 index 000000000..1239ac116 --- /dev/null +++ b/compatibility-suite/pact-compatibility-suite/fixtures/uuid-generator-upper-case-hyphenated.json @@ -0,0 +1,5 @@ +{ + "body": { + "$.one": { "type": "Uuid", "format": "upper-case-hyphenated" } + } +} diff --git a/compatibility-suite/pact-compatibility-suite/fixtures/uuid-generator-urn.json b/compatibility-suite/pact-compatibility-suite/fixtures/uuid-generator-urn.json new file mode 100644 index 000000000..51417f827 --- /dev/null +++ b/compatibility-suite/pact-compatibility-suite/fixtures/uuid-generator-urn.json @@ -0,0 +1,5 @@ +{ + "body": { + "$.one": { "type": "Uuid", "format": "URN" } + } +}