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.entity.PortEntity;
25 import org.openo.nfvo.resmanagement.service.mapper.NetworkMapper;
26 import org.openo.nfvo.resmanagement.service.mapper.PortMapper;
28 import mockit.Expectations;
33 public class PortDaoImplTest {
39 public void testdeletePort() throws ServiceException {
42 mapper.deletePort("123");
45 new MockUp<AbstractDao>() {
48 public <T> T getMapperManager(Class<T> type) {
53 PortDaoImpl impl = new PortDaoImpl();
54 assertEquals(0, impl.deletePort("123"));
59 public void testdeletePortByVimId() throws ServiceException {
60 new MockUp<AbstractDao>() {
63 public <T> T getMapperManager(Class<T> type) {
68 PortDaoImpl impl = new PortDaoImpl();
69 assertEquals(0, impl.deletePortByVimId("123"));
74 public void testaddPort() throws ServiceException {
75 new MockUp<AbstractDao>() {
78 public <T> T getMapperManager(Class<T> type) {
83 PortDaoImpl impl = new PortDaoImpl();
84 PortEntity portEntity =new PortEntity();
85 portEntity.setId("1");
86 assertEquals(0, impl.addPort(portEntity));
91 public void testaddPortSelective() throws ServiceException {
93 new MockUp<AbstractDao>() {
96 public <T> T getMapperManager(Class<T> type) {
101 PortDaoImpl impl = new PortDaoImpl();
102 PortEntity portEntity =new PortEntity();
103 portEntity.setId("1");
104 assertEquals(0, impl.addPortSelective(portEntity));
109 public void testupdatePortSelective() throws ServiceException {
111 new MockUp<AbstractDao>() {
114 public <T> T getMapperManager(Class<T> type) {
119 PortDaoImpl impl = new PortDaoImpl();
120 PortEntity portEntity =new PortEntity();
121 portEntity.setId("1");
122 assertEquals(0, impl.updatePortSelective(portEntity));
125 public void testupdatePort() throws ServiceException {
127 new MockUp<AbstractDao>() {
130 public <T> T getMapperManager(Class<T> type) {
135 PortDaoImpl impl = new PortDaoImpl();
136 PortEntity portEntity =new PortEntity();
137 portEntity.setId("1");
138 assertEquals(0, impl.updatePort(portEntity));
142 public void testupdatePortByVimId() throws ServiceException {
144 new MockUp<AbstractDao>() {
147 public <T> T getMapperManager(Class<T> type) {
152 PortDaoImpl impl = new PortDaoImpl();
153 PortEntity portEntity =new PortEntity();
154 portEntity.setId("1");
155 assertEquals(0, impl.updatePortByVimId(portEntity));