+ controllerUpdateEnbTestExecuter(t, &context)
+}
+
+func TestControllerUpdateEnbValidServedCellsGetNodebNotFound(t *testing.T) {
+ context := controllerUpdateEnbTestContext{
+ getNodebInfoResult: &getNodebInfoResult{
+ nodebInfo: nil,
+ rnibError: common.NewResourceNotFoundError("#reader.GetNodeb - Not found Error"),
+ },
+ requestBody: getUpdateEnbRequest(""),
+ expectedStatusCode: http.StatusNotFound,
+ expectedJsonResponse: ResourceNotFoundJson,
+ }
+
+ controllerUpdateEnbTestExecuter(t, &context)
+}
+
+func TestControllerUpdateEnbValidServedCellsGetNodebInternalError(t *testing.T) {
+ context := controllerUpdateEnbTestContext{
+ getNodebInfoResult: &getNodebInfoResult{
+ nodebInfo: nil,
+ rnibError: common.NewInternalError(errors.New("#reader.GetNodeb - Internal Error")),
+ },
+ requestBody: getUpdateEnbRequest(""),
+ expectedStatusCode: http.StatusInternalServerError,
+ expectedJsonResponse: RnibErrorJson,
+ }
+
+ controllerUpdateEnbTestExecuter(t, &context)
+}
+
+func TestControllerUpdateEnbGetNodebSuccessGnbTypeFailure(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_GNB,
+ Configuration: &entities.NodebInfo_Enb{Enb: &entities.Enb{ServedCells: oldServedCells}},
+ },
+ rnibError: nil,
+ },
+ requestBody: getUpdateEnbRequest(""),
+ expectedStatusCode: http.StatusBadRequest,
+ expectedJsonResponse: ValidationFailureJson,
+ }
+
+ controllerUpdateEnbTestExecuter(t, &context)
+}
+
+func TestControllerUpdateEnbGetNodebSuccessRemoveServedCellsFailure(t *testing.T) {
+ oldServedCells := generateServedCells("whatever1", "whatever2")
+ context := controllerUpdateEnbTestContext{
+ removeServedCellsParams: &removeServedCellsParams{
+ err: common.NewInternalError(errors.New("#writer.RemoveServedCells - Internal Error")),
+ servedCellInfo: oldServedCells,
+ },
+ 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}},
+ },
+ rnibError: nil,
+ },
+ requestBody: getUpdateEnbRequest(""),
+ expectedStatusCode: http.StatusInternalServerError,
+ expectedJsonResponse: RnibErrorJson,
+ }
+
+ controllerUpdateEnbTestExecuter(t, &context)
+}
+
+func TestControllerUpdateEnbGetNodebSuccessUpdateEnbFailure(t *testing.T) {
+ oldServedCells := generateServedCells("whatever1", "whatever2")
+ context := controllerUpdateEnbTestContext{
+ removeServedCellsParams: &removeServedCellsParams{
+ err: nil,
+ servedCellInfo: oldServedCells,
+ },
+ updateEnbCellsParams: &updateEnbCellsParams{
+ err: common.NewInternalError(errors.New("#writer.UpdateEnb - Internal Error")),
+ },
+ 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_ENB}},
+ },
+ rnibError: nil,
+ },
+ requestBody: getUpdateEnbRequest(""),
+ expectedStatusCode: http.StatusInternalServerError,
+ expectedJsonResponse: RnibErrorJson,
+ }
+
+ controllerUpdateEnbTestExecuter(t, &context)
+}
+
+func TestControllerUpdateEnbSuccess(t *testing.T) {
+ oldServedCells := generateServedCells("whatever1", "whatever2")
+ context := controllerUpdateEnbTestContext{
+ removeServedCellsParams: &removeServedCellsParams{
+ err: nil,
+ servedCellInfo: oldServedCells,
+ },
+ updateEnbCellsParams: &updateEnbCellsParams{
+ err: 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_ENB}},
+ },
+ rnibError: nil,
+ },
+ requestBody: getUpdateEnbRequest(""),
+ expectedStatusCode: http.StatusOK,
+ expectedJsonResponse: "{\"ranName\":\"test\",\"connectionStatus\":\"CONNECTED\",\"nodeType\":\"ENB\",\"enb\":{\"enbType\":\"MACRO_ENB\",\"servedCells\":[{\"pci\":1,\"cellId\":\"whatever\",\"tac\":\"whatever3\",\"broadcastPlmns\":[\"whatever\"],\"choiceEutraMode\":{\"fdd\":{}},\"eutraMode\":\"FDD\"}]},\"associatedE2tInstanceAddress\":\"10.0.2.15:38000\"}",
+ }
+
+ controllerUpdateEnbTestExecuter(t, &context)
+}
+
+func TestControllerAddEnbGetNodebInternalError(t *testing.T) {
+ context := controllerAddEnbTestContext{
+ getNodebInfoResult: &getNodebInfoResult{
+ nodebInfo: nil,
+ rnibError: common.NewInternalError(errors.New("#reader.GetNodeb - Internal Error")),
+ },
+ requestBody: getAddEnbRequest(""),
+ expectedStatusCode: http.StatusInternalServerError,
+ expectedJsonResponse: RnibErrorJson,
+ }
+
+ controllerAddEnbTestExecuter(t, &context)
+}
+
+func TestControllerAddEnbNodebExistsFailure(t *testing.T) {
+ context := controllerAddEnbTestContext{
+ getNodebInfoResult: &getNodebInfoResult{
+ nodebInfo: &entities.NodebInfo{},
+ rnibError: nil,
+ },
+ requestBody: getAddEnbRequest(""),
+ expectedStatusCode: http.StatusBadRequest,
+ expectedJsonResponse: NodebExistsJson,
+ }
+
+ controllerAddEnbTestExecuter(t, &context)
+}
+
+func TestControllerAddEnbSaveNodebFailure(t *testing.T) {
+ context := controllerAddEnbTestContext{
+ saveNodebParams: &saveNodebParams{
+ err: common.NewInternalError(errors.New("#reader.SaveeNodeb - Internal Error")),
+ },
+ getNodebInfoResult: &getNodebInfoResult{
+ nodebInfo: nil,
+ rnibError: common.NewResourceNotFoundError("#reader.GetNodeb - Not found Error"),
+ },
+ requestBody: getAddEnbRequest(""),
+ expectedStatusCode: http.StatusInternalServerError,
+ expectedJsonResponse: RnibErrorJson,
+ }
+
+ controllerAddEnbTestExecuter(t, &context)
+}
+
+func TestControllerAddEnbMissingRequiredRequestProps(t *testing.T) {
+
+ for _, v := range AddEnbRequestRequiredFields {
+ context := controllerAddEnbTestContext{
+ requestBody: getAddEnbRequest(v),
+ expectedStatusCode: http.StatusBadRequest,
+ expectedJsonResponse: ValidationFailureJson,
+ }
+
+ controllerAddEnbTestExecuter(t, &context)