2 * Copyright 2016-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.
17 package org.openo.nfvo.resmanagement.service.business.impl;
19 import static org.junit.Assert.assertTrue;
21 import org.junit.Test;
22 import org.openo.baseservice.remoteservice.exception.ServiceException;
23 import org.openo.nfvo.resmanagement.service.dao.impl.HostDaoImpl;
24 import org.openo.nfvo.resmanagement.service.entity.HostEntity;
29 public class HostBusinessImplTest {
32 public void testGetHost() {
33 HostBusinessImpl hostBussinessImp = new HostBusinessImpl();
34 assertTrue(hostBussinessImp.getHost("") == null);
38 public void testGetHostBranch() {
39 new MockUp<HostDaoImpl>() {
42 public HostEntity getHost(String id) {
43 return new HostEntity();
47 HostBusinessImpl hostBussinessImp = new HostBusinessImpl();
48 hostBussinessImp.setHostDao(new HostDaoImpl());
49 assertTrue(hostBussinessImp.getHost("id") != null);
52 @Test(expected = ServiceException.class)
53 public void testDelete() throws ServiceException {
54 HostBusinessImpl hostBussinessImp = new HostBusinessImpl();
55 hostBussinessImp.deleteHost("");
58 @Test(expected = ServiceException.class)
59 public void testUpdateHost() throws ServiceException {
60 HostBusinessImpl hostBussinessImp = new HostBusinessImpl();
61 hostBussinessImp.updateHost(null);
64 @Test(expected = ServiceException.class)
65 public void testDeleteHostByVimId() throws ServiceException {
66 HostBusinessImpl hostBussinessImp = new HostBusinessImpl();
67 hostBussinessImp.deleteHostByVimId("");
70 @Test(expected = ServiceException.class)
71 public void testUpdateHostByVimId() throws ServiceException {
72 HostBusinessImpl hostBussinessImp = new HostBusinessImpl();
73 hostBussinessImp.updateHostByVimId(null);
76 @Test(expected = ServiceException.class)
77 public void testAddHost() throws ServiceException {
78 HostBusinessImpl hostBussinessImp = new HostBusinessImpl();
79 hostBussinessImp.addHost(null);
82 @Test(expected = ServiceException.class)
83 public void testAddHostSelective() throws ServiceException {
84 HostBusinessImpl hostBussinessImp = new HostBusinessImpl();
85 hostBussinessImp.addHostSelective(null);