From 315c21e40acf542d5dd9c62a95236782c0eca633 Mon Sep 17 00:00:00 2001 From: Mehdi Rebiai Date: Wed, 7 Aug 2024 17:38:57 +0200 Subject: [PATCH] test: error on bad json schema Signed-off-by: Mehdi Rebiai --- src/test/resources/features/consumer-json-key-value.feature | 4 ++++ src/test/resources/scripts/schemas/kapoeira.jsonvaluev1.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/test/resources/features/consumer-json-key-value.feature b/src/test/resources/features/consumer-json-key-value.feature index 0f58609..e1a4440 100644 --- a/src/test/resources/features/consumer-json-key-value.feature +++ b/src/test/resources/features/consumer-json-key-value.feature @@ -17,13 +17,17 @@ Feature: consumer-json-key-value | topic_alias | key | value | | topic_in | aTestKey_${uuid} | {"anInt": 1, "aString": "myString1", "anOptionalString": "test"} | | topic_in | aTestKey_${uuid} | {"anInt": 2, "aString": "myString2", "anOptionalString": null } | +# the following payload does not respect json schema => the test must fail +# | topic_in | aTestKey_${uuid} | {"foo": "bar" } | Then expected records | topic_alias | key | value | | topic_out | aTestKey_${uuid} | aliasValue1 | | topic_out | aTestKey_${uuid} | aliasValue2 | +# | topic_out | aTestKey_${uuid} | aliasValue3 | And assert aliasValue1 $.anInt == 1 And assert aliasValue1 $.aString == "myString1" And assert aliasValue1 $.anOptionalString == "test" And assert aliasValue2 $.anInt == 2 And assert aliasValue2 $.aString == "myString2" And assert aliasValue2 $.anOptionalString == null +# And assert aliasValue3 $.foo == "bar" diff --git a/src/test/resources/scripts/schemas/kapoeira.jsonvaluev1.json b/src/test/resources/scripts/schemas/kapoeira.jsonvaluev1.json index dd47cc1..cab541d 100644 --- a/src/test/resources/scripts/schemas/kapoeira.jsonvaluev1.json +++ b/src/test/resources/scripts/schemas/kapoeira.jsonvaluev1.json @@ -1 +1 @@ -{"schemaType": "JSON","schema": "{ \"$schema\": \"http://json-schema.org/draft-04/schema#\", \"title\": \"com.lectra.kapoeira.jsonvaluev1\", \"description\": \"jsonvaluev1\", \"type\": \"object\", \"properties\": { \"anInt\": { \"type\": \"integer\" }, \"aString\": { \"type\": \"string\" }, \"anOptionalString\": {\"type\":[\"string\",\"null\"]} } }"} \ No newline at end of file +{"schemaType": "JSON","schema": "{ \"$schema\": \"http://json-schema.org/draft-04/schema#\", \"title\": \"com.lectra.kapoeira.jsonvaluev1\", \"description\": \"jsonvaluev1\", \"type\": \"object\", \"properties\": { \"anInt\": { \"type\": \"integer\" }, \"aString\": { \"type\": \"string\" }, \"anOptionalString\": {\"type\":[\"string\",\"null\"]} }, \"required\": [\"aString\" ] }"} \ No newline at end of file