From 2ce955e7c3c53b16596a18b0f5f68f2b491d1de6 Mon Sep 17 00:00:00 2001 From: jhh Date: Mon, 27 Jan 2020 06:45:07 -0600 Subject: Schema validation extension to StandardCoder Issue-ID: POLICY-2331 Signed-off-by: jhh Change-Id: Ic3e8d21715d17a61ea5d07740dd9f4dd0dbb8641 Signed-off-by: jhh --- .../onap/policy/common/utils/coder/bad-regex.json | 9 +++ .../common/utils/coder/missing-required.json | 5 ++ .../policy/common/utils/coder/test.schema.json | 71 ++++++++++++++++++++++ .../org/onap/policy/common/utils/coder/valid.json | 9 +++ 4 files changed, 94 insertions(+) create mode 100644 utils/src/test/resources/org/onap/policy/common/utils/coder/bad-regex.json create mode 100644 utils/src/test/resources/org/onap/policy/common/utils/coder/missing-required.json create mode 100644 utils/src/test/resources/org/onap/policy/common/utils/coder/test.schema.json create mode 100644 utils/src/test/resources/org/onap/policy/common/utils/coder/valid.json (limited to 'utils/src/test/resources') diff --git a/utils/src/test/resources/org/onap/policy/common/utils/coder/bad-regex.json b/utils/src/test/resources/org/onap/policy/common/utils/coder/bad-regex.json new file mode 100644 index 00000000..049de2cf --- /dev/null +++ b/utils/src/test/resources/org/onap/policy/common/utils/coder/bad-regex.json @@ -0,0 +1,9 @@ +{ + "aaString": "abc123", + "anInteger": 90, + "aaBoolean": true, + "aaCollection": [ { + "subItemString": "defg", + "subItemInteger": 1200 + }] +} \ No newline at end of file diff --git a/utils/src/test/resources/org/onap/policy/common/utils/coder/missing-required.json b/utils/src/test/resources/org/onap/policy/common/utils/coder/missing-required.json new file mode 100644 index 00000000..e19db9db --- /dev/null +++ b/utils/src/test/resources/org/onap/policy/common/utils/coder/missing-required.json @@ -0,0 +1,5 @@ +{ + "aaString": "abcd", + "anInteger": 90, + "aaBoolean": true +} \ No newline at end of file diff --git a/utils/src/test/resources/org/onap/policy/common/utils/coder/test.schema.json b/utils/src/test/resources/org/onap/policy/common/utils/coder/test.schema.json new file mode 100644 index 00000000..e79475eb --- /dev/null +++ b/utils/src/test/resources/org/onap/policy/common/utils/coder/test.schema.json @@ -0,0 +1,71 @@ +{ + "definitions": {}, + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://onap.org/policy/common/coders/root.json", + "type": "object", + "title": "Test Schema", + "required": [ + "aaString", + "anInteger", + "aaBoolean", + "aaCollection" + ], + "properties": { + "aaString": { + "$id": "#/properties/aaString", + "type": "string", + "title": "an alphabetical string", + "default": "", + "examples": [ + "abcdef" + ], + "pattern": "^([a-z]*)$" + }, + "anInteger": { + "$id": "#/properties/anInteger", + "type": "integer", + "title": "a bounded integer", + "default": 5, + "examples": [ + 98 + ], + "minimum": 10, + "maximum": 100 + }, + "aaBoolean": { + "$id": "#/properties/aaBoolean", + "type": "boolean", + "title": "a boolean", + "default": false, + "examples": [ + true + ] + }, + "aaCollection": { + "$id": "#/properties/aaCollection", + "type": "array", + "title": "a collection", + "items": { + "$id": "#/properties/aaCollection/items", + "type": "object", + "title": "the collection items", + "required": [ + "subItemString" + ], + "properties": { + "subItemString": { + "$id": "#/properties/aaCollection/items/properties/subItemString", + "type": "string", + "title": "the subitem string", + "default": "blah", + "pattern": "^(.*)$" + }, + "subItemInteger": { + "$id": "#/properties/aaCollection/items/properties/subItemInteger", + "type": "integer" + } + } + } + } + } +} \ No newline at end of file diff --git a/utils/src/test/resources/org/onap/policy/common/utils/coder/valid.json b/utils/src/test/resources/org/onap/policy/common/utils/coder/valid.json new file mode 100644 index 00000000..c1738176 --- /dev/null +++ b/utils/src/test/resources/org/onap/policy/common/utils/coder/valid.json @@ -0,0 +1,9 @@ +{ + "aaString": "abcd", + "anInteger": 90, + "aaBoolean": true, + "aaCollection": [ { + "subItemString": "defg", + "subItemInteger": 1200 + }] +} \ No newline at end of file -- cgit 1.2.3-korg