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.onap.vfc.nfvo.res.service.dao.impl;
18 import static org.junit.Assert.*;
20 import org.junit.Test;
21 import org.onap.vfc.nfvo.res.service.dao.impl.AbstractDao;
22 import org.onap.vfc.nfvo.res.service.dao.impl.HostDaoImpl;
23 import org.onap.vfc.nfvo.res.service.entity.HostEntity;
24 import org.onap.vfc.nfvo.res.service.entity.NetworkEntity;
25 import org.onap.vfc.nfvo.res.service.mapper.HostMapper;
26 import org.onap.vfc.nfvo.res.service.mapper.NetworkMapper;
27 import org.openo.baseservice.remoteservice.exception.ServiceException;
29 import mockit.Expectations;
34 public class HostDaoImplTest {
38 public void testdeleteHost() throws ServiceException {
40 new MockUp<AbstractDao>() {
43 public <T> T getMapperManager(Class<T> type) {
48 HostDaoImpl impl = new HostDaoImpl();
49 assertEquals(0, impl.deleteHost("123"));
53 public void testdeleteHostByVimId() throws ServiceException {
55 new MockUp<AbstractDao>() {
58 public <T> T getMapperManager(Class<T> type) {
63 HostDaoImpl impl = new HostDaoImpl();
64 assertEquals(0, impl.deleteHostByVimId("123"));
68 public void testaddHost() throws ServiceException {
70 new MockUp<AbstractDao>() {
73 public <T> T getMapperManager(Class<T> type) {
78 HostDaoImpl impl = new HostDaoImpl();
79 HostEntity hostEntity =new HostEntity();
80 hostEntity.setId("1");
81 assertEquals(0, impl.addHost(hostEntity));
86 public void testaddHostSelective() throws ServiceException {
88 new MockUp<AbstractDao>() {
91 public <T> T getMapperManager(Class<T> type) {
96 HostDaoImpl impl = new HostDaoImpl();
97 HostEntity hostEntity =new HostEntity();
98 hostEntity.setId("1");
99 assertEquals(0, impl.addHostSelective(hostEntity));
104 public void testupdateHostSelective() throws ServiceException {
106 new MockUp<AbstractDao>() {
109 public <T> T getMapperManager(Class<T> type) {
114 HostDaoImpl impl = new HostDaoImpl();
115 HostEntity hostEntity =new HostEntity();
116 hostEntity.setId("1");
117 assertEquals(0, impl.updateHostSelective(hostEntity));
122 public void testupdateHost() throws ServiceException {
124 new MockUp<AbstractDao>() {
127 public <T> T getMapperManager(Class<T> type) {
132 HostDaoImpl impl = new HostDaoImpl();
133 HostEntity hostEntity =new HostEntity();
134 hostEntity.setId("1");
135 assertEquals(0, impl.updateHost(hostEntity));
140 public void testupdateHostByVimId() throws ServiceException {
142 new MockUp<AbstractDao>() {
145 public <T> T getMapperManager(Class<T> type) {
150 HostDaoImpl impl = new HostDaoImpl();
151 HostEntity hostEntity =new HostEntity();
152 hostEntity.setId("1");
153 assertEquals(0, impl.updateHostByVimId(hostEntity));