From 25969bf454bc0c965408cdc1a1ff2df223a8cb49 Mon Sep 17 00:00:00 2001 From: emaclee Date: Tue, 22 Nov 2022 16:04:14 +0000 Subject: Upgrade Open daylight yang tool to version 8.0.6 - changed classes according to upgrade of yang tool - changed methods in YangUtils class to accomodate change for jSonParserStream method - updated unit tests for the upgrade Signed-off-by: emaclee Change-Id: Ib62fe424150ed0695eed168e1ae21f4d9a61cdf4 --- .../test/groovy/org/onap/cps/utils/JsonParserStreamSpec.groovy | 6 +++--- .../src/test/groovy/org/onap/cps/utils/YangUtilsSpec.groovy | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'cps-service/src/test/groovy/org') diff --git a/cps-service/src/test/groovy/org/onap/cps/utils/JsonParserStreamSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/utils/JsonParserStreamSpec.groovy index 68f9251eb..40f0e0a2a 100644 --- a/cps-service/src/test/groovy/org/onap/cps/utils/JsonParserStreamSpec.groovy +++ b/cps-service/src/test/groovy/org/onap/cps/utils/JsonParserStreamSpec.groovy @@ -10,7 +10,7 @@ import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier import org.opendaylight.yangtools.yang.data.codec.gson.JsonParserStream import org.opendaylight.yangtools.yang.data.impl.schema.Builders import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder +import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import spock.lang.Specification import org.onap.cps.TestUtils @@ -38,10 +38,10 @@ class JsonParserStreamSpec extends Specification{ then: 'result is the correct size' result.size() == 2 then: 'data container child is a type of normalized node' - def dataContainerChild = result.getValue()[index] + def dataContainerChild = result.body().getAt(index) dataContainerChild instanceof NormalizedNode == true then: 'qualified name created is as expected' - dataContainerChild.nodeType == QName.create('org:onap:ccsdk:multiDataTree', '2020-09-15', nodeName) + dataContainerChild.identifier.nodeType == QName.create('org:onap:ccsdk:multiDataTree', '2020-09-15', nodeName) where: index | nodeName 0 | 'first-container' diff --git a/cps-service/src/test/groovy/org/onap/cps/utils/YangUtilsSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/utils/YangUtilsSpec.groovy index 3f190910b..65aa3af7d 100644 --- a/cps-service/src/test/groovy/org/onap/cps/utils/YangUtilsSpec.groovy +++ b/cps-service/src/test/groovy/org/onap/cps/utils/YangUtilsSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation + * Copyright (C) 2020-2022 Nordix Foundation * Modifications Copyright (C) 2021 Pantheon.tech * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -36,9 +36,9 @@ class YangUtilsSpec extends Specification { def yangResourceNameToContent = TestUtils.getYangResourcesAsMap('bookstore.yang') def schemaContext = YangTextSchemaSourceSetBuilder.of(yangResourceNameToContent).getSchemaContext() when: 'the json data is parsed' - NormalizedNode result = YangUtils.parseJsonData(jsonData, schemaContext) + NormalizedNode result = YangUtils.parseJsonData(jsonData, schemaContext) then: 'the result is a normalized node of the correct type' - result.nodeType == QName.create('org:onap:ccsdk:sample', '2020-09-15', 'bookstore') + result.getIdentifier().nodeType == QName.create('org:onap:ccsdk:sample', '2020-09-15', 'bookstore') } def 'Parsing invalid data: #description.'() { @@ -63,7 +63,7 @@ class YangUtilsSpec extends Specification { when: 'json string is parsed' def result = YangUtils.parseJsonData(jsonData, schemaContext, parentNodeXpath) then: 'result represents a node of expected type' - result.nodeType == QName.create('org:onap:cps:test:test-tree', '2020-02-02', nodeName) + result.getIdentifier().nodeType == QName.create('org:onap:cps:test:test-tree', '2020-02-02', nodeName) where: scenario | jsonData | parentNodeXpath || nodeName 'list element as container' | '{ "branch": { "name": "B", "nest": { "name": "N", "birds": ["bird"] } } }' | '/test-tree' || 'branch' -- cgit 1.2.3-korg