2 // Copyright 2019 AT&T Intellectual Property
3 // Copyright 2019 Nokia
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
17 // This source code is part of the near-RT RIC (RAN Intelligent Controller)
18 // platform project (RICP).
23 "github.com/stretchr/testify/assert"
27 func TestValidateAndBuildCellKeySuccess(t *testing.T) {
31 key, err := ValidateAndBuildCellIdKey(cellId)
33 t.Errorf("#utils_test.TestValidateAndBuildCellKey - failed to validate key parameter")
35 assert.Contains(t, key, cellId)
36 assert.Contains(t, key, delimiter)
37 assert.Contains(t, key, prefix)
40 func TestValidateAndBuildNodeBNameKeySuccess(t *testing.T) {
44 key, err := ValidateAndBuildNodeBNameKey(name)
46 t.Errorf("#utils_test.TestValidateAndBuildNodeBNameKey - failed to validate key parameter")
48 assert.Contains(t, key, name)
49 assert.Contains(t, key, delimiter)
50 assert.Contains(t, key, prefix)
53 func TestValidateAndBuildNodeBIdKeySuccess(t *testing.T) {
58 key, err := ValidateAndBuildNodeBIdKey(nodeType, plmnId, nbId)
60 t.Errorf("#utils_test.TestValidateAndBuildNodeBIdKey - failed to validate key parameter")
62 assert.Contains(t, key, nodeType)
63 assert.Contains(t, key, plmnId)
64 assert.Contains(t, key, nbId)
65 assert.Contains(t, key, delimiter)
68 func TestValidateAndBuildCellNamePciKeyNameValidationFailure(t *testing.T){
70 _, err := ValidateAndBuildCellNamePciKey("", uint32(pci))
72 assert.IsType(t, &ValidationError{}, err)
73 assert.Equal(t, "#utils.ValidateAndBuildCellNamePciKey - an empty inventory name received", err.Error())
76 func TestValidateAndBuildCellKeyCellidValidationFailure(t *testing.T) {
77 _, err := ValidateAndBuildCellIdKey("")
79 assert.IsType(t, &ValidationError{}, err)
80 assert.Equal(t, "#utils.ValidateAndBuildCellIdKey - an empty cell id received", err.Error())
83 func TestValidateAndBuildNodeBNameKeyNameValidationFailure(t *testing.T) {
84 _, err := ValidateAndBuildNodeBNameKey("")
86 assert.IsType(t, &ValidationError{}, err)
87 assert.Equal(t, "#utils.ValidateAndBuildNodeBNameKey - an empty inventory name received", err.Error())
90 func TestValidateAndBuildNodeBIdKeyNodeTypeValidationFailure(t *testing.T) {
93 _, err := ValidateAndBuildNodeBIdKey("", plmnId, nbId)
95 assert.IsType(t, &ValidationError{}, err)
96 assert.Equal(t, "#utils.ValidateAndBuildNodeBIdKey - an empty node type received", err.Error())
99 func TestValidateAndBuildNodeBIdKeyPlmnIdValidationFailure(t *testing.T) {
102 _, err := ValidateAndBuildNodeBIdKey(nodeType, "", nbId)
103 assert.NotNil(t, err)
104 assert.IsType(t, &ValidationError{}, err)
105 assert.Equal(t, "#utils.ValidateAndBuildNodeBIdKey - an empty plmnId received", err.Error())
108 func TestValidateAndBuildNodeBIdKeyNbIdValidationFailure(t *testing.T) {
111 _, err := ValidateAndBuildNodeBIdKey(nodeType, plmnId, "")
112 assert.NotNil(t, err)
113 assert.IsType(t, &ValidationError{}, err)
114 assert.Equal(t, "#utils.ValidateAndBuildNodeBIdKey - an empty nbId received", err.Error())
117 func TestValidateAndBuildCellNamePciKeySuccess(t *testing.T){
122 key, err := ValidateAndBuildCellNamePciKey(name, uint32(pci))
124 t.Errorf("#utils_test.TestValidateAndBuildCellNamePciKey - failed to validate key parameter")
126 assert.Contains(t, key, name)
127 assert.Contains(t, key, delimiter)
128 assert.Contains(t, key, prefix)
129 assert.Contains(t, key, "270f")
133 func TestValidateAndBuildRanLoadInformationKeySuccess(t *testing.T) {
137 key, err := ValidateAndBuildRanLoadInformationKey(name)
139 t.Errorf("#utils_test.TestValidateAndBuildRanLoadInformationKeySuccess - failed to validate key parameter")
141 assert.Contains(t, key, name)
142 assert.Contains(t, key, delimiter)
143 assert.Contains(t, key, prefix)
146 func TestValidateAndBuildRanLoadInformationKeyFailure(t *testing.T) {
148 _, err := ValidateAndBuildRanLoadInformationKey(name)
149 assert.NotNil(t, err)
150 assert.IsType(t, &ValidationError{}, err)