2 // Copyright 2019 AT&T Intellectual Property
3 // Copyright 2019 Nokia
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
17 // This source code is part of the near-RT RIC (RAN Intelligent Controller)
18 // platform project (RICP).
30 const E2TAddress = "10.0.2.15:38000"
32 // TODO: add response Body and dont check for nil in prod code. itll always be populated
34 func initRoutingManagerClientTest(t *testing.T) (*RoutingManagerClient, *mocks.HttpClientMock, *configuration.Configuration) {
36 config := &configuration.Configuration{
37 RoutingManagerBaseUrl: "http://iltlv740.intl.att.com:8080/ric/v1/handles/v1/",
39 httpClientMock := &mocks.HttpClientMock{}
40 rmClient := NewRoutingManagerClient(logger, config, httpClientMock)
41 return rmClient, httpClientMock, config
44 //func TestAddE2TInstanceSuccess(t *testing.T) {
45 // rmClient, httpClientMock, config := initRoutingManagerClientTest(t)
47 // data := models.NewRoutingManagerE2TData(E2TAddress)
48 // marshaled, _ := json.Marshal(data)
49 // body := bytes.NewBuffer(marshaled)
50 // url := config.RoutingManagerBaseUrl + "e2t"
51 // httpClientMock.On("Post", url, "application/json", body).Return(&http.Response{StatusCode: 200}, nil)
52 // err := rmClient.AddE2TInstance(E2TAddress)
56 //func TestAddE2TInstanceFailure(t *testing.T) {
57 // rmClient, httpClientMock, config := initRoutingManagerClientTest(t)
59 // data := models.NewRoutingManagerE2TData(E2TAddress)
60 // marshaled, _ := json.Marshal(data)
61 // body := bytes.NewBuffer(marshaled)
62 // url := config.RoutingManagerBaseUrl + "e2t"
63 // httpClientMock.On("Post", url, "application/json", body).Return(&http.Response{StatusCode: 400}, nil)
64 // err := rmClient.AddE2TInstance(E2TAddress)
65 // assert.NotNil(t, err)
68 // TODO: extract to test_utils
69 func initLog(t *testing.T) *logger.Logger {
70 log, err := logger.InitLogger(logger.InfoLevel)
72 t.Errorf("#delete_all_request_handler_test.TestHandleSuccessFlow - failed to initialize logger, error: %s", err)
77 //func TestAddE2TInstanceInteg(t *testing.T) {
78 // logger := initLog(t)
79 // config := configuration.ParseConfiguration()
80 // httpClient := &http.Client{}
81 // rmClient := NewRoutingManagerClient(logger, config, httpClient)
82 // err := rmClient.AddE2TInstance(E2TAddress)