2 * Copyright 2016-2017, Nokia Corporation
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.impl;
19 import static org.mockito.Mockito.when;
21 import java.io.IOException;
22 import java.util.HashMap;
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;
46 public class CbamMgmrImplTest {
48 private CbamMgmrImpl cbamMgmr;
51 private HttpClientProcessorInf httpClientProcessor;
53 private String vnfInstanceId = "vnfInstanceId_001";
56 public void setUp() throws Exception {
57 MockitoAnnotations.initMocks(this);
58 AdaptorEnv env = new AdaptorEnv();
59 cbamMgmr.setAdaptorEnv(env);
60 MockitoAnnotations.initMocks(this);
62 String json = "{\"access_token\":\"1234567\"}";
64 when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(json);
68 public void testCreateVnf() throws ClientProtocolException, IOException
70 CBAMCreateVnfRequest cbamRequest = new CBAMCreateVnfRequest();
71 CBAMCreateVnfResponse response = cbamMgmr.createVnf(cbamRequest);
75 public void testInstantiateVnf() throws ClientProtocolException, IOException
77 CBAMInstantiateVnfRequest cbamRequest = new CBAMInstantiateVnfRequest();
78 CBAMInstantiateVnfResponse response = cbamMgmr.instantiateVnf(cbamRequest, vnfInstanceId);
82 public void testTerminateVnf() throws ClientProtocolException, IOException
84 CBAMTerminateVnfRequest cbamRequest = new CBAMTerminateVnfRequest();
85 CBAMTerminateVnfResponse response = cbamMgmr.terminateVnf(cbamRequest, vnfInstanceId);
89 public void testDeleteVnf() throws ClientProtocolException, IOException
91 cbamMgmr.deleteVnf(vnfInstanceId);
95 public void testScaleVnf() throws ClientProtocolException, IOException
97 CBAMScaleVnfRequest cbamRequest = new CBAMScaleVnfRequest();
98 CBAMScaleVnfResponse response = cbamMgmr.scaleVnf(cbamRequest, vnfInstanceId);
102 public void testHealVnf() throws ClientProtocolException, IOException
104 CBAMHealVnfRequest cbamRequest = new CBAMHealVnfRequest();
105 CBAMHealVnfResponse response = cbamMgmr.healVnf(cbamRequest, vnfInstanceId);
109 public void testQueryVnf() throws ClientProtocolException, IOException
111 CBAMQueryVnfResponse response = cbamMgmr.queryVnf(vnfInstanceId);