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);
 
  62                 String json = "{\"access_token\":\"1234567\"}";
 
  63                 HttpResult httpResult = new HttpResult();
 
  64                 httpResult.setContent(json);
 
  66                 when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(httpResult);
 
  70         public void testCreateVnf() throws ClientProtocolException, IOException
 
  72                 CBAMCreateVnfRequest cbamRequest = new CBAMCreateVnfRequest();
 
  73                 CBAMCreateVnfResponse response = cbamMgmr.createVnf(cbamRequest);
 
  77         public void testInstantiateVnf() throws ClientProtocolException, IOException
 
  79                 CBAMInstantiateVnfRequest cbamRequest = new CBAMInstantiateVnfRequest();
 
  80                 CBAMInstantiateVnfResponse response = cbamMgmr.instantiateVnf(cbamRequest, vnfInstanceId);
 
  84         public void testTerminateVnf() throws ClientProtocolException, IOException
 
  86                 CBAMTerminateVnfRequest cbamRequest = new CBAMTerminateVnfRequest();
 
  87                 CBAMTerminateVnfResponse response = cbamMgmr.terminateVnf(cbamRequest, vnfInstanceId);
 
  91         public void testDeleteVnf() throws ClientProtocolException, IOException
 
  93                 cbamMgmr.deleteVnf(vnfInstanceId);
 
  97         public void testScaleVnf() throws ClientProtocolException, IOException
 
  99                 CBAMScaleVnfRequest cbamRequest = new CBAMScaleVnfRequest();
 
 100                 CBAMScaleVnfResponse response = cbamMgmr.scaleVnf(cbamRequest, vnfInstanceId);
 
 104         public void testHealVnf() throws ClientProtocolException, IOException
 
 106                 CBAMHealVnfRequest cbamRequest = new CBAMHealVnfRequest();
 
 107                 CBAMHealVnfResponse response = cbamMgmr.healVnf(cbamRequest, vnfInstanceId);
 
 111         public void testQueryVnf() throws ClientProtocolException, IOException
 
 113                 CBAMQueryVnfResponse response = cbamMgmr.queryVnf(vnfInstanceId);