Fix gvnfm juju compile problem
[vfc/nfvo/driver/vnfm/gvnfm.git] / juju / juju-vnfmadapter / Juju-vnfmadapterService / service / src / test / java / org / onap / vfc / nfvo / vnfm / gvnfm / jujuvnfmadapter / service / process / VnfResourceMgrTest.java
1 /*
2  * Copyright 2017 Huawei Technologies Co., Ltd.
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.vnfm.gvnfm.jujuvnfmadapter.service.process;
17
18 import static org.junit.Assert.assertEquals;
19 import static org.junit.Assert.assertNotNull;
20
21 import java.util.ArrayList;
22 import java.util.Date;
23 import java.util.List;
24
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.service.constant.Constant;
29 import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.service.entity.JujuVnfmInfo;
30 import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.service.entity.JujuVnfmInfoExample;
31 import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.service.entity.JujuVnfmInfoExample.Criteria;
32 import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.service.entity.JujuVnfmInfoExample.Criterion;
33 import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.service.mapper.JujuVnfmInfoMapper;
34 import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.service.process.VnfResourceMgr;
35 import org.openo.baseservice.remoteservice.exception.ServiceException;
36
37 import mockit.Expectations;
38 import mockit.Mock;
39 import mockit.MockUp;
40 import mockit.Mocked;
41 import mockit.integration.junit4.JMockit;
42 import net.sf.json.JSONObject;
43 import static mockit.Deencapsulation.*;
44
45
46 @RunWith(JMockit.class)
47
48 public class VnfResourceMgrTest {
49     VnfResourceMgr vnfMgr;
50     JujuVnfmInfoMapper jujuVnfmInfoMapper;
51     JujuVnfmInfoExample jujuexample = new JujuVnfmInfoExample();
52     Criteria criteria = jujuexample.createCriteria();
53
54     @Before
55     public void setUp() {
56         vnfMgr = new VnfResourceMgr();
57         vnfMgr.setJujuVnfmInfoMapper(jujuVnfmInfoMapper);
58         vnfMgr.getJujuVnfmInfoMapper();
59     }
60
61     @Test
62     public void grantVnfResourceTest() throws ServiceException {
63
64         String vnfId = "1";
65         new Expectations(vnfMgr) {
66             {
67                 invoke(vnfMgr, "findByVnfId", "1");
68                 JujuVnfmInfo info = new JujuVnfmInfo();
69                 info.setId("1");
70                 info.setAppName("Test");
71                 info.setJobId("1");
72                 info.setVnfId(vnfId);
73                 returns(info);
74             }
75         };
76         JSONObject compute = new JSONObject();
77         JSONObject res = vnfMgr.grantVnfResource(compute, vnfId);
78         assertEquals(res.get("retCode"), -1);
79     }
80
81 }