8adf0c8df279345ece4d0564d619cc01292c3cd2
[vfc/nfvo/resmanagement.git] /
1 /*
2  * Copyright 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.resmanagement.service.dao.impl;
18
19 import static org.junit.Assert.*;
20
21 import java.util.List;
22
23 import org.junit.Test;
24 import org.onap.vfc.nfvo.resmanagement.service.dao.impl.AbstractDao;
25 import org.onap.vfc.nfvo.resmanagement.service.dao.impl.VimDaoImpl;
26 import org.onap.vfc.nfvo.resmanagement.service.entity.NetworkEntity;
27 import org.onap.vfc.nfvo.resmanagement.service.entity.VimEntity;
28 import org.onap.vfc.nfvo.resmanagement.service.mapper.VimMapper;
29 import org.openo.baseservice.remoteservice.exception.ServiceException;
30
31 import mockit.Expectations;
32 import mockit.Mock;
33 import mockit.MockUp;
34 import mockit.Mocked;
35
36 public class VimDaoImplTest {
37
38     @Mocked
39     VimMapper mapper;
40
41
42     @Test
43     public void testdeleteVim() throws ServiceException {
44
45          new Expectations() {{
46              mapper.deleteVim("123");
47            }};
48
49         new MockUp<AbstractDao>() {
50
51             @Mock
52              public <T> T getMapperManager(Class<T> type) {
53                 return (T) mapper;
54
55             }
56         };
57         VimDaoImpl impl = new VimDaoImpl();
58         assertEquals(0, impl.deleteVim("123"));
59
60
61     }
62
63     @Test
64     public void testaddVim() throws ServiceException {
65             new MockUp<AbstractDao>() {
66
67             @Mock
68              public <T> T getMapperManager(Class<T> type) {
69                 return (T) mapper;
70
71             }
72         };
73         VimDaoImpl impl = new VimDaoImpl();
74         VimEntity vimEntity =new VimEntity();
75         vimEntity.setId("1");
76         assertEquals(0, impl.addVim(vimEntity));
77
78     }
79 }