Remove the database related code in ESR. 71/9871/1
authorlizi00164331 <li.zi30@zte.com.cn>
Fri, 1 Sep 2017 06:14:08 +0000 (14:14 +0800)
committerlizi00164331 <li.zi30@zte.com.cn>
Fri, 1 Sep 2017 06:14:08 +0000 (14:14 +0800)
ESR will store the external system data to A&AI instead of database.

Change-Id: I0309c9d1d17c358eafbb808794d5ea68791aa069
Issue-ID: AAI-256
Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
32 files changed:
esr-core/esr-mgr/dependency-reduced-pom.xml
esr-core/esr-mgr/pom.xml
esr-core/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java
esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/BaseDao.java [deleted file]
esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/CommonDao.java [deleted file]
esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/DaoManager.java [deleted file]
esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/EmsDao.java [deleted file]
esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/SdncDao.java [deleted file]
esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/VimDao.java [deleted file]
esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/VnfmDao.java [deleted file]
esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/BaseHandler.java [deleted file]
esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/CommonHandler.java [deleted file]
esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/EmsHandler.java [deleted file]
esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/SdncHandler.java [deleted file]
esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/VimHandler.java [deleted file]
esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/VnfmHandler.java [deleted file]
esr-core/esr-mgr/src/main/java/org/onap/aai/esr/hibernate/HibernateBundleAgent.java [deleted file]
esr-core/esr-mgr/src/main/java/org/onap/aai/esr/hibernate/HibernateBundleExt.java [deleted file]
esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/EmsManager.java
esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/ThirdpatySdncManager.java
esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/VimManager.java
esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/VnfmManager.java
esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/resource/EmsManagerTest.java [deleted file]
esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/resource/SdncManagerTest.java [deleted file]
esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/resource/VimManagerTest.java [deleted file]
esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/resource/VnfmManagerTest.java [deleted file]
esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/util/CatalogDbUtilTest.java [deleted file]
esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/util/H2DbServer.java [deleted file]
esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/util/H2DbServerUtil.java [deleted file]
esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/util/HibernateSession.java [deleted file]
esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/util/HqlFactoryTest.java [deleted file]
esr-parent/esrparent/pom.xml

index 70782ac..1465618 100644 (file)
         </exclusion>\r
       </exclusions>\r
     </dependency>\r
-    <dependency>\r
-      <groupId>com.h2database</groupId>\r
-      <artifactId>h2</artifactId>\r
-      <version>1.4.182</version>\r
-      <scope>test</scope>\r
-    </dependency>\r
     <dependency>\r
       <groupId>org.apache.ant</groupId>\r
       <artifactId>ant</artifactId>\r
index cd0a121..13a5fb6 100644 (file)
             <artifactId>powermock-api-mockito</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>com.h2database</groupId>
-            <artifactId>h2</artifactId>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>org.apache.ant</groupId>
             <artifactId>ant</artifactId>
index e1f1548..46595c4 100644 (file)
@@ -29,13 +29,11 @@ import io.swagger.jaxrs.listing.ApiListingResource;
 import org.glassfish.jersey.media.multipart.MultiPartFeature;
 import org.onap.aai.esr.common.Config;
 import org.onap.aai.esr.common.ServiceRegistrer;
-import org.onap.aai.esr.dao.DaoManager;
 import org.onap.aai.esr.entity.aai.BaseData;
 import org.onap.aai.esr.entity.aai.EmsData;
 import org.onap.aai.esr.entity.aai.SdncData;
 import org.onap.aai.esr.entity.aai.VimData;
 import org.onap.aai.esr.entity.aai.VnfmData;
-import org.onap.aai.esr.hibernate.HibernateBundleAgent;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -52,12 +50,10 @@ public class ExtsysApp extends Application<ExtsysAppConfiguration> {
     return "ONAP-ESR";
   }
 
-  private final HibernateBundleAgent bundle = new HibernateBundleAgent();
 
   @Override
   public void initialize(Bootstrap<ExtsysAppConfiguration> bootstrap) {
     bootstrap.addBundle(new AssetsBundle("/api-doc", "/api-doc", "index.html", "api-doc"));
-    initDb(bootstrap);
   }
 
   private void initService() {
@@ -66,9 +62,6 @@ public class ExtsysApp extends Application<ExtsysAppConfiguration> {
     registerExtsysService.start();
   }
 
-  private void initDb(Bootstrap<ExtsysAppConfiguration> bootstrap) {
-    bootstrap.addBundle(bundle);
-  }
 
   @Override
   public void run(ExtsysAppConfiguration configuration, Environment environment) {
diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/BaseDao.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/BaseDao.java
deleted file mode 100644 (file)
index 649c9bd..0000000
+++ /dev/null
@@ -1,216 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.aai.esr.dao;
-
-import io.dropwizard.hibernate.AbstractDAO;
-import io.dropwizard.util.Generics;
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.criterion.Restrictions;
-import org.onap.aai.esr.exception.ExtsysException;
-import org.onap.aai.esr.util.HqlFactory;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * a base class for Hibernate DAO classes.<br>
- * provide the common methods to create,delete,update and query data
- * 
- * 
- */
-public class BaseDao<T> extends AbstractDAO<T> {
-
-  /**
-   * init session.
-   * 
-   * @param sessionFactory session Factory
-   */
-  public BaseDao(SessionFactory sessionFactory) {
-    super(sessionFactory);
-    this.sessionFactory = sessionFactory;
-    this.entityClass = Generics.getTypeParameter(getClass());
-  }
-
-  public String[] excludeProperties;
-  private SessionFactory sessionFactory;
-  protected Session session;
-  private final Class<?> entityClass;
-
-  @Override
-  protected Session currentSession() {
-    return this.session;
-  }
-
-  /**
-   * update entity .
-   * 
-   * @param data the object to update
-   * @throws ExtsysException when db abnormal
-   */
-  public void update(T data, String filter) throws ExtsysException {
-    try {
-      String hql = HqlFactory.getUpdateHql(data, excludeProperties, filter);
-      beginTransaction();
-      Query query = this.session.createQuery(hql);
-      query.executeUpdate();
-      closeTransaction();
-    } catch (Exception error) {
-      transactionRollBack();
-      throw new ExtsysException("", "error while updating data.errorMsg:" + error.getMessage());
-    } finally {
-      closeSession();
-    }
-  }
-
-  /**
-   * delete entity.
-   * 
-   * @param data the object to delete
-   * @throws ExtsysException when db abnormal
-   */
-  public void delete(T data) throws ExtsysException {
-    try {
-      beginTransaction();
-      this.session.delete(data);
-      closeTransaction();
-    } catch (Exception error) {
-      transactionRollBack();
-      throw new ExtsysException("", "error while deleting data.errorMsg:" + error.getMessage());
-    } finally {
-      closeSession();
-    }
-  }
-
-  /**
-   * create entity.
-   * 
-   * @param data the object to create
-   * @return T
-   * @throws ExtsysException when db abnormal
-   * 
-   */
-  public T create(T data) throws ExtsysException {
-    try {
-      beginTransaction();
-      session.save(data);
-      closeTransaction();
-    } catch (HibernateException error) {
-      transactionRollBack();
-      throw new ExtsysException("", "error while creating data.errorMsg:" + error.getMessage());
-    } finally {
-      closeSession();
-    }
-    return data;
-  }
-
-  /**
-   * query entity by condition.
-   * 
-   * @param unionHql query condition.
-   * @return T
-   * @throws ExtsysException when db abnormal
-   * 
-   */
-  public List<T> unionQuery(String unionHql) throws ExtsysException {
-    List<T> data;
-    try {
-      beginTransaction();
-      Query query = this.session.createQuery(unionHql);
-      data = query.list();
-      closeTransaction();
-    } catch (Exception error) {
-      transactionRollBack();
-      throw new ExtsysException("", "error while union query data.errorMsg:" + error.getMessage());
-    } finally {
-      closeSession();
-    }
-    return data;
-  }
-
-  /**
-   * delete entity by condition.
-   * 
-   * @param unionHql delete condition.
-   * @return T
-   * @throws ExtsysException when db abnormal
-   * 
-   */
-  public int unionDelete(String unionHql) throws ExtsysException {
-    int num = 0;
-    try {
-      beginTransaction();
-      Query query = this.session.createQuery(unionHql);
-      num = query.executeUpdate();
-      closeTransaction();
-    } catch (Exception error) {
-      transactionRollBack();
-      throw new ExtsysException("", "error while union query data.errorMsg:" + error.getMessage());
-    } finally {
-      closeSession();
-    }
-    return num;
-  }
-
-  /**
-   * query entity by condition map.
-   * 
-   * @param queryParams the condition map used to query objects
-   * @return List
-   * @throws ExtsysException when db abnormal
-   */
-  @SuppressWarnings("unchecked")
-  public List<T> query(Map<String, String> queryParams) throws ExtsysException {
-    List<T> result = null;
-    try {
-      beginTransaction();
-      Criteria criteria = this.session.createCriteria(entityClass);
-      for (String key : queryParams.keySet()) {
-        criteria.add(Restrictions.eq(key, queryParams.get(key)));
-      }
-      result = (List<T>) criteria.list();
-      closeTransaction();
-    } catch (HibernateException error) {
-      throw new ExtsysException("", "error while querying data.errorMsg:" + error.getMessage());
-    } finally {
-      closeSession();
-    }
-    return result;
-  }
-
-  protected void beginTransaction() {
-    this.session = this.sessionFactory.openSession();
-    this.session.beginTransaction();
-  }
-
-  protected void closeTransaction() {
-    this.session.getTransaction().commit();
-  }
-
-  protected void closeSession() {
-    this.session.close();
-  }
-
-  protected void transactionRollBack() {
-    this.session.getTransaction().rollback();
-  }
-
-}
diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/CommonDao.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/CommonDao.java
deleted file mode 100644 (file)
index 86c5a03..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.aai.esr.dao;
-
-import org.hibernate.SessionFactory;
-import org.onap.aai.esr.entity.aai.BaseData;
-
-
-/**
- * a common class for Hibernate DAO classes.<br>
- * 
- * @author 10159474
- * 
- */
-public class CommonDao extends BaseDao<BaseData> {
-
-  /**
-   * init session.
-   * 
-   * @param sessionFactory session Factory
-   */
-  public CommonDao(SessionFactory sessionFactory) {
-    super(sessionFactory);
-  }
-
-
-}
diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/DaoManager.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/DaoManager.java
deleted file mode 100644 (file)
index f64713d..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.aai.esr.dao;
-
-import org.hibernate.SessionFactory;
-import org.onap.aai.esr.common.ExtSysResuorceType;
-import org.onap.aai.esr.exception.ExtsysException;
-
-/**
- * DAO manager class.<br>
- * a class to store DAO instances and provide methods to get these instances
- * 
- *
- */
-public class DaoManager {
-  private static DaoManager instance = new DaoManager();
-
-  private VimDao vimDao;
-  private EmsDao emsDao;
-  private VnfmDao vnfmDao;
-  private SdncDao sdncDao;
-  private CommonDao commonDao;
-  private SessionFactory sessionFactory;
-
-  private DaoManager() {}
-
-  public static synchronized DaoManager getInstance() {
-    return instance;
-  }
-
-  /**
-   * according to resource type and return proper DAO.
-   * 
-   * @param type resource Type
-   * @return DAO
-   */
-  public BaseDao<?> getDao(String type) throws ExtsysException {
-    if (sessionFactory == null) {
-      throw new ExtsysException("", "errorMsg:database connect init faild!");
-    }
-    switch (ExtSysResuorceType.getType(type)) {
-      case VIM:
-        return getVimDao();
-      case SDNC:
-        return getSdncDao();
-      case VNFM:
-        return getVnfmDao();
-      case EMS:
-        return getEmsDao();
-      default:
-        return getCommonDao();
-    }
-  }
-
-  public void setSessionFactory(SessionFactory sessionFactory) {
-    this.sessionFactory = sessionFactory;
-  }
-
-  public SessionFactory getSessionFactory() {
-    return sessionFactory;
-  }
-
-  /**
-   * @return Returns the vim dao.
-   */
-  public VimDao getVimDao() {    
-    vimDao = new VimDao(sessionFactory);
-    return vimDao;
-  }
-
-  public void setVimDao(VimDao vimDao) {
-    this.vimDao = vimDao;
-  }
-
-  /**
-   * @return Returns the ems dao.
-   */
-  public EmsDao getEmsDao() {
-    emsDao = new EmsDao(sessionFactory);
-    return emsDao;
-  }
-
-  public void setEmsDao(EmsDao emsDao) {
-    this.emsDao = emsDao;
-  }
-
-  /**
-   * @return Returns the vnfm dao.
-   */
-  public VnfmDao getVnfmDao() {
-    vnfmDao = new VnfmDao(sessionFactory);
-    return vnfmDao;
-  }
-
-  public void setVnfmDao(VnfmDao vnfmDao) {
-    this.vnfmDao = vnfmDao;
-  }
-
-  /**
-   * @return Returns the sdnc dao.
-   */
-  public SdncDao getSdncDao() {
-    sdncDao = new SdncDao(sessionFactory);
-    return sdncDao;
-  }
-
-  public void setSdncDao(SdncDao sdncDao) {
-    this.sdncDao = sdncDao;
-  }
-
-  /**
-   * @return Returns the common dao.
-   */
-  public CommonDao getCommonDao() {
-    commonDao = new CommonDao(sessionFactory);
-    return commonDao;
-  }
-
-  public void setCommonDao(CommonDao commonDao) {
-    this.commonDao = commonDao;
-  }
-
-}
diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/EmsDao.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/EmsDao.java
deleted file mode 100644 (file)
index b0e0bc1..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.aai.esr.dao;
-
-import org.hibernate.SessionFactory;
-import org.onap.aai.esr.entity.aai.EmsData;
-
-
-
-/**
- * ems  for Hibernate DAO classes.<br>
- * 
- * @author 10159474
- * 
- */
-public class EmsDao extends BaseDao<EmsData> {
-
-  public EmsDao(SessionFactory sessionFactory) {
-    super(sessionFactory);
-  }
-
-
-}
diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/SdncDao.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/SdncDao.java
deleted file mode 100644 (file)
index 63b697f..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.aai.esr.dao;
-
-import org.hibernate.SessionFactory;
-import org.onap.aai.esr.entity.aai.SdncData;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * sdnc  for Hibernate DAO classes.<br>
- * 
- * @author 10159474
- * 
- */
-public class SdncDao extends BaseDao<SdncData> {
-  private static final Logger logger = LoggerFactory.getLogger(SdncDao.class);
-
-  public SdncDao(SessionFactory sessionFactory) {
-    super(sessionFactory);
-  }
-
-}
diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/VimDao.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/VimDao.java
deleted file mode 100644 (file)
index 904b1b8..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.aai.esr.dao;
-
-import org.hibernate.SessionFactory;
-import org.onap.aai.esr.entity.aai.VimData;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * vim for Hibernate DAO classes.<br>
- * 
- * @author 10159474
- * 
- */
-public class VimDao extends BaseDao<VimData> {
-  private static final Logger logger = LoggerFactory.getLogger(VimDao.class);
-
-  public VimDao(SessionFactory sessionFactory) {
-    super(sessionFactory);
-  }
-
-}
diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/VnfmDao.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/VnfmDao.java
deleted file mode 100644 (file)
index 6399648..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.aai.esr.dao;
-
-import org.hibernate.SessionFactory;
-import org.onap.aai.esr.entity.aai.VnfmData;
-
-
-/**
- * vnfm for Hibernate DAO classes.<br>
- * 
- * @author 10159474
- * 
- */
-public class VnfmDao extends BaseDao<VnfmData> {
-
-  public VnfmDao(SessionFactory sessionFactory) {
-    super(sessionFactory);
-  }
-
-
-}
diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/BaseHandler.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/BaseHandler.java
deleted file mode 100644 (file)
index 997fb88..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.aai.esr.handle;
-
-import com.google.gson.Gson;
-
-import org.onap.aai.esr.dao.BaseDao;
-import org.onap.aai.esr.dao.DaoManager;
-import org.onap.aai.esr.entity.aai.BaseData;
-import org.onap.aai.esr.exception.ExtsysException;
-import org.onap.aai.esr.util.ExtsysUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * an abstract class for wrapper class.<br>
- * provide the common methods to process the DB request
- * 
- * @author 10159474
- */
-public abstract class BaseHandler<T extends BaseData> {
-  private static final Logger logger = LoggerFactory.getLogger(BaseHandler.class);
-
-  public Gson gson = new Gson();
-
-  /**
-   * create entity.
-   * 
-   * @param data entity
-   * @param resouceType resource type
-   * @return entity
-   * @throws ExtsysException when  DAO exception
-   */
-  @SuppressWarnings({"unchecked", "rawtypes"})
-  public T create(T data, String resouceType) throws ExtsysException {
-    T rtnData = null;
-    boolean check = true;
-    logger.info("BaseHandler:start create data.info:" + ExtsysUtil.objectToString(data));
-    try {
-      check = validity(data);
-      if (check) {
-        logger.error("validity check success!");
-      } else {
-        logger.error("validity check failed");
-        throw new ExtsysException("", "validity check failed");
-      }
-    } catch (ExtsysException error) {
-      logger.error("validity check failed,errorMsg:" + error.getErrorMsg());
-      throw error;
-    }
-    try {      
-      data.setId(ExtsysUtil.generateId());
-      data.setCreateTime(ExtsysUtil.getNowTime());
-      data.setCategory(resouceType);
-      BaseDao dao = DaoManager.getInstance().getDao(resouceType);
-      rtnData = (T) dao.create(data);
-    } catch (ExtsysException error) {
-      logger.error("BaseHandler:error while creating " + resouceType, error);
-      throw error;
-    }
-    logger.info("BaseHandler:create data end.info:" + ExtsysUtil.objectToString(data));
-    return rtnData;
-  }
-
-  /**
-   * delete entity.
-   * @param data entity
-   * @param resouceType resource type
-   * @throws ExtsysException  when  DAO exception
-   */
-  @SuppressWarnings({"rawtypes", "unchecked"})
-  public void delete(T data, String resouceType) throws ExtsysException {
-    logger.info("BaseHandler:start delete data.info:" + ExtsysUtil.objectToString(data));
-    try {
-      BaseDao dao = DaoManager.getInstance().getDao(resouceType);
-      dao.delete(data);
-    } catch (ExtsysException error) {
-      logger.error("BaseHandler:error while deleting " + resouceType, error);
-      throw error;
-    }
-    logger.info("BaseHandler:delete data end");
-  }
-
-  /**
-   * delete entity by query condition.
-   * @param queryParam query parameter
-   * @param resouceType resource type
-   * @throws ExtsysException when  DAO exception
-   */
-  @SuppressWarnings({"rawtypes", "unchecked"})
-  public void delete(Map<String, String> queryParam, String resouceType) throws ExtsysException {
-    logger.info("BaseHandler:start delete data by condition.info:"
-        + ExtsysUtil.objectToString(queryParam));
-    List<T> datas;
-    try {
-      BaseDao dao = DaoManager.getInstance().getDao(resouceType);
-      datas = dao.query(queryParam);
-      for (T data : datas) {
-        delete(data, resouceType);
-      }
-    } catch (ExtsysException error) {
-      logger.error("BaseHandler:error while deleting " + resouceType, error);
-      throw error;
-    }
-
-  }
-
-  /**
-   * update entity.
-   * @param data entity
-   * @param filter update condition
-   * @param resouceType resource type
-   * @throws ExtsysException when  DAO exception
-   */
-  @SuppressWarnings({"rawtypes", "unchecked"})
-  public void update(T data, String filter, String resouceType) throws ExtsysException {
-    logger.info("BaseHandler:start update data .info:" + ExtsysUtil.objectToString(data)
-        + " filter:" + filter);
-    try {
-      BaseDao dao = DaoManager.getInstance().getDao(resouceType);
-      data.setId(null);
-      dao.update(data, filter);
-
-    } catch (ExtsysException error) {
-      logger.error("BaseHandler:error while updating " + resouceType, error);
-      throw error;
-    }
-    logger.info("BaseHandler:update data end ");
-  }
-
-  /**
-   * query entity.
-   * @param queryParam query parameter
-   * @param resouceType resource type
-   * @return List entity list
-   * @throws ExtsysException when  DAO exception
-   */
-  @SuppressWarnings({"rawtypes", "unchecked"})
-  public List<T> query(Map<String, String> queryParam, String resouceType) throws ExtsysException {
-    logger.info("BaseHandler:start query data .info:" + ExtsysUtil.objectToString(queryParam));
-    List<T> datas = null;
-    try {
-      BaseDao dao = DaoManager.getInstance().getDao(resouceType);
-      datas = dao.query(queryParam);
-
-    } catch (ExtsysException error) {
-      logger.error("BaseHandler:error while querying " + resouceType, error);
-      throw error;
-    }
-    logger.info("BaseHandler: query data end .info:" + ExtsysUtil.objectToString(datas));
-    return datas;
-  }
-
-  /** 
-   * query entity.
-   * @param filter query condition
-   * @param resouceType resource type
-   * @return list entity
-   * @throws ExtsysException when  DAO exception
-   */
-  @SuppressWarnings({"rawtypes", "unchecked"})
-  public List<T> unionQuery(String filter, String resouceType) throws ExtsysException {
-    logger.info("BaseHandler:start union query data.fliter:" + filter);
-    List<T> datas = null;
-    try {
-      BaseDao dao = DaoManager.getInstance().getDao(resouceType);
-      datas = dao.unionQuery(filter);
-
-    } catch (ExtsysException error) {
-      logger.error("BaseHandler:error while union querying " + resouceType, error);
-      throw error;
-    }
-    logger.info("BaseHandler:union query data end .info:" + ExtsysUtil.objectToString(datas));
-    return datas;
-  }
-
-  /** 
-   * delete entity.
-   * @param filter delete condition
-   * @param resouceType resource type
-   * @return delete entity num
-   * @throws ExtsysException when  DAO exception
-   */
-  @SuppressWarnings({"rawtypes", "unchecked"})
-  public int unionDelete(String filter, String resouceType) throws ExtsysException {
-    logger.info("BaseHandler:start delete query data.fliter:" + filter);
-    int num;
-    try {
-      BaseDao dao = DaoManager.getInstance().getDao(resouceType);
-      num = dao.unionDelete(filter);
-
-    } catch (ExtsysException error) {
-      logger.error("BaseHandler:error while union delete " + resouceType, error);
-      throw error;
-    }
-    logger.info("BaseHandler:union delete data end .num:" + num);
-    return num;
-  }
-
-  /**
-   * check if the esr parameter is correct in the  external system.
-   * @param data esr entity
-   * @return  if esr parameter  correct return true else return false
-   * @throws ExtsysException ExtsysException when external system error
-   */
-  
-  public abstract boolean validity(T data) throws ExtsysException;
-
-}
diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/CommonHandler.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/CommonHandler.java
deleted file mode 100644 (file)
index 46e0146..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.aai.esr.handle;
-
-import org.onap.aai.esr.common.ExtSysResuorceType;
-import org.onap.aai.esr.common.Parameters;
-import org.onap.aai.esr.entity.aai.BaseData;
-import org.onap.aai.esr.exception.ExtsysException;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-
-public class CommonHandler extends BaseHandler<BaseData> {
-
-  public List<BaseData> getAll() throws ExtsysException {
-    Map<String, String> query = new HashMap<String, String>();
-    return query(query, ExtSysResuorceType.BASE.name());
-  }
-
-  /**
-   * query instance list by id.
-   */
-  public List<BaseData> getInstanceById(String id) throws ExtsysException {
-    Map<String, String> query = new HashMap<String, String>();
-    query.put(Parameters.id.name(), id);
-    return query(query, ExtSysResuorceType.BASE.name());
-  }
-
-  @Override
-  public boolean validity(BaseData data) throws ExtsysException {
-    // TODO Auto-generated method stub
-    return false;
-  }
-
-}
diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/EmsHandler.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/EmsHandler.java
deleted file mode 100644 (file)
index 6cad44a..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.aai.esr.handle;
-
-import org.onap.aai.esr.common.ExtSysResuorceType;
-import org.onap.aai.esr.common.Parameters;
-import org.onap.aai.esr.entity.aai.EmsData;
-import org.onap.aai.esr.exception.ExtsysException;
-import org.onap.aai.esr.util.HqlFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-
-public class EmsHandler extends BaseHandler<EmsData> {
-  private static final Logger logger = LoggerFactory.getLogger(EmsHandler.class);
-
-  @Override
-  public boolean validity(EmsData data) throws ExtsysException {
-    return true;
-  }
-
-  public List<EmsData> getAll() throws ExtsysException {
-    Map<String, String> query = new HashMap<String, String>();
-    return query(query, ExtSysResuorceType.EMS.name());
-  }
-
-  /**
-   * get ems list by id.
-   */
-  public List<EmsData> getEmsById(String id) throws ExtsysException {
-    Map<String, String> query = new HashMap<String, String>();
-    query.put(Parameters.id.name(), id);
-    return query(query, ExtSysResuorceType.EMS.name());
-  }
-  
-  /**
-   * update ems list by id.
-   */  
-  public EmsData update(EmsData emsData, String id) throws ExtsysException {
-    update(emsData, HqlFactory.getOidFilter(Parameters.id.name(), id),
-        ExtSysResuorceType.EMS.name());
-    List<EmsData> list = getEmsById(id);
-    if (list.size() <= 0) {
-      logger.error("update ems info error.");
-      throw new ExtsysException("0000", "update ems info error");
-    }
-    return list.get(0);
-  }
-
-  public EmsData add(EmsData emsData) throws ExtsysException {
-
-    return create(emsData, ExtSysResuorceType.EMS.name());
-  }
-  
-  /**
-   * delete ems list by id.
-   */  
-  public void delete(String id) throws ExtsysException {
-    EmsData ems = new EmsData();
-    ems.setId(id);
-    delete(ems, ExtSysResuorceType.EMS.name());
-  }
-}
diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/SdncHandler.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/SdncHandler.java
deleted file mode 100644 (file)
index 6cb3448..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.aai.esr.handle;
-
-import org.onap.aai.esr.common.ExtSysResuorceType;
-import org.onap.aai.esr.common.Parameters;
-import org.onap.aai.esr.entity.aai.SdncData;
-import org.onap.aai.esr.exception.ExtsysException;
-import org.onap.aai.esr.util.HqlFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class SdncHandler extends BaseHandler<SdncData> {
-  private static final Logger logger = LoggerFactory.getLogger(SdncHandler.class);
-
-  @Override
-  public boolean validity(SdncData data) throws ExtsysException {
-    return true;
-  }
-
-  public List<SdncData> getAll() throws ExtsysException {
-    Map<String, String> query = new HashMap<String, String>();
-    return query(query, ExtSysResuorceType.SDNC.name());
-  }
-
-  /**
-   * get sdnc list by id.
-   */
-  public List<SdncData> getSdncById(String id) throws ExtsysException {
-    Map<String, String> query = new HashMap<String, String>();
-    query.put(Parameters.id.name(), id);
-    return query(query, ExtSysResuorceType.SDNC.name());
-  }
-  
-  /**
-   * update sdnc list by id.
-   */
-  public SdncData update(SdncData sdncData, String id) throws ExtsysException {
-    update(sdncData, HqlFactory.getOidFilter(Parameters.id.name(), id),
-        ExtSysResuorceType.SDNC.name());
-    List<SdncData> list = getSdncById(id);
-    if (list.size() <= 0) {
-      logger.error("update sdn info error.");
-      throw new ExtsysException("0000", "update sdn info error");
-    }
-    return list.get(0);
-  }
-
-  public SdncData add(SdncData sdncData) throws ExtsysException {
-    return create(sdncData, ExtSysResuorceType.SDNC.name());
-  }
-  
-  /**
-   * delete sdnc list by id.
-   */
-  public void delete(String id) throws ExtsysException {
-    SdncData sdnc = new SdncData();
-    sdnc.setId(id);
-    delete(sdnc, ExtSysResuorceType.SDNC.name());
-  }
-}
diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/VimHandler.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/VimHandler.java
deleted file mode 100644 (file)
index 75916a9..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.aai.esr.handle;
-
-import org.onap.aai.esr.common.ExtSysResuorceType;
-import org.onap.aai.esr.common.Parameters;
-import org.onap.aai.esr.entity.aai.VimData;
-import org.onap.aai.esr.exception.ExtsysException;
-import org.onap.aai.esr.util.HqlFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-
-public class VimHandler extends BaseHandler<VimData> {
-  private static final Logger logger = LoggerFactory.getLogger(VimHandler.class);
-
-  @Override
-  public boolean validity(VimData data) throws ExtsysException {
-    return true;
-  }
-
-  public List<VimData> getAll() throws ExtsysException {
-    Map<String, String> query = new HashMap<String, String>();
-    return query(query, ExtSysResuorceType.VIM.name());
-  }
-
-  /**
-   * query vim list by id.
-   */
-  public List<VimData> getVimById(String id) throws ExtsysException {
-    Map<String, String> query = new HashMap<String, String>();
-    query.put(Parameters.id.name(), id);
-    return query(query, ExtSysResuorceType.VIM.name());
-  }
-  
-  /**
-   * update vim list by id.
-   */
-  public VimData update(VimData vimData, String id) throws ExtsysException {
-    update(vimData, HqlFactory.getOidFilter(Parameters.id.name(), id),
-        ExtSysResuorceType.VIM.name());
-    List<VimData> list = getVimById(id);
-    if (list.size() <= 0) {
-      logger.error("update vim info error.");
-      throw new ExtsysException("0000", "update vim info error");
-    }
-    return list.get(0);
-  }
-
-  public VimData add(VimData vimData) throws ExtsysException {
-    return create(vimData, ExtSysResuorceType.VIM.name());
-  }
-  
-  /**
-   * delete vim list by id.
-   */
-  public void delete(String id) throws ExtsysException {
-    VimData vim = new VimData();
-    vim.setId(id);
-    delete(vim, ExtSysResuorceType.VIM.name());
-  }
-}
diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/VnfmHandler.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/VnfmHandler.java
deleted file mode 100644 (file)
index b5bb37d..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.aai.esr.handle;
-
-import org.onap.aai.esr.common.ExtSysResuorceType;
-import org.onap.aai.esr.common.Parameters;
-import org.onap.aai.esr.entity.aai.VnfmData;
-import org.onap.aai.esr.exception.ExtsysException;
-import org.onap.aai.esr.util.HqlFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-
-public class VnfmHandler extends BaseHandler<VnfmData> {
-  private static final Logger logger = LoggerFactory.getLogger(VnfmHandler.class);
-
-  @Override
-  public boolean validity(VnfmData data) throws ExtsysException {
-    return true;
-  }
-
-  public List<VnfmData> getAll() throws ExtsysException {
-    Map<String, String> query = new HashMap<String, String>();
-    return query(query, ExtSysResuorceType.VNFM.name());
-  }
-
-  /**
-   * query vnfm list  by id.
-   */
-  public List<VnfmData> getVnfmById(String id) throws ExtsysException {
-    Map<String, String> query = new HashMap<String, String>();
-    query.put(Parameters.id.name(), id);
-    return query(query, ExtSysResuorceType.VNFM.name());
-  }
-  
-  /**
-   * update vnfm list  by id.
-   */
-  public VnfmData update(VnfmData vnfmData, String id) throws ExtsysException {
-    update(vnfmData, HqlFactory.getOidFilter(Parameters.id.name(), id),
-        ExtSysResuorceType.VNFM.name());
-    List<VnfmData> list = getVnfmById(id);
-    if (list.size() <= 0) {
-      logger.error("update vnfm info error.");
-      throw new ExtsysException("0000", "update vnfm info error");
-    }
-    return list.get(0);
-  }
-
-  public VnfmData add(VnfmData vnfmData) throws ExtsysException {
-    return create(vnfmData, ExtSysResuorceType.VNFM.name());
-  }
-  
-  /**
-   * delete vnfm list  by id.
-   */
-  public void delete(String id) throws ExtsysException {
-    VnfmData vnfm = new VnfmData();
-    vnfm.setId(id);
-    delete(vnfm, ExtSysResuorceType.VNFM.name());
-  }
-}
diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/hibernate/HibernateBundleAgent.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/hibernate/HibernateBundleAgent.java
deleted file mode 100644 (file)
index 77fa9e5..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.aai.esr.hibernate;
-
-import io.dropwizard.ConfiguredBundle;
-import io.dropwizard.setup.Bootstrap;
-import io.dropwizard.setup.Environment;
-
-import org.onap.aai.esr.ExtsysAppConfiguration;
-import org.onap.aai.esr.dao.DaoManager;
-import org.onap.aai.esr.entity.aai.BaseData;
-import org.onap.aai.esr.entity.aai.EmsData;
-import org.onap.aai.esr.entity.aai.SdncData;
-import org.onap.aai.esr.entity.aai.VimData;
-import org.onap.aai.esr.entity.aai.VnfmData;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class HibernateBundleAgent implements ConfiguredBundle<ExtsysAppConfiguration> {
-
-  private final HibernateBundleExt bundle = new HibernateBundleExt(EmsData.class, BaseData.class, VimData.class,
-      VnfmData.class, SdncData.class);
-  private static final Logger LOGGER = LoggerFactory.getLogger(HibernateBundleAgent.class);
-
-  @Override
-  public void run(final ExtsysAppConfiguration configuration, final Environment environment)
-      throws Exception {
-    Thread thread = new Thread(new Runnable() {
-      int retry = 0;
-      boolean flag = true;
-      public void run() {
-        while (retry < 1000) {
-          LOGGER.info("init hibernateBundle.retry:" + retry);
-          retry++;
-          try {
-            bundle.runExt(configuration, environment);
-          } catch (Exception e1) {
-            flag = false;
-            LOGGER.warn(
-                "init hibernateBundle failed, sleep 15S and try again.errorMsg:" + e1.getMessage());
-            threadSleep(15000);
-          }
-          if (flag) {
-            LOGGER.info("init hibernateBundle success!");
-            initDao();
-            break;
-          }
-        }
-      }
-    });
-    thread.setName("init hibernateBundle");
-    thread.start();
-  }
-
-  private void initDao() {
-    DaoManager.getInstance().setSessionFactory(bundle.getSessionFactory());
-  }
-
-  private void threadSleep(int second) {
-    LOGGER.info("start sleep ....");
-    try {
-      Thread.sleep(second);
-    } catch (InterruptedException error) {
-      LOGGER.error("thread sleep error.errorMsg:" + error.getMessage());
-    }
-    LOGGER.info("sleep end .");
-  }
-
-  @Override
-  public void initialize(Bootstrap<?> bootstrap) {
-    bundle.initializeExt(bootstrap);
-  }
-//
-//  public SessionFactory getSessionFactory() {
-//    return bundle.getSessionFactory();
-//  }
-}
diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/hibernate/HibernateBundleExt.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/hibernate/HibernateBundleExt.java
deleted file mode 100644 (file)
index d609adc..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.aai.esr.hibernate;
-
-
-import com.google.common.collect.ImmutableList;
-
-import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module;
-import io.dropwizard.db.DataSourceFactory;
-import io.dropwizard.hibernate.HibernateBundle;
-import io.dropwizard.hibernate.SessionFactoryFactory;
-import io.dropwizard.setup.Bootstrap;
-import io.dropwizard.setup.Environment;
-import org.hibernate.SessionFactory;
-import org.onap.aai.esr.ExtsysAppConfiguration;
-
-
-public class HibernateBundleExt extends HibernateBundle<ExtsysAppConfiguration> {
-
-  private static final String DEFAULT_NAME = "hibernate";
-
-  private SessionFactory sessionFactory;
-
-  private final ImmutableList<Class<?>> entities;
-  private final SessionFactoryFactory sessionFactoryFactory;
-
-  protected HibernateBundleExt(Class<?> entity, Class<?>... entities) {
-    this(ImmutableList.<Class<?>>builder().add(entity).add(entities).build(),
-        new SessionFactoryFactory());
-  }
-
-  protected HibernateBundleExt(ImmutableList<Class<?>> entities,
-      SessionFactoryFactory sessionFactoryFactory) {
-    super(entities, sessionFactoryFactory);
-    this.entities = entities;
-    this.sessionFactoryFactory = sessionFactoryFactory;
-  }
-
-  public final void initializeExt(Bootstrap<?> bootstrap) {
-    bootstrap.getObjectMapper().registerModule(createHibernate4Module());
-  }
-
-  /**
-   * Override to configure the {@link Hibernate4Module}.
-   */
-  protected Hibernate4Module createHibernate4Module() {
-    return new Hibernate4Module();
-  }
-
-  protected String name() {
-    return DEFAULT_NAME;
-  }
-
-  /**
-   * ext run function.
-   * @param configuration inventory configuration
-   * @param environment environment
-   * @throws Exception Exception
-   */
-  public final void runExt(ExtsysAppConfiguration configuration, Environment environment)
-      throws Exception {
-    final DataSourceFactory dbConfig = getDataSourceFactory(configuration);
-    this.sessionFactory =
-        sessionFactoryFactory.build(this, environment, dbConfig, entities, name());
-
-  }
-
-  public SessionFactory getSessionFactory() {
-    return sessionFactory;
-  }
-
-
-  @Override
-  public DataSourceFactory getDataSourceFactory(ExtsysAppConfiguration configuration) {
-    return configuration.getDataSourceFactory();
-  }
-
-}
index 0ab970a..368a0c3 100644 (file)
@@ -26,7 +26,6 @@ import org.eclipse.jetty.http.HttpStatus;
 import org.onap.aai.esr.entity.aai.EmsData;
 import org.onap.aai.esr.entity.rest.EmsRestData;
 import org.onap.aai.esr.exception.ExtsysException;
-import org.onap.aai.esr.handle.EmsHandler;
 import org.onap.aai.esr.util.ExtsysUtil;
 import org.onap.aai.esr.util.RestResponseUtil;
 import org.onap.aai.esr.wrapper.EmsManagerWrapper;
@@ -50,7 +49,6 @@ import javax.ws.rs.core.Response;
 @Api(tags = {" ems Management "})
 public class EmsManager {
 
-  EmsHandler handler = new EmsHandler();
   private static final Logger LOGGER = LoggerFactory.getLogger(EmsManager.class);
 
   /**
index b5a1e30..1a3095c 100644 (file)
@@ -24,7 +24,6 @@ import io.swagger.annotations.ApiResponses;
 
 import org.eclipse.jetty.http.HttpStatus;
 import org.onap.aai.esr.entity.rest.ThirdPartySdncRestData;
-import org.onap.aai.esr.handle.SdncHandler;
 import org.onap.aai.esr.util.ExtsysUtil;
 import org.onap.aai.esr.wrapper.ThirdpatySdncWrapper;
 import org.slf4j.Logger;
@@ -45,7 +44,6 @@ import javax.ws.rs.core.Response;
 @Api(tags = {"ThirdParty sdnc Management     "})
 public class ThirdpatySdncManager {
 
-  SdncHandler handler = new SdncHandler();
   private static final Logger LOGGER = LoggerFactory.getLogger(ThirdpatySdncManager.class);
 
   /**
index 5e049c4..f31140b 100644 (file)
@@ -25,7 +25,6 @@ import org.eclipse.jetty.http.HttpStatus;
 import org.onap.aai.esr.entity.aai.VimData;
 import org.onap.aai.esr.entity.rest.VimRestData;
 import org.onap.aai.esr.exception.ExtsysException;
-import org.onap.aai.esr.handle.VimHandler;
 import org.onap.aai.esr.util.ExtsysUtil;
 import org.onap.aai.esr.util.RestResponseUtil;
 import org.onap.aai.esr.wrapper.VimManagerWrapper;
@@ -49,7 +48,6 @@ import javax.ws.rs.core.Response;
 @Api(tags = {" vim Management "})
 public class VimManager {
 
-  VimHandler handler = new VimHandler();
   private static final Logger LOGGER = LoggerFactory.getLogger(VimManager.class);
 
   /**
index d01114e..f7e7097 100644 (file)
@@ -25,7 +25,6 @@ import org.eclipse.jetty.http.HttpStatus;
 import org.onap.aai.esr.entity.aai.VnfmData;
 import org.onap.aai.esr.entity.rest.VnfmRestData;
 import org.onap.aai.esr.exception.ExtsysException;
-import org.onap.aai.esr.handle.VnfmHandler;
 import org.onap.aai.esr.util.ExtsysUtil;
 import org.onap.aai.esr.util.RestResponseUtil;
 import org.onap.aai.esr.wrapper.VnfmManagerWrapper;
@@ -49,7 +48,6 @@ import javax.ws.rs.core.Response;
 @Api(tags = {" vnfm Management "})
 public class VnfmManager {
 
-  VnfmHandler handler = new VnfmHandler();
   private static final Logger LOGGER = LoggerFactory.getLogger(VnfmManager.class);
 
   /**
diff --git a/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/resource/EmsManagerTest.java b/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/resource/EmsManagerTest.java
deleted file mode 100644 (file)
index e0da1f4..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.aai.esr.db.resource;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.aai.esr.dao.DaoManager;
-import org.onap.aai.esr.db.util.H2DbServer;
-import org.onap.aai.esr.db.util.HibernateSession;
-import org.onap.aai.esr.entity.aai.EmsData;
-import org.onap.aai.esr.exception.ExtsysException;
-import org.onap.aai.esr.handle.EmsHandler;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import java.util.List;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({EmsHandler.class})
-public class EmsManagerTest {
-  private EmsHandler handler;
-  private static String id = "0000000000000000";
-
-  @BeforeClass
-  public static void setUpBeforeClass() throws Exception {
-    H2DbServer.startUp();
-
-  }
-
-  /**
-   * shut down db.
-   */
-  @AfterClass
-  public static void tearDownAfterClass() throws Exception {
-    try {
-      HibernateSession.destory();
-      H2DbServer.shutDown();
-    } catch (Exception error) {
-      Assert.fail("Exception" + error.getMessage());
-    }
-  }
-
-  /**
-   * init db data.
-   */
-  @Before
-  public void setUp() throws Exception {
-    DaoManager.getInstance().setSessionFactory(HibernateSession.init());
-    EmsData data = new EmsData();
-    data.setName("ems");
-    handler = PowerMockito.spy(new EmsHandler());
-    PowerMockito.doReturn(true).when(handler, "validity", data);
-    try {
-      id = handler.add(data).getId();
-    } catch (ExtsysException error) {
-      Assert.fail("Exception" + error.getMessage());
-    }
-  }
-
-  /**
-   * clear db data.
-   */
-  @After
-  public void tearDown() {
-    try {
-      handler.delete(id);
-    } catch (ExtsysException error) {
-      Assert.fail("Exception" + error.getMessage());
-    }
-  }
-
-  @Test
-  @Ignore
-  public void testQueryEmsById_exist() {
-    List<EmsData> list = null;
-    try {
-      list = handler.getEmsById(id);
-    } catch (ExtsysException error) {
-      Assert.fail("Exception" + error.getMessage());
-      return;
-    }
-    Assert.assertTrue(list.size() > 0);
-  }
-
-  @Ignore
-  @Test
-  public void testAddEmsInstance_validity_false() throws Exception {
-    EmsData data = new EmsData();
-    data.setName("ems2");
-    PowerMockito.doReturn(false).when(handler, "validity", data);
-    try {
-      handler.add(data);
-    } catch (ExtsysException error) {
-      Assert.assertTrue(true);
-      return;
-    }
-    Assert.fail("not Exception");
-  }
-
-  @Ignore
-  @Test
-  public void testAddEmsInstance_validity_throw_ExtsysException() throws Exception {
-    EmsData data = new EmsData();
-    data.setName("ems2");
-    PowerMockito.doReturn(false).when(handler, "validity", data);
-    PowerMockito.doThrow(new ExtsysException()).when(handler, "validity", data);
-    try {
-      handler.add(data);
-    } catch (ExtsysException error) {
-      Assert.assertTrue(true);
-      return;
-    }
-    Assert.fail("not Exception");
-  }
-
-  @Ignore
-  @Test
-  public void testQueryEmsById_not_exist() {
-    List<EmsData> list = null;
-    try {
-      list = handler.getEmsById("123456");
-    } catch (ExtsysException error) {
-      Assert.fail("Exception" + error.getMessage());
-      return;
-    }
-    Assert.assertTrue(list.size() == 0);
-  }
-
-  @Ignore
-  @Test
-  public void testUpdateEms() {
-    EmsData data = new EmsData();
-    data.setName("ems_new");
-    try {
-      handler.update(data, id);
-    } catch (ExtsysException error1) {
-      Assert.fail("Exception" + error1.getMessage());
-      return;
-    }
-    List<EmsData> list = null;
-    try {
-      list = handler.getEmsById(id);
-    } catch (ExtsysException error) {
-      Assert.fail("Exception" + error.getMessage());
-      return;
-    }
-    assertTrue(list.size() > 0 && list.get(0).getName().equals("ems_new"));
-  }
-
-}
diff --git a/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/resource/SdncManagerTest.java b/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/resource/SdncManagerTest.java
deleted file mode 100644 (file)
index d1df22e..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.aai.esr.db.resource;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.aai.esr.dao.DaoManager;
-import org.onap.aai.esr.db.util.H2DbServer;
-import org.onap.aai.esr.db.util.HibernateSession;
-import org.onap.aai.esr.entity.aai.SdncData;
-import org.onap.aai.esr.exception.ExtsysException;
-import org.onap.aai.esr.handle.SdncHandler;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import java.util.List;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({SdncHandler.class})
-public class SdncManagerTest {
-  private SdncHandler handler;
-  private String id = "0000000000000000";
-
-  @BeforeClass
-  public static void setUpBeforeClass() throws Exception {
-    H2DbServer.startUp();
-  }
-  
-  /**
-   * shut down db.
-   */
-  @AfterClass
-  public static void tearDownAfterClass() throws Exception {
-    try {
-      HibernateSession.destory();
-      H2DbServer.shutDown();
-    } catch (Exception error) {
-      Assert.fail("Exception" + error.getMessage());
-    }
-  }
-
-  /**
-   * init db data.
-   */
-  @Before
-  public void setUp() throws Exception {
-    DaoManager.getInstance().setSessionFactory(HibernateSession.init());
-    SdncData data = new SdncData();
-    data.setName("sdnc");
-    handler = PowerMockito.spy(new SdncHandler());
-    PowerMockito.doReturn(true).when(handler, "validity", data);
-    try {
-      id = handler.add(data).getId();
-    } catch (ExtsysException error) {
-      Assert.fail("Exception" + error.getMessage());
-    }
-  }
-
-  /**
-   * clear db data.
-   */
-  @After
-  public void tearDown() {
-    try {
-      handler.delete(id);
-    } catch (ExtsysException error) {
-      Assert.fail("Exception" + error.getMessage());
-    }
-  }
-
-  @Ignore
-  @Test
-  public void testAddSdncInstance_validity_false() throws Exception {
-    SdncData data = new SdncData();
-    data.setName("sdnc");
-    PowerMockito.doReturn(false).when(handler, "validity", data);
-    try {
-      handler.add(data);
-    } catch (ExtsysException error) {
-      Assert.assertTrue(true);
-      return;
-    }
-    Assert.fail("not Exception");
-  }
-
-  @Ignore
-  @Test
-  public void testAddSdncInstance_validity_throw_ExtsysException() throws Exception {
-    SdncData data = new SdncData();
-    data.setName("ems2");
-    PowerMockito.doReturn(false).when(handler, "validity", data);
-    PowerMockito.doThrow(new ExtsysException()).when(handler, "validity", data);
-    try {
-      handler.add(data);
-    } catch (ExtsysException error) {
-      Assert.assertTrue(true);
-      return;
-    }
-    Assert.fail("not Exception");
-  }
-
-  @Ignore
-  @Test
-  public void testQuerySdncById_exist() {
-    List<SdncData> list = null;
-    try {
-      list = handler.getSdncById(id);
-    } catch (ExtsysException error) {
-      Assert.fail("Exception" + error.getMessage());
-      return;
-    }
-    Assert.assertTrue(list.size() > 0);
-  }
-
-  @Ignore
-  @Test
-  public void testQuerySdncById_not_exist() {
-    List<SdncData> list = null;
-    try {
-      list = handler.getSdncById("100001");
-    } catch (ExtsysException error) {
-      Assert.fail("Exception" + error.getMessage());
-      return;
-    }
-    Assert.assertTrue(list.size() == 0);
-  }
-
-  @Ignore
-  @Test
-  public void testUpdateSdnc() {
-    SdncData data = new SdncData();
-    data.setName("Sdnc_new");
-    try {
-      handler.update(data, id);
-    } catch (ExtsysException error1) {
-      Assert.fail("Exception" + error1.getMessage());
-      return;
-    }
-    List<SdncData> list = null;
-    try {
-      list = handler.getSdncById(id);
-    } catch (ExtsysException error) {
-      Assert.fail("Exception" + error.getMessage());
-      return;
-    }
-    assertTrue(list.size() > 0 && list.get(0).getName().equals("Sdnc_new"));
-  }
-
-}
diff --git a/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/resource/VimManagerTest.java b/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/resource/VimManagerTest.java
deleted file mode 100644 (file)
index e035b22..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.aai.esr.db.resource;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.aai.esr.dao.DaoManager;
-import org.onap.aai.esr.db.util.H2DbServer;
-import org.onap.aai.esr.db.util.HibernateSession;
-import org.onap.aai.esr.entity.aai.VimData;
-import org.onap.aai.esr.exception.ExtsysException;
-import org.onap.aai.esr.handle.VimHandler;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-
-import java.util.List;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({VimHandler.class})
-public class VimManagerTest {
-  private VimHandler handler;
-  private String id = "0000000000000000";
-
-  @BeforeClass
-  public static void setUpBeforeClass() throws Exception {
-    H2DbServer.startUp();
-
-  }
-
-  /**
-   * shut down db.
-   */
-  @AfterClass
-  public static void tearDownAfterClass() throws Exception {
-    try {
-      HibernateSession.destory();
-      H2DbServer.shutDown();
-    } catch (Exception error) {
-      Assert.fail("Exception" + error.getMessage());
-    }
-  }
-
-  /**
-   * init db data.
-   */
-  @Before
-  public void setUp() throws Exception {
-    DaoManager.getInstance().setSessionFactory(HibernateSession.init());
-    VimData data = new VimData();
-    handler = PowerMockito.spy(new VimHandler());
-    PowerMockito.doReturn(true).when(handler, "validity", data);
-    data.setId("10000");
-    data.setName("vim");
-    try {
-      id = handler.add(data).getId();
-    } catch (ExtsysException error) {
-      Assert.fail("Exception" + error.getMessage());
-    }
-  }
-
-  /**
-   * clear db data.
-   */
-  @After
-  public void tearDown() {
-    try {
-      handler.delete(id);
-    } catch (ExtsysException error) {
-      Assert.fail("Exception" + error.getMessage());
-    }
-  }
-
-  @Ignore
-  @Test
-  public void testAddVimInstance_validity_false() throws Exception {
-    VimData data = new VimData();
-    data.setName("Vim");
-    PowerMockito.doReturn(false).when(handler, "validity", data);
-    try {
-      handler.add(data);
-    } catch (ExtsysException error) {
-      Assert.assertTrue(true);
-      return;
-    }
-    Assert.fail("not Exception");
-  }
-
-  @Ignore
-  @Test
-  public void testAddVimInstance_validity_throw_ExtsysException() throws Exception {
-    VimData data = new VimData();
-    data.setName("vim2");
-    PowerMockito.doReturn(false).when(handler, "validity", data);
-    PowerMockito.doThrow(new ExtsysException()).when(handler, "validity", data);
-    try {
-      handler.add(data);
-    } catch (ExtsysException error) {
-      Assert.assertTrue(true);
-      return;
-    }
-    Assert.fail("not Exception");
-  }
-
-  @Ignore
-  @Test
-  public void testQueryVimById_exist() {
-    List<VimData> list = null;
-    try {
-      list = handler.getVimById(id);
-    } catch (ExtsysException error) {
-      Assert.fail("Exception" + error.getMessage());
-      return;
-    }
-    Assert.assertTrue(list.size() > 0);
-  }
-
-  @Ignore
-  @Test
-  public void testQueryVimById_not_exist() {
-    List<VimData> list = null;
-    try {
-      list = handler.getVimById("100001");
-    } catch (ExtsysException error) {
-      Assert.fail("Exception" + error.getMessage());
-      return;
-    }
-    Assert.assertTrue(list.size() == 0);
-  }
-
-  @Ignore
-  @Test
-  public void testUpdateVim() {
-    VimData data = new VimData();
-    data.setName("vim_new");
-    try {
-      handler.update(data, id);
-    } catch (ExtsysException error1) {
-      Assert.fail("Exception" + error1.getMessage());
-      return;
-    }
-    List<VimData> list = null;
-    try {
-      list = handler.getVimById(id);
-    } catch (ExtsysException error) {
-      Assert.fail("Exception" + error.getMessage());
-      return;
-    }
-    assertTrue(list.size() > 0 && list.get(0).getName().equals("vim_new"));
-  }
-
-}
diff --git a/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/resource/VnfmManagerTest.java b/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/resource/VnfmManagerTest.java
deleted file mode 100644 (file)
index cabb1c1..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.aai.esr.db.resource;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.aai.esr.dao.DaoManager;
-import org.onap.aai.esr.db.util.H2DbServer;
-import org.onap.aai.esr.db.util.HibernateSession;
-import org.onap.aai.esr.entity.aai.VnfmData;
-import org.onap.aai.esr.exception.ExtsysException;
-import org.onap.aai.esr.handle.VnfmHandler;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-
-import java.util.List;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({VnfmHandler.class})
-public class VnfmManagerTest {
-  private VnfmHandler handler;
-  private String id = "0000000000000000";
-
-  @BeforeClass
-  public static void setUpBeforeClass() throws Exception {
-    H2DbServer.startUp();
-  }
-
-  /**
-   * shut down db.
-   */
-  @AfterClass
-  public static void tearDownAfterClass() throws Exception {
-    try {
-      HibernateSession.destory();
-      H2DbServer.shutDown();
-    } catch (Exception error) {
-      Assert.fail("Exception" + error.getMessage());
-    }
-  }
-
-  /**
-   * init db data.
-   */
-  @Before
-  public void setUp() throws Exception {
-    DaoManager.getInstance().setSessionFactory(HibernateSession.init());
-    VnfmData data = new VnfmData();
-    data.setName("vnfm");
-    handler = PowerMockito.spy(new VnfmHandler());
-    PowerMockito.doReturn(true).when(handler, "validity", data);
-    try {
-      id = handler.add(data).getId();
-    } catch (ExtsysException error) {
-      Assert.fail("Exception" + error.getMessage());
-    }
-  }
-
-  /**
-   * clear db data.
-   */
-  @After
-  public void tearDown() {
-    try {
-      handler.delete(id);
-    } catch (ExtsysException error) {
-      Assert.fail("Exception" + error.getMessage());
-    }
-  }
-
-
-  @Ignore
-  @Test
-  public void testQueryVnfmById_exist() {
-    List<VnfmData> list = null;
-    try {
-      list = handler.getVnfmById(id);
-    } catch (ExtsysException error) {
-      Assert.fail("Exception" + error.getMessage());
-      return;
-    }
-    Assert.assertTrue(list.size() > 0);
-  }
-
-  @Ignore
-  @Test
-  public void testQueryVnfmById_not_exist() {
-    List<VnfmData> list = null;
-    try {
-      list = handler.getVnfmById("100001");
-    } catch (ExtsysException error) {
-      Assert.fail("Exception" + error.getMessage());
-      return;
-    }
-    Assert.assertTrue(list.size() == 0);
-  }
-
-  @Ignore
-  @Test
-  public void testUpdateVnfm() {
-    VnfmData data = new VnfmData();
-    data.setName("vnfm_new");
-    try {
-      handler.update(data, id);
-    } catch (ExtsysException error1) {
-      Assert.fail("Exception" + error1.getMessage());
-      return;
-    }
-    List<VnfmData> list = null;
-    try {
-      list = handler.getVnfmById(id);
-    } catch (ExtsysException error) {
-      Assert.fail("Exception" + error.getMessage());
-      return;
-    }
-    assertTrue(list.size() > 0 && list.get(0).getName().equals("vnfm_new"));
-  }
-
-  @Ignore
-  @Test
-  public void testAddVnfmInstance_validity_false() throws Exception {
-    VnfmData data = new VnfmData();
-    data.setName("Vnfm");
-    PowerMockito.doReturn(false).when(handler, "validity", data);
-    try {
-      handler.add(data);
-    } catch (ExtsysException error) {
-      Assert.assertTrue(true);
-      return;
-    }
-    Assert.fail("not Exception");
-  }
-
-  @Ignore
-  @Test
-  public void testAddVnfmInstance_validity_throw_ExtsysException() throws Exception {
-    VnfmData data = new VnfmData();
-    data.setName("vnfm2");
-    PowerMockito.doReturn(false).when(handler, "validity", data);
-    PowerMockito.doThrow(new ExtsysException()).when(handler, "validity", data);
-    try {
-      handler.add(data);
-    } catch (ExtsysException error) {
-      Assert.assertTrue(true);
-      return;
-    }
-    Assert.fail("not Exception");
-  }
-}
diff --git a/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/util/CatalogDbUtilTest.java b/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/util/CatalogDbUtilTest.java
deleted file mode 100644 (file)
index 6fb8f3a..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.aai.esr.db.util;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.Test;
-import org.onap.aai.esr.util.ExtsysUtil;
-
-public class CatalogDbUtilTest {
-
-  @Test
-  public void when_generate_id_is_not_null() {
-    String actualUuid = ExtsysUtil.generateId();
-    assertNotNull(actualUuid);
-  }
-
-  @Test
-  public void when_input_empty_string_output_false() {
-    boolean expect = false;
-    boolean actual = ExtsysUtil.isNotEmpty("");
-    assertEquals(expect, actual);
-  }
-
-  @Test
-  public void when_input_blan_string_output_true() {
-    boolean expect = true;
-    boolean actual = ExtsysUtil.isNotEmpty(" ");
-    assertEquals(expect, actual);
-  }
-
-  @Test
-  public void when_input_null_string_output_false() {
-    boolean expect = false;
-    boolean actual = ExtsysUtil.isNotEmpty(null);
-    assertEquals(expect, actual);
-  }
-
-  @Test
-  public void when_input_str_string_output_true() {
-    boolean expect = true;
-    boolean actual = ExtsysUtil.isNotEmpty("str");
-    assertEquals(expect, actual);
-  }
-
-}
diff --git a/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/util/H2DbServer.java b/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/util/H2DbServer.java
deleted file mode 100644 (file)
index 4746fad..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.aai.esr.db.util;
-
-import org.h2.tools.Server;
-
-import java.sql.SQLException;
-
-
-public class H2DbServer {
-
-  private static Server h2DbWebServer;
-  private static Server h2DbTcpServer;
-
-  /**
-   * start db.
-   */
-  public static void startUp() {
-    try {
-      h2DbWebServer =
-          Server.createWebServer(new String[] {"-web", "-webAllowOthers", "-webPort", "18208"});
-      h2DbWebServer.start();
-
-      h2DbTcpServer =
-          Server.createTcpServer(new String[] {"-tcp", "-tcpAllowOthers", "-tcpPort", "18207"});
-      h2DbTcpServer.start();
-    } catch (SQLException error) {
-      error.printStackTrace();
-    }
-  }
-
-  /**
-   * stop db.
-   */
-  public static void shutDown() {
-    if (h2DbWebServer.isRunning(true)) {
-      h2DbWebServer.stop();
-      h2DbWebServer.shutdown();
-    }
-    if (h2DbTcpServer.isRunning(true)) {
-      h2DbTcpServer.stop();
-      h2DbTcpServer.shutdown();
-    }
-  }
-}
diff --git a/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/util/H2DbServerUtil.java b/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/util/H2DbServerUtil.java
deleted file mode 100644 (file)
index b3bb743..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.aai.esr.db.util;
-
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.SQLExec;
-import org.apache.tools.ant.types.EnumeratedAttribute;
-
-import java.io.File;
-import java.net.URISyntaxException;
-
-
-public class H2DbServerUtil {
-  private static String resourcePath;
-
-  /**
-   * init db table.
-   */
-  public static void initTable() {
-    init();
-    SQLExec sqlExec = new SQLExec();
-    // set db connetc parameter
-    sqlExec.setDriver("org.h2.Driver");
-    sqlExec.setUrl("jdbc:h2:tcp://localhost:18209/" + resourcePath + "db/extsys");
-    sqlExec.setUserid("extsys");
-    sqlExec.setPassword("extsys");
-    // execute sql
-    sqlExec.setSrc(new File(resourcePath + "sql/extsys-resource-createObj-mysql.sql"));
-    sqlExec.setOnerror(
-        (SQLExec.OnError) (EnumeratedAttribute.getInstance(SQLExec.OnError.class, "abort")));
-    sqlExec.setPrint(true); // set print
-    sqlExec.setProject(new Project());
-    sqlExec.execute();
-  }
-
-  private static void init() {
-    try {
-      resourcePath = HibernateSession.class.getResource("/").toURI().getPath();
-    } catch (URISyntaxException error) {
-      error.printStackTrace();
-    }
-  }
-
-  /**
-   * init db.
-   */
-  public static void main(String [] args) {
-    H2DbServer.startUp();
-    H2DbServerUtil.initTable();
-    H2DbServer.shutDown();
-  }
-
-}
diff --git a/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/util/HibernateSession.java b/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/util/HibernateSession.java
deleted file mode 100644 (file)
index f3c786f..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.aai.esr.db.util;
-
-import org.hibernate.SessionFactory;
-import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.service.ServiceRegistry;
-
-import java.io.File;
-import java.net.URISyntaxException;
-
-public class HibernateSession {
-  private static File cfgfile = null;
-
-  private static ServiceRegistry serviceRegistry = null;
-  private static Configuration configuration = null;
-  private static SessionFactory sessionFactory = null;
-  private static String resourcePath;
-
-  /**
-   * Get a hibernate sessionFactory.
-   */
-  public static SessionFactory init() {
-    initConfigure();
-    configuration = new Configuration().configure(cfgfile);
-    configuration.setProperty("hibernate.connection.url",
-        "jdbc:h2:tcp://localhost:18207/" + resourcePath + "db/extsys");
-    serviceRegistry =
-        new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
-    sessionFactory = configuration.buildSessionFactory(serviceRegistry);
-    return sessionFactory;
-  }
-
-  private static void initConfigure() {
-    try {
-      resourcePath = HibernateSession.class.getResource("/").toURI().getPath();
-    } catch (URISyntaxException error) {
-      error.printStackTrace();
-    }
-    final String filename = "Hibernate.cfg.xml";
-    cfgfile = new File(resourcePath + filename);
-  }
-
-  /**
-   * Destory a hibernate sessionFactory.
-   */
-  public static void destory() {
-    if (sessionFactory != null && !sessionFactory.isClosed()) {
-      sessionFactory.close();
-    }
-  }
-
-
-}
diff --git a/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/util/HqlFactoryTest.java b/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/util/HqlFactoryTest.java
deleted file mode 100644 (file)
index 0caef38..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.aai.esr.db.util;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-import org.onap.aai.esr.entity.aai.VnfmData;
-import org.onap.aai.esr.util.HqlFactory;
-
-
-public class HqlFactoryTest {
-
-  @Test
-  public void when_input_entity_output_udatehql() {
-    VnfmData data = new VnfmData();
-    String filter = "vnfmId='xd03dsfsdfsfsdfsd'";
-    data.setName("csarName");
-    data.setType("NS");
-    String expect =
-        "update VnfmData set name='csarName',type='NS' where vnfmId='xd03dsfsdfsfsdfsd'";
-    String actual = HqlFactory.getUpdateHql(data, null, filter);
-    assertEquals(expect, actual);
-  }
-
-  @Test
-  public void when_input_null_testContain_output_false() {
-    boolean expect = false;
-    boolean actual = HqlFactory.contain(null, "name");
-    assertEquals(expect, actual);
-    String[] src = new String[0];
-    actual = HqlFactory.contain(src, "name");
-    assertEquals(expect, actual);
-    src = new String[1];
-    actual = HqlFactory.contain(src, null);
-    assertEquals(expect, actual);
-  }
-
-  @Test
-  public void when_input_src_contain_target_testContain_output_true() {
-    boolean expect = true;
-    String [] src = {"name", "type"};
-    String target = "name";
-    boolean actual = HqlFactory.contain(src, target);
-    assertEquals(expect, actual);
-  }
-
-  @Test
-  public void when_input_src_not_contain_target_testContain_output_false() {
-    boolean expect = false;
-    String [] src = {"name", "type"};
-    String target = "version";
-    boolean actual = HqlFactory.contain(src, target);
-    assertEquals(expect, actual);
-  }
-
-  @Test
-  public void testGetOidFilter() {
-    // fail("Not yet implemented");
-    String key = "csarId";
-    String value = "xd03dsfsdfsfsdfsd";
-    String expect = "csarId= 'xd03dsfsdfsfsdfsd'";
-    String actual = HqlFactory.getOidFilter(key, value);
-    assertEquals(expect, actual);
-  }
-
-  @Test
-  public void when_input_entity_output_queryhql() {
-    VnfmData data = new VnfmData();
-    String filter = "vnfmId";
-    data.setName("csarName");
-    data.setType("NS");
-    String expect = "select q.vnfmId from VnfmData as q where q.name='csarName' and q.type='NS'";
-    String actual = HqlFactory.getQueryHql(data, filter);
-    assertEquals(expect, actual);
-  }
-
-}
index d33e5bf..c60b0d0 100644 (file)
@@ -37,7 +37,6 @@
         <gson.version>2.2.4</gson.version>
         <junit.version>4.10</junit.version>
         <org.powermock.version>1.4.10</org.powermock.version>
-        <h2database.version>1.4.182</h2database.version>
         <org.apache.ant.version>1.8.2</org.apache.ant.version>
     </properties>
 
                 <artifactId>powermock-api-mockito</artifactId> 
                 <version>${org.powermock.version}</version>
             </dependency> 
-            <dependency>
-                <groupId>com.h2database</groupId>
-                <artifactId>h2</artifactId>
-                <version>${h2database.version}</version>
-                <scope>test</scope>
-            </dependency>
             <dependency>
                 <groupId>org.apache.ant</groupId>
                 <artifactId>ant</artifactId>