Fix sonar issues
[vfc/nfvo/driver/vnfm/svnfm.git] / nokiav2 / driver / src / test / java / org / onap / vfc / nfvo / driver / vnfm / svnfm / nokia / onap / direct / TestGrantlessGrantManager.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 package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct;
17
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
21 import org.onap.vnfmdriver.model.GrantVNFResponseVim;
22
23 import static junit.framework.TestCase.assertEquals;
24 import static org.mockito.Mockito.verify;
25 import static org.springframework.test.util.ReflectionTestUtils.setField;
26
27 public class TestGrantlessGrantManager extends TestBase {
28     private GrantlessGrantManager grantlessGrantManager;
29
30     @Before
31     public void init() {
32         grantlessGrantManager = new GrantlessGrantManager();
33         setField(GrantlessGrantManager.class, "logger", logger);
34     }
35
36     /**
37      * grant is only logged for healing
38      */
39     @Test
40     public void testGrantForHeal() throws Exception {
41         //when
42         grantlessGrantManager.requestGrantForHeal(null, null, null, null, null, null);
43         //verify
44         verify(logger).info("No grant is requested in direct mode");
45     }
46
47     /**
48      * grant is only logged for instantiation
49      */
50     @Test
51     public void testGrantForInstantiate() throws Exception {
52         //when
53         GrantVNFResponseVim grant = grantlessGrantManager.requestGrantForInstantiate(null, null, VIM_ID, null, null, null, null);
54         //verify
55         verify(logger).info("No grant is requested in direct mode");
56         assertEquals(VIM_ID, grant.getVimId());
57     }
58
59     /**
60      * grant is only logged for scaling
61      */
62     @Test
63     public void testGrantForScaling() throws Exception {
64         //when
65         grantlessGrantManager.requestGrantForScale(null, null, null, null, null, null);
66         //verify
67         verify(logger).info("No grant is requested in direct mode");
68     }
69
70     /**
71      * grant is only logged for termination
72      */
73     @Test
74     public void testGrantForTerminate() throws Exception {
75         //when
76         grantlessGrantManager.requestGrantForTerminate(null, null, null, null, null, null);
77         //verify
78         verify(logger).info("No grant is requested in direct mode");
79     }
80 }