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