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.openo.nfvo.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.openo.baseservice.remoteservice.exception.ServiceException;
 
  29 import org.openo.nfvo.jujuvnfmadapter.service.constant.Constant;
 
  30 import org.openo.nfvo.jujuvnfmadapter.service.entity.JujuVnfmInfo;
 
  31 import org.openo.nfvo.jujuvnfmadapter.service.entity.JujuVnfmInfoExample;
 
  32 import org.openo.nfvo.jujuvnfmadapter.service.entity.JujuVnfmInfoExample.Criteria;
 
  33 import org.openo.nfvo.jujuvnfmadapter.service.entity.JujuVnfmInfoExample.Criterion;
 
  34 import org.openo.nfvo.jujuvnfmadapter.service.mapper.JujuVnfmInfoMapper;
 
  36 import mockit.Expectations;
 
  40 import mockit.integration.junit4.JMockit;
 
  41 import net.sf.json.JSONObject;
 
  42 import static mockit.Deencapsulation.*;
 
  45 @RunWith(JMockit.class)
 
  47 public class VnfResourceMgrTest {
 
  48     VnfResourceMgr vnfMgr;
 
  49     JujuVnfmInfoMapper jujuVnfmInfoMapper;
 
  50     JujuVnfmInfoExample jujuexample = new JujuVnfmInfoExample();
 
  51     Criteria criteria = jujuexample.createCriteria();
 
  55         vnfMgr = new VnfResourceMgr();
 
  56         vnfMgr.setJujuVnfmInfoMapper(jujuVnfmInfoMapper);
 
  57         vnfMgr.getJujuVnfmInfoMapper();
 
  61     public void grantVnfResourceTest() throws ServiceException {
 
  64         new Expectations(vnfMgr) {
 
  66                 invoke(vnfMgr, "findByVnfId", "1");
 
  67                 JujuVnfmInfo info = new JujuVnfmInfo();
 
  69                 info.setAppName("Test");
 
  75         JSONObject compute = new JSONObject();
 
  76         JSONObject res = vnfMgr.grantVnfResource(compute, vnfId);
 
  77         assertEquals(res.get("retCode"), -1);