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 / HealVnfContinueRunnableTest.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.CBAMHealVnfRequest;
29 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfResponse;
30 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf;
31 import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean.VnfmJobExecutionInfo;
32 import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.mapper.VnfmJobExecutionMapper;
33 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmGrantVnfRequest;
34 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmGrantVnfResponse;
35 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.inf.NslcmMgmrInf;
36 import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.HealVnfRequest;
37
38 public class HealVnfContinueRunnableTest {
39         @InjectMocks
40         private HealVnfContinueRunnable healVnfContinueRunnable;
41         
42         @Mock
43         private CbamMgmrInf cbamMgmr;
44         
45         @Mock
46         private NslcmMgmrInf nslcmMgmr;
47         
48         @Mock
49         private VnfmJobExecutionMapper jobDbMgmr;
50         
51         @Before
52         public void setUp() throws Exception {
53                 MockitoAnnotations.initMocks(this);
54                 HealVnfRequest driverRequest = new HealVnfRequest();
55                 Driver2CbamRequestConverter requestConverter = new Driver2CbamRequestConverter();
56                 String vnfInstanceId = "vnfInstanceId_001";
57                 String jobId = "001";
58                 String vnfmId = "vnfmId_001";
59                 
60                 healVnfContinueRunnable.setDriverRequest(driverRequest);
61                 healVnfContinueRunnable.setRequestConverter(requestConverter);
62                 healVnfContinueRunnable.setVnfInstanceId(vnfInstanceId);
63                 healVnfContinueRunnable.setJobId(jobId);
64                 healVnfContinueRunnable.setVnfmId(vnfmId);
65                 
66                 NslcmGrantVnfResponse grantResponse = new NslcmGrantVnfResponse();
67                 CBAMHealVnfResponse cbamResponse = new CBAMHealVnfResponse();
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.healVnf(Mockito.any(CBAMHealVnfRequest.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         
79         @Test
80         public void testRun()
81         {
82                 healVnfContinueRunnable.run();
83         }
84 }