2 * Copyright 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.
16 package org.openo.nfvo.resmanagement.service.dao.impl;
18 import static org.junit.Assert.*;
20 import org.junit.Test;
21 import org.openo.baseservice.remoteservice.exception.ServiceException;
22 import org.openo.nfvo.resmanagement.service.entity.HostEntity;
23 import org.openo.nfvo.resmanagement.service.entity.NetworkEntity;
24 import org.openo.nfvo.resmanagement.service.mapper.HostMapper;
25 import org.openo.nfvo.resmanagement.service.mapper.NetworkMapper;
27 import mockit.Expectations;
32 public class HostDaoImplTest {
36 public void testdeleteHost() throws ServiceException {
38 new MockUp<AbstractDao>() {
41 public <T> T getMapperManager(Class<T> type) {
46 HostDaoImpl impl = new HostDaoImpl();
47 assertEquals(0, impl.deleteHost("123"));
51 public void testdeleteHostByVimId() throws ServiceException {
53 new MockUp<AbstractDao>() {
56 public <T> T getMapperManager(Class<T> type) {
61 HostDaoImpl impl = new HostDaoImpl();
62 assertEquals(0, impl.deleteHostByVimId("123"));
66 public void testaddHost() throws ServiceException {
68 new MockUp<AbstractDao>() {
71 public <T> T getMapperManager(Class<T> type) {
76 HostDaoImpl impl = new HostDaoImpl();
77 HostEntity hostEntity =new HostEntity();
78 hostEntity.setId("1");
79 assertEquals(0, impl.addHost(hostEntity));
84 public void testaddHostSelective() throws ServiceException {
86 new MockUp<AbstractDao>() {
89 public <T> T getMapperManager(Class<T> type) {
94 HostDaoImpl impl = new HostDaoImpl();
95 HostEntity hostEntity =new HostEntity();
96 hostEntity.setId("1");
97 assertEquals(0, impl.addHostSelective(hostEntity));
102 public void testupdateHostSelective() throws ServiceException {
104 new MockUp<AbstractDao>() {
107 public <T> T getMapperManager(Class<T> type) {
112 HostDaoImpl impl = new HostDaoImpl();
113 HostEntity hostEntity =new HostEntity();
114 hostEntity.setId("1");
115 assertEquals(0, impl.updateHostSelective(hostEntity));
120 public void testupdateHost() throws ServiceException {
122 new MockUp<AbstractDao>() {
125 public <T> T getMapperManager(Class<T> type) {
130 HostDaoImpl impl = new HostDaoImpl();
131 HostEntity hostEntity =new HostEntity();
132 hostEntity.setId("1");
133 assertEquals(0, impl.updateHost(hostEntity));
138 public void testupdateHostByVimId() throws ServiceException {
140 new MockUp<AbstractDao>() {
143 public <T> T getMapperManager(Class<T> type) {
148 HostDaoImpl impl = new HostDaoImpl();
149 HostEntity hostEntity =new HostEntity();
150 hostEntity.setId("1");
151 assertEquals(0, impl.updateHostByVimId(hostEntity));