X-Git-Url: https://gerrit.onap.org/r/gitweb?p=cps.git;a=blobdiff_plain;f=cps-service%2Fsrc%2Ftest%2Fgroovy%2Forg%2Fonap%2Fcps%2Fspi%2Fmodel%2FDataNodeBuilderSpec.groovy;fp=cps-service%2Fsrc%2Ftest%2Fgroovy%2Forg%2Fonap%2Fcps%2Fmodel%2FDataNodeBuilderSpec.groovy;h=ce54ead2a0fb31ba7fd9b7e2ee5b8537063c73ee;hp=7af1ed41c75cb45fb9974ce405f81f61641e1bdd;hb=9a87c1476c92aa4a6e1731efc417c01532cc8dc6;hpb=c96cc73a13205ae2eb86388b6cf1e59707763c0c diff --git a/cps-service/src/test/groovy/org/onap/cps/model/DataNodeBuilderSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/spi/model/DataNodeBuilderSpec.groovy similarity index 90% rename from cps-service/src/test/groovy/org/onap/cps/model/DataNodeBuilderSpec.groovy rename to cps-service/src/test/groovy/org/onap/cps/spi/model/DataNodeBuilderSpec.groovy index 7af1ed41c..ce54ead2a 100644 --- a/cps-service/src/test/groovy/org/onap/cps/model/DataNodeBuilderSpec.groovy +++ b/cps-service/src/test/groovy/org/onap/cps/spi/model/DataNodeBuilderSpec.groovy @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2021 Pantheon.tech - * Modifications Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021-2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,12 +18,15 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.model +package org.onap.cps.spi.model import org.onap.cps.TestUtils import org.onap.cps.spi.model.DataNodeBuilder import org.onap.cps.utils.YangUtils import org.onap.cps.yang.YangTextSchemaSourceSetBuilder +import org.opendaylight.yangtools.yang.common.QName +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode import spock.lang.Specification class DataNodeBuilderSpec extends Specification { @@ -157,6 +160,18 @@ class DataNodeBuilderSpec extends Specification { 'multiple entries' | '{"branch": [{"name": "One"}, {"name": "Two"}]}' | 2 | ['/test-tree/branch[@name=\'One\']', '/test-tree/branch[@name=\'Two\']'] } + def 'Converting NormalizedNode to a DataNode collection -- edge cases: #scenario.'() { + when: 'the normalized node is #node' + def result = new DataNodeBuilder().withNormalizedNodeTree(normalizedNode).buildCollection() + then: 'the resulting collection contains data nodes for expected list elements' + assert result.size() == expectedSize + assert result.containsAll(expectedNodes) + where: 'following parameters are used' + scenario | node | normalizedNode | expectedSize | expectedNodes + 'NormalizedNode is null' | 'null' | null | 1 | [ new DataNode() ] + 'NormalizedNode is an unsupported type' | 'not supported' | Mock(NormalizedNode) | 0 | [ ] + } + def static assertLeavesMaps(actualLeavesMap, expectedLeavesMap) { expectedLeavesMap.each { key, value -> {