Add Unit Tests.
[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.springframework.web.bind.annotation.RequestMethod;
45
46 public class CbamMgmrImplTest {
47         @InjectMocks
48         private CbamMgmrImpl cbamMgmr;
49         
50         @Mock
51         private HttpClientProcessorInf httpClientProcessor;
52         
53         private String vnfInstanceId = "vnfInstanceId_001";
54         
55         @Before
56         public void setUp() throws Exception {
57                 MockitoAnnotations.initMocks(this);
58                 AdaptorEnv env = new AdaptorEnv();
59                 cbamMgmr.setAdaptorEnv(env);
60                 MockitoAnnotations.initMocks(this);
61                 
62                 String json = "{\"access_token\":\"1234567\"}";
63                 
64                 when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(json);
65         }
66         
67         @Test
68         public void testCreateVnf() throws ClientProtocolException, IOException
69         {
70                 CBAMCreateVnfRequest cbamRequest = new CBAMCreateVnfRequest();
71                 CBAMCreateVnfResponse response = cbamMgmr.createVnf(cbamRequest);
72         }
73         
74         @Test
75         public void testInstantiateVnf() throws ClientProtocolException, IOException
76         {
77                 CBAMInstantiateVnfRequest cbamRequest = new CBAMInstantiateVnfRequest();
78                 CBAMInstantiateVnfResponse response = cbamMgmr.instantiateVnf(cbamRequest, vnfInstanceId);
79         }
80         
81         @Test
82         public void testTerminateVnf() throws ClientProtocolException, IOException
83         {
84                 CBAMTerminateVnfRequest cbamRequest = new CBAMTerminateVnfRequest();
85                 CBAMTerminateVnfResponse response = cbamMgmr.terminateVnf(cbamRequest, vnfInstanceId);
86         }
87         
88         @Test
89         public void testDeleteVnf() throws ClientProtocolException, IOException
90         {
91                 cbamMgmr.deleteVnf(vnfInstanceId);
92         }
93         
94         @Test
95         public void testScaleVnf() throws ClientProtocolException, IOException
96         {
97                 CBAMScaleVnfRequest cbamRequest = new CBAMScaleVnfRequest();
98                 CBAMScaleVnfResponse response = cbamMgmr.scaleVnf(cbamRequest, vnfInstanceId);
99         }
100         
101         @Test
102         public void testHealVnf() throws ClientProtocolException, IOException
103         {
104                 CBAMHealVnfRequest cbamRequest = new CBAMHealVnfRequest();
105                 CBAMHealVnfResponse response = cbamMgmr.healVnf(cbamRequest, vnfInstanceId);
106         }
107         
108         @Test
109         public void testQueryVnf() throws ClientProtocolException, IOException
110         {
111                 CBAMQueryVnfResponse response = cbamMgmr.queryVnf(vnfInstanceId);
112         }
113 }