2 // ========================LICENSE_START=================================
5 // Copyright (C) 2021: Nordix Foundation
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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===================================
26 "github.com/stretchr/testify/require"
29 func TestGetMeasurements(t *testing.T) {
30 assertions := require.New(t)
40 name: "get measurements message",
43 CommonEventHeader: CommonEventHeader{
44 Domain: "stndDefined",
45 StndDefinedNamespace: "o-ran-sc-du-hello-world-pm-streaming-oas3",
47 StndDefinedFields: StndDefinedFields{
48 StndDefinedFieldsVersion: "1.0",
49 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",
52 Measurements: []Measurement{{
53 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']",
62 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']",
69 for _, tt := range tests {
70 t.Run(tt.name, func(t *testing.T) {
71 message := StdDefinedMessage{
72 Event: tt.fields.Event,
75 if got = message.GetMeasurements(); len(got) != len(tt.want) {
76 t.Errorf("Message.GetMeasurements() = %v, want %v", got, tt.want)
79 for _, meas := range got {
80 assertions.Equal(51232, meas.Value)
81 assertions.Contains(meas.MeasurementTypeInstanceReference, "user-equipment-average-throughput-uplink")