Updating Nokia driver
[vfc/nfvo/driver/vnfm/svnfm.git] / nokiav2 / driver / src / test / java / org / onap / vfc / nfvo / driver / vnfm / svnfm / nokia / onap / vfc / TestVfcRestApiProvider.java
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.api.VnfpackageApi;
23 import org.onap.vnfmdriver.api.NslcmApi;
24
25 import static junit.framework.TestCase.assertEquals;
26 import static junit.framework.TestCase.assertNull;
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      * test VF-C NSLCM API retrieval
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         NslcmApi nsLcmApi = vfcRestApiProvider.getNsLcmApi();
45         //verify
46         assertEquals("http://1.2.3.4:1234/lead", nsLcmApi.getApiClient().getBasePath());
47         assertNull(nsLcmApi.getApiClient().getSslCaCert());
48         assertEquals(0, nsLcmApi.getApiClient().getAuthentications().size());
49     }
50
51     /**
52      * test VF-C catalog API retrieval
53      */
54     @Test
55     public void testNsCatalogApi() throws Exception {
56         when(msbApiProvider.getMicroServiceUrl(VfcRestApiProvider.NSCATALOG_SERVICE_NAME, VfcRestApiProvider.NSCATALOG_API_VERSION)).thenReturn("http://1.2.3.4:1234/lead");
57         //when
58         VnfpackageApi nsCatalogApi = vfcRestApiProvider.getOnapCatalogApi();
59         //verify
60         assertEquals("http://1.2.3.4:1234/lead", nsCatalogApi.getApiClient().getBasePath());
61         assertNull(nsCatalogApi.getApiClient().getSslCaCert());
62         assertEquals(0, nsCatalogApi.getApiClient().getAuthentications().size());
63     }
64 }