6c7eede1ceeaaf9e783e7fc1eb182c5cf7809b45
[vfc/nfvo/driver/vnfm/svnfm.git] / nokia / vnfmdriver / vfcadaptorservice / vfcadaptor / src / test / java / org / onap / vfc / nfvo / driver / vnfm / svnfm / cbam / impl / CbamMgmrImplTest.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.cbam.impl;
18
19 import static org.mockito.Mockito.when;
20
21 import java.io.IOException;
22 import java.util.HashMap;
23
24 import org.apache.http.client.ClientProtocolException;
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.mockito.InjectMocks;
28 import org.mockito.Mock;
29 import org.mockito.Mockito;
30 import org.mockito.MockitoAnnotations;
31 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfRequest;
32 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfResponse;
33 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfRequest;
34 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfResponse;
35 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMInstantiateVnfRequest;
36 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMInstantiateVnfResponse;
37 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMQueryVnfResponse;
38 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfRequest;
39 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfResponse;
40 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfRequest;
41 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfResponse;
42 import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv;
43 import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf;
44 import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpResult;
45 import org.springframework.web.bind.annotation.RequestMethod;
46
47 public class CbamMgmrImplTest {
48         @InjectMocks
49         private CbamMgmrImpl cbamMgmr;
50         
51         @Mock
52         private HttpClientProcessorInf httpClientProcessor;
53         
54         private String vnfInstanceId = "vnfInstanceId_001";
55         
56         @Before
57         public void setUp() throws Exception {
58                 MockitoAnnotations.initMocks(this);
59                 AdaptorEnv env = new AdaptorEnv();
60                 cbamMgmr.setAdaptorEnv(env);
61                 MockitoAnnotations.initMocks(this);
62                 
63                 String json = "{\"access_token\":\"1234567\"}";
64                 HttpResult httpResult = new HttpResult();
65                 httpResult.setContent(json);
66                 
67                 when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(httpResult);
68         }
69         
70         @Test
71         public void testCreateVnf() throws ClientProtocolException, IOException
72         {
73                 CBAMCreateVnfRequest cbamRequest = new CBAMCreateVnfRequest();
74                 CBAMCreateVnfResponse response = cbamMgmr.createVnf(cbamRequest);
75         }
76         
77         @Test
78         public void testInstantiateVnf() throws ClientProtocolException, IOException
79         {
80                 CBAMInstantiateVnfRequest cbamRequest = new CBAMInstantiateVnfRequest();
81                 CBAMInstantiateVnfResponse response = cbamMgmr.instantiateVnf(cbamRequest, vnfInstanceId);
82         }
83         
84         @Test
85         public void testTerminateVnf() throws ClientProtocolException, IOException
86         {
87                 CBAMTerminateVnfRequest cbamRequest = new CBAMTerminateVnfRequest();
88                 CBAMTerminateVnfResponse response = cbamMgmr.terminateVnf(cbamRequest, vnfInstanceId);
89         }
90         
91         @Test
92         public void testDeleteVnf() throws ClientProtocolException, IOException
93         {
94                 cbamMgmr.deleteVnf(vnfInstanceId);
95         }
96         
97         @Test
98         public void testScaleVnf() throws ClientProtocolException, IOException
99         {
100                 CBAMScaleVnfRequest cbamRequest = new CBAMScaleVnfRequest();
101                 CBAMScaleVnfResponse response = cbamMgmr.scaleVnf(cbamRequest, vnfInstanceId);
102         }
103         
104         @Test
105         public void testHealVnf() throws ClientProtocolException, IOException
106         {
107                 CBAMHealVnfRequest cbamRequest = new CBAMHealVnfRequest();
108                 CBAMHealVnfResponse response = cbamMgmr.healVnf(cbamRequest, vnfInstanceId);
109         }
110         
111         @Test
112         public void testQueryVnf() throws ClientProtocolException, IOException
113         {
114                 CBAMQueryVnfResponse response = cbamMgmr.queryVnf(vnfInstanceId);
115         }
116 }