summaryrefslogtreecommitdiffstats
path: root/cps-service/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'cps-service/src/test')
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/utils/JsonObjectMapperSpec.groovy18
1 files changed, 18 insertions, 0 deletions
diff --git a/cps-service/src/test/groovy/org/onap/cps/utils/JsonObjectMapperSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/utils/JsonObjectMapperSpec.groovy
index f9b8febd43..acb52413f8 100644
--- a/cps-service/src/test/groovy/org/onap/cps/utils/JsonObjectMapperSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/utils/JsonObjectMapperSpec.groovy
@@ -84,4 +84,22 @@ class JsonObjectMapperSpec extends Specification {
then: 'an exception is thrown'
thrown(DataValidationException)
}
+
+ def 'Map a structurally compatible json String to JsonNode.'() {
+ given: 'Unstructured object'
+ def content = '{ "nest": { "birds": "bird" } }'
+ when: 'the object is mapped to string'
+ def result = jsonObjectMapper.convertToJsonNode(content);
+ then: 'the result is a valid JsonNode'
+ result.fieldNames().next() == "nest"
+ }
+
+ def 'Map a unstructured json String to JsonNode.'() {
+ given: 'Unstructured object'
+ def content = '{ "nest": { "birds": "bird" }] }'
+ when: 'the object is mapped to string'
+ jsonObjectMapper.convertToJsonNode(content);
+ then: 'a data validation exception is thrown'
+ thrown(DataValidationException)
+ }
}