aboutsummaryrefslogtreecommitdiffstats
path: root/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@est.tech>2020-10-02 13:21:17 +0100
committerwaqas.ikram <waqas.ikram@est.tech>2020-10-02 14:59:52 +0100
commit1ae0b7fb1fd12587f24b19cabfcfc93e2204204e (patch)
tree9061f59e03d07d9f0c4e4e6730c4394479273bc4 /so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main
parent23312bd92a1bc9a64b26602a2798c05005187d0f (diff)
Increasing code coverage ns-lcm-database-service
Change-Id: Iee314c28e9f65e5bcac542b390df0d8b05ed2e31 Issue-ID: SO-2867 Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main')
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java7
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java10
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java8
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java4
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java18
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/Utils.java3
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java5
7 files changed, 33 insertions, 22 deletions
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java
index 9453caac9e..ce2487ea9d 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java
@@ -238,14 +238,17 @@ public class NfvoJob {
@Override
public boolean equals(final Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
if (obj instanceof NfvoJob) {
final NfvoJob other = (NfvoJob) obj;
return Objects.equals(jobId, other.jobId) && Objects.equals(processInstanceId, other.processInstanceId)
&& Objects.equals(jobType, other.jobType) && Objects.equals(jobAction, other.jobAction)
&& Objects.equals(progress, other.progress) && Objects.equals(status, other.status)
&& Objects.equals(startTime, other.startTime) && Objects.equals(endTime, other.endTime)
- && Objects.equals(status, other.status) && Objects.equals(resourceId, other.resourceId)
- && Objects.equals(resourceName, other.resourceName)
+ && Objects.equals(resourceId, other.resourceId) && Objects.equals(resourceName, other.resourceName)
&& Utils.isEquals(nfvoJobStatuses, other.nfvoJobStatuses);
}
return false;
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java
index 89e07701ed..be673b47fa 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java
@@ -116,17 +116,21 @@ public class NfvoJobStatus {
@Override
public int hashCode() {
- return Objects.hash(id, status, updatedTime, description, nfvoJob.getJobId());
+ return Objects.hash(id, status, updatedTime, description, nfvoJob != null ? nfvoJob.getJobId() : 0);
}
@Override
public boolean equals(final Object obj) {
-
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
if (obj instanceof NfvoJobStatus) {
final NfvoJobStatus other = (NfvoJobStatus) obj;
return Objects.equals(id, other.id) && Objects.equals(status, other.status)
&& Objects.equals(updatedTime, other.updatedTime) && Objects.equals(description, other.description)
- && Objects.equals(nfvoJob.getJobId(), other.nfvoJob.getJobId());
+ && (nfvoJob == null ? other.nfvoJob == null
+ : other.nfvoJob != null && Objects.equals(nfvoJob.getJobId(), other.nfvoJob.getJobId()));
}
return false;
}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java
index e901e10596..e685781308 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java
@@ -184,13 +184,15 @@ public class NfvoNfInst {
final NfvoNfInst that = (NfvoNfInst) object;
return Objects.equals(nfInstId, that.nfInstId) && Objects.equals(name, that.name)
&& Objects.equals(vnfdId, that.vnfdId) && Objects.equals(packageId, that.packageId)
- && Objects.equals(nsInst, that.nsInst) && Objects.equals(status, that.status)
- && Objects.equals(createTime, that.createTime) && Objects.equals(lastUpdateTime, that.lastUpdateTime);
+ && (nsInst == null ? that.nsInst == null : that.nsInst != null && Objects.equals(nsInst, that.nsInst))
+ && Objects.equals(status, that.status) && Objects.equals(createTime, that.createTime)
+ && Objects.equals(lastUpdateTime, that.lastUpdateTime);
}
@Override
public int hashCode() {
- return Objects.hash(nfInstId, name, vnfdId, packageId, nsInst, status, createTime, lastUpdateTime);
+ return Objects.hash(nfInstId, name, vnfdId, packageId, nsInst != null ? nsInst.getNsInstId() : 0, status,
+ createTime, lastUpdateTime);
}
@Override
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java
index dd8448fe56..146e5512fc 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java
@@ -251,6 +251,10 @@ public class NfvoNsInst {
@Override
public boolean equals(final Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
if (obj instanceof NfvoNsInst) {
final NfvoNsInst other = (NfvoNsInst) obj;
return Objects.equals(nsInstId, other.nsInstId) && Objects.equals(name, other.name)
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java
index c47bbdbefb..7668ed272d 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java
@@ -193,24 +193,26 @@ public class NsLcmOpOcc {
}
@Override
- public boolean equals(final Object object) {
- if (this == object)
+ public boolean equals(final Object obj) {
+ if (this == obj)
return true;
- if (object == null || getClass() != object.getClass())
+ if (obj == null || getClass() != obj.getClass())
return false;
- final NsLcmOpOcc that = (NsLcmOpOcc) object;
+ final NsLcmOpOcc that = (NsLcmOpOcc) obj;
return Objects.equals(id, that.id) && Objects.equals(operationState, that.operationState)
&& Objects.equals(stateEnteredTime, that.stateEnteredTime) && Objects.equals(startTime, that.startTime)
- && Objects.equals(nfvoNsInst, that.nfvoNsInst) && Objects.equals(operation, that.operation)
- && Objects.equals(isAutoInnovation, that.isAutoInnovation)
+ && (nfvoNsInst == null ? that.nfvoNsInst == null
+ : that.nfvoNsInst != null && Objects.equals(nfvoNsInst, that.nfvoNsInst))
+ && Objects.equals(operation, that.operation) && Objects.equals(isAutoInnovation, that.isAutoInnovation)
&& Objects.equals(operationParams, that.operationParams)
&& Objects.equals(isCancelPending, that.isCancelPending);
}
@Override
public int hashCode() {
- return Objects.hash(id, operationState, stateEnteredTime, startTime, nfvoNsInst, operation, isAutoInnovation,
- operationParams, isCancelPending);
+ return Objects.hash(id, operationState, stateEnteredTime, startTime,
+ nfvoNsInst != null ? nfvoNsInst.getNsInstId() : 0, operation, isAutoInnovation, operationParams,
+ isCancelPending);
}
@Override
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/Utils.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/Utils.java
index c55ef5728e..b84f95aa50 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/Utils.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/Utils.java
@@ -39,10 +39,11 @@ public class Utils {
if (first == null) {
return second == null;
}
+
if (first.isEmpty()) {
return second.isEmpty();
}
- if (first.size() == second.size()) {
+ if ((first != null && second != null) && (first.size() == second.size())) {
for (int index = 0; index < first.size(); index++) {
if (!Objects.equals(first.get(index), second.get(index))) {
return false;
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java
index 8a2a1bdd89..1487b630c7 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java
@@ -120,11 +120,6 @@ public class DatabaseServiceProvider {
return nfvoNfInstRepository.save(nfvoNfInst) != null;
}
- public Optional<NfvoNfInst> getNfvoNfInstByNfInstId(final String nfInstId) {
- logger.info("Querying database for NfvoNfInst using nfInstId: {}", nfInstId);
- return nfvoNfInstRepository.findByNfInstId(nfInstId);
- }
-
public List<NfvoNfInst> getNfvoNfInstByNsInstId(final String nsInstId) {
logger.info("Querying database for NfvoNfInst using nsInstId: {}", nsInstId);
return nfvoNfInstRepository.findByNsInstNsInstId(nsInstId);