2 // ========================LICENSE_START=================================
5 // Copyright (C) 2022: 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===================================
21 package sliceassurance
27 "oransc.org/usecase/oduclosedloop/icsversion/messages"
30 func TestGetStdDefinedMessages(t *testing.T) {
32 messageStrings *[]string
37 want []messages.StdDefinedMessage
42 messageStrings: &[]string{
43 `{"event":{"commonEventHeader":{"domain":"stnd","eventId":"pm-1","eventName":"stndDefined","eventType":"performanceMeasurementStreaming","sequence":825,"priority":"Low","reportingEntityId":"","reportingEntityName":"O-DU-1122","sourceId":"","sourceName":"O-DU-1122","stndDefinedNamespace":"o-ran-sc-du-hello-world","version":"4.1","vesEventListenerVersion":"7.2.1"},"stndDefinedFields":{"stndDefinedFieldsVersion":"1.0","schemaReference":"o-ran-sc-du-hello-world","data":{"id":"pm-1_123","administrative-state":"unlocked","operational-state":"enabled","user-label":"pm","job-tag":"my-job-tag","granularity-period":30,"measurements":[{"measurement-type-instance-reference":"reference","value":5861,"unit":"kbit/s"}]}}}}`,
46 want: []messages.StdDefinedMessage{{
47 Event: messages.Event{
48 CommonEventHeader: messages.CommonEventHeader{
51 EventName: "stndDefined",
52 EventType: "performanceMeasurementStreaming",
55 ReportingEntityName: "O-DU-1122",
56 SourceName: "O-DU-1122",
57 StndDefinedNamespace: "o-ran-sc-du-hello-world",
59 VesEventListenerVersion: "7.2.1",
61 StndDefinedFields: messages.StndDefinedFields{
62 StndDefinedFieldsVersion: "1.0",
63 SchemaReference: "o-ran-sc-du-hello-world",
66 AdministrativeState: "unlocked",
67 OperationalState: "enabled",
70 GranularityPeriod: 30,
71 Measurements: []messages.Measurement{{
72 MeasurementTypeInstanceReference: "reference",
82 for _, tt := range tests {
83 t.Run(tt.name, func(t *testing.T) {
84 if got := getStdMessages(tt.args.messageStrings); !reflect.DeepEqual(got, tt.want) {
85 t.Errorf("getStdMessages() = %v, want %v", got, tt.want)