blob: fe6135615ba07200e6459b96d98859c47b44ead7 [file] [log] [blame]
kalnagy92162652019-07-02 15:15:49 +02001/*
2==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
wahidw761934a2019-11-27 06:07:26 +000017
18
19 This source code is part of the near-RT RIC (RAN Intelligent Controller)
20 platform project (RICP).
21
kalnagy92162652019-07-02 15:15:49 +020022==================================================================================
23*/
24/*
wahidwbce67472020-06-15 13:52:55 +000025 Mnemonic: rmrpub_test.go
kalnagy92162652019-07-02 15:15:49 +020026 Abstract:
27 Date: 25 April 2019
28*/
29package rpe
30
31import (
32 "routing-manager/pkg/rtmgr"
33 "routing-manager/pkg/stub"
34 "testing"
35)
36
37func resetTestDataset(testdata []rtmgr.Endpoint) {
38 rtmgr.Eps = make(map[string]*rtmgr.Endpoint)
zkoczkaaaf8d392019-10-02 17:16:06 +020039 for _, endpoint := range testdata {
kalnagy92162652019-07-02 15:15:49 +020040 ep := endpoint
41 rtmgr.Eps[ep.Uuid] = &ep
42 }
43}
44
45/*
kalnagy92162652019-07-02 15:15:49 +020046RmrPush.GeneratePolicies() method is tested for happy path case
47*/
48func TestRmrPushGeneratePolicies(t *testing.T) {
49 var rmrpush = RmrPush{}
wahidwda0fd3a2020-01-01 04:28:41 +000050 var pcs rtmgr.RicComponents
wahidw480359e2020-04-06 06:56:02 +000051 resetTestDataset(stub.ValidEndpoints1)
wahidwda0fd3a2020-01-01 04:28:41 +000052 stub.ValidPlatformComponents = nil
53 rtmgr.Subs = *stub.ValidSubscriptions
54 rtmgr.PrsCfg = stub.DummyRoutes
55 stub.E2map["E2instance1.com"] = stub.ValidE2TInstance
56 pcs = stub.ValidRicComponents
kalnagy92162652019-07-02 15:15:49 +020057
prabhukaliswamye110ee02019-12-23 09:51:01 +000058 rawrt := rmrpush.GeneratePolicies(rtmgr.Eps, &pcs)
kalnagy92162652019-07-02 15:15:49 +020059 t.Log(rawrt)
60}
wahidw427929c2019-12-16 07:02:50 +000061
62/*
63getEndpointByUuid: Pass empty and valid values
64*/
65func TestRmrgetEndpointByUuid(t *testing.T) {
wahidwda0fd3a2020-01-01 04:28:41 +000066 var ep *rtmgr.Endpoint
67 ep = getEndpointByUuid("")
68 t.Logf("getEndpointByUuid() return was correct, got: %v, want: %v.", ep, "<nil>")
69 ep = getEndpointByUuid("10.0.0.1:0")
wahidw427929c2019-12-16 07:02:50 +000070}
71
72/*
73GetRpe Instance with empty and valid values
74*/
75func TestRmrGetRpe(t *testing.T) {
wahidwda0fd3a2020-01-01 04:28:41 +000076 _, _ = GetRpe("")
77 _, _ = GetRpe("rmrpush")
wahidw427929c2019-12-16 07:02:50 +000078}
wahidw2f9b55c2020-01-14 05:20:39 +000079
80/*
81generateRouteTable with empty Platform components
82*/
83func TestGenerateRouteTableRmrGetRpe(t *testing.T) {
84 rpe := Rpe{}
85 _ = rpe.generateRouteTable(stub.ValidEndPointsEmpty)
86}