From aa3e21c2fb093d886be4592d6061829448a0a9e1 Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Mon, 5 Dec 2022 11:40:41 +0000 Subject: [PATCH] Model to handle Reset Response Provided the model to support Reset response. Issue-ID: RIC-387 Signed-off-by: subhash kumar singh Change-Id: Ibff6de48ce8070ebbb0a35cc04ce1420d48b5dcb --- E2Manager/models/e2_reset_response.go | 61 ++++++++++++++++++++++ E2Manager/models/e2_reset_response_test.go | 51 ++++++++++++++++++ E2Manager/tests/resources/reset/reset-response.xml | 19 +++++++ 3 files changed, 131 insertions(+) create mode 100644 E2Manager/models/e2_reset_response.go create mode 100644 E2Manager/models/e2_reset_response_test.go create mode 100644 E2Manager/tests/resources/reset/reset-response.xml diff --git a/E2Manager/models/e2_reset_response.go b/E2Manager/models/e2_reset_response.go new file mode 100644 index 0000000..846bf70 --- /dev/null +++ b/E2Manager/models/e2_reset_response.go @@ -0,0 +1,61 @@ +// +// Copyright 2022 Samsung Electronics Co. +// +// 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 models + +import ( + "encoding/xml" +) + +type E2ResetResponseMessage struct { + XMLName xml.Name `xml:"E2ResetRequestMessage"` + Text string `xml:",chardata"` + E2APPDU struct { + XMLName xml.Name `xml:"E2AP-PDU"` + Text string `xml:",chardata"` + SuccessfulOutcome struct { + Text string `xml:",chardata"` + ProcedureCode string `xml:"procedureCode"` + Criticality struct { + Text string `xml:",chardata"` + Ignore string `xml:"ignore"` + } `xml:"criticality"` + Value struct { + Text string `xml:",chardata"` + ResetResponse struct { + Text string `xml:",chardata"` + ProtocolIEs struct { + Text string `xml:",chardata"` + ResetResponseIEs []struct { + Text string `xml:",chardata"` + ID string `xml:"id"` + Criticality struct { + Text string `xml:",chardata"` + Ignore string `xml:"ignore"` + } `xml:"criticality"` + Value struct { + Text string `xml:",chardata"` + TransactionID string `xml:"TransactionID"` + } `xml:"value"` + } `xml:"ResetResponseIEs"` + } `xml:"protocolIEs"` + } `xml:"ResetResponse"` + } `xml:"value"` + } `xml:"successfulOutcome"` + } `xml:"E2AP-PDU"` +} diff --git a/E2Manager/models/e2_reset_response_test.go b/E2Manager/models/e2_reset_response_test.go new file mode 100644 index 0000000..bba984f --- /dev/null +++ b/E2Manager/models/e2_reset_response_test.go @@ -0,0 +1,51 @@ +// +// Copyright 2022 Samsung Electronics Co. +// +// 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 models_test + +import ( + "e2mgr/models" + "e2mgr/utils" + "encoding/xml" + "testing" + + "github.com/stretchr/testify/assert" +) + +const ( + ResetResponseXMLPath = "../tests/resources/reset/reset-response.xml" +) + +func getResetResponseMessage(t *testing.T, xmlPath string) *models.E2ResetResponseMessage { + resetResponse := utils.ReadXmlFile(t, xmlPath) + resetResponseMsg := &models.E2ResetResponseMessage{} + err := xml.Unmarshal(utils.NormalizeXml(resetResponse), &resetResponseMsg.E2APPDU) + assert.Nil(t, err) + return resetResponseMsg +} + +func TestParseResetResponse(t *testing.T) { + rr := getResetResponseMessage(t, ResetResponseXMLPath) + assert.NotEqual(t, nil, rr, "xml is not parsed correctly") + assert.Equal(t, models.ProcedureCode_id_Reset, rr.E2APPDU.SuccessfulOutcome.ProcedureCode) + assert.Equal(t, 1, len(rr.E2APPDU.SuccessfulOutcome.Value.ResetResponse.ProtocolIEs.ResetResponseIEs)) + + txid := rr.E2APPDU.SuccessfulOutcome.Value.ResetResponse.ProtocolIEs.ResetResponseIEs[0] + + assert.Equal(t, models.ProtocolIE_ID_id_TransactionID, txid.ID) +} diff --git a/E2Manager/tests/resources/reset/reset-response.xml b/E2Manager/tests/resources/reset/reset-response.xml new file mode 100644 index 0000000..46ea291 --- /dev/null +++ b/E2Manager/tests/resources/reset/reset-response.xml @@ -0,0 +1,19 @@ + + + 3 + + + + + + 49 + + + 1 + + + + + + + \ No newline at end of file -- 2.16.6