Merge "Automation of nodeb health check"
[ric-plt/e2mgr.git] / E2Manager / controllers / nodeb_controller_test.go
index f57522c..bfdf270 100644 (file)
@@ -1,6 +1,7 @@
 //
 // Copyright 2019 AT&T Intellectual Property
 // Copyright 2019 Nokia
+// Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -160,9 +161,7 @@ func generateServedNrCells(cellIds ...string) []*entities.ServedNRCell {
                servedNrCells = append(servedNrCells, &entities.ServedNRCell{ServedNrCellInformation: &entities.ServedNRCellInformation{
                        CellId: v,
                        ChoiceNrMode: &entities.ServedNRCellInformation_ChoiceNRMode{
-                               Fdd: &entities.ServedNRCellInformation_ChoiceNRMode_FddInfo{
-
-                               },
+                               Fdd: &entities.ServedNRCellInformation_ChoiceNRMode_FddInfo{},
                        },
                        NrMode:      entities.Nr_FDD,
                        NrPci:       5,
@@ -631,8 +630,7 @@ func TestControllerUpdateGnbEmptyServedNrCells(t *testing.T) {
        context := controllerUpdateGnbTestContext{
                getNodebInfoResult: nil,
                requestBody: map[string]interface{}{
-                       "servedNrCells": []interface{}{
-                       },
+                       "servedNrCells": []interface{}{},
                },
                expectedStatusCode:   http.StatusBadRequest,
                expectedJsonResponse: ValidationFailureJson,
@@ -1176,16 +1174,16 @@ func TestControllerUpdateEnbNgEnbFailure(t *testing.T) {
        oldServedCells := generateServedCells("whatever1", "whatever2")
 
        context := controllerUpdateEnbTestContext{
-               getNodebInfoResult:  &getNodebInfoResult{
-               nodebInfo: &entities.NodebInfo{
-               RanName:                      RanName,
-               ConnectionStatus:             entities.ConnectionStatus_CONNECTED,
-               AssociatedE2TInstanceAddress: AssociatedE2TInstanceAddress,
-               NodeType:                     entities.Node_ENB,
-               Configuration:                &entities.NodebInfo_Enb{Enb: &entities.Enb{ServedCells: oldServedCells, EnbType: entities.EnbType_MACRO_NG_ENB}},
-       },
-               rnibError: nil,
-       },
+               getNodebInfoResult: &getNodebInfoResult{
+                       nodebInfo: &entities.NodebInfo{
+                               RanName:                      RanName,
+                               ConnectionStatus:             entities.ConnectionStatus_CONNECTED,
+                               AssociatedE2TInstanceAddress: AssociatedE2TInstanceAddress,
+                               NodeType:                     entities.Node_ENB,
+                               Configuration:                &entities.NodebInfo_Enb{Enb: &entities.Enb{ServedCells: oldServedCells, EnbType: entities.EnbType_MACRO_NG_ENB}},
+                       },
+                       rnibError: nil,
+               },
                requestBody:          requestBody,
                expectedStatusCode:   http.StatusBadRequest,
                expectedJsonResponse: ValidationFailureJson,
@@ -1807,6 +1805,10 @@ func TestHandleErrorResponse(t *testing.T) {
        controller.handleErrorResponse(e2managererrors.NewRmrError(), writer)
        assert.Equal(t, http.StatusInternalServerError, writer.Result().StatusCode)
 
+       writer = httptest.NewRecorder()
+       controller.handleErrorResponse(e2managererrors.NewNoConnectedRanError(), writer)
+       assert.Equal(t, http.StatusNotFound, writer.Result().StatusCode)
+
        writer = httptest.NewRecorder()
        controller.handleErrorResponse(e2managererrors.NewResourceNotFoundError(), writer)
        assert.Equal(t, http.StatusNotFound, writer.Result().StatusCode)