1a1d14286f36066fef700050f5587233354d7730
[vfc/nfvo/resmanagement.git] /
1 /*
2  * Copyright 2016-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
17 package org.openo.nfvo.resmanagement.service.business.impl;
18
19 import static org.junit.Assert.assertTrue;
20
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;
25
26 import mockit.Mock;
27 import mockit.MockUp;
28
29 public class HostBusinessImplTest {
30
31     @Test
32     public void testGetHost() {
33         HostBusinessImpl hostBussinessImp = new HostBusinessImpl();
34         assertTrue(hostBussinessImp.getHost("") == null);
35     }
36
37     @Test
38     public void testGetHostBranch() {
39         new MockUp<HostDaoImpl>() {
40
41             @Mock
42             public HostEntity getHost(String id) {
43                 return new HostEntity();
44             }
45
46         };
47         HostBusinessImpl hostBussinessImp = new HostBusinessImpl();
48         hostBussinessImp.setHostDao(new HostDaoImpl());
49         assertTrue(hostBussinessImp.getHost("id") != null);
50     }
51
52     @Test(expected = ServiceException.class)
53     public void testDelete() throws ServiceException {
54         HostBusinessImpl hostBussinessImp = new HostBusinessImpl();
55         hostBussinessImp.deleteHost("");
56     }
57
58     @Test(expected = ServiceException.class)
59     public void testUpdateHost() throws ServiceException {
60         HostBusinessImpl hostBussinessImp = new HostBusinessImpl();
61         hostBussinessImp.updateHost(null);
62     }
63
64     @Test(expected = ServiceException.class)
65     public void testDeleteHostByVimId() throws ServiceException {
66         HostBusinessImpl hostBussinessImp = new HostBusinessImpl();
67         hostBussinessImp.deleteHostByVimId("");
68     }
69
70     @Test(expected = ServiceException.class)
71     public void testUpdateHostByVimId() throws ServiceException {
72         HostBusinessImpl hostBussinessImp = new HostBusinessImpl();
73         hostBussinessImp.updateHostByVimId(null);
74     }
75
76     @Test(expected = ServiceException.class)
77     public void testAddHost() throws ServiceException {
78         HostBusinessImpl hostBussinessImp = new HostBusinessImpl();
79         hostBussinessImp.addHost(null);
80     }
81
82     @Test(expected = ServiceException.class)
83     public void testAddHostSelective() throws ServiceException {
84         HostBusinessImpl hostBussinessImp = new HostBusinessImpl();
85         hostBussinessImp.addHostSelective(null);
86     }
87 }