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.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpResult;
45 import org.springframework.web.bind.annotation.RequestMethod;
47 public class CbamMgmrImplTest {
49 private CbamMgmrImpl cbamMgmr;
52 private HttpClientProcessorInf httpClientProcessor;
54 private String vnfInstanceId = "vnfInstanceId_001";
57 public void setUp() throws Exception {
58 MockitoAnnotations.initMocks(this);
59 AdaptorEnv env = new AdaptorEnv();
60 cbamMgmr.setAdaptorEnv(env);
61 MockitoAnnotations.initMocks(this);
63 String json = "{\"access_token\":\"1234567\"}";
64 HttpResult httpResult = new HttpResult();
65 httpResult.setContent(json);
67 when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(httpResult);
71 public void testCreateVnf() throws ClientProtocolException, IOException
73 CBAMCreateVnfRequest cbamRequest = new CBAMCreateVnfRequest();
74 CBAMCreateVnfResponse response = cbamMgmr.createVnf(cbamRequest);
78 public void testInstantiateVnf() throws ClientProtocolException, IOException
80 CBAMInstantiateVnfRequest cbamRequest = new CBAMInstantiateVnfRequest();
81 CBAMInstantiateVnfResponse response = cbamMgmr.instantiateVnf(cbamRequest, vnfInstanceId);
85 public void testTerminateVnf() throws ClientProtocolException, IOException
87 CBAMTerminateVnfRequest cbamRequest = new CBAMTerminateVnfRequest();
88 CBAMTerminateVnfResponse response = cbamMgmr.terminateVnf(cbamRequest, vnfInstanceId);
92 public void testDeleteVnf() throws ClientProtocolException, IOException
94 cbamMgmr.deleteVnf(vnfInstanceId);
98 public void testScaleVnf() throws ClientProtocolException, IOException
100 CBAMScaleVnfRequest cbamRequest = new CBAMScaleVnfRequest();
101 CBAMScaleVnfResponse response = cbamMgmr.scaleVnf(cbamRequest, vnfInstanceId);
105 public void testHealVnf() throws ClientProtocolException, IOException
107 CBAMHealVnfRequest cbamRequest = new CBAMHealVnfRequest();
108 CBAMHealVnfResponse response = cbamMgmr.healVnf(cbamRequest, vnfInstanceId);
112 public void testQueryVnf() throws ClientProtocolException, IOException
114 CBAMQueryVnfResponse response = cbamMgmr.queryVnf(vnfInstanceId);