summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/BpelRestClient.java16
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java264
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java2911
3 files changed, 2142 insertions, 1049 deletions
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/BpelRestClient.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/BpelRestClient.java
index a8189925fb..749b9f9fc3 100644
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/BpelRestClient.java
+++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/BpelRestClient.java
@@ -256,13 +256,9 @@ public class BpelRestClient {
.build();
post.setConfig(requestConfig);
- //Client 4.3+
- CloseableHttpClient client = null;
-
//Client 4.3+
//Execute & GetResponse
- try {
- client = HttpClients.createDefault();
+ try(CloseableHttpClient client = HttpClients.createDefault()) {
CloseableHttpResponse response = client.execute(post);
if (response != null) {
lastResponseCode = response.getStatusLine().getStatusCode();
@@ -277,16 +273,6 @@ public class BpelRestClient {
LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, error, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Error sending Bpel notification", e);
lastResponseCode = 900;
lastResponse = "";
- } finally {
- try {
- client.close();
- } catch (IOException e) {
- // ignore
- LOGGER.debug("IOException: ", e);
- } catch (NullPointerException e) {
- //ignore
- LOGGER.debug("NullPointerException: ", e);
- }
}
LOGGER.debug("Response code from BPEL server: "+lastResponseCode);
LOGGER.debug("Response body is: "+lastResponse);
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java
index cdde98dd36..0219e304cb 100644
--- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java
@@ -219,29 +219,29 @@ public class CatalogDatabase implements Closeable {
* @param version
* @return HeatTemplate object or null if none found
*/
- public HeatTemplate getHeatTemplate (String templateName, String version) {
+ public HeatTemplate getHeatTemplate(String templateName, String version) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get Heat template with name " + templateName
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get Heat template with name " + templateName
+ " and version "
+ version);
String hql = "FROM HeatTemplate WHERE templateName = :template_name AND version = :version";
- Query query = getSession ().createQuery (hql);
- query.setParameter ("template_name", templateName);
- query.setParameter ("version", version);
+ Query query = getSession().createQuery(hql);
+ query.setParameter("template_name", templateName);
+ query.setParameter("version", version);
@SuppressWarnings("unchecked")
- List <HeatTemplate> resultList = query.list ();
+ List <HeatTemplate> resultList = query.list();
// See if something came back.
- if (resultList.isEmpty ()) {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No template found.", "CatalogDB", "getHeatTemplate", null);
+ if (resultList.isEmpty()) {
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No template found.", "CatalogDB", "getHeatTemplate", null);
return null;
}
// Name + Version is unique, so should only be one element
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null);
- return resultList.get (0);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null);
+ return resultList.get(0);
}
/**
@@ -266,10 +266,10 @@ public class CatalogDatabase implements Closeable {
*
* @param artifactUuid
* @return HeatTemplate object or null if none found
- */
+ */
public HeatTemplate getHeatTemplateByArtifactUuidRegularQuery(String artifactUuid) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get Heat template (regular query) with artifactUuid " + artifactUuid);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get Heat template (regular query) with artifactUuid " + artifactUuid);
String hql = "FROM HeatTemplate WHERE artifactUuid = :artifactUuidValue";
HashMap<String, String> variables = new HashMap<>();
@@ -277,9 +277,9 @@ public class CatalogDatabase implements Closeable {
HeatTemplate template = (HeatTemplate) this.executeQuerySingleRow(hql, variables, true);
if (template == null) {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getHeatTemplateByArtifactUuidRegularQuery", null);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getHeatTemplateByArtifactUuidRegularQuery", null);
} else {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplateByArtifactUuidRegularQuery", null);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplateByArtifactUuidRegularQuery", null);
}
return template;
}
@@ -314,19 +314,18 @@ public class CatalogDatabase implements Closeable {
* @return HeatEnvironment object or null if none found
*/
public HeatEnvironment getHeatEnvironmentByArtifactUuid(String artifactUuid) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get Heat Environment with artifactUuid " + artifactUuid);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get Heat Environment with artifactUuid " + artifactUuid);
String hql = "FROM HeatEnvironment WHERE artifactUuid = :artifactUuidValue";
Query query = getSession().createQuery(hql);
- query.setParameter ("artifactUuidValue", artifactUuid);
+ query.setParameter("artifactUuidValue", artifactUuid);
HeatEnvironment environment = null;
try {
- environment = (HeatEnvironment) query.uniqueResult ();
+ environment = (HeatEnvironment) query.uniqueResult();
} catch (org.hibernate.NonUniqueResultException nure) {
LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row for Envt - data integrity error: artifactUuid='" + artifactUuid +"'", nure);
LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for heatEnvironment artifactUuid=" + artifactUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for artifactUuid==" + artifactUuid);
- environment = null;
} catch (org.hibernate.HibernateException he) {
LOGGER.debug("Hibernate Exception - while searching for envt: artifactUuid='" + artifactUuid + "' " + he.getMessage());
LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching envt for artifactUuid=" + artifactUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching envt for artifactUuid=" + artifactUuid);
@@ -352,11 +351,11 @@ public class CatalogDatabase implements Closeable {
*/
public Service getServiceByInvariantUUID (String modelInvariantUUID) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get service with Invariant UUID " + modelInvariantUUID);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get service with Invariant UUID " + modelInvariantUUID);
String hql = "FROM Service WHERE modelInvariantUUID = :model_invariant_uuid";
- Query query = getSession ().createQuery (hql);
+ Query query = getSession().createQuery(hql);
query.setParameter ("model_invariant_uuid", modelInvariantUUID);
@SuppressWarnings("unchecked")
@@ -379,16 +378,16 @@ public class CatalogDatabase implements Closeable {
*/
public Service getService (String modelName) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get service with name " + modelName);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get service with name " + modelName);
String hql = "FROM Service WHERE modelName = :MODEL_NAME";
- Query query = getSession ().createQuery (hql);
- query.setParameter ("MODEL_NAME", modelName);
+ Query query = getSession().createQuery(hql);
+ query.setParameter("MODEL_NAME", modelName);
Service service = null;
try {
- service = (Service) query.uniqueResult ();
+ service = (Service) query.uniqueResult();
} catch (org.hibernate.NonUniqueResultException nure) {
LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelName='" + modelName + "'");
LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelName=" + modelName, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelName=" + modelName);
@@ -413,8 +412,8 @@ public class CatalogDatabase implements Closeable {
public Service getServiceByModelUUID (String modelUUID) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get service with Model UUID " + modelUUID);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get service with Model UUID " + modelUUID);
String hql = "FROM Service WHERE modelUUID = :MODEL_UUID";
HashMap<String, String> parameters = new HashMap<>();
@@ -463,25 +462,25 @@ public class CatalogDatabase implements Closeable {
LOGGER.debug ("Catalog database - get service modelUUID with id " + serviceNameVersionId);
String hql = "FROM Service WHERE MODEL_UUID = :MODEL_UUID and http_method = :http_method";
- query = getSession ().createQuery (hql);
- query.setParameter ("MODEL_UUID", serviceNameVersionId);
+ query = getSession().createQuery(hql);
+ query.setParameter("MODEL_UUID", serviceNameVersionId);
} else {
serviceId = map.get("serviceId");
serviceVersion = map.get("serviceVersion");
- LOGGER.debug ("Catalog database - get serviceId with id " + serviceId + " and serviceVersion with " + serviceVersion);
+ LOGGER.debug("Catalog database - get serviceId with id " + serviceId + " and serviceVersion with " + serviceVersion);
String hql = "FROM Service WHERE service_id = :service_id and service_version = :service_version and http_method = :http_method";
- query = getSession ().createQuery (hql);
- query.setParameter ("service_id", serviceId);
- query.setParameter ("service_version", serviceVersion);
+ query = getSession().createQuery(hql);
+ query.setParameter("service_id", serviceId);
+ query.setParameter("service_version", serviceVersion);
}
- query.setParameter ("http_method", httpMethod);
+ query.setParameter("http_method", httpMethod);
- long startTime = System.currentTimeMillis ();
+ long startTime = System.currentTimeMillis();
Service service = null;
try {
- service = (Service) query.uniqueResult ();
+ service = (Service) query.uniqueResult();
} catch (org.hibernate.NonUniqueResultException nure) {
LOGGER.debug("Non Unique Result Exception - data integrity error: service_id='" + serviceId + "', serviceVersion='" + serviceVersion + "'");
LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for service_id=" + serviceId + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for service_id=" + serviceId);
@@ -512,37 +511,37 @@ public class CatalogDatabase implements Closeable {
* @param modelName
* @return Service object or null if none found
*/
- public Service getServiceByModelName (String modelName){
+ public Service getServiceByModelName(String modelName){
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get service with name " + modelName);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get service with name " + modelName);
String hql = "FROM Service WHERE modelName = :MODEL_NAME";
- Query query = getSession ().createQuery (hql);
- query.setParameter ("MODEL_NAME", modelName);
+ Query query = getSession().createQuery(hql);
+ query.setParameter("MODEL_NAME", modelName);
@SuppressWarnings("unchecked")
- List <Service> resultList = query.list ();
+ List <Service> resultList = query.list();
// See if something came back.
- if (resultList.isEmpty ()) {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service not found", "CatalogDB", "getServiceByModelName", null);
+ if (resultList.isEmpty()) {
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service not found", "CatalogDB", "getServiceByModelName", null);
return null;
}
- Collections.sort (resultList, new MavenLikeVersioningComparator ());
- Collections.reverse (resultList);
+ Collections.sort(resultList, new MavenLikeVersioningComparator ());
+ Collections.reverse(resultList);
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByModelName", null);
- return resultList.get (0);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByModelName", null);
+ return resultList.get(0);
}
public Service getServiceByVersionAndInvariantId(String modelInvariantId, String modelVersion) throws Exception {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get service with modelInvariantId: " + modelInvariantId + " and modelVersion: " + modelVersion);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get service with modelInvariantId: " + modelInvariantId + " and modelVersion: " + modelVersion);
String hql = "FROM Service WHERE modelInvariantUUID = :MODEL_INVARIANT_UUID AND version = :VERSION_STR";
- Query query = getSession ().createQuery (hql);
- query.setParameter ("MODEL_INVARIANT_UUID", modelInvariantId);
+ Query query = getSession().createQuery(hql);
+ query.setParameter("MODEL_INVARIANT_UUID", modelInvariantId);
query.setParameter("VERSION_STR", modelVersion);
Service result = null;
@@ -555,11 +554,11 @@ public class CatalogDatabase implements Closeable {
}
// See if something came back.
if (result==null) {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service not found", "CatalogDB", "getServiceByVersionAndInvariantId", null);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service not found", "CatalogDB", "getServiceByVersionAndInvariantId", null);
return null;
}
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByVersionAndInvariantId", null);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByVersionAndInvariantId", null);
return result;
}
@@ -615,67 +614,67 @@ public class CatalogDatabase implements Closeable {
* @param action *
* @return ServiceRecipe object or null if none found
*/
- public ServiceRecipe getServiceRecipeByServiceModelUuid (String serviceModelUuid, String action) {
+ public ServiceRecipe getServiceRecipeByServiceModelUuid(String serviceModelUuid, String action) {
StringBuilder hql;
if(action == null){
- hql = new StringBuilder ("FROM ServiceRecipe WHERE serviceModelUuid = :serviceModelUuid");
+ hql = new StringBuilder("FROM ServiceRecipe WHERE serviceModelUuid = :serviceModelUuid");
}else {
- hql = new StringBuilder ("FROM ServiceRecipe WHERE serviceModelUuid = :serviceModelUuid AND action = :action ");
+ hql = new StringBuilder("FROM ServiceRecipe WHERE serviceModelUuid = :serviceModelUuid AND action = :action ");
}
long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get Service recipe with serviceModelUuid " + serviceModelUuid
+ LOGGER.debug("Catalog database - get Service recipe with serviceModelUuid " + serviceModelUuid
+ " and action "
+ action
);
- Query query = getSession ().createQuery (hql.toString ());
- query.setParameter ("serviceModelUuid", serviceModelUuid);
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter("serviceModelUuid", serviceModelUuid);
if(action != null){
- query.setParameter (ACTION, action);
+ query.setParameter(ACTION, action);
}
@SuppressWarnings("unchecked")
- List <ServiceRecipe> resultList = query.list ();
+ List <ServiceRecipe> resultList = query.list();
- if (resultList.isEmpty ()) {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service recipe not found", "CatalogDB", "getServiceRecipe", null);
+ if (resultList.isEmpty()) {
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service recipe not found", "CatalogDB", "getServiceRecipe", null);
return null;
}
- Collections.sort (resultList, new MavenLikeVersioningComparator ());
- Collections.reverse (resultList);
+ Collections.sort(resultList, new MavenLikeVersioningComparator());
+ Collections.reverse(resultList);
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipe", null);
- return resultList.get (0);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipe", null);
+ return resultList.get(0);
}
- public List<ServiceRecipe> getServiceRecipes (String serviceModelUuid) {
+ public List<ServiceRecipe> getServiceRecipes(String serviceModelUuid) {
StringBuilder hql;
- hql = new StringBuilder ("FROM ServiceRecipe WHERE serviceModelUUID = :serviceModelUUID");
+ hql = new StringBuilder("FROM ServiceRecipe WHERE serviceModelUUID = :serviceModelUUID");
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get Service recipe with serviceModelUUID " + serviceModelUuid);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get Service recipe with serviceModelUUID " + serviceModelUuid);
- Query query = getSession ().createQuery (hql.toString ());
- query.setParameter ("serviceModelUUID", serviceModelUuid);
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter("serviceModelUUID", serviceModelUuid);
@SuppressWarnings("unchecked")
- List <ServiceRecipe> resultList = query.list ();
+ List <ServiceRecipe> resultList = query.list();
- if (resultList.isEmpty ()) {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service recipe not found", "CatalogDB", "getServiceRecipes", null);
+ if (resultList.isEmpty()) {
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service recipe not found", "CatalogDB", "getServiceRecipes", null);
return Collections.EMPTY_LIST;
}
- Collections.sort (resultList, new MavenLikeVersioningComparator ());
- Collections.reverse (resultList);
+ Collections.sort(resultList, new MavenLikeVersioningComparator());
+ Collections.reverse(resultList);
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipes", null);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipes", null);
return resultList;
}
@@ -734,48 +733,48 @@ public class CatalogDatabase implements Closeable {
*/
public VnfResource getVnfResource (String vnfType) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get vnf resource with model_name " + vnfType);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get vnf resource with model_name " + vnfType);
String hql = "FROM VnfResource WHERE modelName = :vnf_name";
- Query query = getSession ().createQuery (hql);
- query.setParameter ("vnf_name", vnfType);
+ Query query = getSession().createQuery(hql);
+ query.setParameter("vnf_name", vnfType);
@SuppressWarnings("unchecked")
- List <VnfResource> resultList = query.list ();
+ List <VnfResource> resultList = query.list();
// See if something came back. Name is unique, so
- if (resultList.isEmpty ()) {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF not found", "CatalogDB", "getVnfResource", null);
+ if (resultList.isEmpty()) {
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF not found", "CatalogDB", "getVnfResource", null);
return null;
}
- Collections.sort (resultList, new MavenLikeVersioningComparator ());
- Collections.reverse (resultList);
+ Collections.sort(resultList, new MavenLikeVersioningComparator());
+ Collections.reverse(resultList);
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResource", null);
- return resultList.get (0);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResource", null);
+ return resultList.get(0);
}
/**
* Return the newest version of a specific VNF resource (queried by Name).
*
* @param vnfType
- * @param version
+ * @param serviceVersion
* @return VnfResource object or null if none found
*/
public VnfResource getVnfResource (String vnfType, String serviceVersion) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get VNF resource with model_name " + vnfType + " and version=" + serviceVersion);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get VNF resource with model_name " + vnfType + " and version=" + serviceVersion);
String hql = "FROM VnfResource WHERE modelName = :vnfName and version = :serviceVersion";
- Query query = getSession ().createQuery (hql);
- query.setParameter ("vnfName", vnfType);
- query.setParameter ("serviceVersion", serviceVersion);
+ Query query = getSession().createQuery(hql);
+ query.setParameter("vnfName", vnfType);
+ query.setParameter("serviceVersion", serviceVersion);
VnfResource resource = null;
try {
- resource = (VnfResource) query.uniqueResult ();
+ resource = (VnfResource) query.uniqueResult();
} catch (org.hibernate.NonUniqueResultException nure) {
LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: vnfType='" + vnfType + "', serviceVersion='" + serviceVersion + "'");
LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vnfType=" + vnfType + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for vnfType=" + vnfType);
@@ -808,22 +807,22 @@ public class CatalogDatabase implements Closeable {
* @param modelCustomizationId
* @return VnfResource object or null if none found
*/
- public VnfResource getVnfResourceByModelCustomizationId (String modelCustomizationId) {
+ public VnfResource getVnfResourceByModelCustomizationId(String modelCustomizationId) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get VNF resource with modelCustomizationId " + modelCustomizationId);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get VNF resource with modelCustomizationId " + modelCustomizationId);
String hql = "SELECT vr "
+ "FROM VnfResource as vr JOIN vr.vnfResourceCustomizations as vrc "
+ "WHERE vrc.modelCustomizationUuid = :modelCustomizationId";
- Query query = getSession ().createQuery (hql);
- query.setParameter ("modelCustomizationId", modelCustomizationId);
+ Query query = getSession().createQuery(hql);
+ query.setParameter("modelCustomizationId", modelCustomizationId);
VnfResource resource = null;
try {
- resource = (VnfResource) query.uniqueResult ();
- } catch (org.hibernate.NonUniqueResultException nure) {
+ resource = (VnfResource) query.uniqueResult();
+ } catch(org.hibernate.NonUniqueResultException nure) {
LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelCustomizationUuid='" + modelCustomizationId + "'");
LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelCustomizationUuid=" + modelCustomizationId, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelCustomizationId=" + modelCustomizationId);
@@ -840,9 +839,9 @@ public class CatalogDatabase implements Closeable {
throw e;
}
if (resource == null) {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResourceByModelCustomizationId", null);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResourceByModelCustomizationId", null);
} else {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceByModelCustomizationId", null);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceByModelCustomizationId", null);
}
return resource;
}
@@ -855,53 +854,54 @@ public class CatalogDatabase implements Closeable {
*/
public VnfResourceCustomization getVnfResourceCustomizationByModelCustomizationName (String modelCustomizationName, String modelVersionId) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get VNF resource Customization with modelCustomizationName " + modelCustomizationName + " serviceModelUUID " + modelVersionId);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get VNF resource Customization with modelCustomizationName " + modelCustomizationName + " serviceModelUUID " + modelVersionId);
String hql = "SELECT vrc FROM VnfResourceCustomization as vrc WHERE vrc.modelCustomizationUuid IN "
+ "(SELECT src.resourceModelCustomizationUUID FROM ServiceToResourceCustomization src "
+ "WHERE src.serviceModelUUID = :modelVersionId)"
+ "AND vrc.modelInstanceName = :modelCustomizationName";
- Query query = getSession ().createQuery (hql);
- query.setParameter ("modelCustomizationName", modelCustomizationName);
- query.setParameter ("modelVersionId", modelVersionId);
+ Query query = getSession().createQuery(hql);
+ query.setParameter("modelCustomizationName", modelCustomizationName);
+ query.setParameter("modelVersionId", modelVersionId);
@SuppressWarnings("unchecked")
- List <VnfResourceCustomization> resultList = query.list ();
+ List<VnfResourceCustomization> resultList = query.list();
- if (resultList.isEmpty ()) {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VnfResourceCustomization not found", "CatalogDB", "getVnfResourceCustomizationByModelCustomizationName", null);
+ if (resultList.isEmpty()) {
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VnfResourceCustomization not found", "CatalogDB", "getVnfResourceCustomizationByModelCustomizationName", null);
return null;
}
- Collections.sort (resultList, new MavenLikeVersioningComparator ());
- Collections.reverse (resultList);
+ Collections.sort(resultList, new MavenLikeVersioningComparator());
+ Collections.reverse(resultList);
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceCustomizationByModelCustomizationName", null);
- return resultList.get (0);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceCustomizationByModelCustomizationName", null);
+ return resultList.get(0);
}
/**
* Return the newest version of a specific VNF resource (queried by modelInvariantId).
*
- * @param version
+ * @param modelInvariantUuid model invariant ID
+ * @param modelVersion model version
* @return VnfResource object or null if none found
*/
public VnfResource getVnfResourceByModelInvariantId(String modelInvariantUuid, String modelVersion) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get VNF resource with modelInvariantUuid " + modelInvariantUuid);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get VNF resource with modelInvariantUuid " + modelInvariantUuid);
String hql = "FROM VnfResource WHERE modelInvariantUuid = :modelInvariantUuid and version = :serviceVersion";
- Query query = getSession ().createQuery (hql);
- query.setParameter ("modelInvariantUuid", modelInvariantUuid);
- query.setParameter ("serviceVersion", modelVersion);
+ Query query = getSession().createQuery(hql);
+ query.setParameter("modelInvariantUuid", modelInvariantUuid);
+ query.setParameter("serviceVersion", modelVersion);
VnfResource resource = null;
try {
- resource = (VnfResource) query.uniqueResult ();
+ resource = (VnfResource) query.uniqueResult();
} catch (org.hibernate.NonUniqueResultException nure) {
LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelInvariantUuid='" + modelInvariantUuid + "', serviceVersion='" + modelVersion + "'");
LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelInvariantUuid=" + modelInvariantUuid + " and serviceVersion=" + modelVersion, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelInvariantUuid=" + modelInvariantUuid);
@@ -4880,7 +4880,7 @@ public class CatalogDatabase implements Closeable {
}
public < E > E executeQuerySingleRow(String hql, HashMap<String, String> variables, boolean retry) {
- long startTime = System.currentTimeMillis ();
+ long startTime = System.currentTimeMillis();
LOGGER.debug("Catalog database - executeQuery: " + hql + (retry ? ", retry=true" : ", retry=false"));
Query query = getSession().createQuery(hql);
@@ -4895,7 +4895,7 @@ public class CatalogDatabase implements Closeable {
E theObject = null;
try {
- theObject = (E) query.uniqueResult ();
+ theObject = (E) query.uniqueResult();
} catch (org.hibernate.NonUniqueResultException nure) {
LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row");
LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for " + hql, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for " + hql );
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java
index 9b0f120222..219e70ea87 100644
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java
+++ b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java
@@ -1,902 +1,2009 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.Connection;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-import mockit.Mock;
-import mockit.MockUp;
-import org.hibernate.CacheMode;
-import org.hibernate.Criteria;
-import org.hibernate.Filter;
-import org.hibernate.FlushMode;
-import org.hibernate.HibernateException;
-import org.hibernate.IdentifierLoadAccess;
-import org.hibernate.LobHelper;
-import org.hibernate.LockMode;
-import org.hibernate.LockOptions;
-import org.hibernate.NaturalIdLoadAccess;
-import org.hibernate.Query;
-import org.hibernate.ReplicationMode;
-import org.hibernate.SQLQuery;
-import org.hibernate.ScrollMode;
-import org.hibernate.ScrollableResults;
-import org.hibernate.Session;
-import org.hibernate.SessionEventListener;
-import org.hibernate.SessionFactory;
-import org.hibernate.SharedSessionBuilder;
-import org.hibernate.SimpleNaturalIdLoadAccess;
-import org.hibernate.Transaction;
-import org.hibernate.TypeHelper;
-import org.hibernate.UnknownProfileException;
-import org.hibernate.jdbc.ReturningWork;
-import org.hibernate.jdbc.Work;
-import org.hibernate.metamodel.source.annotations.xml.mocker.MockHelper;
-import org.hibernate.procedure.ProcedureCall;
-import org.hibernate.stat.SessionStatistics;
-import org.hibernate.transform.ResultTransformer;
-import org.hibernate.type.Type;
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.AllottedResource;
-import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.HeatEnvironment;
-import org.openecomp.mso.db.catalog.beans.HeatFiles;
-import org.openecomp.mso.db.catalog.beans.HeatTemplate;
-import org.openecomp.mso.db.catalog.beans.HeatTemplateParam;
-import org.openecomp.mso.db.catalog.beans.NetworkResource;
-import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.Service;
-import org.openecomp.mso.db.catalog.beans.ServiceRecipe;
-import org.openecomp.mso.db.catalog.beans.ServiceToResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.TempNetworkHeatTemplateLookup;
-import org.openecomp.mso.db.catalog.beans.ToscaCsar;
-import org.openecomp.mso.db.catalog.beans.VfModule;
-import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
-import org.openecomp.mso.db.catalog.beans.VfModuleToHeatFiles;
-import org.openecomp.mso.db.catalog.beans.VnfComponent;
-import org.openecomp.mso.db.catalog.beans.VnfComponentsRecipe;
-import org.openecomp.mso.db.catalog.beans.VnfRecipe;
-import org.openecomp.mso.db.catalog.beans.VnfResource;
-import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
-import org.openecomp.mso.db.catalog.utils.RecordNotFoundException;
-
-public class CatalogDatabaseTest {
-
- CatalogDatabase cd = null;
-
- @Before
- public void setup(){
- cd = CatalogDatabase.getInstance();
- }
-
-
- @Test
- public void getAllHeatTemplatesTest(){
-
- MockUp<Query> mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<HeatTemplate> list() {
- HeatTemplate heatTemplate = new HeatTemplate();
- return Arrays.asList(heatTemplate);
- }
- };
-
- MockUp<Session> mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- List <HeatTemplate> list = cd.getAllHeatTemplates();
- assertEquals(list.size(), 1);
- }
-
- @Test
- public void getHeatTemplateByIdTest(){
-
- MockUp<Session> mockedSession = new MockUp<Session>() {
- @Mock
- public Object get(Class cls, Serializable id) {
- HeatTemplate heatTemplate = new HeatTemplate();
- heatTemplate.setAsdcUuid("123-uuid");
- return heatTemplate;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- HeatTemplate ht = cd.getHeatTemplate(10);
- assertEquals("123-uuid", ht.getAsdcUuid());
- }
-
- @Test
- public void getHeatTemplateByNameEmptyListTest(){
-
- MockUp<Query> mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<HeatTemplate> list() {
- HeatTemplate heatTemplate = new HeatTemplate();
- return Arrays.asList();
- }
- };
-
- MockUp<Session> mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- HeatTemplate ht = cd.getHeatTemplate("heat123");
- assertEquals(null, ht);
- }
-
- @Test
- public void getHeatTemplateByNameTest(){
-
- MockUp<Query> mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<HeatTemplate> list() {
- HeatTemplate heatTemplate1 = new HeatTemplate();
- heatTemplate1.setAsdcUuid("123-uuid");
- heatTemplate1.setVersion("1.2");
- HeatTemplate heatTemplate2 = new HeatTemplate();
- heatTemplate2.setAsdcUuid("456-uuid");
- heatTemplate2.setVersion("1.3");
- return Arrays.asList(heatTemplate1, heatTemplate2);
- }
- };
-
- MockUp<Session> mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- HeatTemplate ht = cd.getHeatTemplate("heat123");
- assertEquals("456-uuid", ht.getAsdcUuid());
- }
-
- @Test(expected = Exception.class)
- public void getHeatTemplateTest3Exception(){
- HeatTemplate ht = cd.getHeatTemplate("heat123","v2");
- }
-
- @Test(expected = Exception.class)
- public void getHeatTemplateByArtifactUuidException(){
- HeatTemplate ht = cd.getHeatTemplateByArtifactUuid("123");
- }
-
- @Test(expected = Exception.class)
- public void getHeatTemplateByArtifactUuidRegularQueryException(){
- HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123");
- }
-
- @Test(expected = Exception.class)
- public void getParametersForHeatTemplateTestException(){
- List<HeatTemplateParam> ht = cd.getParametersForHeatTemplate("123");
- }
-
- @Test(expected = Exception.class)
- public void getHeatEnvironmentByArtifactUuidTestException(){
- HeatEnvironment ht = cd.getHeatEnvironmentByArtifactUuid("123");
- }
-
- @Test(expected = Exception.class)
- public void getServiceByInvariantUUIDTestException(){
- Service ht = cd.getServiceByInvariantUUID("123");
- }
-
- @Test(expected = Exception.class)
- public void getServiceTestException(){
- Service ht = cd.getService("123");
- }
-
- @Test(expected = Exception.class)
- public void getServiceByModelUUIDTestException(){
- Service ht = cd.getServiceByModelUUID("123");
- }
-
- @Test(expected = Exception.class)
- public void getService2TestException(){
- HashMap<String, String> map = new HashMap<>();
- map.put("serviceNameVersionId", "v2");
- Service ht = cd.getService(map, "123");
- }
-
- @Test(expected = Exception.class)
- public void getServiceByModelNameTestException(){
- Service ht = cd.getServiceByModelName("123");
- }
-
- @Test(expected = Exception.class)
- public void getServiceByVersionAndInvariantIdTestException() throws Exception{
- Service ht = cd.getServiceByVersionAndInvariantId("123","tetwe");
- }
-
- @Test(expected = Exception.class)
- public void getServiceRecipeTestException() throws Exception{
- ServiceRecipe ht = cd.getServiceRecipe("123","tetwe");
- }
-
- @Test(expected = Exception.class)
- public void getServiceRecipeByServiceModelUuidTestException() throws Exception{
- ServiceRecipe ht = cd.getServiceRecipeByServiceModelUuid("123","tetwe");
- }
-
- @Test(expected = Exception.class)
- public void getServiceRecipesTestException() throws Exception{
- List<ServiceRecipe> ht = cd.getServiceRecipes("123");
- }
-
- @Test(expected = Exception.class)
- public void getVnfComponentTestException() throws Exception{
- VnfComponent ht = cd.getVnfComponent(123,"vnf");
- }
-
- @Test(expected = Exception.class)
- public void getVnfResourceTestException() throws Exception{
- VnfResource ht = cd.getVnfResource("vnf");
- }
-
- @Test(expected = Exception.class)
- public void getVnfResource2TestException() throws Exception{
- VnfResource ht = cd.getVnfResource("vnf","3992");
- }
-
- @Test(expected = Exception.class)
- public void getVnfResourceByModelCustomizationIdTestException() throws Exception{
- VnfResource ht = cd.getVnfResourceByModelCustomizationId("3992");
- }
-
- @Test(expected = Exception.class)
- public void getServiceRecipeTest2Exception() throws Exception{
- ServiceRecipe ht = cd.getServiceRecipe(1001,"3992");
- }
-
- @Test(expected = Exception.class)
- public void getVnfResourceCustomizationByModelCustomizationNameTestException(){
- VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelCustomizationName("test", "test234");
- }
-
- @Test(expected = Exception.class)
- public void getVnfResourceByModelInvariantIdTestException(){
- VnfResource vnf = cd.getVnfResourceByModelInvariantId("test", "test234");
- }
-
- @Test(expected = Exception.class)
- public void getVnfResourceByIdTestException(){
- VnfResource vnf = cd.getVnfResourceById(19299);
- }
-
- @Test(expected = Exception.class)
- public void getVfModuleModelNameTestException(){
- VfModule vnf = cd.getVfModuleModelName("tetes");
- }
-
- @Test(expected = Exception.class)
- public void getVfModuleModelName2TestException(){
- VfModule vnf = cd.getVfModuleModelName("tetes","4kidsl");
- }
-
- @Test(expected = Exception.class)
- public void ggetVfModuleCustomizationByModelNameTestException(){
- VfModuleCustomization vnf = cd.getVfModuleCustomizationByModelName("tetes");
- }
-
- @Test(expected = Exception.class)
- public void getNetworkResourceTestException(){
- NetworkResource vnf = cd.getNetworkResource("tetes");
- }
-
- @Test(expected = Exception.class)
- public void getVnfRecipeTestException(){
- VnfRecipe vnf = cd.getVnfRecipe("tetes","ergfedrf","4993493");
- }
-
- @Test(expected = Exception.class)
- public void getVnfRecipe2TestException(){
- VnfRecipe vnf = cd.getVnfRecipe("tetes","4993493");
- }
-
- @Test(expected = Exception.class)
- public void getVnfRecipeByVfModuleIdTestException(){
- VnfRecipe vnf = cd.getVnfRecipeByVfModuleId("tetes","4993493","vnf");
- }
-
- @Test(expected = Exception.class)
- public void getVfModuleTypeTestException(){
- VfModule vnf = cd.getVfModuleType("4993493");
- }
-
- @Test(expected = Exception.class)
- public void getVfModuleType2TestException(){
- VfModule vnf = cd.getVfModuleType("4993493","vnf");
- }
- @Test(expected = Exception.class)
- public void getVnfResourceByServiceUuidTestException(){
- VnfResource vnf = cd.getVnfResourceByServiceUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getVnfResourceByVnfUuidTestException(){
- VnfResource vnf = cd.getVnfResourceByVnfUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getVfModuleByModelInvariantUuidTestException(){
- VfModule vnf = cd.getVfModuleByModelInvariantUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getVfModuleByModelCustomizationUuidTestException(){
- VfModuleCustomization vnf = cd.getVfModuleByModelCustomizationUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getVfModuleByModelInvariantUuidAndModelVersionTestException(){
- VfModule vnf = cd.getVfModuleByModelInvariantUuidAndModelVersion("4993493","vnf");
- }
- @Test(expected = Exception.class)
- public void getVfModuleCustomizationByModelCustomizationIdTestException(){
- VfModuleCustomization vnf = cd.getVfModuleCustomizationByModelCustomizationId("4993493");
- }
- @Test(expected = Exception.class)
- public void getVfModuleByModelUuidTestException(){
- VfModule vnf = cd.getVfModuleByModelUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getVnfResourceCustomizationByModelCustomizationUuidTestException(){
- VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelCustomizationUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getVnfResourceCustomizationByModelVersionIdTestException(){
- VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelVersionId("4993493");
- }
- @Test(expected = Exception.class)
- public void getVfModuleByModelCustomizationIdAndVersionTestException(){
- cd.getVfModuleByModelCustomizationIdAndVersion("4993493","test");
- }
- @Test(expected = Exception.class)
- public void getVfModuleByModelCustomizationIdModelVersionAndModelInvariantIdTestException(){
- cd.getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId("4993493","vnf","test");
- }
- @Test(expected = Exception.class)
- public void getVnfResourceCustomizationByModelInvariantIdTest(){
- cd.getVnfResourceCustomizationByModelInvariantId("4993493","vnf","test");
- }
- @Test(expected = Exception.class)
- public void getVfModuleCustomizationByVnfModuleCustomizationUuidTest(){
- cd.getVfModuleCustomizationByVnfModuleCustomizationUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionIdTest(){
- cd.getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId("4993493","test");
- }
- @Test(expected = Exception.class)
- public void getAllVfModuleCustomizationstest(){
- cd.getAllVfModuleCustomizations("4993493");
- }
- @Test(expected = Exception.class)
- public void getVnfResourceByModelUuidTest(){
- cd.getVnfResourceByModelUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getVnfResCustomToVfModuleTest(){
- cd.getVnfResCustomToVfModule("4993493","test");
- }
- @Test(expected = Exception.class)
- public void getVfModulesForVnfResourceTest(){
- VnfResource vnfResource = new VnfResource();
- vnfResource.setModelUuid("48839");
- cd.getVfModulesForVnfResource(vnfResource);
- }
- @Test(expected = Exception.class)
- public void getVfModulesForVnfResource2Test(){
- cd.getVfModulesForVnfResource("4993493");
- }
- @Test(expected = Exception.class)
- public void getServiceByUuidTest(){
- cd.getServiceByUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getNetworkResourceById2Test(){
- cd.getNetworkResourceById(4993493);
- }
- @Test(expected = Exception.class)
- public void getNetworkResourceByIdTest(){
- cd.getVfModuleTypeByUuid("4993493");
- }
- @Test
- public void isEmptyOrNullTest(){
- boolean is = cd.isEmptyOrNull("4993493");
- assertFalse(is);
- }
- @Test(expected = Exception.class)
- public void getSTRTest(){
- cd.getSTR("4993493","test","vnf");
- }
- @Test(expected = Exception.class)
- public void getVRCtoVFMCTest(){
- cd.getVRCtoVFMC("4993493","388492");
- }
- @Test(expected = Exception.class)
- public void getVfModuleTypeByUuidTestException(){
- cd.getVfModuleTypeByUuid("4993493");
- }
-
- @Test(expected = Exception.class)
- public void getTempNetworkHeatTemplateLookupTest(){
- cd.getTempNetworkHeatTemplateLookup("4993493");
- }
-
- @Test(expected = Exception.class)
- public void getAllNetworksByServiceModelUuidTest(){
- cd.getAllNetworksByServiceModelUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getAllNetworksByServiceModelInvariantUuidTest(){
- cd.getAllNetworksByServiceModelInvariantUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getAllNetworksByServiceModelInvariantUuid2Test(){
- cd.getAllNetworksByServiceModelInvariantUuid("4993493","test");
- }
- @Test(expected = Exception.class)
- public void getAllNetworksByNetworkModelCustomizationUuidTest(){
- cd.getAllNetworksByNetworkModelCustomizationUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getAllNetworksByNetworkTypeTest(){
- cd.getAllNetworksByNetworkType("4993493");
- }
- @Test(expected = Exception.class)
- public void getAllVfmcForVrcTest(){
- VnfResourceCustomization re = new VnfResourceCustomization();
- re.setModelCustomizationUuid("377483");
- cd.getAllVfmcForVrc(re);
- }
- @Test(expected = Exception.class)
- public void getAllVnfsByServiceModelUuidTest(){
- cd.getAllVnfsByServiceModelUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getAllVnfsByServiceModelInvariantUuidTest(){
- cd.getAllVnfsByServiceModelInvariantUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getAllVnfsByServiceModelInvariantUuid2Test(){
- cd.getAllVnfsByServiceModelInvariantUuid("4993493","test");
- }
- @Test(expected = Exception.class)
- public void getAllVnfsByServiceNameTest(){
- cd.getAllVnfsByServiceName("4993493","test");
- }
- @Test(expected = Exception.class)
- public void getAllVnfsByServiceName2Test(){
- cd.getAllVnfsByServiceName("4993493");
- }
- @Test(expected = Exception.class)
- public void getAllVnfsByVnfModelCustomizationUuidTest(){
- cd.getAllVnfsByVnfModelCustomizationUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getAllAllottedResourcesByServiceModelUuidTest(){
- cd.getAllAllottedResourcesByServiceModelUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getAllAllottedResourcesByServiceModelInvariantUuidTest(){
- cd.getAllAllottedResourcesByServiceModelInvariantUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getAllAllottedResourcesByServiceModelInvariantUuid2Test(){
- cd.getAllAllottedResourcesByServiceModelInvariantUuid("4993493","test");
- }
- @Test(expected = Exception.class)
- public void getAllAllottedResourcesByArModelCustomizationUuidTest(){
- cd.getAllAllottedResourcesByArModelCustomizationUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getAllottedResourceByModelUuidTest(){
- cd.getAllottedResourceByModelUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getAllResourcesByServiceModelUuidTest(){
- cd.getAllResourcesByServiceModelUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getAllResourcesByServiceModelInvariantUuidTest(){
- cd.getAllResourcesByServiceModelInvariantUuid("4993493");
- }
-
- @Test(expected = Exception.class)
- public void getAllResourcesByServiceModelInvariantUuid2Test(){
- cd.getAllResourcesByServiceModelInvariantUuid("4993493","test");
- }
- @Test(expected = Exception.class)
- public void getSingleNetworkByModelCustomizationUuidTest(){
- cd.getSingleNetworkByModelCustomizationUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getSingleAllottedResourceByModelCustomizationUuidTest(){
- cd.getSingleAllottedResourceByModelCustomizationUuid("4993493");
- }
- @Test(expected = Exception.class)
- public void getVfModuleRecipeTest(){
- cd.getVfModuleRecipe("4993493","test","get");
- }
- @Test(expected = Exception.class)
- public void getVfModuleTest(){
- cd.getVfModule("4993493","test","get","v2","vnf");
- }
- @Test(expected = Exception.class)
- public void getVnfComponentsRecipeTest(){
- cd.getVnfComponentsRecipe("4993493","test","v2","vnf","get","3992");
- }
- @Test(expected = Exception.class)
- public void getVnfComponentsRecipeByVfModuleTest(){
- List <VfModule> resultList = new ArrayList<>();
- VfModule m = new VfModule();
- resultList.add(m);
- cd.getVnfComponentsRecipeByVfModule(resultList,"4993493");
- }
- @Test(expected = Exception.class)
- public void getAllVnfResourcesTest(){
- cd.getAllVnfResources();
- }
- @Test(expected = Exception.class)
- public void getVnfResourcesByRoleTest(){
- cd.getVnfResourcesByRole("4993493");
- }
- @Test(expected = Exception.class)
- public void getVnfResourceCustomizationsByRoleTest(){
- cd.getVnfResourceCustomizationsByRole("4993493");
- }
- @Test(expected = Exception.class)
- public void getAllNetworkResourcesTest(){
- cd.getAllNetworkResources();
- }
- @Test(expected = Exception.class)
- public void getAllNetworkResourceCustomizationsTest(){
- cd.getAllNetworkResourceCustomizations();
- }
- @Test(expected = Exception.class)
- public void getAllVfModulesTest(){
- cd.getAllVfModules();
- }
- @Test(expected = Exception.class)
- public void getAllVfModuleCustomizationsTest(){
- cd.getAllVfModuleCustomizations();
- }
- @Test(expected = Exception.class)
- public void getAllHeatEnvironmentTest(){
- cd.getAllHeatEnvironment();
- }
- @Test(expected = Exception.class)
- public void getHeatEnvironment2Test(){
- cd.getHeatEnvironment(4993493);
- }
- @Test(expected = Exception.class)
- public void getNestedTemplatesTest(){
- cd.getNestedTemplates(4993493);
- }
- @Test(expected = Exception.class)
- public void getNestedTemplates2Test(){
- cd.getNestedTemplates("4993493");
- }
- @Test(expected = Exception.class)
- public void getHeatFilesTest(){
- cd.getHeatFiles(4993493);
- }
- @Test(expected = Exception.class)
- public void getVfModuleToHeatFilesEntryTest(){
- cd.getVfModuleToHeatFilesEntry("4993493","49959499");
- }
- @Test(expected = Exception.class)
- public void getServiceToResourceCustomization(){
- cd.getServiceToResourceCustomization("4993493","599349","49900");
- }
- @Test(expected = Exception.class)
- public void getHeatFilesForVfModuleTest(){
- cd.getHeatFilesForVfModule("4993493");
- }
- @Test(expected = Exception.class)
- public void getHeatTemplateTest(){
- cd.getHeatTemplate("4993493","test","heat");
- }
-
- @Test(expected = Exception.class)
- public void saveHeatTemplateTest(){
- HeatTemplate heat = new HeatTemplate();
- Set <HeatTemplateParam> paramSet = new HashSet<HeatTemplateParam>();
- cd.saveHeatTemplate(heat,paramSet);
- }
- @Test(expected = Exception.class)
- public void getHeatEnvironmentTest(){
- cd.getHeatEnvironment("4993493","test","heat");
- }
- @Test(expected = Exception.class)
- public void getHeatEnvironment3Test(){
- cd.getHeatEnvironment("4993493","test");
- }
- @Test(expected = Exception.class)
- public void saveHeatEnvironmentTest(){
- HeatEnvironment en = new HeatEnvironment();
- cd.saveHeatEnvironment(en);
- }
- @Test(expected = Exception.class)
- public void saveHeatTemplate2Test(){
- HeatTemplate heat = new HeatTemplate();
- cd.saveHeatTemplate(heat);
- }
- @Test(expected = Exception.class)
- public void saveHeatFileTest(){
- HeatFiles hf = new HeatFiles();
- cd.saveHeatFile(hf);
- }
- @Test(expected = Exception.class)
- public void saveVnfRecipeTest(){
- VnfRecipe vr = new VnfRecipe();
- cd.saveVnfRecipe(vr);
- }
- @Test(expected = Exception.class)
- public void saveVnfComponentsRecipe(){
- VnfComponentsRecipe vr = new VnfComponentsRecipe();
- cd.saveVnfComponentsRecipe(vr);
- }
- @Test(expected = Exception.class)
- public void saveOrUpdateVnfResourceTest(){
- VnfResource vr = new VnfResource();
- cd.saveOrUpdateVnfResource(vr);
- }
- @Test(expected = Exception.class)
- public void saveVnfResourceCustomizationTest(){
- VnfResourceCustomization vr = new VnfResourceCustomization();
- cd.saveVnfResourceCustomization(vr);
- }
- @Test(expected = Exception.class)
- public void saveAllottedResourceCustomizationTest(){
- AllottedResourceCustomization arc = new AllottedResourceCustomization();
- cd.saveAllottedResourceCustomization(arc);
- }
- @Test(expected = Exception.class)
- public void saveAllottedResourceTest(){
- AllottedResource ar = new AllottedResource();
- cd.saveAllottedResource(ar);
- }
- @Test(expected = Exception.class)
- public void saveNetworkResourceTest() throws RecordNotFoundException {
- NetworkResource nr = new NetworkResource();
- cd.saveNetworkResource(nr);
- }
- @Test(expected = Exception.class)
- public void saveToscaCsarTest()throws RecordNotFoundException {
- ToscaCsar ts = new ToscaCsar();
- cd.saveToscaCsar(ts);
- }
- @Test(expected = Exception.class)
- public void getToscaCsar(){
- cd.getToscaCsar("4993493");
- }
- @Test(expected = Exception.class)
- public void saveTempNetworkHeatTemplateLookupTest(){
- TempNetworkHeatTemplateLookup t = new TempNetworkHeatTemplateLookup();
- cd.saveTempNetworkHeatTemplateLookup(t);
- }
- @Test(expected = Exception.class)
- public void saveVfModuleToHeatFiles(){
- VfModuleToHeatFiles v = new VfModuleToHeatFiles();
- cd.saveVfModuleToHeatFiles(v);
- }
- @Test(expected = Exception.class)
- public void saveVnfResourceToVfModuleCustomizationTest() throws RecordNotFoundException {
- VnfResourceCustomization v =new VnfResourceCustomization();
- VfModuleCustomization vm = new VfModuleCustomization();
- cd.saveVnfResourceToVfModuleCustomization(v, vm);
- }
- @Test(expected = Exception.class)
- public void saveNetworkResourceCustomizationTest() throws RecordNotFoundException {
- NetworkResourceCustomization nrc = new NetworkResourceCustomization();
- cd.saveNetworkResourceCustomization(nrc);
- }
-
- @Test(expected = Exception.class)
- public void saveServiceToNetworksTest(){
- AllottedResource ar = new AllottedResource();
- cd.saveAllottedResource(ar);
- }
- @Test(expected = Exception.class)
- public void saveServiceToResourceCustomizationTest(){
- ServiceToResourceCustomization ar = new ServiceToResourceCustomization();
- cd.saveServiceToResourceCustomization(ar);
- }
- @Test(expected = Exception.class)
- public void saveServiceTest(){
- Service ar = new Service();
- cd.saveService(ar);
- }
- @Test(expected = Exception.class)
- public void saveOrUpdateVfModuleTest(){
- VfModule ar = new VfModule();
- cd.saveOrUpdateVfModule(ar);
- }
- @Test(expected = Exception.class)
- public void saveOrUpdateVfModuleCustomizationTest(){
- VfModuleCustomization ar = new VfModuleCustomization();
- cd.saveOrUpdateVfModuleCustomization(ar);
- }
-
- @Test(expected = Exception.class)
- public void getNestedHeatTemplateTest(){
- cd.getNestedHeatTemplate(101,201);
- }
- @Test(expected = Exception.class)
- public void getNestedHeatTemplate2Test(){
- cd.getNestedHeatTemplate("1002","1002");
- }
- @Test(expected = Exception.class)
- public void saveNestedHeatTemplateTest(){
- HeatTemplate ar = new HeatTemplate();
- cd.saveNestedHeatTemplate("1001",ar,"test");
- }
- @Test(expected = Exception.class)
- public void getHeatFiles2Test(){
- VfModuleCustomization ar = new VfModuleCustomization();
- cd.getHeatFiles(101,"test","1001","v2");
- }
- @Test(expected = Exception.class)
- public void getHeatFiles3Test(){
- VfModuleCustomization ar = new VfModuleCustomization();
- cd.getHeatFiles("200192");
- }
- @Test(expected = Exception.class)
- public void saveHeatFilesTest(){
- HeatFiles ar = new HeatFiles();
- cd.saveHeatFiles(ar);
- }
- @Test(expected = Exception.class)
- public void saveVfModuleToHeatFilesTest(){
- HeatFiles ar = new HeatFiles();
- cd.saveVfModuleToHeatFiles("3772893",ar);
- }
- @Test
- public void getNetworkResourceByModelUuidTest(){
-
- cd.getNetworkResourceByModelUuid("3899291");
- }
- @Test(expected = Exception.class)
- public void getNetworkRecipeTest(){
-
- cd.getNetworkRecipe("test","test1","test2");
- }
- @Test(expected = Exception.class)
- public void getNetworkRecipe2Test(){
-
- cd.getNetworkRecipe("test","test1");
- }
- @Test
- public void getNetworkResourceByModelCustUuidTest(){
-
- cd.getNetworkResourceByModelCustUuid("test");
- }
- @Test(expected = Exception.class)
- public void getVnfComponentsRecipe2Test(){
-
- cd.getVnfComponentsRecipe("test1","test2","test3","test4");
- }
- @Test(expected = Exception.class)
- public void getVnfComponentsRecipeByVfModuleModelUUIdTest(){
-
- cd.getVnfComponentsRecipeByVfModuleModelUUId("test1","test2","test3");
- }
- @Test(expected = Exception.class)
- public void getVnfComponentRecipesTest(){
-
- cd.getVnfComponentRecipes("test");
- }
- @Test(expected = Exception.class)
- public void saveOrUpdateVnfComponentTest(){
- VnfComponent ar = new VnfComponent();
- cd.saveOrUpdateVnfComponent(ar);
- }
-
- @Test(expected = Exception.class)
- public void getVfModule2Test(){
-
- cd.getVfModule("test");
- }
- @Test(expected = Exception.class)
- public void getVfModuleByModelUUIDTest(){
-
- cd.getVfModuleByModelUUID("test");
- }
- @Test(expected = Exception.class)
- public void getServiceRecipeByModelUUIDTest(){
-
- cd.getServiceRecipeByModelUUID("test1","test2");
- }
- @Test(expected = Exception.class)
- public void getModelRecipeTest(){
-
- cd.getModelRecipe("test1","test2","test3");
- }
- @Test(expected = Exception.class)
- public void healthCheck(){
-
- cd.healthCheck();
- }
- @Test(expected = Exception.class)
- public void executeQuerySingleRow(){
- VnfComponent ar = new VnfComponent();
- HashMap<String, String> variables = new HashMap<String, String>();
- cd.executeQuerySingleRow("tets",variables,false);
- }
- @Test(expected = Exception.class)
- public void executeQueryMultipleRows(){
- HashMap<String, String> variables = new HashMap<String, String>();
- cd.executeQueryMultipleRows("select",variables,false);
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.db.catalog.test;
+
+import mockit.Mock;
+import mockit.MockUp;
+import org.hibernate.HibernateException;
+import org.hibernate.NonUniqueResultException;
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.mso.db.catalog.CatalogDatabase;
+import org.openecomp.mso.db.catalog.beans.AllottedResource;
+import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
+import org.openecomp.mso.db.catalog.beans.HeatEnvironment;
+import org.openecomp.mso.db.catalog.beans.HeatFiles;
+import org.openecomp.mso.db.catalog.beans.HeatTemplate;
+import org.openecomp.mso.db.catalog.beans.HeatTemplateParam;
+import org.openecomp.mso.db.catalog.beans.NetworkResource;
+import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
+import org.openecomp.mso.db.catalog.beans.Service;
+import org.openecomp.mso.db.catalog.beans.ServiceRecipe;
+import org.openecomp.mso.db.catalog.beans.ServiceToResourceCustomization;
+import org.openecomp.mso.db.catalog.beans.TempNetworkHeatTemplateLookup;
+import org.openecomp.mso.db.catalog.beans.ToscaCsar;
+import org.openecomp.mso.db.catalog.beans.VfModule;
+import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
+import org.openecomp.mso.db.catalog.beans.VfModuleToHeatFiles;
+import org.openecomp.mso.db.catalog.beans.VnfComponent;
+import org.openecomp.mso.db.catalog.beans.VnfComponentsRecipe;
+import org.openecomp.mso.db.catalog.beans.VnfRecipe;
+import org.openecomp.mso.db.catalog.beans.VnfResource;
+import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
+import org.openecomp.mso.db.catalog.utils.RecordNotFoundException;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+public class CatalogDatabaseTest {
+
+ CatalogDatabase cd = null;
+
+ @Before
+ public void setup(){
+ cd = CatalogDatabase.getInstance();
+ }
+
+
+ @Test
+ public void getAllHeatTemplatesTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<HeatTemplate> list() {
+ HeatTemplate heatTemplate = new HeatTemplate();
+ return Arrays.asList(heatTemplate);
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ List <HeatTemplate> list = cd.getAllHeatTemplates();
+ assertEquals(list.size(), 1);
+ }
+
+ @Test
+ public void getHeatTemplateByIdTest(){
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Object get(Class cls, Serializable id) {
+ HeatTemplate heatTemplate = new HeatTemplate();
+ heatTemplate.setAsdcUuid("123-uuid");
+ return heatTemplate;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ HeatTemplate ht = cd.getHeatTemplate(10);
+ assertEquals("123-uuid", ht.getAsdcUuid());
+ }
+
+ @Test
+ public void getHeatTemplateByNameEmptyListTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<HeatTemplate> list() {
+ HeatTemplate heatTemplate = new HeatTemplate();
+ return Arrays.asList();
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ HeatTemplate ht = cd.getHeatTemplate("heat123");
+ assertEquals(null, ht);
+ }
+
+ @Test
+ public void getHeatTemplateByNameTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<HeatTemplate> list() {
+ HeatTemplate heatTemplate1 = new HeatTemplate();
+ heatTemplate1.setAsdcUuid("123-uuid");
+ heatTemplate1.setVersion("1.2");
+ HeatTemplate heatTemplate2 = new HeatTemplate();
+ heatTemplate2.setAsdcUuid("456-uuid");
+ heatTemplate2.setVersion("1.3");
+ return Arrays.asList(heatTemplate1, heatTemplate2);
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ HeatTemplate ht = cd.getHeatTemplate("heat123");
+ assertEquals("456-uuid", ht.getAsdcUuid());
+ }
+
+ @Test
+ public void getHeatTemplateByTemplateNameTest() {
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<HeatTemplate> list() {
+ HeatTemplate heatTemplate = new HeatTemplate();
+ heatTemplate.setAsdcUuid("1234-uuid");
+ return Arrays.asList(heatTemplate);
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ HeatTemplate ht = cd.getHeatTemplate("heat123","v2");
+ assertEquals("1234-uuid", ht.getAsdcUuid());
+ }
+
+ @Test
+ public void getHeatTemplateByTemplateNameEmptyResultTest() {
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<HeatTemplate> list() {
+ return Arrays.asList();
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ HeatTemplate ht = cd.getHeatTemplate("heat123","v2");
+ assertEquals(null, ht);
+ }
+
+ @Test
+ public void getHeatTemplateByArtifactUuidException(){
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Object get(Class cls, Serializable id) {
+ HeatTemplate heatTemplate = new HeatTemplate();
+ heatTemplate.setAsdcUuid("123-uuid");
+ return heatTemplate;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ HeatTemplate ht = cd.getHeatTemplateByArtifactUuid("123");
+ assertEquals("123-uuid", ht.getAsdcUuid());
+ }
+
+ @Test
+ public void getHeatTemplateByArtifactUuidTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() {
+ HeatTemplate heatTemplate = new HeatTemplate();
+ heatTemplate.setAsdcUuid("123-uuid");
+ return heatTemplate;
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123-uuid");
+ assertEquals("123-uuid", ht.getAsdcUuid());
+ }
+
+ @Test(expected = HibernateException.class)
+ public void getHeatTemplateByArtifactUuidHibernateErrorTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() {
+ throw new HibernateException("hibernate exception");
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123-uuid");
+ }
+
+ @Test(expected = NonUniqueResultException.class)
+ public void getHeatTemplateByArtifactUuidNonUniqueResultTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() {
+ throw new NonUniqueResultException(2);
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123-uuid");
+ }
+
+ @Test(expected = Exception.class)
+ public void getHeatTemplateByArtifactUuidGenericExceptionTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() throws Exception {
+ throw new Exception();
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123-uuid");
+ }
+
+ @Test
+ public void getParametersForHeatTemplateTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<HeatTemplate> list() {
+ HeatTemplate heatTemplate = new HeatTemplate();
+ heatTemplate.setAsdcUuid("1234-uuid");
+ return Arrays.asList(heatTemplate);
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ List<HeatTemplateParam> htList = cd.getParametersForHeatTemplate("12l3");
+ assertEquals(1, htList.size());
+ }
+
+ @Test(expected = HibernateException.class)
+ public void getParametersForHeatTemplateHibernateExceptionTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<HeatTemplate> list() {
+ throw new HibernateException("hibernate exception");
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ List<HeatTemplateParam> htList = cd.getParametersForHeatTemplate("12l3");
+ }
+
+ @Test(expected = Exception.class)
+ public void getParametersForHeatTemplateExceptionTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<HeatTemplate> list() throws Exception {
+ throw new Exception();
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ List<HeatTemplateParam> htList = cd.getParametersForHeatTemplate("12l3");
+ }
+
+ @Test
+ public void getHeatEnvironmentByArtifactUuidTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() {
+ HeatEnvironment heatEnvironment = new HeatEnvironment();
+ heatEnvironment.setArtifactUuid("123-uuid");
+ return heatEnvironment;
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ HeatEnvironment he = cd.getHeatEnvironmentByArtifactUuid("123");
+ assertEquals("123-uuid", he.getArtifactUuid());
+ }
+
+ @Test(expected = HibernateException.class)
+ public void getHeatEnvironmentByArtifactUuidHibernateExceptionTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() {
+ throw new HibernateException("hibernate exception");
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ HeatEnvironment he = cd.getHeatEnvironmentByArtifactUuid("123");
+ }
+
+ @Test(expected = Exception.class)
+ public void getHeatEnvironmentByArtifactUuidExceptionTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() throws Exception {
+ throw new Exception();
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ HeatEnvironment he = cd.getHeatEnvironmentByArtifactUuid("123");
+ }
+
+ @Test
+ public void getServiceByInvariantUUIDTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public List<Service> list() {
+ Service service = new Service();
+ service.setModelUUID("123-uuid");
+ return Arrays.asList(service);
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ Service service = cd.getServiceByInvariantUUID("123");
+ assertEquals("123-uuid", service.getModelUUID());
+ }
+
+ @Test
+ public void getServiceByInvariantUUIDEmptyResultTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public List<Service> list() {
+ return Arrays.asList();
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ Service service = cd.getServiceByInvariantUUID("123");
+ assertEquals(null, service);
+ }
+
+ @Test
+ public void getServiceTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() throws Exception {
+ Service service = new Service();
+ service.setModelUUID("123-uuid");
+ return service;
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ Service service = cd.getService("123");
+ assertEquals("123-uuid", service.getModelUUID());
+ }
+
+ @Test(expected = NonUniqueResultException.class)
+ public void getServiceNoUniqueResultTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() throws Exception {
+ throw new NonUniqueResultException(-1);
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ Service service = cd.getService("123");
+ }
+
+ @Test(expected = HibernateException.class)
+ public void getServiceHibernateExceptionTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() throws Exception {
+ throw new HibernateException("hibernate exception");
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ Service service = cd.getService("123");
+ }
+
+ @Test(expected = Exception.class)
+ public void getServiceExceptionTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() throws Exception {
+ throw new Exception("generic exception");
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ Service service = cd.getService("123");
+ }
+
+ @Test
+ public void getServiceByModelUUIDTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() throws Exception {
+ Service service = new Service();
+ service.setModelUUID("123-uuid");
+ return service;
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ Service service = cd.getServiceByModelUUID("123");
+ assertEquals("123-uuid", service.getModelUUID());
+ }
+
+ @Test
+ public void getService2Test(){
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() throws Exception {
+ Service service = new Service();
+ service.setModelUUID("123-uuid");
+ return service;
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ HashMap<String, String> map = new HashMap<>();
+ map.put("serviceNameVersionId", "v2");
+ Service service = cd.getService(map, "123");
+
+ assertEquals("123-uuid", service.getModelUUID());
+ }
+
+ @Test
+ public void getServiceByModelNameTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<Service> list() throws Exception {
+ Service service = new Service();
+ service.setModelUUID("123-uuid");
+ return Arrays.asList(service);
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ Service service = cd.getServiceByModelName("123");
+ assertEquals("123-uuid", service.getModelUUID());
+ }
+
+ @Test
+ public void getServiceByModelNameEmptyTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<Service> list() throws Exception {
+ return Arrays.asList();
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ Service service = cd.getServiceByModelName("123");
+ assertEquals(null, service);
+ }
+
+ @Test
+ public void getServiceByVersionAndInvariantIdTest() throws Exception{
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() throws Exception {
+ Service service = new Service();
+ service.setModelUUID("123-uuid");
+ return service;
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ Service service = cd.getServiceByVersionAndInvariantId("123","tetwe");
+ assertEquals("123-uuid", service.getModelUUID());
+ }
+
+ @Test(expected = Exception.class)
+ public void getServiceByVersionAndInvariantIdNonUniqueResultTest() throws Exception{
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() throws Exception {
+ throw new NonUniqueResultException(-1);
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ Service service = cd.getServiceByVersionAndInvariantId("123","tetwe");
+ }
+
+ @Test(expected = Exception.class)
+ public void getServiceRecipeTestException() throws Exception{
+ ServiceRecipe ht = cd.getServiceRecipe("123","tetwe");
+ }
+
+ @Test
+ public void getServiceRecipeByServiceModelUuidTest() {
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<ServiceRecipe> list() throws Exception {
+ ServiceRecipe serviceRecipe = new ServiceRecipe();
+ serviceRecipe.setId(1);
+ return Arrays.asList(serviceRecipe);
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ ServiceRecipe serviceRecipe = cd.getServiceRecipeByServiceModelUuid("123","tetwe");
+ assertEquals(1, serviceRecipe.getId());
+ }
+
+ @Test
+ public void getServiceRecipeByServiceModelUuidEmptyTest() {
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<ServiceRecipe> list() throws Exception {
+ return Arrays.asList();
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ ServiceRecipe serviceRecipe = cd.getServiceRecipeByServiceModelUuid("123","tetwe");
+ assertEquals(null, serviceRecipe);
+ }
+
+ @Test
+ public void getServiceRecipesTestException() throws Exception{
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<ServiceRecipe> list() {
+ ServiceRecipe serviceRecipe = new ServiceRecipe();
+ serviceRecipe.setId(1);
+ return Arrays.asList(serviceRecipe);
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ List<ServiceRecipe> serviceRecipes = cd.getServiceRecipes("123");
+ assertEquals(1, serviceRecipes.size());
+ }
+
+ @Test
+ public void getServiceRecipesEmptyTest() throws Exception{
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<ServiceRecipe> list() {
+ return Arrays.asList();
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ List<ServiceRecipe> serviceRecipes = cd.getServiceRecipes("123");
+ assertEquals(0, serviceRecipes.size());
+ }
+
+ @Test(expected = Exception.class)
+ public void getVnfComponentTestException() throws Exception{
+ VnfComponent ht = cd.getVnfComponent(123,"vnf");
+ }
+
+ @Test
+ public void getVnfResourceTest() throws Exception{
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<VnfResource> list() {
+ VnfResource vnfResource = new VnfResource();
+ vnfResource.setModelUuid("123-uuid");
+ return Arrays.asList(vnfResource);
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ VnfResource vnfResource = cd.getVnfResource("vnf");
+ assertEquals("123-uuid", vnfResource.getModelUuid());
+ }
+
+ @Test
+ public void getVnfResourceEmptyTest() throws Exception{
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<VnfResource> list() {
+ return Arrays.asList();
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ VnfResource vnfResource = cd.getVnfResource("vnf");
+ assertEquals(null, vnfResource);
+ }
+
+ @Test
+ public void getVnfResourceByTypeTest() {
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() {
+ VnfResource vnfResource = new VnfResource();
+ vnfResource.setModelUuid("123-uuid");
+ return vnfResource;
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ VnfResource vnfResource = cd.getVnfResource("vnf","3992");
+ assertEquals("123-uuid", vnfResource.getModelUuid());
+ }
+
+ @Test(expected = NonUniqueResultException.class)
+ public void getVnfResourceNURExceptionTest() {
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() {
+ throw new NonUniqueResultException(-1);
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ VnfResource vnfResource = cd.getVnfResource("vnf","3992");
+ }
+
+ @Test(expected = HibernateException.class)
+ public void getVnfResourceHibernateExceptionTest() {
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() {
+ throw new HibernateException("hibernate exception");
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ VnfResource vnfResource = cd.getVnfResource("vnf","3992");
+ }
+
+ @Test(expected = Exception.class)
+ public void getVnfResourceExceptionTest() {
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() throws Exception {
+ throw new Exception();
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ VnfResource vnfResource = cd.getVnfResource("vnf","3992");
+ }
+
+ @Test
+ public void getVnfResourceByModelCustomizationIdTest() {
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() throws Exception {
+ VnfResource vnfResource = new VnfResource();
+ vnfResource.setModelUuid("123-uuid");
+ return vnfResource;
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ VnfResource vnfResource = cd.getVnfResourceByModelCustomizationId("3992");
+ assertEquals("123-uuid",vnfResource.getModelUuid());
+ }
+
+ @Test(expected = NonUniqueResultException.class)
+ public void getVnfResourceByModelCustomizationIdNURExceptionTest() {
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() throws Exception {
+ throw new NonUniqueResultException(-1);
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ VnfResource vnfResource = cd.getVnfResourceByModelCustomizationId("3992");
+ }
+
+ @Test(expected = HibernateException.class)
+ public void getVnfResourceByModelCustomizationIdHibernateExceptionTest() {
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() throws Exception {
+ throw new HibernateException("hibernate exception");
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ VnfResource vnfResource = cd.getVnfResourceByModelCustomizationId("3992");
+ }
+
+
+ @Test(expected = Exception.class)
+ public void getServiceRecipeTest2Exception() throws Exception{
+ ServiceRecipe ht = cd.getServiceRecipe(1001,"3992");
+ }
+
+ @Test
+ public void getVnfResourceCustomizationByModelCustomizationNameTest(){
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<VnfResourceCustomization> list() throws Exception {
+ VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
+ vnfResourceCustomization.setVnfResourceModelUUID("123-uuid");
+ return Arrays.asList(vnfResourceCustomization);
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelCustomizationName("test", "test234");
+ assertEquals("123-uuid", vnf.getVnfResourceModelUUID());
+ }
+
+ @Test
+ public void getVnfResourceCustomizationByModelCustomizationNameEmptyTest(){
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<VnfResourceCustomization> list() throws Exception {
+ return Arrays.asList();
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelCustomizationName("test", "test234");
+ assertEquals(null, vnf);
+ }
+
+ @Test
+ public void getVnfResourceByModelInvariantIdTest(){
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult(){
+ VnfResource vnfResource = new VnfResource();
+ vnfResource.setModelUuid("123-uuid");
+ return vnfResource;
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ VnfResource vnf = cd.getVnfResourceByModelInvariantId("test", "test234");
+ assertEquals("123-uuid", vnf.getModelUuid());
+ }
+
+ @Test(expected = NonUniqueResultException.class)
+ public void getVnfResourceByModelInvariantIdNURExceptionTest(){
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult(){
+ throw new NonUniqueResultException(-1);
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ VnfResource vnf = cd.getVnfResourceByModelInvariantId("test", "test234");
+ }
+
+ @Test(expected = HibernateException.class)
+ public void getVnfResourceByModelInvariantIdHibernateExceptionTest(){
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult(){
+ throw new HibernateException("hibernate exception");
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ VnfResource vnf = cd.getVnfResourceByModelInvariantId("test", "test234");
+ }
+
+ @Test(expected = Exception.class)
+ public void getVnfResourceByModelInvariantIdExceptionTest(){
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+
+ @Mock
+ public Object uniqueResult() throws Exception {
+ throw new Exception();
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ VnfResource vnf = cd.getVnfResourceByModelInvariantId("test", "test234");
+ }
+
+ @Test(expected = Exception.class)
+ public void getVnfResourceByIdTestException(){
+ VnfResource vnf = cd.getVnfResourceById(19299);
+ }
+
+ @Test(expected = Exception.class)
+ public void getVfModuleModelNameTestException(){
+ VfModule vnf = cd.getVfModuleModelName("tetes");
+ }
+
+ @Test(expected = Exception.class)
+ public void getVfModuleModelName2TestException(){
+ VfModule vnf = cd.getVfModuleModelName("tetes","4kidsl");
+ }
+
+ @Test(expected = Exception.class)
+ public void ggetVfModuleCustomizationByModelNameTestException(){
+ VfModuleCustomization vnf = cd.getVfModuleCustomizationByModelName("tetes");
+ }
+
+ @Test(expected = Exception.class)
+ public void getNetworkResourceTestException(){
+ NetworkResource vnf = cd.getNetworkResource("tetes");
+ }
+
+ @Test(expected = Exception.class)
+ public void getVnfRecipeTestException(){
+ VnfRecipe vnf = cd.getVnfRecipe("tetes","ergfedrf","4993493");
+ }
+
+ @Test(expected = Exception.class)
+ public void getVnfRecipe2TestException(){
+ VnfRecipe vnf = cd.getVnfRecipe("tetes","4993493");
+ }
+
+ @Test(expected = Exception.class)
+ public void getVnfRecipeByVfModuleIdTestException(){
+ VnfRecipe vnf = cd.getVnfRecipeByVfModuleId("tetes","4993493","vnf");
+ }
+
+ @Test(expected = Exception.class)
+ public void getVfModuleTypeTestException(){
+ VfModule vnf = cd.getVfModuleType("4993493");
+ }
+
+ @Test(expected = Exception.class)
+ public void getVfModuleType2TestException(){
+ VfModule vnf = cd.getVfModuleType("4993493","vnf");
+ }
+ @Test(expected = Exception.class)
+ public void getVnfResourceByServiceUuidTestException(){
+ VnfResource vnf = cd.getVnfResourceByServiceUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getVnfResourceByVnfUuidTestException(){
+ VnfResource vnf = cd.getVnfResourceByVnfUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getVfModuleByModelInvariantUuidTestException(){
+ VfModule vnf = cd.getVfModuleByModelInvariantUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getVfModuleByModelCustomizationUuidTestException(){
+ VfModuleCustomization vnf = cd.getVfModuleByModelCustomizationUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getVfModuleByModelInvariantUuidAndModelVersionTestException(){
+ VfModule vnf = cd.getVfModuleByModelInvariantUuidAndModelVersion("4993493","vnf");
+ }
+ @Test(expected = Exception.class)
+ public void getVfModuleCustomizationByModelCustomizationIdTestException(){
+ VfModuleCustomization vnf = cd.getVfModuleCustomizationByModelCustomizationId("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getVfModuleByModelUuidTestException(){
+ VfModule vnf = cd.getVfModuleByModelUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getVnfResourceCustomizationByModelCustomizationUuidTestException(){
+ VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelCustomizationUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getVnfResourceCustomizationByModelVersionIdTestException(){
+ VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelVersionId("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getVfModuleByModelCustomizationIdAndVersionTestException(){
+ cd.getVfModuleByModelCustomizationIdAndVersion("4993493","test");
+ }
+ @Test(expected = Exception.class)
+ public void getVfModuleByModelCustomizationIdModelVersionAndModelInvariantIdTestException(){
+ cd.getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId("4993493","vnf","test");
+ }
+ @Test(expected = Exception.class)
+ public void getVnfResourceCustomizationByModelInvariantIdTest(){
+ cd.getVnfResourceCustomizationByModelInvariantId("4993493","vnf","test");
+ }
+ @Test(expected = Exception.class)
+ public void getVfModuleCustomizationByVnfModuleCustomizationUuidTest(){
+ cd.getVfModuleCustomizationByVnfModuleCustomizationUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionIdTest(){
+ cd.getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId("4993493","test");
+ }
+ @Test(expected = Exception.class)
+ public void getAllVfModuleCustomizationstest(){
+ cd.getAllVfModuleCustomizations("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getVnfResourceByModelUuidTest(){
+ cd.getVnfResourceByModelUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getVnfResCustomToVfModuleTest(){
+ cd.getVnfResCustomToVfModule("4993493","test");
+ }
+ @Test(expected = Exception.class)
+ public void getVfModulesForVnfResourceTest(){
+ VnfResource vnfResource = new VnfResource();
+ vnfResource.setModelUuid("48839");
+ cd.getVfModulesForVnfResource(vnfResource);
+ }
+ @Test(expected = Exception.class)
+ public void getVfModulesForVnfResource2Test(){
+ cd.getVfModulesForVnfResource("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getServiceByUuidTest(){
+ cd.getServiceByUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getNetworkResourceById2Test(){
+ cd.getNetworkResourceById(4993493);
+ }
+ @Test(expected = Exception.class)
+ public void getNetworkResourceByIdTest(){
+ cd.getVfModuleTypeByUuid("4993493");
+ }
+ @Test
+ public void isEmptyOrNullTest(){
+ boolean is = cd.isEmptyOrNull("4993493");
+ assertFalse(is);
+ }
+ @Test(expected = Exception.class)
+ public void getSTRTest(){
+ cd.getSTR("4993493","test","vnf");
+ }
+ @Test(expected = Exception.class)
+ public void getVRCtoVFMCTest(){
+ cd.getVRCtoVFMC("4993493","388492");
+ }
+ @Test(expected = Exception.class)
+ public void getVfModuleTypeByUuidTestException(){
+ cd.getVfModuleTypeByUuid("4993493");
+ }
+
+ @Test(expected = Exception.class)
+ public void getTempNetworkHeatTemplateLookupTest(){
+ cd.getTempNetworkHeatTemplateLookup("4993493");
+ }
+
+ @Test(expected = Exception.class)
+ public void getAllNetworksByServiceModelUuidTest(){
+ cd.getAllNetworksByServiceModelUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getAllNetworksByServiceModelInvariantUuidTest(){
+ cd.getAllNetworksByServiceModelInvariantUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getAllNetworksByServiceModelInvariantUuid2Test(){
+ cd.getAllNetworksByServiceModelInvariantUuid("4993493","test");
+ }
+ @Test(expected = Exception.class)
+ public void getAllNetworksByNetworkModelCustomizationUuidTest(){
+ cd.getAllNetworksByNetworkModelCustomizationUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getAllNetworksByNetworkTypeTest(){
+ cd.getAllNetworksByNetworkType("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getAllVfmcForVrcTest(){
+ VnfResourceCustomization re = new VnfResourceCustomization();
+ re.setModelCustomizationUuid("377483");
+ cd.getAllVfmcForVrc(re);
+ }
+ @Test(expected = Exception.class)
+ public void getAllVnfsByServiceModelUuidTest(){
+ cd.getAllVnfsByServiceModelUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getAllVnfsByServiceModelInvariantUuidTest(){
+ cd.getAllVnfsByServiceModelInvariantUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getAllVnfsByServiceModelInvariantUuid2Test(){
+ cd.getAllVnfsByServiceModelInvariantUuid("4993493","test");
+ }
+ @Test(expected = Exception.class)
+ public void getAllVnfsByServiceNameTest(){
+ cd.getAllVnfsByServiceName("4993493","test");
+ }
+ @Test(expected = Exception.class)
+ public void getAllVnfsByServiceName2Test(){
+ cd.getAllVnfsByServiceName("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getAllVnfsByVnfModelCustomizationUuidTest(){
+ cd.getAllVnfsByVnfModelCustomizationUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getAllAllottedResourcesByServiceModelUuidTest(){
+ cd.getAllAllottedResourcesByServiceModelUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getAllAllottedResourcesByServiceModelInvariantUuidTest(){
+ cd.getAllAllottedResourcesByServiceModelInvariantUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getAllAllottedResourcesByServiceModelInvariantUuid2Test(){
+ cd.getAllAllottedResourcesByServiceModelInvariantUuid("4993493","test");
+ }
+ @Test(expected = Exception.class)
+ public void getAllAllottedResourcesByArModelCustomizationUuidTest(){
+ cd.getAllAllottedResourcesByArModelCustomizationUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getAllottedResourceByModelUuidTest(){
+ cd.getAllottedResourceByModelUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getAllResourcesByServiceModelUuidTest(){
+ cd.getAllResourcesByServiceModelUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getAllResourcesByServiceModelInvariantUuidTest(){
+ cd.getAllResourcesByServiceModelInvariantUuid("4993493");
+ }
+
+ @Test(expected = Exception.class)
+ public void getAllResourcesByServiceModelInvariantUuid2Test(){
+ cd.getAllResourcesByServiceModelInvariantUuid("4993493","test");
+ }
+ @Test(expected = Exception.class)
+ public void getSingleNetworkByModelCustomizationUuidTest(){
+ cd.getSingleNetworkByModelCustomizationUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getSingleAllottedResourceByModelCustomizationUuidTest(){
+ cd.getSingleAllottedResourceByModelCustomizationUuid("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getVfModuleRecipeTest(){
+ cd.getVfModuleRecipe("4993493","test","get");
+ }
+ @Test(expected = Exception.class)
+ public void getVfModuleTest(){
+ cd.getVfModule("4993493","test","get","v2","vnf");
+ }
+ @Test(expected = Exception.class)
+ public void getVnfComponentsRecipeTest(){
+ cd.getVnfComponentsRecipe("4993493","test","v2","vnf","get","3992");
+ }
+ @Test(expected = Exception.class)
+ public void getVnfComponentsRecipeByVfModuleTest(){
+ List <VfModule> resultList = new ArrayList<>();
+ VfModule m = new VfModule();
+ resultList.add(m);
+ cd.getVnfComponentsRecipeByVfModule(resultList,"4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getAllVnfResourcesTest(){
+ cd.getAllVnfResources();
+ }
+ @Test(expected = Exception.class)
+ public void getVnfResourcesByRoleTest(){
+ cd.getVnfResourcesByRole("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getVnfResourceCustomizationsByRoleTest(){
+ cd.getVnfResourceCustomizationsByRole("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getAllNetworkResourcesTest(){
+ cd.getAllNetworkResources();
+ }
+ @Test(expected = Exception.class)
+ public void getAllNetworkResourceCustomizationsTest(){
+ cd.getAllNetworkResourceCustomizations();
+ }
+ @Test(expected = Exception.class)
+ public void getAllVfModulesTest(){
+ cd.getAllVfModules();
+ }
+ @Test(expected = Exception.class)
+ public void getAllVfModuleCustomizationsTest(){
+ cd.getAllVfModuleCustomizations();
+ }
+ @Test(expected = Exception.class)
+ public void getAllHeatEnvironmentTest(){
+ cd.getAllHeatEnvironment();
+ }
+ @Test(expected = Exception.class)
+ public void getHeatEnvironment2Test(){
+ cd.getHeatEnvironment(4993493);
+ }
+ @Test(expected = Exception.class)
+ public void getNestedTemplatesTest(){
+ cd.getNestedTemplates(4993493);
+ }
+ @Test(expected = Exception.class)
+ public void getNestedTemplates2Test(){
+ cd.getNestedTemplates("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getHeatFilesTest(){
+ cd.getHeatFiles(4993493);
+ }
+ @Test(expected = Exception.class)
+ public void getVfModuleToHeatFilesEntryTest(){
+ cd.getVfModuleToHeatFilesEntry("4993493","49959499");
+ }
+ @Test(expected = Exception.class)
+ public void getServiceToResourceCustomization(){
+ cd.getServiceToResourceCustomization("4993493","599349","49900");
+ }
+ @Test(expected = Exception.class)
+ public void getHeatFilesForVfModuleTest(){
+ cd.getHeatFilesForVfModule("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void getHeatTemplateTest(){
+ cd.getHeatTemplate("4993493","test","heat");
+ }
+
+ @Test(expected = Exception.class)
+ public void saveHeatTemplateTest(){
+ HeatTemplate heat = new HeatTemplate();
+ Set <HeatTemplateParam> paramSet = new HashSet<HeatTemplateParam>();
+ cd.saveHeatTemplate(heat,paramSet);
+ }
+ @Test(expected = Exception.class)
+ public void getHeatEnvironmentTest(){
+ cd.getHeatEnvironment("4993493","test","heat");
+ }
+ @Test(expected = Exception.class)
+ public void getHeatEnvironment3Test(){
+ cd.getHeatEnvironment("4993493","test");
+ }
+ @Test(expected = Exception.class)
+ public void saveHeatEnvironmentTest(){
+ HeatEnvironment en = new HeatEnvironment();
+ cd.saveHeatEnvironment(en);
+ }
+ @Test(expected = Exception.class)
+ public void saveHeatTemplate2Test(){
+ HeatTemplate heat = new HeatTemplate();
+ cd.saveHeatTemplate(heat);
+ }
+ @Test(expected = Exception.class)
+ public void saveHeatFileTest(){
+ HeatFiles hf = new HeatFiles();
+ cd.saveHeatFile(hf);
+ }
+ @Test(expected = Exception.class)
+ public void saveVnfRecipeTest(){
+ VnfRecipe vr = new VnfRecipe();
+ cd.saveVnfRecipe(vr);
+ }
+ @Test(expected = Exception.class)
+ public void saveVnfComponentsRecipe(){
+ VnfComponentsRecipe vr = new VnfComponentsRecipe();
+ cd.saveVnfComponentsRecipe(vr);
+ }
+ @Test(expected = Exception.class)
+ public void saveOrUpdateVnfResourceTest(){
+ VnfResource vr = new VnfResource();
+ cd.saveOrUpdateVnfResource(vr);
+ }
+ @Test(expected = Exception.class)
+ public void saveVnfResourceCustomizationTest(){
+ VnfResourceCustomization vr = new VnfResourceCustomization();
+ cd.saveVnfResourceCustomization(vr);
+ }
+ @Test(expected = Exception.class)
+ public void saveAllottedResourceCustomizationTest(){
+ AllottedResourceCustomization arc = new AllottedResourceCustomization();
+ cd.saveAllottedResourceCustomization(arc);
+ }
+ @Test(expected = Exception.class)
+ public void saveAllottedResourceTest(){
+ AllottedResource ar = new AllottedResource();
+ cd.saveAllottedResource(ar);
+ }
+ @Test(expected = Exception.class)
+ public void saveNetworkResourceTest() throws RecordNotFoundException {
+ NetworkResource nr = new NetworkResource();
+ cd.saveNetworkResource(nr);
+ }
+ @Test(expected = Exception.class)
+ public void saveToscaCsarTest()throws RecordNotFoundException {
+ ToscaCsar ts = new ToscaCsar();
+ cd.saveToscaCsar(ts);
+ }
+ @Test(expected = Exception.class)
+ public void getToscaCsar(){
+ cd.getToscaCsar("4993493");
+ }
+ @Test(expected = Exception.class)
+ public void saveTempNetworkHeatTemplateLookupTest(){
+ TempNetworkHeatTemplateLookup t = new TempNetworkHeatTemplateLookup();
+ cd.saveTempNetworkHeatTemplateLookup(t);
+ }
+ @Test(expected = Exception.class)
+ public void saveVfModuleToHeatFiles(){
+ VfModuleToHeatFiles v = new VfModuleToHeatFiles();
+ cd.saveVfModuleToHeatFiles(v);
+ }
+ @Test(expected = Exception.class)
+ public void saveVnfResourceToVfModuleCustomizationTest() throws RecordNotFoundException {
+ VnfResourceCustomization v =new VnfResourceCustomization();
+ VfModuleCustomization vm = new VfModuleCustomization();
+ cd.saveVnfResourceToVfModuleCustomization(v, vm);
+ }
+ @Test(expected = Exception.class)
+ public void saveNetworkResourceCustomizationTest() throws RecordNotFoundException {
+ NetworkResourceCustomization nrc = new NetworkResourceCustomization();
+ cd.saveNetworkResourceCustomization(nrc);
+ }
+
+ @Test(expected = Exception.class)
+ public void saveServiceToNetworksTest(){
+ AllottedResource ar = new AllottedResource();
+ cd.saveAllottedResource(ar);
+ }
+ @Test(expected = Exception.class)
+ public void saveServiceToResourceCustomizationTest(){
+ ServiceToResourceCustomization ar = new ServiceToResourceCustomization();
+ cd.saveServiceToResourceCustomization(ar);
+ }
+ @Test(expected = Exception.class)
+ public void saveServiceTest(){
+ Service ar = new Service();
+ cd.saveService(ar);
+ }
+ @Test(expected = Exception.class)
+ public void saveOrUpdateVfModuleTest(){
+ VfModule ar = new VfModule();
+ cd.saveOrUpdateVfModule(ar);
+ }
+ @Test(expected = Exception.class)
+ public void saveOrUpdateVfModuleCustomizationTest(){
+ VfModuleCustomization ar = new VfModuleCustomization();
+ cd.saveOrUpdateVfModuleCustomization(ar);
+ }
+
+ @Test(expected = Exception.class)
+ public void getNestedHeatTemplateTest(){
+ cd.getNestedHeatTemplate(101,201);
+ }
+ @Test(expected = Exception.class)
+ public void getNestedHeatTemplate2Test(){
+ cd.getNestedHeatTemplate("1002","1002");
+ }
+ @Test(expected = Exception.class)
+ public void saveNestedHeatTemplateTest(){
+ HeatTemplate ar = new HeatTemplate();
+ cd.saveNestedHeatTemplate("1001",ar,"test");
+ }
+ @Test(expected = Exception.class)
+ public void getHeatFiles2Test(){
+ VfModuleCustomization ar = new VfModuleCustomization();
+ cd.getHeatFiles(101,"test","1001","v2");
+ }
+ @Test(expected = Exception.class)
+ public void getHeatFiles3Test(){
+ VfModuleCustomization ar = new VfModuleCustomization();
+ cd.getHeatFiles("200192");
+ }
+ @Test(expected = Exception.class)
+ public void saveHeatFilesTest(){
+ HeatFiles ar = new HeatFiles();
+ cd.saveHeatFiles(ar);
+ }
+ @Test(expected = Exception.class)
+ public void saveVfModuleToHeatFilesTest(){
+ HeatFiles ar = new HeatFiles();
+ cd.saveVfModuleToHeatFiles("3772893",ar);
+ }
+ @Test
+ public void getNetworkResourceByModelUuidTest(){
+
+ cd.getNetworkResourceByModelUuid("3899291");
+ }
+ @Test(expected = Exception.class)
+ public void getNetworkRecipeTest(){
+
+ cd.getNetworkRecipe("test","test1","test2");
+ }
+ @Test(expected = Exception.class)
+ public void getNetworkRecipe2Test(){
+
+ cd.getNetworkRecipe("test","test1");
+ }
+ @Test
+ public void getNetworkResourceByModelCustUuidTest(){
+
+ cd.getNetworkResourceByModelCustUuid("test");
+ }
+ @Test(expected = Exception.class)
+ public void getVnfComponentsRecipe2Test(){
+
+ cd.getVnfComponentsRecipe("test1","test2","test3","test4");
+ }
+ @Test(expected = Exception.class)
+ public void getVnfComponentsRecipeByVfModuleModelUUIdTest(){
+
+ cd.getVnfComponentsRecipeByVfModuleModelUUId("test1","test2","test3");
+ }
+ @Test(expected = Exception.class)
+ public void getVnfComponentRecipesTest(){
+
+ cd.getVnfComponentRecipes("test");
+ }
+ @Test(expected = Exception.class)
+ public void saveOrUpdateVnfComponentTest(){
+ VnfComponent ar = new VnfComponent();
+ cd.saveOrUpdateVnfComponent(ar);
+ }
+
+ @Test(expected = Exception.class)
+ public void getVfModule2Test(){
+
+ cd.getVfModule("test");
+ }
+ @Test(expected = Exception.class)
+ public void getVfModuleByModelUUIDTest(){
+
+ cd.getVfModuleByModelUUID("test");
+ }
+ @Test(expected = Exception.class)
+ public void getServiceRecipeByModelUUIDTest(){
+
+ cd.getServiceRecipeByModelUUID("test1","test2");
+ }
+ @Test(expected = Exception.class)
+ public void getModelRecipeTest(){
+
+ cd.getModelRecipe("test1","test2","test3");
+ }
+ @Test(expected = Exception.class)
+ public void healthCheck(){
+
+ cd.healthCheck();
+ }
+ @Test(expected = Exception.class)
+ public void executeQuerySingleRow(){
+ VnfComponent ar = new VnfComponent();
+ HashMap<String, String> variables = new HashMap<String, String>();
+ cd.executeQuerySingleRow("tets",variables,false);
+ }
+ @Test(expected = Exception.class)
+ public void executeQueryMultipleRows(){
+ HashMap<String, String> variables = new HashMap<String, String>();
+ cd.executeQueryMultipleRows("select",variables,false);
+ }
+}