summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-requests-db/src
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-03-28 15:49:21 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2018-03-28 15:49:36 -0400
commit2153f867baa6966a04493fa1e11fcf9a0c260035 (patch)
tree944df4410ecd1a9b78de1fc4f4f57b24fe7fff33 /mso-api-handlers/mso-requests-db/src
parent28975e0498b6b66b71e3d5a888e78858a34de0ac (diff)
improved request-db test coverage
Change-Id: I790517aaa524189c09fcc59d23dd301758f0145c Issue-ID: SO-544 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-api-handlers/mso-requests-db/src')
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraRequests.java86
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationStatus.java456
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatus.java16
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatus.java16
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/ResourceOperationStatus.java444
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/SiteStatus.java4
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatus.java10
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatus.java8
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookup.java6
-rw-r--r--mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusDbTest.java106
-rw-r--r--mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusDbTest.java155
-rw-r--r--mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusDbTest.java122
-rw-r--r--mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusDbTest.java111
-rw-r--r--mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupDbTest.java69
14 files changed, 892 insertions, 717 deletions
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraRequests.java
index 5089b36573..d2db8fb35b 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraRequests.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraRequests.java
@@ -38,50 +38,50 @@ public class InfraRequests implements java.io.Serializable {
*/
private static final long serialVersionUID = -661307666798018192L;
- private String requestId;
- private String clientRequestId;
- private String action;
- private String requestStatus;
- private String statusMessage;
+ private String requestId = null;
+ private String clientRequestId = null;
+ private String action = null;
+ private String requestStatus = null;
+ private String statusMessage = null;
private Long progress;
- private Timestamp startTime;
- private Timestamp endTime;
- private String source;
- private String vnfId;
- private String vnfName;
- private String vnfType;
- private String serviceType;
- private String aicNodeClli;
- private String tenantId;
- private String provStatus;
- private String vnfParams;
- private String vnfOutputs;
- private String requestBody;
- private String responseBody;
- private String lastModifiedBy;
- private Timestamp modifyTime;
- private String requestType;
- private String volumeGroupId;
- private String volumeGroupName;
- private String vfModuleId;
- private String vfModuleName;
- private String vfModuleModelName;
- private String aaiServiceId;
- private String aicCloudRegion;
- private String callBackUrl;
- private String correlator;
- private String serviceInstanceId;
- private String serviceInstanceName;
- private String requestScope;
- private String requestAction;
- private String networkId;
- private String networkName;
- private String networkType;
- private String requestorId;
- private String configurationId;
- private String configurationName;
- private String operationalEnvId;
- private String operationalEnvName;
+ private Timestamp startTime = null;
+ private Timestamp endTime = null;
+ private String source = null;
+ private String vnfId = null;
+ private String vnfName = null;
+ private String vnfType = null;
+ private String serviceType = null;
+ private String aicNodeClli = null;
+ private String tenantId = null;
+ private String provStatus = null;
+ private String vnfParams = null;
+ private String vnfOutputs = null;
+ private String requestBody = null;
+ private String responseBody = null;
+ private String lastModifiedBy = null;
+ private Timestamp modifyTime = null;
+ private String requestType = null;
+ private String volumeGroupId = null;
+ private String volumeGroupName = null;
+ private String vfModuleId = null;
+ private String vfModuleName = null;
+ private String vfModuleModelName = null;
+ private String aaiServiceId = null;
+ private String aicCloudRegion = null;
+ private String callBackUrl = null;
+ private String correlator = null;
+ private String serviceInstanceId = null;
+ private String serviceInstanceName = null;
+ private String requestScope = null;
+ private String requestAction = null;
+ private String networkId = null;
+ private String networkName = null;
+ private String networkType = null;
+ private String requestorId = null;
+ private String configurationId = null;
+ private String configurationName = null;
+ private String operationalEnvId = null;
+ private String operationalEnvName = null;
public InfraRequests() {
}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationStatus.java
index ddf6b44cc2..f61b2729e8 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationStatus.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationStatus.java
@@ -1,228 +1,228 @@
-/*-
- * ============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.requestsdb;
-
-import java.io.Serializable;
-import java.sql.Timestamp;
-
-/**
- * The service operation status
- * <br>
- * <p>
- * </p>
- *
- * @author
- * @version ONAP Amsterdam Release 2017-08-28
- */
-public class OperationStatus implements Serializable{
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- private String serviceId;
-
- private String operationId;
-
- private String serviceName;
-
- private String operation;
-
- private String userId;
-
- private String result;
-
- private String operationContent;
-
- private String progress = "0";
-
- private String reason;
-
- private Timestamp operateAt;
-
- private Timestamp finishedAt;
-
-
- public String getServiceId() {
- return serviceId;
- }
-
-
- public void setServiceId(String serviceId) {
- this.serviceId = serviceId;
- }
-
-
- public String getOperationId() {
- return operationId;
- }
-
-
- public void setOperationId(String operationId) {
- this.operationId = operationId;
- }
-
-
- public String getOperation() {
- return operation;
- }
-
-
- public void setOperation(String operation) {
- this.operation = operation;
- }
-
-
- public String getUserId() {
- return userId;
- }
-
-
- public void setUserId(String userId) {
- this.userId = userId;
- }
-
-
- public String getResult() {
- return result;
- }
-
-
- public void setResult(String result) {
- this.result = result;
- }
-
-
- public String getOperationContent() {
- return operationContent;
- }
-
-
- public void setOperationContent(String operationContent) {
- this.operationContent = operationContent;
- }
-
-
- public String getProgress() {
- return progress;
- }
-
-
- public void setProgress(String progress) {
- this.progress = progress;
- }
-
-
- public String getReason() {
- return reason;
- }
-
-
- public void setReason(String reason) {
- this.reason = reason;
- }
-
-
- public Timestamp getOperateAt() {
- return operateAt;
- }
-
-
- public void setOperateAt(Timestamp operateAt) {
- this.operateAt = operateAt;
- }
-
-
- public Timestamp getFinishedAt() {
- return finishedAt;
- }
-
-
- public void setFinishedAt(Timestamp finishedAt) {
- this.finishedAt = finishedAt;
- }
-
-
-
- /**
- * @return Returns the serviceName.
- */
- public String getServiceName() {
- return serviceName;
- }
-
-
-
- /**
- * @param serviceName The serviceName to set.
- */
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
- }
-
-
- /**
- * <br>
- *
- * @return
- * @since ONAP Amsterdam Release
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((operationId == null) ? 0 : operationId.hashCode());
- result = prime * result + ((serviceId == null) ? 0 : serviceId.hashCode());
- return result;
- }
-
-
- /**
- * <br>
- *
- * @param obj
- * @return
- * @since ONAP Amsterdam Release
- */
- @Override
- public boolean equals(Object obj) {
- if(this == obj)
- return true;
- if(obj == null)
- return false;
- if(getClass() != obj.getClass())
- return false;
- OperationStatus other = (OperationStatus)obj;
- if(operationId == null) {
- if(other.operationId != null)
- return false;
- } else if(!operationId.equals(other.operationId))
- return false;
- if(serviceId == null) {
- if(other.serviceId != null)
- return false;
- } else if(!serviceId.equals(other.serviceId))
- return false;
- return true;
- }
-
-
-}
+/*-
+ * ============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.requestsdb;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * The service operation status
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version ONAP Amsterdam Release 2017-08-28
+ */
+public class OperationStatus implements Serializable{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private String serviceId = null;
+
+ private String operationId = null;
+
+ private String serviceName = null;
+
+ private String operation = null;
+
+ private String userId = null;
+
+ private String result = null;
+
+ private String operationContent = null;
+
+ private String progress = "0";
+
+ private String reason = null;
+
+ private Timestamp operateAt = null;
+
+ private Timestamp finishedAt = null;
+
+
+ public String getServiceId() {
+ return serviceId;
+ }
+
+
+ public void setServiceId(String serviceId) {
+ this.serviceId = serviceId;
+ }
+
+
+ public String getOperationId() {
+ return operationId;
+ }
+
+
+ public void setOperationId(String operationId) {
+ this.operationId = operationId;
+ }
+
+
+ public String getOperation() {
+ return operation;
+ }
+
+
+ public void setOperation(String operation) {
+ this.operation = operation;
+ }
+
+
+ public String getUserId() {
+ return userId;
+ }
+
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+
+ public String getResult() {
+ return result;
+ }
+
+
+ public void setResult(String result) {
+ this.result = result;
+ }
+
+
+ public String getOperationContent() {
+ return operationContent;
+ }
+
+
+ public void setOperationContent(String operationContent) {
+ this.operationContent = operationContent;
+ }
+
+
+ public String getProgress() {
+ return progress;
+ }
+
+
+ public void setProgress(String progress) {
+ this.progress = progress;
+ }
+
+
+ public String getReason() {
+ return reason;
+ }
+
+
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
+
+ public Timestamp getOperateAt() {
+ return operateAt;
+ }
+
+
+ public void setOperateAt(Timestamp operateAt) {
+ this.operateAt = operateAt;
+ }
+
+
+ public Timestamp getFinishedAt() {
+ return finishedAt;
+ }
+
+
+ public void setFinishedAt(Timestamp finishedAt) {
+ this.finishedAt = finishedAt;
+ }
+
+
+
+ /**
+ * @return Returns the serviceName.
+ */
+ public String getServiceName() {
+ return serviceName;
+ }
+
+
+
+ /**
+ * @param serviceName The serviceName to set.
+ */
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+
+ /**
+ * <br>
+ *
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((operationId == null) ? 0 : operationId.hashCode());
+ result = prime * result + ((serviceId == null) ? 0 : serviceId.hashCode());
+ return result;
+ }
+
+
+ /**
+ * <br>
+ *
+ * @param obj
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if(this == obj)
+ return true;
+ if(obj == null)
+ return false;
+ if(getClass() != obj.getClass())
+ return false;
+ OperationStatus other = (OperationStatus)obj;
+ if(operationId == null) {
+ if(other.operationId != null)
+ return false;
+ } else if(!operationId.equals(other.operationId))
+ return false;
+ if(serviceId == null) {
+ if(other.serviceId != null)
+ return false;
+ } else if(!serviceId.equals(other.serviceId))
+ return false;
+ return true;
+ }
+
+
+}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatus.java
index 2818a85020..c5df122816 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatus.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatus.java
@@ -30,14 +30,14 @@ public class OperationalEnvDistributionStatus implements Serializable {
*/
private static final long serialVersionUID = 7398393659281364650L;
- private String distributionId;
- private String operationalEnvId;
- private String serviceModelVersionId;
- private String requestId;
- private String distributionIdStatus;
- private String distributionIdErrorReason;
- private Timestamp createTime;
- private Timestamp modifyTime;
+ private String distributionId = null;
+ private String operationalEnvId = null;
+ private String serviceModelVersionId = null;
+ private String requestId = null;
+ private String distributionIdStatus = null;
+ private String distributionIdErrorReason = null;
+ private Timestamp createTime = null;
+ private Timestamp modifyTime = null;
public String getDistributionId() {
return distributionId;
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatus.java
index 27b90ae549..fe581de71b 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatus.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatus.java
@@ -37,15 +37,15 @@ public class OperationalEnvServiceModelStatus implements Serializable {
*/
private static final long serialVersionUID = 8197084996598869656L;
- private String requestId;
- private String operationalEnvId;
- private String serviceModelVersionId;
- private String serviceModelVersionDistrStatus;
- private String recoveryAction;
+ private String requestId = null;
+ private String operationalEnvId = null;
+ private String serviceModelVersionId = null;
+ private String serviceModelVersionDistrStatus = null;
+ private String recoveryAction = null;
private int retryCount;
- private String workloadContext;
- private Timestamp createTime;
- private Timestamp modifyTime;
+ private String workloadContext = null;
+ private Timestamp createTime = null;
+ private Timestamp modifyTime = null;
public String getRequestId() {
return requestId;
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/ResourceOperationStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/ResourceOperationStatus.java
index 2e91397d14..07650ac417 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/ResourceOperationStatus.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/ResourceOperationStatus.java
@@ -1,222 +1,222 @@
-/*-
- * ============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.requestsdb;
-
-import java.io.Serializable;
-
-/**
- * The Resource operation status
- * <br>
- * <p>
- * </p>
- *
- * @author
- * @version ONAP Amsterdam Release 2017-08-28
- */
-public class ResourceOperationStatus implements Serializable{
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- private String serviceId;
-
- private String operationId;
-
- private String resourceTemplateUUID;
-
- private String operType;
-
- private String resourceInstanceID;
-
- private String jobId;
-
- private String status;
-
- private String progress = "0";
-
- private String errorCode;
-
- private String statusDescription;
-
- public ResourceOperationStatus(){
-
- }
-
- public ResourceOperationStatus(String serviceId, String operationId, String resourceTemplateUUID)
- {
- this.serviceId = serviceId;
- this.operationId = operationId;
- this.resourceTemplateUUID = resourceTemplateUUID;
- }
-
- public String getServiceId() {
- return serviceId;
- }
-
-
- public void setServiceId(String serviceId) {
- this.serviceId = serviceId;
- }
-
-
- public String getOperationId() {
- return operationId;
- }
-
-
- public void setOperationId(String operationId) {
- this.operationId = operationId;
- }
-
-
- public String getResourceTemplateUUID() {
- return resourceTemplateUUID;
- }
-
-
- public void setResourceTemplateUUID(String resourceTemplateUUId) {
- this.resourceTemplateUUID = resourceTemplateUUId;
- }
-
-
- public String getJobId() {
- return jobId;
- }
-
-
- public void setJobId(String jobId) {
- this.jobId = jobId;
- }
-
-
- public String getStatus() {
- return status;
- }
-
-
- public void setStatus(String status) {
- this.status = status;
- }
-
-
- public String getProgress() {
- return progress;
- }
-
-
- public void setProgress(String progress) {
- this.progress = progress;
- }
-
-
- public String getErrorCode() {
- return errorCode;
- }
-
-
- public void setErrorCode(String errorCode) {
- this.errorCode = errorCode;
- }
-
-
- public String getStatusDescription() {
- return statusDescription;
- }
-
-
- public void setStatusDescription(String statusDescription) {
- this.statusDescription = statusDescription;
- }
-
-
-
- public String getResourceInstanceID() {
- return resourceInstanceID;
- }
-
-
-
- public void setResourceInstanceID(String resourceInstanceID) {
- this.resourceInstanceID = resourceInstanceID;
- }
-
-
- public String getOperType() {
- return operType;
- }
-
-
- public void setOperType(String operType) {
- this.operType = operType;
- }
-
- /**
- * <br>
- *
- * @return
- * @since ONAP Amsterdam Release
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((operationId == null) ? 0 : operationId.hashCode());
- result = prime * result + ((resourceTemplateUUID == null) ? 0 : resourceTemplateUUID.hashCode());
- result = prime * result + ((serviceId == null) ? 0 : serviceId.hashCode());
- return result;
- }
-
- /**
- * <br>
- *
- * @param obj
- * @return
- * @since ONAP Amsterdam Release
- */
- @Override
- public boolean equals(Object obj) {
- if(this == obj)
- return true;
- if(obj == null)
- return false;
- if(getClass() != obj.getClass())
- return false;
- ResourceOperationStatus other = (ResourceOperationStatus)obj;
- if(operationId == null) {
- if(other.operationId != null)
- return false;
- } else if(!operationId.equals(other.operationId))
- return false;
- if(resourceTemplateUUID == null) {
- if(other.resourceTemplateUUID != null)
- return false;
- } else if(!resourceTemplateUUID.equals(other.resourceTemplateUUID))
- return false;
- if(serviceId == null) {
- if(other.serviceId != null)
- return false;
- } else if(!serviceId.equals(other.serviceId))
- return false;
- return true;
- }
-
-}
+/*-
+ * ============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.requestsdb;
+
+import java.io.Serializable;
+
+/**
+ * The Resource operation status
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version ONAP Amsterdam Release 2017-08-28
+ */
+public class ResourceOperationStatus implements Serializable{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private String serviceId = null;
+
+ private String operationId = null;
+
+ private String resourceTemplateUUID = null;
+
+ private String operType = null;
+
+ private String resourceInstanceID = null;
+
+ private String jobId = null;
+
+ private String status = null;
+
+ private String progress = "0";
+
+ private String errorCode = null;
+
+ private String statusDescription = null;
+
+ public ResourceOperationStatus(){
+
+ }
+
+ public ResourceOperationStatus(String serviceId, String operationId, String resourceTemplateUUID)
+ {
+ this.serviceId = serviceId;
+ this.operationId = operationId;
+ this.resourceTemplateUUID = resourceTemplateUUID;
+ }
+
+ public String getServiceId() {
+ return serviceId;
+ }
+
+
+ public void setServiceId(String serviceId) {
+ this.serviceId = serviceId;
+ }
+
+
+ public String getOperationId() {
+ return operationId;
+ }
+
+
+ public void setOperationId(String operationId) {
+ this.operationId = operationId;
+ }
+
+
+ public String getResourceTemplateUUID() {
+ return resourceTemplateUUID;
+ }
+
+
+ public void setResourceTemplateUUID(String resourceTemplateUUId) {
+ this.resourceTemplateUUID = resourceTemplateUUId;
+ }
+
+
+ public String getJobId() {
+ return jobId;
+ }
+
+
+ public void setJobId(String jobId) {
+ this.jobId = jobId;
+ }
+
+
+ public String getStatus() {
+ return status;
+ }
+
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+
+ public String getProgress() {
+ return progress;
+ }
+
+
+ public void setProgress(String progress) {
+ this.progress = progress;
+ }
+
+
+ public String getErrorCode() {
+ return errorCode;
+ }
+
+
+ public void setErrorCode(String errorCode) {
+ this.errorCode = errorCode;
+ }
+
+
+ public String getStatusDescription() {
+ return statusDescription;
+ }
+
+
+ public void setStatusDescription(String statusDescription) {
+ this.statusDescription = statusDescription;
+ }
+
+
+
+ public String getResourceInstanceID() {
+ return resourceInstanceID;
+ }
+
+
+
+ public void setResourceInstanceID(String resourceInstanceID) {
+ this.resourceInstanceID = resourceInstanceID;
+ }
+
+
+ public String getOperType() {
+ return operType;
+ }
+
+
+ public void setOperType(String operType) {
+ this.operType = operType;
+ }
+
+ /**
+ * <br>
+ *
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((operationId == null) ? 0 : operationId.hashCode());
+ result = prime * result + ((resourceTemplateUUID == null) ? 0 : resourceTemplateUUID.hashCode());
+ result = prime * result + ((serviceId == null) ? 0 : serviceId.hashCode());
+ return result;
+ }
+
+ /**
+ * <br>
+ *
+ * @param obj
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if(this == obj)
+ return true;
+ if(obj == null)
+ return false;
+ if(getClass() != obj.getClass())
+ return false;
+ ResourceOperationStatus other = (ResourceOperationStatus)obj;
+ if(operationId == null) {
+ if(other.operationId != null)
+ return false;
+ } else if(!operationId.equals(other.operationId))
+ return false;
+ if(resourceTemplateUUID == null) {
+ if(other.resourceTemplateUUID != null)
+ return false;
+ } else if(!resourceTemplateUUID.equals(other.resourceTemplateUUID))
+ return false;
+ if(serviceId == null) {
+ if(other.serviceId != null)
+ return false;
+ } else if(!serviceId.equals(other.serviceId))
+ return false;
+ return true;
+ }
+
+}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/SiteStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/SiteStatus.java
index 1551ab08c2..3685093740 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/SiteStatus.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/SiteStatus.java
@@ -31,8 +31,8 @@ public class SiteStatus {
private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL);
private boolean status;
- private String siteName;
- private Timestamp created;
+ private String siteName = null;
+ private Timestamp created = null;
public SiteStatus() {
}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatus.java
index c52fe5013c..8f2bda3728 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatus.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatus.java
@@ -31,11 +31,11 @@ public class WatchdogComponentDistributionStatus implements Serializable {
*/
private static final long serialVersionUID = -4344508954204488669L;
- private String distributionId;
- private String componentName;
- private String componentDistributionStatus;
- private Timestamp createTime;
- private Timestamp modifyTime;
+ private String distributionId = null;
+ private String componentName = null;
+ private String componentDistributionStatus = null;
+ private Timestamp createTime = null;
+ private Timestamp modifyTime = null;
public String getDistributionId() {
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatus.java
index 60f123a781..deb2b6824d 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatus.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatus.java
@@ -31,10 +31,10 @@ public class WatchdogDistributionStatus implements Serializable {
private static final long serialVersionUID = -4449711060885719079L;
- private String distributionId;
- private String distributionIdStatus;
- private Timestamp createTime;
- private Timestamp modifyTime;
+ private String distributionId = null;
+ private String distributionIdStatus = null;
+ private Timestamp createTime = null;
+ private Timestamp modifyTime = null;
public String getDistributionId() {
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookup.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookup.java
index a19b2db942..ced4f4f0a5 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookup.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookup.java
@@ -30,9 +30,9 @@ public class WatchdogServiceModVerIdLookup implements Serializable {
*/
private static final long serialVersionUID = 7783869906430250355L;
- private String distributionId;
- private String serviceModelVersionId;
- private Timestamp createTime;
+ private String distributionId = null;
+ private String serviceModelVersionId = null;
+ private Timestamp createTime = null;
public String getDistributionId() {
diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusDbTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusDbTest.java
index 77f5a1d699..89213f9948 100644
--- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusDbTest.java
+++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusDbTest.java
@@ -27,62 +27,86 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.util.Arrays;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.Mock;
import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.mso.db.AbstractSessionFactoryManager;
public class OperationalEnvDistributionStatusDbTest {
+ @Mock
+ private AbstractSessionFactoryManager sessionFactoryRequest;
+ @Mock
+ private SessionFactory sessionFactory;
+ @Mock
+ private Session session;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ when(sessionFactory.openSession()).thenReturn(session);
+ when(sessionFactoryRequest.getSessionFactory()).thenReturn(sessionFactory);
+
+ }
-
- private static final String distributionId = "ff3514e3-5a33-55df-13ab-12abad84e7ff";
- private static final String operationalEnvId = "12abad84e7ff";
- private static final String serviceModelVersionId = "ff305d54-75b4-431b-adb2-eb6b9e5ff001";
- private static final String requestId = "431b-adb2-eb6b9e5ff001";
- private static final String status = "SENT";
- private OperationalEnvDistributionStatus operEnvDistStatus;
-
-
@Test
- public void testGetOperationalEnvDistributionStatus() {
-
- OperationalEnvDistributionStatusDb oeds = Mockito.mock(OperationalEnvDistributionStatusDb.class);
- Mockito.when(oeds.getOperationalEnvDistributionStatus("ff3514e3-5a33-55df-13ab-12abad84e7ff")).thenReturn(operEnvDistStatus);
- OperationalEnvDistributionStatus actual = oeds.getOperationalEnvDistributionStatus(distributionId);
- assertEquals(actual, operEnvDistStatus);
- verify(oeds, times(1)).getOperationalEnvDistributionStatus(any(String.class));
+ public void insertFailure() {
+ OperationalEnvDistributionStatusDb omsDB = new OperationalEnvDistributionStatusDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(mockQuery.uniqueResult()).thenReturn(null);
+ when(session.isOpen()).thenReturn(true);
+ when(session.getTransaction()).thenThrow(Exception.class);
+ thrown.expect(Exception.class);
+
+ omsDB.insertOperationalEnvDistributionStatus("myDistId", "myEnvId", "myModelVerId", "myDistIdStatus", "myReqId");
}
@Test
- public void testGetOperationalEnvDistributionStatusPerReqId() {
-
- OperationalEnvDistributionStatusDb oeds = Mockito.mock(OperationalEnvDistributionStatusDb.class);
- Mockito.when(oeds.getOperationalEnvDistributionStatusPerReqId("ff3514e3-5a33-55df-13ab-12abad84e7ff", "431b-adb2-eb6b9e5ff001")).thenReturn(operEnvDistStatus);
- OperationalEnvDistributionStatus actual = oeds.getOperationalEnvDistributionStatusPerReqId(distributionId, requestId);
- assertEquals(actual, operEnvDistStatus);
- verify(oeds, times(1)).getOperationalEnvDistributionStatusPerReqId(any(String.class), any(String.class));
+ public void updateFailureRetryCount() {
+ OperationalEnvDistributionStatusDb omsDB = new OperationalEnvDistributionStatusDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(session.isOpen()).thenReturn(true);
+ when(session.getTransaction()).thenThrow(Exception.class);
+ thrown.expect(Exception.class);
+
+ omsDB.updateOperationalEnvDistributionStatus("asdcStatus", "myDistId", "myEnvId", "myVerId");
}
-
+
@Test
- public void testUpdateOperationalEnvDistributionStatus() {
-
- int val = 1;
- OperationalEnvDistributionStatusDb oeds = Mockito.mock(OperationalEnvDistributionStatusDb.class);
- Mockito.when(oeds.updateOperationalEnvDistributionStatus("OK", "ff3514e3-5a33", "ff3514e3-5a33", "ff3514e3-5a33-55df-13ab-12abad84e7ff")).thenReturn(val);
- int actual = oeds.updateOperationalEnvDistributionStatus("OK", "ff3514e3-5a33", "ff3514e3-5a33", "ff3514e3-5a33-55df-13ab-12abad84e7ff");
- assertEquals(actual, val);
- verify(oeds, times(1)).updateOperationalEnvDistributionStatus(any(String.class), any(String.class), any(String.class), any(String.class));
+ public void getOperationalEnvIdStatusTest() {
+ OperationalEnvDistributionStatusDb omsDB = new OperationalEnvDistributionStatusDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ OperationalEnvDistributionStatus status = new OperationalEnvDistributionStatus();
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(mockQuery.uniqueResult()).thenReturn(status);
+ when(session.isOpen()).thenReturn(true);
+ assertEquals(status, omsDB.getOperationalEnvDistributionStatusPerReqId("myDistId", "myReqId"));
}
@Test
- public void testInsertOperationalEnvDistributionStatus() {
-
- OperationalEnvDistributionStatusDb oeds = mock(OperationalEnvDistributionStatusDb.class);
-
- oeds.insertOperationalEnvDistributionStatus(distributionId, operationalEnvId, serviceModelVersionId, status, requestId);
- doNothing().when(oeds).insertOperationalEnvDistributionStatus(any(String.class), any(String.class), any(String.class), any(String.class), any(String.class));
- verify(oeds, times(1)).insertOperationalEnvDistributionStatus(any(String.class), any(String.class), any(String.class), any(String.class), any(String.class));
-
+ public void getOperationalEnvServiceModelStatusTest() {
+ OperationalEnvDistributionStatusDb omsDB = new OperationalEnvDistributionStatusDb(this.sessionFactoryRequest);
+ OperationalEnvDistributionStatus status = new OperationalEnvDistributionStatus();
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(mockQuery.uniqueResult()).thenReturn(status);
+ when(session.isOpen()).thenReturn(true);
+ assertEquals(status, omsDB.getOperationalEnvDistributionStatus("myDistId"));
}
-
} \ No newline at end of file
diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusDbTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusDbTest.java
index 77776c2fe1..fb2a5a44d2 100644
--- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusDbTest.java
+++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusDbTest.java
@@ -22,88 +22,99 @@ package org.openecomp.mso.requestsdb;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Arrays;
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
-import org.mockito.Mockito;
+import org.junit.rules.ExpectedException;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.mso.db.AbstractSessionFactoryManager;
public class OperationalEnvServiceModelStatusDbTest {
-
- private static final String operationalEnvId = "12abad84e7ff";
- private static final String serviceModelVersionId = "ff305d54-75b4-431b-adb2-eb6b9e5ff001";
- private static final String requestId = "431b-adb2-eb6b9e5ff001";
- private static final String status = "SENT";
- private static final int retryCount = 1;
- private static final String recoveryAction = "Retry";
- private static final String workloadContext = "VNF_D2D";
-
- private OperationalEnvServiceModelStatus operEnvDistStatus;
+ @Mock
+ private AbstractSessionFactoryManager sessionFactoryRequest;
+ @Mock
+ private SessionFactory sessionFactory;
+ @Mock
+ private Session session;
-
- @Test
- public void testGetOperationalEnvDistributionStatus() {
-
- OperationalEnvServiceModelStatusDb oesms = Mockito.mock(OperationalEnvServiceModelStatusDb.class);
- Mockito.when(oesms.getOperationalEnvServiceModelStatus("12abad84e7ff", "ff305d54-75b4-431b-adb2-eb6b9e5ff001")).thenReturn(operEnvDistStatus);
- OperationalEnvServiceModelStatus actual = oesms.getOperationalEnvServiceModelStatus(operationalEnvId, serviceModelVersionId);
- assertEquals(actual, operEnvDistStatus);
- verify(oesms, times(1)).getOperationalEnvServiceModelStatus(any(String.class), any(String.class));
- }
-
- @Test
- public void testGetOperationalEnvIdStatus() {
-
- List<OperationalEnvServiceModelStatus> operEnvSvcModelStatus = new ArrayList<>();
- OperationalEnvServiceModelStatusDb oesms = Mockito.mock(OperationalEnvServiceModelStatusDb.class);
- Mockito.when(oesms.getOperationalEnvIdStatus("12abad84e7ff", "ff305d54-75b4-431b-adb2-eb6b9e5ff001")).thenReturn(operEnvSvcModelStatus);
- List<OperationalEnvServiceModelStatus> actual = oesms.getOperationalEnvIdStatus(operationalEnvId, requestId);
- assertEquals(actual, operEnvSvcModelStatus);
- verify(oesms, times(1)).getOperationalEnvIdStatus(any(String.class), any(String.class));
-
- }
-
- @Test
- public void testUpdateOperationalEnvRetryCountStatus() {
-
- int val = 1;
- OperationalEnvServiceModelStatusDb oesms = Mockito.mock(OperationalEnvServiceModelStatusDb.class);
- Mockito.when(oesms.updateOperationalEnvRetryCountStatus("12abad84e7ff", "ff305d54-75b4-431b-adb2-eb6b9e5ff001", "SENT", 1)).thenReturn(val);
- int actual = oesms.updateOperationalEnvRetryCountStatus(operationalEnvId, serviceModelVersionId, status, retryCount);
- assertEquals(actual, val);
- verify(oesms, times(1)).updateOperationalEnvRetryCountStatus(any(String.class), any(String.class), any(String.class), any(int.class));
- }
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
- @Test
- public void testUpdateOperationalEnvRetryCountStatusPerReqId() {
-
- int val = 1;
- OperationalEnvServiceModelStatusDb oesms = Mockito.mock(OperationalEnvServiceModelStatusDb.class);
- Mockito.when(oesms.updateOperationalEnvRetryCountStatusPerReqId("12abad84e7ff", "ff305d54-75b4-431b-adb2-eb6b9e5ff001", "SENT", 1, "431b-adb2-eb6b9e5ff001")).thenReturn(val);
- int actual = oesms.updateOperationalEnvRetryCountStatusPerReqId(operationalEnvId, serviceModelVersionId, status, retryCount, requestId);
- assertEquals(actual, val);
- verify(oesms, times(1)).updateOperationalEnvRetryCountStatusPerReqId(any(String.class), any(String.class), any(String.class),
- any(int.class), any(String.class));
- }
-
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ when(sessionFactory.openSession()).thenReturn(session);
+ when(sessionFactoryRequest.getSessionFactory()).thenReturn(sessionFactory);
- @Test
- public void testInsertOperationalEnvServiceModelStatus() {
-
- OperationalEnvServiceModelStatusDb oesms = mock(OperationalEnvServiceModelStatusDb.class);
-
- oesms.insertOperationalEnvServiceModelStatus(requestId, operationalEnvId, serviceModelVersionId, status, recoveryAction, retryCount, workloadContext);
- doNothing().when(oesms).insertOperationalEnvServiceModelStatus(any(String.class), any(String.class), any(String.class),
- any(String.class), any(String.class), any(int.class), any(String.class));
- verify(oesms, times(1)).insertOperationalEnvServiceModelStatus(any(String.class), any(String.class), any(String.class),
- any(String.class), any(String.class), any(int.class), any(String.class));
+ }
+
+ @Test
+ public void insertFailure() {
+ OperationalEnvServiceModelStatusDb omsDB = new OperationalEnvServiceModelStatusDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(mockQuery.uniqueResult()).thenReturn(null);
+ when(session.isOpen()).thenReturn(true);
+ when(session.getTransaction()).thenThrow(Exception.class);
+ thrown.expect(Exception.class);
+
+ omsDB.insertOperationalEnvServiceModelStatus("myRequestId", "myOperationalEnvId", "myServiceModelVersionId", "myVal", "myRecoveryAction", 1, "myWorkloadContext");
+ }
+
+ @Test
+ public void updateFailureRetryCount() {
+ OperationalEnvServiceModelStatusDb omsDB = new OperationalEnvServiceModelStatusDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(session.isOpen()).thenReturn(true);
+ when(session.getTransaction()).thenThrow(Exception.class);
+ thrown.expect(Exception.class);
- }
+ omsDB.updateOperationalEnvRetryCountStatus("myOperationalEnvId", "myServiceModelVersionId", "status", 1);
+ }
+
+ @Test
+ public void updateFailureRetryCountPerReqId() {
+ OperationalEnvServiceModelStatusDb omsDB = new OperationalEnvServiceModelStatusDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(session.isOpen()).thenReturn(true);
+ when(session.getTransaction()).thenThrow(Exception.class);
+ thrown.expect(Exception.class);
+ omsDB.updateOperationalEnvRetryCountStatusPerReqId("myOperationalEnvId", "myServiceModelVersionId", "status", 1, "myReqId");
+ }
+
+
+ @Test
+ public void getOperationalEnvIdStatusTest() {
+ OperationalEnvServiceModelStatusDb omsDB = new OperationalEnvServiceModelStatusDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ OperationalEnvServiceModelStatus status = new OperationalEnvServiceModelStatus();
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(mockQuery.list()).thenReturn(Arrays.asList(status));
+ when(session.isOpen()).thenReturn(true);
+ assertEquals(status, omsDB.getOperationalEnvIdStatus("myEnvId", "myReqId").get(0));
+ }
+
+ @Test
+ public void getOperationalEnvServiceModelStatusTest() {
+ OperationalEnvServiceModelStatusDb omsDB = new OperationalEnvServiceModelStatusDb(this.sessionFactoryRequest);
+ OperationalEnvServiceModelStatus status = new OperationalEnvServiceModelStatus();
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(mockQuery.uniqueResult()).thenReturn(status);
+ when(session.isOpen()).thenReturn(true);
+ assertEquals(status, omsDB.getOperationalEnvServiceModelStatus("myEnvId", "myModelId"));
+ }
}
diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusDbTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusDbTest.java
index cc0a5983b6..a86812e167 100644
--- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusDbTest.java
+++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusDbTest.java
@@ -20,48 +20,108 @@
package org.openecomp.mso.requestsdb;
-import org.junit.Test;
-import org.mockito.Mockito;
-
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Arrays;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.mso.db.AbstractSessionFactoryManager;
public class WatchdogComponentDistributionStatusDbTest {
- private static final String distributionId = "ff3514e3-5a33-55df-13ab-12abad84e7ff";
- private static final String componentName = "MSO";
- private static final String componentDistributionStatus = "SENT";
-
-
+ @Mock
+ private AbstractSessionFactoryManager sessionFactoryRequest;
+ @Mock
+ private SessionFactory sessionFactory;
+ @Mock
+ private Session session;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ when(sessionFactory.openSession()).thenReturn(session);
+ when(sessionFactoryRequest.getSessionFactory()).thenReturn(sessionFactory);
+
+ }
+
@Test
- public void testGetWatchdogComponentDistributionStatus() {
- List<WatchdogComponentDistributionStatus> watchDogCompDistStatus = new ArrayList<>();
- WatchdogComponentDistributionStatusDb wdcds = Mockito.mock(WatchdogComponentDistributionStatusDb.class);
- Mockito.when(wdcds.getWatchdogComponentDistributionStatus("ff3514e3-5a33-55df-13ab-12abad84e7ff")).thenReturn(watchDogCompDistStatus);
- List<WatchdogComponentDistributionStatus> actual = wdcds.getWatchdogComponentDistributionStatus(distributionId);
-
- assertEquals(actual, watchDogCompDistStatus);
- verify(wdcds, times(1)).getWatchdogComponentDistributionStatus(any(String.class));
+ public void insertFailure() {
+ WatchdogComponentDistributionStatusDb wds = new WatchdogComponentDistributionStatusDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(mockQuery.uniqueResult()).thenReturn(null);
+ when(session.isOpen()).thenReturn(true);
+ when(session.getTransaction()).thenThrow(Exception.class);
+ thrown.expect(Exception.class);
+
+ wds.insertWatchdogComponentDistributionStatus("myId", "myComponentName", "myStatus");
}
-
-
+
+
@Test
- public void testInsertWatchdogComponentDistributionStatus() {
-
- WatchdogComponentDistributionStatusDb wdcds = mock(WatchdogComponentDistributionStatusDb.class);
-
- wdcds.insertWatchdogComponentDistributionStatus(distributionId, componentName, componentDistributionStatus);
- doNothing().when(wdcds).insertWatchdogComponentDistributionStatus(any(String.class), any(String.class), any(String.class));
- verify(wdcds, times(1)).insertWatchdogComponentDistributionStatus(any(String.class), any(String.class), any(String.class));
-
+ public void getWatchdogComponentNamesTest() {
+ WatchdogComponentDistributionStatusDb wds = new WatchdogComponentDistributionStatusDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(mockQuery.list()).thenReturn(Arrays.asList("myValue"));
+ when(session.isOpen()).thenReturn(true);
+ assertEquals("myValue", wds.getWatchdogComponentNames("myId").get(0));
+ }
+
+ @Test
+ public void getWatchdogComponentDistributionStatusTest() {
+ WatchdogComponentDistributionStatusDb wds = new WatchdogComponentDistributionStatusDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(mockQuery.list()).thenReturn(Arrays.asList("myValue"));
+ when(session.isOpen()).thenReturn(true);
+ assertEquals("myValue", wds.getWatchdogComponentDistributionStatus("myStatus").get(0));
+ assertEquals("myValue", wds.getWatchdogComponentDistributionStatus("myId", "myName").get(0));
}
+ @Test
+ public void testGetWatchdogDistributionIdNotFound() {
+ WatchdogDistributionStatusDb wds = new WatchdogDistributionStatusDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(mockQuery.uniqueResult()).thenReturn(null);
+ when(session.isOpen()).thenReturn(true);
+ assertEquals(null, wds.getWatchdogDistributionId("test"));
+ }
+
+ @Test
+ public void testGetWatchdogDistributionIdStatus() {
+ WatchdogDistributionStatusDb wds = new WatchdogDistributionStatusDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(mockQuery.uniqueResult()).thenReturn("myValue");
+ when(session.isOpen()).thenReturn(true);
+ assertEquals("myValue", wds.getWatchdogDistributionIdStatus("test"));
+ }
+
+ @Test
+ public void testGetWatchdogDistributionIdStatusNotFound() {
+ WatchdogDistributionStatusDb wds = new WatchdogDistributionStatusDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(mockQuery.uniqueResult()).thenReturn(null);
+ when(session.isOpen()).thenReturn(true);
+ assertEquals(null, wds.getWatchdogDistributionIdStatus("test"));
+ }
+
}
diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusDbTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusDbTest.java
index 3343e0aaf6..3371018605 100644
--- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusDbTest.java
+++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusDbTest.java
@@ -20,48 +20,105 @@
package org.openecomp.mso.requestsdb;
-import org.junit.Test;
-import org.mockito.Mockito;
-
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.mso.db.AbstractSessionFactoryManager;
public class WatchdogDistributionStatusDbTest {
- private static final String distributionId = "ff3514e3-5a33-55df-13ab-12abad84e7ff";
-
+ @Mock
+ private AbstractSessionFactoryManager sessionFactoryRequest;
+ @Mock
+ private SessionFactory sessionFactory;
+ @Mock
+ private Session session;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ when(sessionFactory.openSession()).thenReturn(session);
+ when(sessionFactoryRequest.getSessionFactory()).thenReturn(sessionFactory);
+
+ }
+
@Test
- public void testUpdateWatchdogDistributionIdStatus() {
- WatchdogDistributionStatusDb wdds = Mockito.mock(WatchdogDistributionStatusDb.class);
+ public void insertFailure() {
+ WatchdogDistributionStatusDb wds = new WatchdogDistributionStatusDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(mockQuery.uniqueResult()).thenReturn(null);
+ when(session.isOpen()).thenReturn(true);
+ when(session.getTransaction()).thenThrow(Exception.class);
+ thrown.expect(Exception.class);
- doNothing().when(wdds).updateWatchdogDistributionIdStatus("ff3514e3-5a33-55df-13ab-12abad84e7ff", "SENT");
- wdds.updateWatchdogDistributionIdStatus(any(String.class), any(String.class));
- verify(wdds, times(1)).updateWatchdogDistributionIdStatus(any(String.class), any(String.class));
- }
+ wds.insertWatchdogDistributionId("myId");
+ }
@Test
- public void testInsertWatchdogDistributionId() {
-
- WatchdogDistributionStatusDb wdds = mock(WatchdogDistributionStatusDb.class);
+ public void updateFailure() {
+ WatchdogDistributionStatusDb wds = new WatchdogDistributionStatusDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(session.isOpen()).thenReturn(true);
+ when(session.getTransaction()).thenThrow(Exception.class);
+ thrown.expect(Exception.class);
- wdds.insertWatchdogDistributionId(distributionId);
- doNothing().when(wdds).insertWatchdogDistributionId(any(String.class));
- verify(wdds, times(1)).insertWatchdogDistributionId(any(String.class));
+ wds.updateWatchdogDistributionIdStatus("myId", "myStatus");
+ }
+ @Test
+ public void testGetWatchdogDistributionId() {
+ WatchdogDistributionStatusDb wds = new WatchdogDistributionStatusDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(mockQuery.uniqueResult()).thenReturn("myValue");
+ when(session.isOpen()).thenReturn(true);
+ assertEquals("myValue", wds.getWatchdogDistributionId("test"));
}
-
+
+ @Test
+ public void testGetWatchdogDistributionIdNotFound() {
+ WatchdogDistributionStatusDb wds = new WatchdogDistributionStatusDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(mockQuery.uniqueResult()).thenReturn(null);
+ when(session.isOpen()).thenReturn(true);
+ assertEquals(null, wds.getWatchdogDistributionId("test"));
+ }
+
@Test
public void testGetWatchdogDistributionIdStatus() {
-
- WatchdogDistributionStatusDb wdds = Mockito.mock(WatchdogDistributionStatusDb.class);
- Mockito.when(wdds.getWatchdogDistributionIdStatus("ff305d54-75b4-431b-adb2-eb6b9e5ff001")).thenReturn("ff3514e3-5a33-55df-13ab-12abad84e7ff");
- String actual = wdds.getWatchdogDistributionIdStatus("ff305d54-75b4-431b-adb2-eb6b9e5ff001");
- assertEquals(actual, distributionId);
- verify(wdds, times(1)).getWatchdogDistributionIdStatus(any(String.class));
+ WatchdogDistributionStatusDb wds = new WatchdogDistributionStatusDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(mockQuery.uniqueResult()).thenReturn("myValue");
+ when(session.isOpen()).thenReturn(true);
+ assertEquals("myValue", wds.getWatchdogDistributionIdStatus("test"));
+ }
+
+ @Test
+ public void testGetWatchdogDistributionIdStatusNotFound() {
+ WatchdogDistributionStatusDb wds = new WatchdogDistributionStatusDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(mockQuery.uniqueResult()).thenReturn(null);
+ when(session.isOpen()).thenReturn(true);
+ assertEquals(null, wds.getWatchdogDistributionIdStatus("test"));
}
}
diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupDbTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupDbTest.java
index 9e09aeed00..42224b0238 100644
--- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupDbTest.java
+++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupDbTest.java
@@ -23,41 +23,64 @@
*/
package org.openecomp.mso.requestsdb;
-import org.junit.Test;
-import org.mockito.Mockito;
-
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.mso.db.AbstractSessionFactoryManager;
public class WatchdogServiceModVerIdLookupDbTest {
+ @Mock
+ private AbstractSessionFactoryManager sessionFactoryRequest;
+ @Mock
+ private SessionFactory sessionFactory;
+ @Mock
+ private Session session;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ when(sessionFactory.openSession()).thenReturn(session);
+ when(sessionFactoryRequest.getSessionFactory()).thenReturn(sessionFactory);
- private static final String distributionId = "ff3514e3-5a33-55df-13ab-12abad84e7ff";
- private static final String serviceModelVersionId = "SENT";
+ }
@Test
- public void testInsertWatchdogServiceModVerIdLookup() {
-
- WatchdogServiceModVerIdLookupDb wdsm = mock(WatchdogServiceModVerIdLookupDb.class);
-
- wdsm.insertWatchdogServiceModVerIdLookup(distributionId, serviceModelVersionId);
- doNothing().when(wdsm).insertWatchdogServiceModVerIdLookup(any(String.class), any(String.class));
- verify(wdsm, times(1)).insertWatchdogServiceModVerIdLookup(any(String.class), any(String.class));
-
+ public void getWatchdogServiceModVerIdTest() {
+ WatchdogServiceModVerIdLookupDb wds = new WatchdogServiceModVerIdLookupDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(mockQuery.uniqueResult()).thenReturn(null);
+ when(session.isOpen()).thenReturn(true);
+ assertEquals(null, wds.getWatchdogServiceModVerId("test"));
}
@Test
- public void testGetWatchdogServiceModVerId() {
-
- WatchdogServiceModVerIdLookupDb wdsm = Mockito.mock(WatchdogServiceModVerIdLookupDb.class);
- Mockito.when(wdsm.getWatchdogServiceModVerId("ff305d54-75b4-431b-adb2-eb6b9e5ff001")).thenReturn("ff3514e3-5a33-55df-13ab-12abad84e7ff");
- String actual = wdsm.getWatchdogServiceModVerId("ff305d54-75b4-431b-adb2-eb6b9e5ff001");
- assertEquals(actual, "ff3514e3-5a33-55df-13ab-12abad84e7ff");
- verify(wdsm, times(1)).getWatchdogServiceModVerId(any(String.class));
+ public void insertWatchdogServiceModVerIdLookupTest() {
+ WatchdogServiceModVerIdLookupDb wds = new WatchdogServiceModVerIdLookupDb(this.sessionFactoryRequest);
+ Query mockQuery = mock(Query.class);
+ when(session.createQuery(any(String.class))).thenReturn(mockQuery);
+ when(mockQuery.uniqueResult()).thenReturn(null);
+ when(session.isOpen()).thenReturn(true);
+ when(session.getTransaction()).thenThrow(Exception.class);
+ thrown.expect(Exception.class);
+
+ wds.insertWatchdogServiceModVerIdLookup("myId", "myModelVersion");
}
+
}