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