2904d49f16d3198f052dc034b45f8da71bdecc49
[nonrtric.git] / test / usecases / odusliceassurance / goversion / messages / stdVesMessage_test.go
1 // -
2 //   ========================LICENSE_START=================================
3 //   O-RAN-SC
4 //   %%
5 //   Copyright (C) 2021: Nordix Foundation
6 //   %%
7 //   Licensed under the Apache License, Version 2.0 (the "License");
8 //   you may not use this file except in compliance with the License.
9 //   You may obtain a copy of the License at
10 //
11 //        http://www.apache.org/licenses/LICENSE-2.0
12 //
13 //   Unless required by applicable law or agreed to in writing, software
14 //   distributed under the License is distributed on an "AS IS" BASIS,
15 //   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 //   See the License for the specific language governing permissions and
17 //   limitations under the License.
18 //   ========================LICENSE_END===================================
19 //
20
21 package messages
22
23 import (
24         "testing"
25 )
26
27 func TestGetMeasurements(t *testing.T) {
28         type fields struct {
29                 Event Event
30         }
31         tests := []struct {
32                 name   string
33                 fields fields
34                 want   []Measurement
35         }{
36                 {
37                         name: "get measurements message",
38                         fields: fields{
39                                 Event: Event{
40                                         CommonEventHeader: CommonEventHeader{
41                                                 Domain:               "stndDefined",
42                                                 StndDefinedNamespace: "o-ran-sc-du-hello-world-pm-streaming-oas3",
43                                         },
44                                         StndDefinedFields: StndDefinedFields{
45                                                 StndDefinedFieldsVersion: "1.0",
46                                                 SchemaReference:          "https://gerrit.o-ran-sc.org/r/gitweb?p=scp/oam/modeling.git;a=blob_plain;f=data-model/oas3/experimental/o-ran-sc-du-hello-world-oas3.json;hb=refs/heads/master",
47                                                 Data: Data{
48                                                         DataId: "id",
49                                                         Measurements: []Measurement{{
50                                                                 MeasurementTypeInstanceReference: "/o-ran-sc-du-hello-world:network-function/distributed-unit-functions[id='O-DU-1211']/cell[id='cell-1']/supported-measurements[performance-measurement-type='user-equipment-average-throughput-uplink']/supported-snssai-subcounter-instances[slice-differentiator='1'][slice-service-type='1']",
51                                                                 Value:                            51232,
52                                                                 Unit:                             "kbit/s",
53                                                         }},
54                                                 },
55                                         },
56                                 },
57                         },
58                         want: []Measurement{{
59                                 MeasurementTypeInstanceReference: "/o-ran-sc-du-hello-world:network-function/distributed-unit-functions[id='O-DU-1211']/cell[id='cell-1']/supported-measurements[performance-measurement-type='user-equipment-average-throughput-uplink']/supported-snssai-subcounter-instances[slice-differentiator='1'][slice-service-type='1']",
60                                 Value:                            51232,
61                                 Unit:                             "kbit/s",
62                         }},
63                 },
64         }
65
66         for _, tt := range tests {
67                 t.Run(tt.name, func(t *testing.T) {
68                         message := StdDefinedMessage{
69                                 Event: tt.fields.Event,
70                         }
71                         if got := message.GetMeasurements(); len(got) != len(tt.want) {
72                                 t.Errorf("Message.GetMeasurements() = %v, want %v", got, tt.want)
73                         }
74                 })
75         }
76 }