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 java.util.HashMap;
21 import java.util.List;
24 import org.junit.Test;
25 import org.openo.baseservice.remoteservice.exception.ServiceException;
26 import org.openo.nfvo.resmanagement.service.entity.NetworkEntity;
27 import org.openo.nfvo.resmanagement.service.mapper.NetworkMapper;
28 import mockit.Expectations;
33 public class NetworkDaoImplTest {
37 public void testdeleteNetwork() throws ServiceException {
40 mapper.deleteNetwork("123");
43 new MockUp<AbstractDao>() {
46 public <T> T getMapperManager(Class<T> type) {
51 NetworkDaoImpl impl = new NetworkDaoImpl();
52 assertEquals(0, impl.deleteNetwork("123"));
56 public void testdeleteNetworkByVimId() throws ServiceException {
57 new MockUp<AbstractDao>() {
60 public <T> T getMapperManager(Class<T> type) {
65 NetworkDaoImpl impl = new NetworkDaoImpl();
66 assertEquals(0, impl.deleteNetworkByVimId("123"));
70 public void testaddNetwork() throws ServiceException {
71 new MockUp<AbstractDao>() {
74 public <T> T getMapperManager(Class<T> type) {
79 NetworkDaoImpl impl = new NetworkDaoImpl();
80 NetworkEntity networkEntity =new NetworkEntity();
81 networkEntity.setId("1");
82 assertEquals(0, impl.addNetwork(networkEntity));
87 public void testaddNetworkSelective() throws ServiceException {
89 new MockUp<AbstractDao>() {
92 public <T> T getMapperManager(Class<T> type) {
97 NetworkDaoImpl impl = new NetworkDaoImpl();
98 NetworkEntity networkEntity =new NetworkEntity();
99 networkEntity.setId("1");
100 assertEquals(0, impl.addNetworkSelective(networkEntity));
103 public void testupdateNetworkSelective() throws ServiceException {
105 new MockUp<AbstractDao>() {
108 public <T> T getMapperManager(Class<T> type) {
113 NetworkDaoImpl impl = new NetworkDaoImpl();
114 NetworkEntity networkEntity =new NetworkEntity();
115 networkEntity.setId("1");
116 assertEquals(0, impl.updateNetworkSelective(networkEntity));
119 public void testupdateNetwork() throws ServiceException {
121 new MockUp<AbstractDao>() {
124 public <T> T getMapperManager(Class<T> type) {
129 NetworkDaoImpl impl = new NetworkDaoImpl();
130 NetworkEntity networkEntity =new NetworkEntity();
131 networkEntity.setId("1");
132 assertEquals(0, impl.updateNetwork(networkEntity));
136 public void testupdateNetworkByVimId() throws ServiceException {
138 new MockUp<AbstractDao>() {
141 public <T> T getMapperManager(Class<T> type) {
146 NetworkDaoImpl impl = new NetworkDaoImpl();
147 NetworkEntity networkEntity =new NetworkEntity();
148 networkEntity.setId("1");
149 assertEquals(0, impl.updateNetworkByVimId(networkEntity));