2 * Copyright 2017 Huawei Technologies Co., Ltd.
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.
16 package org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.service.process;
18 import static org.junit.Assert.assertEquals;
19 import static org.junit.Assert.assertNotNull;
21 import java.util.ArrayList;
22 import java.util.Date;
23 import java.util.List;
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;
37 import mockit.Expectations;
41 import mockit.integration.junit4.JMockit;
42 import net.sf.json.JSONObject;
43 import static mockit.Deencapsulation.*;
46 @RunWith(JMockit.class)
48 public class VnfResourceMgrTest {
49 VnfResourceMgr vnfMgr;
50 JujuVnfmInfoMapper jujuVnfmInfoMapper;
51 JujuVnfmInfoExample jujuexample = new JujuVnfmInfoExample();
52 Criteria criteria = jujuexample.createCriteria();
56 vnfMgr = new VnfResourceMgr();
57 vnfMgr.setJujuVnfmInfoMapper(jujuVnfmInfoMapper);
58 vnfMgr.getJujuVnfmInfoMapper();
62 public void grantVnfResourceTest() throws ServiceException {
65 new Expectations(vnfMgr) {
67 invoke(vnfMgr, "findByVnfId", "1");
68 JujuVnfmInfo info = new JujuVnfmInfo();
70 info.setAppName("Test");
76 JSONObject compute = new JSONObject();
77 JSONObject res = vnfMgr.grantVnfResource(compute, vnfId);
78 assertEquals(res.get("retCode"), -1);