9881749e71261e75f05b399fd86ff62b654f2db4
[vfc/nfvo/driver/vnfm/svnfm.git] /
1 /*
2  * Copyright 2016-2017, Nokia Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc;
18
19 import org.junit.Before;
20 import org.junit.Test;
21 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
22 import org.onap.vfccatalog.ApiClient;
23 import org.onap.vfccatalog.api.VnfpackageApi;
24
25 import static junit.framework.TestCase.assertEquals;
26 import static junit.framework.TestCase.assertNotNull;
27 import static org.mockito.Mockito.when;
28
29 public class TestVfcRestApiProvider extends TestBase {
30     private VfcRestApiProvider vfcRestApiProvider;
31
32     @Before
33     public void init() {
34         vfcRestApiProvider = new VfcRestApiProvider(msbApiProvider);
35     }
36
37     /**
38      * the base URL of the LCM API is set
39      */
40     @Test
41     public void testNsLcmApi() throws Exception {
42         when(msbApiProvider.getMicroServiceUrl(VfcRestApiProvider.NSLCM_API_SERVICE_NAME, VfcRestApiProvider.NSLCM_API_VERION)).thenReturn("http://1.2.3.4:1234/nslcm/v1/lead/");
43         //when
44         org.onap.vnfmdriver.ApiClient apiClient = vfcRestApiProvider.buildNslcmApiClient();
45         //verify
46         assertEquals("http://1.2.3.4:1234/lead/", apiClient.getAdapterBuilder().build().baseUrl().toString());
47     }
48
49     /**
50      * the base URL of the Catalog API is set
51      */
52     @Test
53     public void testNsCatalogApi() throws Exception {
54         when(msbApiProvider.getMicroServiceUrl(VfcRestApiProvider.NSCATALOG_SERVICE_NAME, VfcRestApiProvider.NSCATALOG_API_VERSION)).thenReturn("http://1.2.3.4:1234/lead/");
55         //when
56         ApiClient apiClient = vfcRestApiProvider.buildCatalogApiClient();
57         //verify
58         assertEquals("http://1.2.3.4:1234/lead/", apiClient.getAdapterBuilder().build().baseUrl().toString());
59     }
60
61     @Test
62     public void testNsLcm() {
63         when(msbApiProvider.getMicroServiceUrl(VfcRestApiProvider.NSLCM_API_SERVICE_NAME, VfcRestApiProvider.NSLCM_API_VERION)).thenReturn("http://1.2.3.4:1234/nslcm/v1/lead/");
64         //when
65         //verify
66         assertNotNull(vfcRestApiProvider.getNsLcmApi());
67     }
68
69     @Test
70     public void testNsCatalog() {
71         when(msbApiProvider.getMicroServiceUrl(VfcRestApiProvider.NSCATALOG_SERVICE_NAME, VfcRestApiProvider.NSCATALOG_API_VERSION)).thenReturn("http://1.2.3.4:1234/lead/");
72         //when
73         VnfpackageApi catalogApi = vfcRestApiProvider.getVfcCatalogApi();
74         //verify
75         assertNotNull(catalogApi);
76     }
77 }