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.adaptor;
 
  19 import static org.mockito.Mockito.doNothing;
 
  20 import static org.mockito.Mockito.when;
 
  22 import org.junit.Before;
 
  23 import org.junit.Test;
 
  24 import org.mockito.InjectMocks;
 
  25 import org.mockito.Mock;
 
  26 import org.mockito.Mockito;
 
  27 import org.mockito.MockitoAnnotations;
 
  28 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfRequest;
 
  29 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfResponse;
 
  30 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf;
 
  31 import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.ScaleType;
 
  32 import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean.VnfmJobExecutionInfo;
 
  33 import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.mapper.VnfmJobExecutionMapper;
 
  34 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmGrantVnfRequest;
 
  35 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmGrantVnfResponse;
 
  36 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.inf.NslcmMgmrInf;
 
  37 import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.ScaleVnfRequest;
 
  39 public class ScaleVnfContinueRunnableTest{
 
  41         private ScaleVnfContinueRunnable scaleVnfContinueRunnable;
 
  44         private CbamMgmrInf cbamMgmr;
 
  47         private NslcmMgmrInf nslcmMgmr;
 
  50         private VnfmJobExecutionMapper jobDbMgmr;
 
  53         public void setUp() throws Exception {
 
  54                 MockitoAnnotations.initMocks(this);
 
  55                 ScaleVnfRequest driverRequest = new ScaleVnfRequest();
 
  56                 driverRequest.setType(ScaleType.SCALE_IN);
 
  57                 Driver2CbamRequestConverter requestConverter = new Driver2CbamRequestConverter();
 
  59                 scaleVnfContinueRunnable.setDriverRequest(driverRequest);
 
  60                 scaleVnfContinueRunnable.setJobId("1");
 
  61                 scaleVnfContinueRunnable.setType(ScaleType.SCALE_IN);
 
  62                 scaleVnfContinueRunnable.setVnfInstanceId("001");
 
  63                 scaleVnfContinueRunnable.setVnfmId("001");
 
  64                 scaleVnfContinueRunnable.setRequestConverter(requestConverter);
 
  66                 NslcmGrantVnfResponse grantResponse = new NslcmGrantVnfResponse();
 
  67                 CBAMScaleVnfResponse cbamResponse = new CBAMScaleVnfResponse();
 
  68                 cbamResponse.setId("1");
 
  69                 VnfmJobExecutionInfo execInfo = new VnfmJobExecutionInfo();
 
  70                 execInfo.setJobId(1L);
 
  72                 when(nslcmMgmr.grantVnf(Mockito.any(NslcmGrantVnfRequest.class))).thenReturn(grantResponse);
 
  73                 when(cbamMgmr.scaleVnf(Mockito.any(CBAMScaleVnfRequest.class), Mockito.anyString())).thenReturn(cbamResponse);
 
  74                 when(jobDbMgmr.findOne(Mockito.anyLong())).thenReturn(execInfo);
 
  75                 doNothing().when(jobDbMgmr).update(Mockito.any(VnfmJobExecutionInfo.class));
 
  81                 scaleVnfContinueRunnable.run();