X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-service%2Fsrc%2Ftest%2Fgroovy%2Forg%2Fonap%2Fcps%2Futils%2FJsonObjectMapperSpec.groovy;h=acb52413f8fd243d492f206eb6d786ed4b3c8456;hb=40a8211b8f8f4b244b43620776a71371bc5371d6;hp=f9b8febd432c391cb8dfe28529785504a4193677;hpb=31cf29d21096ab7200658f586ecb9e40ee72249e;p=cps.git 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 f9b8febd4..acb52413f 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) + } }