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 java.util.HashMap;
21 import java.util.List;
24 import org.junit.Test;
25 import org.onap.vfc.nfvo.res.service.dao.impl.AbstractDao;
26 import org.onap.vfc.nfvo.res.service.dao.impl.NetworkDaoImpl;
27 import org.onap.vfc.nfvo.res.service.entity.NetworkEntity;
28 import org.onap.vfc.nfvo.res.service.mapper.NetworkMapper;
29 import org.openo.baseservice.remoteservice.exception.ServiceException;
31 import mockit.Expectations;
36 public class NetworkDaoImplTest {
40 public void testdeleteNetwork() throws ServiceException {
43 mapper.deleteNetwork("123");
46 new MockUp<AbstractDao>() {
49 public <T> T getMapperManager(Class<T> type) {
54 NetworkDaoImpl impl = new NetworkDaoImpl();
55 assertEquals(0, impl.deleteNetwork("123"));
59 public void testdeleteNetworkByVimId() throws ServiceException {
60 new MockUp<AbstractDao>() {
63 public <T> T getMapperManager(Class<T> type) {
68 NetworkDaoImpl impl = new NetworkDaoImpl();
69 assertEquals(0, impl.deleteNetworkByVimId("123"));
73 public void testaddNetwork() throws ServiceException {
74 new MockUp<AbstractDao>() {
77 public <T> T getMapperManager(Class<T> type) {
82 NetworkDaoImpl impl = new NetworkDaoImpl();
83 NetworkEntity networkEntity =new NetworkEntity();
84 networkEntity.setId("1");
85 assertEquals(0, impl.addNetwork(networkEntity));
90 public void testaddNetworkSelective() throws ServiceException {
92 new MockUp<AbstractDao>() {
95 public <T> T getMapperManager(Class<T> type) {
100 NetworkDaoImpl impl = new NetworkDaoImpl();
101 NetworkEntity networkEntity =new NetworkEntity();
102 networkEntity.setId("1");
103 assertEquals(0, impl.addNetworkSelective(networkEntity));
106 public void testupdateNetworkSelective() throws ServiceException {
108 new MockUp<AbstractDao>() {
111 public <T> T getMapperManager(Class<T> type) {
116 NetworkDaoImpl impl = new NetworkDaoImpl();
117 NetworkEntity networkEntity =new NetworkEntity();
118 networkEntity.setId("1");
119 assertEquals(0, impl.updateNetworkSelective(networkEntity));
122 public void testupdateNetwork() throws ServiceException {
124 new MockUp<AbstractDao>() {
127 public <T> T getMapperManager(Class<T> type) {
132 NetworkDaoImpl impl = new NetworkDaoImpl();
133 NetworkEntity networkEntity =new NetworkEntity();
134 networkEntity.setId("1");
135 assertEquals(0, impl.updateNetwork(networkEntity));
139 public void testupdateNetworkByVimId() throws ServiceException {
141 new MockUp<AbstractDao>() {
144 public <T> T getMapperManager(Class<T> type) {
149 NetworkDaoImpl impl = new NetworkDaoImpl();
150 NetworkEntity networkEntity =new NetworkEntity();
151 networkEntity.setId("1");
152 assertEquals(0, impl.updateNetworkByVimId(networkEntity));