Improve unit-test coverage
[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 import java.util.List;
24
25 import org.apache.http.client.ClientProtocolException;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.mockito.InjectMocks;
29 import org.mockito.Mock;
30 import org.mockito.Mockito;
31 import org.mockito.MockitoAnnotations;
32 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateSubscriptionRequest;
33 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateSubscriptionResponse;
34 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfRequest;
35 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfResponse;
36 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfRequest;
37 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfResponse;
38 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMInstantiateVnfRequest;
39 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMInstantiateVnfResponse;
40 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMModifyVnfRequest;
41 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMModifyVnfResponse;
42 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMQueryOperExecutionResponse;
43 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMQueryVnfResponse;
44 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfRequest;
45 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfResponse;
46 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfRequest;
47 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfResponse;
48 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMVnfNotificationRequest;
49 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMVnfNotificationResponse;
50 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.Subscription;
51 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.VnfcResourceInfo;
52 import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv;
53 import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf;
54 import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpResult;
55 import org.springframework.web.bind.annotation.RequestMethod;
56
57 public class CbamMgmrImplTest {
58         @InjectMocks
59         private CbamMgmrImpl cbamMgmr;
60         
61         @Mock
62         private HttpClientProcessorInf httpClientProcessor;
63         
64         private String vnfInstanceId = "vnfInstanceId_001";
65         
66         @Before
67         public void setUp() throws Exception {
68                 MockitoAnnotations.initMocks(this);
69                 AdaptorEnv env = new AdaptorEnv();
70                 cbamMgmr.setAdaptorEnv(env);
71                 
72                 String json = "{\"access_token\":\"1234567\"}";
73                 HttpResult httpResult = new HttpResult();
74                 httpResult.setStatusCode(200);
75                 httpResult.setContent(json);
76                 
77                 when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(httpResult);
78         }
79         
80         @Test
81         public void testCreateVnf() throws ClientProtocolException, IOException
82         {
83                 CBAMCreateVnfRequest cbamRequest = new CBAMCreateVnfRequest();
84                 CBAMCreateVnfResponse response = cbamMgmr.createVnf(cbamRequest);
85         }
86         
87         @Test
88         public void testInstantiateVnf() throws ClientProtocolException, IOException
89         {
90                 CBAMInstantiateVnfRequest cbamRequest = new CBAMInstantiateVnfRequest();
91                 CBAMInstantiateVnfResponse response = cbamMgmr.instantiateVnf(cbamRequest, vnfInstanceId);
92         }
93         
94         @Test
95         public void testModifyVnf() throws ClientProtocolException, IOException
96         {
97                 CBAMModifyVnfRequest cbamRequest = new CBAMModifyVnfRequest();
98                 CBAMModifyVnfResponse response = cbamMgmr.modifyVnf(cbamRequest, vnfInstanceId);
99         }
100         
101         @Test
102         public void testTerminateVnf() throws ClientProtocolException, IOException
103         {
104                 CBAMTerminateVnfRequest cbamRequest = new CBAMTerminateVnfRequest();
105                 CBAMTerminateVnfResponse response = cbamMgmr.terminateVnf(cbamRequest, vnfInstanceId);
106         }
107         
108         @Test
109         public void testDeleteVnf() throws ClientProtocolException, IOException
110         {
111                 cbamMgmr.deleteVnf(vnfInstanceId);
112         }
113         
114         @Test
115         public void testScaleVnf() throws ClientProtocolException, IOException
116         {
117                 CBAMScaleVnfRequest cbamRequest = new CBAMScaleVnfRequest();
118                 CBAMScaleVnfResponse response = cbamMgmr.scaleVnf(cbamRequest, vnfInstanceId);
119         }
120         
121         @Test
122         public void testHealVnf() throws ClientProtocolException, IOException
123         {
124                 CBAMHealVnfRequest cbamRequest = new CBAMHealVnfRequest();
125                 CBAMHealVnfResponse response = cbamMgmr.healVnf(cbamRequest, vnfInstanceId);
126         }
127         
128         @Test
129         public void testQueryVnf() throws ClientProtocolException, IOException
130         {
131                 CBAMQueryVnfResponse response = cbamMgmr.queryVnf(vnfInstanceId);
132         }
133         
134         @Test
135         public void testCreateSubscription() throws ClientProtocolException, IOException
136         {
137                 CBAMCreateSubscriptionRequest cbamRequest = new CBAMCreateSubscriptionRequest();
138                 CBAMCreateSubscriptionResponse response = cbamMgmr.createSubscription(cbamRequest);
139         }
140         
141         @Test
142         public void testGetNotification() throws ClientProtocolException, IOException
143         {
144                 CBAMVnfNotificationRequest cbamRequest = new CBAMVnfNotificationRequest();
145                 CBAMVnfNotificationResponse response = cbamMgmr.getNotification(cbamRequest);
146         }
147         
148         @Test
149         public void testGetSubscription() throws ClientProtocolException, IOException
150         {
151                 String subscriptionId = "subscriptionId_001";
152                 Subscription response = cbamMgmr.getSubscription(subscriptionId);
153         }
154         
155         @Test
156         public void testQueryVnfcResource() throws ClientProtocolException, IOException
157         {
158                 String json = "[{'id':'id_001'}]";
159                 HttpResult httpResult = new HttpResult();
160                 httpResult.setStatusCode(200);
161                 httpResult.setContent(json);
162                 
163                 when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(httpResult);
164                 List<VnfcResourceInfo> response = cbamMgmr.queryVnfcResource(vnfInstanceId);
165         }
166         
167         @Test
168         public void testQueryOperExecution() throws ClientProtocolException, IOException
169         {
170                 String execId = "execId_001";
171                 CBAMQueryOperExecutionResponse response = cbamMgmr.queryOperExecution(execId);
172         }
173         
174         @Test
175         public void testUploadVnfPackage() throws ClientProtocolException, IOException
176         {
177                 String cbamPackageFilePath = "cbamPackageFilePath_001";
178                 cbamMgmr.uploadVnfPackage(cbamPackageFilePath);
179         }
180 }