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.PortDaoImpl;
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.entity.PortEntity;
26 import org.onap.vfc.nfvo.res.service.mapper.NetworkMapper;
27 import org.onap.vfc.nfvo.res.service.mapper.PortMapper;
28 import org.openo.baseservice.remoteservice.exception.ServiceException;
30 import mockit.Expectations;
35 public class PortDaoImplTest {
41 public void testdeletePort() throws ServiceException {
44 mapper.deletePort("123");
47 new MockUp<AbstractDao>() {
50 public <T> T getMapperManager(Class<T> type) {
55 PortDaoImpl impl = new PortDaoImpl();
56 assertEquals(0, impl.deletePort("123"));
61 public void testdeletePortByVimId() throws ServiceException {
62 new MockUp<AbstractDao>() {
65 public <T> T getMapperManager(Class<T> type) {
70 PortDaoImpl impl = new PortDaoImpl();
71 assertEquals(0, impl.deletePortByVimId("123"));
76 public void testaddPort() throws ServiceException {
77 new MockUp<AbstractDao>() {
80 public <T> T getMapperManager(Class<T> type) {
85 PortDaoImpl impl = new PortDaoImpl();
86 PortEntity portEntity =new PortEntity();
87 portEntity.setId("1");
88 assertEquals(0, impl.addPort(portEntity));
93 public void testaddPortSelective() throws ServiceException {
95 new MockUp<AbstractDao>() {
98 public <T> T getMapperManager(Class<T> type) {
103 PortDaoImpl impl = new PortDaoImpl();
104 PortEntity portEntity =new PortEntity();
105 portEntity.setId("1");
106 assertEquals(0, impl.addPortSelective(portEntity));
111 public void testupdatePortSelective() throws ServiceException {
113 new MockUp<AbstractDao>() {
116 public <T> T getMapperManager(Class<T> type) {
121 PortDaoImpl impl = new PortDaoImpl();
122 PortEntity portEntity =new PortEntity();
123 portEntity.setId("1");
124 assertEquals(0, impl.updatePortSelective(portEntity));
127 public void testupdatePort() throws ServiceException {
129 new MockUp<AbstractDao>() {
132 public <T> T getMapperManager(Class<T> type) {
137 PortDaoImpl impl = new PortDaoImpl();
138 PortEntity portEntity =new PortEntity();
139 portEntity.setId("1");
140 assertEquals(0, impl.updatePort(portEntity));
144 public void testupdatePortByVimId() throws ServiceException {
146 new MockUp<AbstractDao>() {
149 public <T> T getMapperManager(Class<T> type) {
154 PortDaoImpl impl = new PortDaoImpl();
155 PortEntity portEntity =new PortEntity();
156 portEntity.setId("1");
157 assertEquals(0, impl.updatePortByVimId(portEntity));