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.SitesDaoImpl;
23 import org.onap.vfc.nfvo.res.service.entity.NetworkEntity;
24 import org.onap.vfc.nfvo.res.service.entity.SitesEntity;
25 import org.onap.vfc.nfvo.res.service.mapper.NetworkMapper;
26 import org.onap.vfc.nfvo.res.service.mapper.SitesMapper;
27 import org.openo.baseservice.remoteservice.exception.ServiceException;
29 import mockit.Expectations;
34 public class SitesDaoImplTest {
38 public void testdeleteSite() throws ServiceException {
41 mapper.deleteSite("123");
44 new MockUp<AbstractDao>() {
47 public <T> T getMapperManager(Class<T> type) {
52 SitesDaoImpl impl = new SitesDaoImpl();
53 assertEquals(0, impl.deleteSite("123"));
56 public void testaddSite() throws ServiceException {
57 new MockUp<AbstractDao>() {
60 public <T> T getMapperManager(Class<T> type) {
65 SitesDaoImpl impl = new SitesDaoImpl();
66 SitesEntity sitesEntity =new SitesEntity();
67 sitesEntity.setId("1");
68 assertEquals(0, impl.addSite(sitesEntity));
71 public void testaddSiteSelective() throws ServiceException {
73 new MockUp<AbstractDao>() {
76 public <T> T getMapperManager(Class<T> type) {
81 SitesDaoImpl impl = new SitesDaoImpl();
82 SitesEntity sitesEntity =new SitesEntity();
83 sitesEntity.setId("1");
84 assertEquals(0, impl.addSiteSelective(sitesEntity));
87 public void testupdateSiteSelective() throws ServiceException {
89 new MockUp<AbstractDao>() {
92 public <T> T getMapperManager(Class<T> type) {
97 SitesDaoImpl impl = new SitesDaoImpl();
98 SitesEntity sitesEntity =new SitesEntity();
99 sitesEntity.setId("1");
100 assertEquals(0, impl.updateSiteSelective(sitesEntity));
103 public void testupdateNetwork() throws ServiceException {
105 new MockUp<AbstractDao>() {
108 public <T> T getMapperManager(Class<T> type) {
113 SitesDaoImpl impl = new SitesDaoImpl();
114 SitesEntity sitesEntity =new SitesEntity();
115 sitesEntity.setId("1");
116 assertEquals(0, impl.updateSite(sitesEntity));
119 public void testupdateSiteByVimId() throws ServiceException {
121 new MockUp<AbstractDao>() {
124 public <T> T getMapperManager(Class<T> type) {
129 SitesDaoImpl impl = new SitesDaoImpl();
130 SitesEntity sitesEntity =new SitesEntity();
131 sitesEntity.setId("1");
132 assertEquals(0, impl.updateSiteByVimId(sitesEntity));