'another invalid parent path' | '/test-tree/branch[@name=\'Branch\']/nest/name/last-name'
'fragment does not belong to parent' | '/test-tree/'
}
+
+ def 'Parsing json data with invalid json string: #description.'() {
+ given: 'schema context'
+ def yangResourcesMap = TestUtils.getYangResourcesAsMap('bookstore.yang')
+ def schemaContext = YangTextSchemaSourceSetBuilder.of(yangResourcesMap).getSchemaContext()
+ when: 'malformed json string is parsed'
+ YangUtils.parseJsonData(invalidJson, schemaContext)
+ then: 'an exception is thrown'
+ thrown(DataValidationException)
+ where: 'the following malformed json is provided'
+ description | invalidJson
+ 'malformed json string with unterminated array data' | '{bookstore={categories=[{books=[{authors=[Iain M. Banks]}]}]}}'
+ 'incorrect json' | '{" }'
+ }
+
+ def 'Parsing json data with space.'() {
+ given: 'schema context'
+ def yangResourcesMap = TestUtils.getYangResourcesAsMap('bookstore.yang')
+ def schemaContext = YangTextSchemaSourceSetBuilder.of(yangResourcesMap).getSchemaContext()
+ and: 'some json data with space in the array elements'
+ def jsonDataWithSpacesInArrayElement = TestUtils.getResourceFileContent('bookstore.json')
+ when: 'that json data is parsed'
+ YangUtils.parseJsonData(jsonDataWithSpacesInArrayElement, schemaContext)
+ then: 'no exception thrown'
+ noExceptionThrown()
+ }
+
}