UT for GetAllPolicyIntances 71/9971/3
authornaman.gupta <naman.gupta@samsung.com>
Tue, 6 Dec 2022 15:02:58 +0000 (20:32 +0530)
committernaman.gupta <naman.gupta@samsung.com>
Wed, 7 Dec 2022 07:47:40 +0000 (13:17 +0530)
UT for GetAllPolicyIntances

Signed-off-by: naman.gupta <naman.gupta@samsung.com>
Change-Id: I0b2cf8457bb8b3d4562b078d0b5c81c27cc24d16

a1-go/pkg/policy/policyManager_test.go

index 7714b81..42a9807 100644 (file)
@@ -1,3 +1,24 @@
+/*
+==================================================================================
+  Copyright (c) 2022 Samsung
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+   This source code is part of the near-RT RIC (RAN Intelligent Controller)
+   platform project (RICP).
+==================================================================================
+*/
+
 package policy
 
 import (
@@ -36,10 +57,24 @@ func TestSetPolicyInstance(t *testing.T) {
        sdlInst.On("Set", "A1m_ns", instancehandlerKey, instancearr).Return(nil)
        errresp := pm.SetPolicyInstanceStatus(policyTypeId, policyInstanceID, status)
        assert.NoError(t, errresp)
-
        sdlInst.AssertExpectations(t)
 }
 
+func TestGetAllPolicyIntances(t *testing.T) {
+       var policyTypeId int
+       policyTypeId = 20005
+       sdlInst.On("GetAll", "A1m_ns").Return([]string{"a1.policy_instance.1006001.qos",
+               "a1.policy_instance.20005.123456",
+               "a1.policy_instance.20005.234567",
+               "a1.policy_type.1006001",
+               "a1.policy_type.20000",
+               "a1.policy_inst_metadata.1006001.qos",
+       }, nil)
+       resp, err := pm.GetAllPolicyInstance(policyTypeId)
+       assert.NoError(t, err)
+       assert.Equal(t, 2, len(resp))
+}
+
 func (s *SdlMock) Set(ns string, pairs ...interface{}) error {
        args := s.MethodCalled("Set", ns, pairs)
        return args.Error(0)