Improve unit-test coverage
[vfc/nfvo/driver/vnfm/svnfm.git] / nokia / vnfmdriver / vfcadaptorservice / vfcadaptor / src / test / java / org / onap / vfc / nfvo / driver / vnfm / svnfm / adaptor / ScaleVnfContinueRunnableTest.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.adaptor;
18
19 import static org.mockito.Mockito.doNothing;
20 import static org.mockito.Mockito.when;
21
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;
38
39 public class ScaleVnfContinueRunnableTest{
40         @InjectMocks
41         private ScaleVnfContinueRunnable scaleVnfContinueRunnable;
42         
43         @Mock
44         private CbamMgmrInf cbamMgmr;
45         
46         @Mock
47         private NslcmMgmrInf nslcmMgmr;
48         
49         @Mock
50         private VnfmJobExecutionMapper jobDbMgmr;
51         
52         @Before
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();
58                 
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);
65                 
66                 NslcmGrantVnfResponse grantResponse = new NslcmGrantVnfResponse();
67                 CBAMScaleVnfResponse cbamResponse = new CBAMScaleVnfResponse();
68                 cbamResponse.setId("1");
69                 VnfmJobExecutionInfo execInfo = new VnfmJobExecutionInfo();
70                 execInfo.setJobId(1L);
71                 
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));
76         }
77         
78         @Test
79         public void testRun()
80         {
81                 scaleVnfContinueRunnable.run();
82         }
83 }