Model to handle Reset Response 51/9951/1
authorsubhash kumar singh <subh.singh@samsung.com>
Mon, 5 Dec 2022 11:40:41 +0000 (11:40 +0000)
committersubhash kumar singh <subh.singh@samsung.com>
Mon, 5 Dec 2022 11:40:41 +0000 (11:40 +0000)
Provided the model to support Reset response.

Issue-ID: RIC-387
Signed-off-by: subhash kumar singh <subh.singh@samsung.com>
Change-Id: Ibff6de48ce8070ebbb0a35cc04ce1420d48b5dcb

E2Manager/models/e2_reset_response.go [new file with mode: 0644]
E2Manager/models/e2_reset_response_test.go [new file with mode: 0644]
E2Manager/tests/resources/reset/reset-response.xml [new file with mode: 0644]

diff --git a/E2Manager/models/e2_reset_response.go b/E2Manager/models/e2_reset_response.go
new file mode 100644 (file)
index 0000000..846bf70
--- /dev/null
@@ -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 (file)
index 0000000..bba984f
--- /dev/null
@@ -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 (file)
index 0000000..46ea291
--- /dev/null
@@ -0,0 +1,19 @@
+<E2AP-PDU>
+    <successfulOutcome>
+        <procedureCode>3</procedureCode>
+        <criticality><ignore/></criticality>
+        <value>
+            <ResetResponse>
+                <protocolIEs>
+                    <ResetResponseIEs>
+                        <id>49</id>
+                        <criticality><ignore/></criticality>
+                        <value>
+                            <TransactionID>1</TransactionID>
+                        </value>
+                    </ResetResponseIEs>
+                </protocolIEs>
+            </ResetResponse>
+        </value>
+    </successfulOutcome>
+</E2AP-PDU>
\ No newline at end of file