aboutsummaryrefslogtreecommitdiffstats
path: root/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src
diff options
context:
space:
mode:
Diffstat (limited to 'so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src')
-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/JobAction.java29
-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/JobStatusEnum.java29
-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.java274
-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.java147
-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.java213
-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.java289
-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.java233
-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/NsLcmOpType.java28
-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/OperationStateEnum.java29
-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/State.java29
-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.java58
-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/config/NfvoDatabaseConfiguration.java87
-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/repository/NSLcmOpOccRepository.java33
-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/repository/NfvoJobRepository.java35
-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/repository/NfvoJobStatusRepository.java30
-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/repository/NfvoNfInstRepository.java38
-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/repository/NfvoNsInstRepository.java39
-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.java141
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/resources/db/migration/V1_1__create_nfvo_tables.sql74
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/DatabaseServiceProviderTest.java176
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/TestApplication.java45
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/UtilsTest.java65
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/resources/application.yaml31
23 files changed, 2152 insertions, 0 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/JobAction.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/JobAction.java
new file mode 100644
index 0000000000..8a22689f8a
--- /dev/null
+++ 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/JobAction.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.database.beans;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public enum JobAction {
+ CREATE, INSTANTIATE, TERMINATE, DELETE;
+
+}
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/JobStatusEnum.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/JobStatusEnum.java
new file mode 100644
index 0000000000..c67a3cc692
--- /dev/null
+++ 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/JobStatusEnum.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.database.beans;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public enum JobStatusEnum {
+ STARTING, STARTED, IN_PROGRESS, ERROR, FINISHED, FINISHED_WITH_ERROR;
+
+}
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
new file mode 100644
index 0000000000..9453caac9e
--- /dev/null
+++ 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
@@ -0,0 +1,274 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.database.beans;
+
+import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.UUID;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils;
+
+
+@Entity
+@Table(name = "JOB")
+public class NfvoJob {
+
+ @Id
+ @Column(name = "JOB_ID")
+ private String jobId;
+
+ @Column(name = "JOB_TYPE")
+ private String jobType;
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "JOB_ACTION")
+ private JobAction jobAction;
+
+ @Column(name = "RESOURCE_ID")
+ private String resourceId;
+
+ @Column(name = "RESOURCE_NAME")
+ private String resourceName;
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "STATUS")
+ private JobStatusEnum status;
+
+ @Column(name = "START_TIME")
+ private LocalDateTime startTime;
+
+ @Column(name = "END_TIME")
+ private LocalDateTime endTime;
+
+ @Column(name = "PROGRESS")
+ private int progress;
+
+ @Column(name = "PROCESS_INSTANCE_ID")
+ private String processInstanceId;
+
+ @OneToMany(mappedBy = "nfvoJob", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+ private List<NfvoJobStatus> nfvoJobStatuses = new ArrayList<>();
+
+ public NfvoJob() {
+ this.jobId = UUID.randomUUID().toString();
+ }
+
+ public void setJobId(final String jobId) {
+ this.jobId = jobId;
+ }
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ public NfvoJob jobId(final String jobId) {
+ this.jobId = jobId;
+ return this;
+ }
+
+ public String getJobType() {
+ return jobType;
+ }
+
+ public void setJobType(final String jobType) {
+ this.jobType = jobType;
+ }
+
+ public NfvoJob jobType(final String jobType) {
+ this.jobType = jobType;
+ return this;
+ }
+
+ public JobAction getJobAction() {
+ return jobAction;
+ }
+
+ public void setJobAction(final JobAction jobAction) {
+ this.jobAction = jobAction;
+ }
+
+ public NfvoJob jobAction(final JobAction jobAction) {
+ this.jobAction = jobAction;
+ return this;
+ }
+
+ public String getResourceId() {
+ return resourceId;
+ }
+
+ public void setResourceId(final String resourceId) {
+ this.resourceId = resourceId;
+ }
+
+ public NfvoJob resourceId(final String resourceId) {
+ this.resourceId = resourceId;
+ return this;
+ }
+
+ public JobStatusEnum getStatus() {
+ return status;
+ }
+
+ public void setStatus(final JobStatusEnum status) {
+ this.status = status;
+ }
+
+ public NfvoJob status(final JobStatusEnum status) {
+ this.status = status;
+ return this;
+ }
+
+ public LocalDateTime getStartTime() {
+ return startTime;
+ }
+
+ public void setStartTime(final LocalDateTime startTime) {
+ this.startTime = startTime;
+ }
+
+ public NfvoJob startTime(final LocalDateTime startTime) {
+ this.startTime = startTime;
+ return this;
+ }
+
+ public LocalDateTime getEndTime() {
+ return endTime;
+ }
+
+ public void setEndTime(final LocalDateTime endTime) {
+ this.endTime = endTime;
+ }
+
+ public NfvoJob endTime(final LocalDateTime endTime) {
+ this.endTime = endTime;
+ return this;
+ }
+
+ public int getProgress() {
+ return progress;
+ }
+
+ public void setProgress(final int progress) {
+ this.progress = progress;
+ }
+
+ public NfvoJob progress(final int progress) {
+ this.progress = progress;
+ return this;
+ }
+
+ public String getProcessInstanceId() {
+ return processInstanceId;
+ }
+
+ public void setProcessInstanceId(final String processInstanceId) {
+ this.processInstanceId = processInstanceId;
+ }
+
+ public NfvoJob processInstanceId(final String processInstanceId) {
+ this.processInstanceId = processInstanceId;
+ return this;
+ }
+
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public void setResourceName(final String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ public NfvoJob resourceName(final String resourceName) {
+ this.resourceName = resourceName;
+ return this;
+ }
+
+ public List<NfvoJobStatus> getNfvoJobStatuses() {
+ return nfvoJobStatuses;
+ }
+
+ public void setJobStatuses(final List<NfvoJobStatus> nfvoJobStatuses) {
+ this.nfvoJobStatuses = nfvoJobStatuses;
+ }
+
+ public NfvoJob nfvoJobStatuses(final List<NfvoJobStatus> nfvoJobStatuses) {
+ this.nfvoJobStatuses = nfvoJobStatuses;
+ return this;
+ }
+
+ public NfvoJob nfvoJobStatus(final NfvoJobStatus nfvoJobStatus) {
+ nfvoJobStatus.setNfvoJob(this);
+ this.nfvoJobStatuses.add(nfvoJobStatus);
+ return this;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(jobId, processInstanceId, jobType, jobAction, startTime, endTime, status, progress,
+ resourceId, resourceName, nfvoJobStatuses);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ 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)
+ && Utils.isEquals(nfvoJobStatuses, other.nfvoJobStatuses);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("class NfvoJob {\n");
+ sb.append(" jobId: ").append(toIndentedString(jobId)).append("\n");
+ sb.append(" processInstanceId: ").append(toIndentedString(processInstanceId)).append("\n");
+ sb.append(" jobType: ").append(toIndentedString(jobType)).append("\n");
+ sb.append(" jobAction: ").append(toIndentedString(jobAction)).append("\n");
+ sb.append(" progress: ").append(toIndentedString(progress)).append("\n");
+ sb.append(" status: ").append(toIndentedString(status)).append("\n");
+ sb.append(" startTime: ").append(toIndentedString(startTime)).append("\n");
+ sb.append(" endTime: ").append(toIndentedString(endTime)).append("\n");
+ sb.append(" resId: ").append(toIndentedString(resourceId)).append("\n");
+ sb.append(" resName: ").append(toIndentedString(resourceName)).append("\n");
+ sb.append(" nfvoJobStatuses: ").append(toIndentedString(nfvoJobStatuses)).append("\n");
+
+ sb.append("}");
+ return sb.toString();
+ }
+
+}
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
new file mode 100644
index 0000000000..89e07701ed
--- /dev/null
+++ 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
@@ -0,0 +1,147 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.database.beans;
+
+import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString;
+import java.time.LocalDateTime;
+import java.util.Objects;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "JOB_STATUS")
+public class NfvoJobStatus {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "ID")
+ private int id;
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "STATUS")
+ private JobStatusEnum status;
+
+ @Column(name = "DESCRIPTION", columnDefinition = "LONGTEXT")
+ private String description;
+
+ @Column(name = "UPDATED_TIME")
+ private LocalDateTime updatedTime;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "JOB_ID")
+ private NfvoJob nfvoJob;
+
+ public int getId() {
+ return id;
+ }
+
+ public JobStatusEnum getStatus() {
+ return status;
+ }
+
+ public void setStatus(final JobStatusEnum status) {
+ this.status = status;
+ }
+
+ public NfvoJobStatus status(final JobStatusEnum status) {
+ this.status = status;
+ return this;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(final String description) {
+ this.description = description;
+ }
+
+ public NfvoJobStatus description(final String description) {
+ this.description = description;
+ return this;
+ }
+
+ public LocalDateTime getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(final LocalDateTime updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ public NfvoJobStatus updatedTime(final LocalDateTime addTime) {
+ this.updatedTime = addTime;
+ return this;
+ }
+
+ public NfvoJob getNfvoJob() {
+ return nfvoJob;
+ }
+
+ public void setNfvoJob(final NfvoJob nfvoJob) {
+ this.nfvoJob = nfvoJob;
+ }
+
+ public NfvoJobStatus nfvoJob(final NfvoJob nfvoJob) {
+ this.nfvoJob = nfvoJob;
+ return this;
+ }
+
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, status, updatedTime, description, nfvoJob.getJobId());
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+
+ 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());
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("class NfvoJobStatus {\n");
+ sb.append(" Id: ").append(toIndentedString(id)).append("\n");
+ sb.append(" status: ").append(toIndentedString(status)).append("\n");
+ sb.append(" descp: ").append(toIndentedString(description)).append("\n");
+ sb.append(" updatedTime: ").append(toIndentedString(updatedTime)).append("\n");
+ sb.append(" jobId: ").append(nfvoJob != null ? toIndentedString(nfvoJob.getJobId()) : "").append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+}
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
new file mode 100644
index 0000000000..e901e10596
--- /dev/null
+++ 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
@@ -0,0 +1,213 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.database.beans;
+
+import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString;
+import java.time.LocalDateTime;
+import java.util.Objects;
+import java.util.UUID;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * @author mukeshsharma (mukeshsharma@est.tech)
+ */
+@Entity
+@Table(name = "NF_INST")
+public class NfvoNfInst {
+
+ @Id
+ @Column(name = "NF_INST_ID")
+ private String nfInstId;
+
+ @Column(name = "NAME")
+ private String name;
+
+ @Column(name = "VNFD_ID")
+ private String vnfdId;
+
+ @Column(name = "PACKAGE_ID")
+ private String packageId;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "NS_INST_ID")
+ private NfvoNsInst nsInst;
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "STATUS")
+ private State status;
+
+ @Column(name = "CREATE_TIME")
+ private LocalDateTime createTime;
+
+ @Column(name = "LAST_UPDATE_TIME")
+ private LocalDateTime lastUpdateTime;
+
+ public NfvoNfInst() {
+ this.nfInstId = UUID.randomUUID().toString();
+ }
+
+ public String getNfInstId() {
+ return nfInstId;
+ }
+
+ public void setNfInstId(final String nfInstId) {
+ this.nfInstId = nfInstId;
+ }
+
+ public NfvoNfInst nfInstId(final String nfInstId) {
+ this.nfInstId = nfInstId;
+ return this;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public NfvoNfInst name(final String name) {
+ this.name = name;
+ return this;
+ }
+
+ public String getVnfdId() {
+ return vnfdId;
+ }
+
+ public void setVnfdId(final String vnfdId) {
+ this.vnfdId = vnfdId;
+ }
+
+ public NfvoNfInst vnfdId(final String vnfdId) {
+ this.vnfdId = vnfdId;
+ return this;
+ }
+
+ public String getPackageId() {
+ return packageId;
+ }
+
+ public void setPackageId(final String packageId) {
+ this.packageId = packageId;
+ }
+
+ public NfvoNfInst packageId(final String packageId) {
+ this.packageId = packageId;
+ return this;
+ }
+
+ public NfvoNsInst getNsInst() {
+ return nsInst;
+ }
+
+ public void setNsInst(final NfvoNsInst nsInst) {
+ this.nsInst = nsInst;
+ }
+
+ public NfvoNfInst nfvoNsInst(final NfvoNsInst nfvoNsInst) {
+ this.nsInst = nfvoNsInst;
+ return this;
+ }
+
+ public State getStatus() {
+ return status;
+ }
+
+ public void setStatus(final State status) {
+ this.status = status;
+ }
+
+ public NfvoNfInst status(final State status) {
+ this.status = status;
+ return this;
+ }
+
+ public LocalDateTime getCreateTime() {
+ return createTime;
+ }
+
+ public void setCreateTime(final LocalDateTime createTime) {
+ this.createTime = createTime;
+ }
+
+ public NfvoNfInst createTime(final LocalDateTime createTime) {
+ this.createTime = createTime;
+ return this;
+ }
+
+ public LocalDateTime getLastUpdateTime() {
+ return lastUpdateTime;
+ }
+
+ public void setLastUpdateTime(final LocalDateTime lastUpdateTime) {
+ this.lastUpdateTime = lastUpdateTime;
+ }
+
+ public NfvoNfInst lastUpdateTime(final LocalDateTime lastUpdateTime) {
+ this.lastUpdateTime = lastUpdateTime;
+ return this;
+ }
+
+ @Override
+ public boolean equals(final Object object) {
+ if (this == object)
+ return true;
+ if (object == null || getClass() != object.getClass())
+ return false;
+ 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);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(nfInstId, name, vnfdId, packageId, nsInst, status, createTime, lastUpdateTime);
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("class NfvoNfInst {\n");
+ sb.append(" nfInstId: ").append(toIndentedString(nfInstId)).append("\n");
+ sb.append(" name: ").append(toIndentedString(name)).append("\n");
+ sb.append(" vnfdId: ").append(toIndentedString(vnfdId)).append("\n");
+ sb.append(" packageId: ").append(toIndentedString(packageId)).append("\n");
+ sb.append(" nsInst: ").append(nsInst != null ? toIndentedString(nsInst.getNsInstId()) : null).append("\n");
+ sb.append(" status: ").append(toIndentedString(status)).append("\n");
+ sb.append(" createTime: ").append(toIndentedString(createTime)).append("\n");
+ sb.append(" lastUpdateTime: ").append(toIndentedString(lastUpdateTime)).append("\n");
+
+ sb.append("}");
+ return sb.toString();
+ }
+
+}
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
new file mode 100644
index 0000000000..dd8448fe56
--- /dev/null
+++ 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
@@ -0,0 +1,289 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.database.beans;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.UUID;
+import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Entity
+@Table(name = "NS_INST")
+public class NfvoNsInst {
+
+ @Id
+ @Column(name = "NS_INST_ID")
+ private String nsInstId;
+
+ @Column(name = "NAME")
+ private String name;
+
+ @Column(name = "NS_PACKAGE_ID")
+ private String nsPackageId;
+
+ @Column(name = "NSD_ID")
+ private String nsdId;
+
+ @Column(name = "NSD_INVARIANT_ID")
+ private String nsdInvariantId;
+
+ @Column(name = "DESCRIPTION", columnDefinition = "LONGTEXT")
+ private String description;
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "STATUS")
+ private State status;
+
+ @Column(name = "STATUS_UPDATED_TIME")
+ private LocalDateTime statusUpdatedTime;
+
+ @Column(name = "GLOBAL_CUSTOMER_ID")
+ private String globalCustomerId;
+
+ @Column(name = "SERVICE_TYPE")
+ private String serviceType;
+
+ @OneToMany(mappedBy = "nsInst", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
+ private List<NfvoNfInst> nfvoNfInsts = new ArrayList<>();
+
+ @OneToMany(mappedBy = "nfvoNsInst", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
+ private List<NsLcmOpOcc> nsLcmOpOccs = new ArrayList<>();
+
+ public NfvoNsInst() {
+ this.nsInstId = UUID.randomUUID().toString();
+ }
+
+ public String getNsInstId() {
+ return nsInstId;
+ }
+
+ public void setNsInstId(final String nsInstId) {
+ this.nsInstId = nsInstId;
+ }
+
+ public NfvoNsInst nsInstId(final String nsInstId) {
+ this.nsInstId = nsInstId;
+ return this;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public NfvoNsInst name(final String name) {
+ this.name = name;
+ return this;
+ }
+
+ public String getNsPackageId() {
+ return nsPackageId;
+ }
+
+ public void setNsPackageId(final String nsPackageId) {
+ this.nsPackageId = nsPackageId;
+ }
+
+ public NfvoNsInst nsPackageId(final String nsPackageId) {
+ this.nsPackageId = nsPackageId;
+ return this;
+ }
+
+ public String getNsdId() {
+ return nsdId;
+ }
+
+ public void setNsdId(final String nsdId) {
+ this.nsdId = nsdId;
+ }
+
+ public NfvoNsInst nsdId(final String nsdId) {
+ this.nsdId = nsdId;
+ return this;
+ }
+
+ public String getNsdInvariantId() {
+ return nsdInvariantId;
+ }
+
+ public void setNsdInvariantId(final String nsdInvariantId) {
+ this.nsdInvariantId = nsdInvariantId;
+ }
+
+ public NfvoNsInst nsdInvariantId(final String nsdInvariantId) {
+ this.nsdInvariantId = nsdInvariantId;
+ return this;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(final String description) {
+ this.description = description;
+ }
+
+ public NfvoNsInst description(final String description) {
+ this.description = description;
+ return this;
+ }
+
+ public State getStatus() {
+ return status;
+ }
+
+ public void setStatus(final State status) {
+ this.status = status;
+ }
+
+ public NfvoNsInst status(final State status) {
+ this.status = status;
+ return this;
+ }
+
+ public LocalDateTime getStatusUpdatedTime() {
+ return statusUpdatedTime;
+ }
+
+ public void setStatusUpdatedTime(final LocalDateTime statusUpdatedTime) {
+ this.statusUpdatedTime = statusUpdatedTime;
+ }
+
+ public NfvoNsInst statusUpdatedTime(final LocalDateTime statusUpdatedTime) {
+ this.statusUpdatedTime = statusUpdatedTime;
+ return this;
+ }
+
+ public String getGlobalCustomerId() {
+ return globalCustomerId;
+ }
+
+ public void setGlobalCustomerId(final String globalCustomerId) {
+ this.globalCustomerId = globalCustomerId;
+ }
+
+ public NfvoNsInst globalCustomerId(final String globalCustomerId) {
+ this.globalCustomerId = globalCustomerId;
+ return this;
+ }
+
+ public String getServiceType() {
+ return serviceType;
+ }
+
+ public void setServiceType(final String serviceType) {
+ this.serviceType = serviceType;
+ }
+
+ public NfvoNsInst serviceType(final String serviceType) {
+ this.serviceType = serviceType;
+ return this;
+ }
+
+ public List<NfvoNfInst> getNfvoNfInsts() {
+ return nfvoNfInsts;
+ }
+
+ public void setNfvoNfInsts(final List<NfvoNfInst> nfvoNfInsts) {
+ this.nfvoNfInsts = nfvoNfInsts;
+ }
+
+ public NfvoNsInst nfvoNfInsts(final NfvoNfInst nfvoNfInsts) {
+ nfvoNfInsts.nfvoNsInst(this);
+ this.nfvoNfInsts.add(nfvoNfInsts);
+ return this;
+ }
+
+ public List<NsLcmOpOcc> getNsLcmOpOccs() {
+ return nsLcmOpOccs;
+ }
+
+ public void setNsLcmOpOccs(final List<NsLcmOpOcc> nsLcmOpOccs) {
+ this.nsLcmOpOccs = nsLcmOpOccs;
+ }
+
+ public NfvoNsInst nsLcmOpOccs(final NsLcmOpOcc nsLcmOpOcc) {
+ nsLcmOpOcc.nfvoNsInst(this);
+ this.nsLcmOpOccs.add(nsLcmOpOcc);
+ return this;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(nsInstId, name, nsPackageId, nsdId, nsdInvariantId, description, status, statusUpdatedTime,
+ globalCustomerId, serviceType, nfvoNfInsts, nsLcmOpOccs);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj instanceof NfvoNsInst) {
+ final NfvoNsInst other = (NfvoNsInst) obj;
+ return Objects.equals(nsInstId, other.nsInstId) && Objects.equals(name, other.name)
+ && Objects.equals(nsPackageId, other.nsPackageId) && Objects.equals(nsdId, other.nsdId)
+ && Objects.equals(nsdInvariantId, other.nsdInvariantId)
+ && Objects.equals(description, other.description) && Objects.equals(status, other.status)
+ && Objects.equals(statusUpdatedTime, other.statusUpdatedTime)
+ && Objects.equals(globalCustomerId, other.globalCustomerId)
+ && Objects.equals(serviceType, other.serviceType) && Objects.equals(nfvoNfInsts, other.nfvoNfInsts)
+ && Objects.equals(nsLcmOpOccs, other.nsLcmOpOccs);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("class NfvoNsInst {\n");
+ sb.append(" nsInstId: ").append(toIndentedString(nsInstId)).append("\n");
+ sb.append(" name: ").append(toIndentedString(name)).append("\n");
+ sb.append(" nsPackageId: ").append(toIndentedString(nsPackageId)).append("\n");
+ sb.append(" nsdId: ").append(toIndentedString(nsdId)).append("\n");
+ sb.append(" nsdInvariantId: ").append(toIndentedString(nsdInvariantId)).append("\n");
+ sb.append(" description: ").append(toIndentedString(description)).append("\n");
+ sb.append(" status: ").append(toIndentedString(status)).append("\n");
+ sb.append(" statusUpdatedTime: ").append(toIndentedString(statusUpdatedTime)).append("\n");
+ sb.append(" globalCustomerId: ").append(toIndentedString(globalCustomerId)).append("\n");
+ sb.append(" serviceType: ").append(toIndentedString(serviceType)).append("\n");
+ sb.append(" nfvoNfInsts: ").append(toIndentedString(nfvoNfInsts)).append("\n");
+ sb.append(" nsLcmOpOccs: ").append(toIndentedString(nsLcmOpOccs)).append("\n");
+
+ sb.append("}");
+ return sb.toString();
+ }
+
+}
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
new file mode 100644
index 0000000000..cb8f92070a
--- /dev/null
+++ 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
@@ -0,0 +1,233 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.database.beans;
+
+import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString;
+import java.time.LocalDateTime;
+import java.util.Objects;
+import java.util.UUID;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * @author mukeshsharma(mukeshsharma@est.tech)
+ */
+@Entity
+@Table(name = "NS_LCM_OP_OCCS")
+public class NsLcmOpOcc {
+
+ @Id
+ @Column(name = "ID")
+ private String id;
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "OPERATION_STATE")
+ private OperationStateEnum operationState;
+
+ @Column(name = "STATE_ENTERED_TIME")
+ private LocalDateTime stateEnteredTime;
+
+ @Column(name = "START_TIME")
+ private LocalDateTime startTime;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "NS_INST_ID")
+ private NfvoNsInst nfvoNsInst;
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "OPERATION")
+ private NsLcmOpType operation;
+
+ @Column(name = "IS_AUTO_INNOVATION")
+ private boolean isAutoInnovation;
+
+ @Column(name = "OPERATION_PARAMS", columnDefinition = "LONGTEXT")
+ private String operationParams;
+
+ @Column(name = "IS_CANCEL_PENDING")
+ private boolean isCancelPending;
+
+ public NsLcmOpOcc() {
+ this.id = UUID.randomUUID().toString();
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(final String id) {
+ this.id = id;
+ }
+
+ public NsLcmOpOcc id(final String id) {
+ this.id = id;
+ return this;
+ }
+
+ public OperationStateEnum getOperationState() {
+ return operationState;
+ }
+
+ public void setOperationState(final OperationStateEnum operationState) {
+ this.operationState = operationState;
+ }
+
+ public NsLcmOpOcc operationState(final OperationStateEnum operationState) {
+ this.operationState = operationState;
+ return this;
+ }
+
+ public LocalDateTime getStateEnteredTime() {
+ return stateEnteredTime;
+ }
+
+ public void setStateEnteredTime(final LocalDateTime stateEnteredTime) {
+ this.stateEnteredTime = stateEnteredTime;
+ }
+
+ public NsLcmOpOcc stateEnteredTime(final LocalDateTime stateEnteredTime) {
+ this.stateEnteredTime = stateEnteredTime;
+ return this;
+ }
+
+ public LocalDateTime getStartTime() {
+ return startTime;
+ }
+
+ public void setStartTime(final LocalDateTime startTime) {
+ this.startTime = startTime;
+ }
+
+ public NsLcmOpOcc startTime(final LocalDateTime startTime) {
+ this.startTime = startTime;
+ return this;
+ }
+
+ public NfvoNsInst getNfvoNsInst() {
+ return nfvoNsInst;
+ }
+
+ public void setNfvoNsInst(final NfvoNsInst nfvoNsInst) {
+ this.nfvoNsInst = nfvoNsInst;
+ }
+
+ public NsLcmOpOcc nfvoNsInst(final NfvoNsInst nfvoNsInst) {
+ this.nfvoNsInst = nfvoNsInst;
+ return this;
+ }
+
+ public NsLcmOpType getOperation() {
+ return operation;
+ }
+
+ public void setOperation(final NsLcmOpType operation) {
+ this.operation = operation;
+ }
+
+ public NsLcmOpOcc operation(final NsLcmOpType operation) {
+ this.operation = operation;
+ return this;
+ }
+
+ public boolean getIsAutoInnovation() {
+ return isAutoInnovation;
+ }
+
+ public void setIsAutoInnovation(final boolean isAutoInnovation) {
+ this.isAutoInnovation = isAutoInnovation;
+ }
+
+ public NsLcmOpOcc isAutoInnovation(final boolean isAutoInnovation) {
+ this.isAutoInnovation = isAutoInnovation;
+ return this;
+ }
+
+ public String getOperationParams() {
+ return operationParams;
+ }
+
+ public void setOperationParams(final String operationParams) {
+ this.operationParams = operationParams;
+ }
+
+ public NsLcmOpOcc operationParams(final String operationParams) {
+ this.operationParams = operationParams;
+ return this;
+ }
+
+ public boolean getIsCancelPending() {
+ return isCancelPending;
+ }
+
+ public void setIsCancelPending(final boolean isCancelPending) {
+ this.isCancelPending = isCancelPending;
+ }
+
+ public NsLcmOpOcc isCancelPending(final boolean isCancelPending) {
+ this.isCancelPending = isCancelPending;
+ return this;
+ }
+
+ @Override
+ public boolean equals(final Object object) {
+ if (this == object)
+ return true;
+ if (object == null || getClass() != object.getClass())
+ return false;
+ final NsLcmOpOcc that = (NsLcmOpOcc) object;
+ 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)
+ && 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);
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("class NfvoNsInst {\n");
+ sb.append(" id: ").append(toIndentedString(id)).append("\n");
+ sb.append(" operationState: ").append(toIndentedString(operationState)).append("\n");
+ sb.append(" stateEnteredTime: ").append(toIndentedString(stateEnteredTime)).append("\n");
+ sb.append(" startTime: ").append(toIndentedString(startTime)).append("\n");
+ sb.append(" nfvoNsInst: ").append(nfvoNsInst != null ? toIndentedString(nfvoNsInst.getNsInstId()) : null)
+ .append("\n");
+ sb.append(" operation: ").append(toIndentedString(operation)).append("\n");
+ sb.append(" isAutoInnovation: ").append(toIndentedString(isAutoInnovation)).append("\n");
+ sb.append(" operationParams: ").append(toIndentedString(operationParams)).append("\n");
+ sb.append(" isCancelPending: ").append(toIndentedString(isCancelPending)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+}
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/NsLcmOpType.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/NsLcmOpType.java
new file mode 100644
index 0000000000..351f9611c5
--- /dev/null
+++ 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/NsLcmOpType.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.database.beans;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public enum NsLcmOpType {
+ INSTANTIATE, TERMINATE, SCALE, UPDATE, HEAL;
+}
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/OperationStateEnum.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/OperationStateEnum.java
new file mode 100644
index 0000000000..236652e027
--- /dev/null
+++ 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/OperationStateEnum.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.database.beans;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public enum OperationStateEnum {
+ PROCESSING, COMPLETED, PARTIALLY_COMPLETED, FAILED_TEMP, FAILED, ROLLING_BACK, ROLLED_BACK;
+
+}
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/State.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/State.java
new file mode 100644
index 0000000000..390c7fd776
--- /dev/null
+++ 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/State.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.database.beans;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public enum State {
+ NOT_INSTANTIATED, INSTANTIATING, INSTANTIATED, FAILED;
+
+}
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
new file mode 100644
index 0000000000..c55ef5728e
--- /dev/null
+++ 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
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils;
+
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class Utils {
+
+ private Utils() {}
+
+ public static final String toIndentedString(final Object object) {
+ return object == null ? "null" : object.toString().replace("\n", "\n ");
+ }
+
+
+ public static boolean isEquals(final List<?> first, List<?> second) {
+ if (first == null) {
+ return second == null;
+ }
+ if (first.isEmpty()) {
+ return second.isEmpty();
+ }
+ if (first.size() == second.size()) {
+ for (int index = 0; index < first.size(); index++) {
+ if (!Objects.equals(first.get(index), second.get(index))) {
+ return false;
+ }
+ }
+ return true;
+
+ }
+ 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/config/NfvoDatabaseConfiguration.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/config/NfvoDatabaseConfiguration.java
new file mode 100644
index 0000000000..8f146e5378
--- /dev/null
+++ 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/config/NfvoDatabaseConfiguration.java
@@ -0,0 +1,87 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.database.config;
+
+import javax.persistence.EntityManagerFactory;
+import javax.sql.DataSource;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.jmx.export.MBeanExporter;
+import org.springframework.orm.jpa.JpaTransactionManager;
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Configuration
+@EnableTransactionManagement
+@EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactory",
+ basePackages = {"org.onap.so.etsi.nfvo.ns.lcm.database.repository"})
+public class NfvoDatabaseConfiguration {
+
+ private static final String PERSISTENCE_UNIT = "nfvo";
+ private static final String NFVO_DATA_SOURCE_QUALIFIER = "nfvoDataSource";
+
+ @Autowired(required = false)
+ private MBeanExporter mBeanExporter;
+
+ @Bean
+ @ConfigurationProperties(prefix = "spring.datasource.hikari.nfvo")
+ public HikariConfig nfvoDbConfig() {
+ return new HikariConfig();
+ }
+
+ @Bean(name = NFVO_DATA_SOURCE_QUALIFIER)
+ public DataSource dataSource() {
+ if (mBeanExporter != null) {
+ mBeanExporter.addExcludedBean(NFVO_DATA_SOURCE_QUALIFIER);
+ }
+ final HikariConfig hikariConfig = this.nfvoDbConfig();
+ return new HikariDataSource(hikariConfig);
+ }
+
+ @Primary
+ @Bean(name = "entityManagerFactory")
+ public LocalContainerEntityManagerFactoryBean entityManagerFactory(final EntityManagerFactoryBuilder builder,
+ @Qualifier(NFVO_DATA_SOURCE_QUALIFIER) final DataSource dataSource) {
+ return builder.dataSource(dataSource).packages(NfvoJob.class.getPackage().getName())
+ .persistenceUnit(PERSISTENCE_UNIT).build();
+ }
+
+ @Primary
+ @Bean(name = "transactionManager")
+ public PlatformTransactionManager transactionManager(
+ @Qualifier("entityManagerFactory") final EntityManagerFactory entityManagerFactory) {
+ return new JpaTransactionManager(entityManagerFactory);
+ }
+
+}
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/repository/NSLcmOpOccRepository.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/repository/NSLcmOpOccRepository.java
new file mode 100644
index 0000000000..696c7be5dd
--- /dev/null
+++ 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/repository/NSLcmOpOccRepository.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.database.repository;
+
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc;
+import org.springframework.data.repository.CrudRepository;
+import java.util.Optional;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ * @author mukeshsharma(mukeshsharma@est.tech)
+ */
+public interface NSLcmOpOccRepository extends CrudRepository<NsLcmOpOcc, String> {
+
+ Optional<NsLcmOpOcc> findById(final String id);
+}
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/repository/NfvoJobRepository.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/repository/NfvoJobRepository.java
new file mode 100644
index 0000000000..844f60827e
--- /dev/null
+++ 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/repository/NfvoJobRepository.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.database.repository;
+
+import java.util.Optional;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob;
+import org.springframework.data.repository.CrudRepository;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public interface NfvoJobRepository extends CrudRepository<NfvoJob, String> {
+
+ Optional<NfvoJob> findByResourceId(final String resourceId);
+
+
+}
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/repository/NfvoJobStatusRepository.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/repository/NfvoJobStatusRepository.java
new file mode 100644
index 0000000000..c3fe469ff6
--- /dev/null
+++ 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/repository/NfvoJobStatusRepository.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.database.repository;
+
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJobStatus;
+import org.springframework.data.repository.CrudRepository;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public interface NfvoJobStatusRepository extends CrudRepository<NfvoJobStatus, Integer> {
+}
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/repository/NfvoNfInstRepository.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/repository/NfvoNfInstRepository.java
new file mode 100644
index 0000000000..de14d43de4
--- /dev/null
+++ 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/repository/NfvoNfInstRepository.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.database.repository;
+
+import java.util.List;
+import java.util.Optional;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst;
+import org.springframework.data.repository.CrudRepository;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ * @author mukeshsharma(mukeshsharma@est.tech)
+ */
+public interface NfvoNfInstRepository extends CrudRepository<NfvoNfInst, String> {
+
+ Optional<NfvoNfInst> findByNfInstId(final String nfInstId);
+
+ List<NfvoNfInst> findByNsInstNsInstId(final String nsInstId);
+
+ List<NfvoNfInst> findByNsInstNsInstIdAndName(final String nsInstId, final String 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/repository/NfvoNsInstRepository.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/repository/NfvoNsInstRepository.java
new file mode 100644
index 0000000000..beeeacf8cf
--- /dev/null
+++ 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/repository/NfvoNsInstRepository.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.database.repository;
+
+import java.util.Optional;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst;
+import org.springframework.data.repository.CrudRepository;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public interface NfvoNsInstRepository extends CrudRepository<NfvoNsInst, String> {
+
+ Optional<NfvoNsInst> findByName(final String name);
+
+ Optional<NfvoNsInst> findByNsInstId(final String nsInstId);
+
+ boolean existsNfvoNsInstByName(final String 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/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
new file mode 100644
index 0000000000..368242515b
--- /dev/null
+++ 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
@@ -0,0 +1,141 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.database.service;
+
+import java.util.List;
+import java.util.Optional;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc;
+import org.onap.so.etsi.nfvo.ns.lcm.database.repository.NSLcmOpOccRepository;
+import org.onap.so.etsi.nfvo.ns.lcm.database.repository.NfvoJobRepository;
+import org.onap.so.etsi.nfvo.ns.lcm.database.repository.NfvoNfInstRepository;
+import org.onap.so.etsi.nfvo.ns.lcm.database.repository.NfvoNsInstRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+
+@Service
+public class DatabaseServiceProvider {
+ private static final Logger logger = LoggerFactory.getLogger(DatabaseServiceProvider.class);
+
+ private final NfvoJobRepository nfvoJobRepository;
+
+ private final NfvoNsInstRepository nfvoNsInstRepository;
+
+ private final NfvoNfInstRepository nfvoNfInstRepository;
+
+ private final NSLcmOpOccRepository nsLcmOpOccRepository;
+
+ @Autowired
+ public DatabaseServiceProvider(final NfvoJobRepository nfvoJobRepository,
+ final NfvoNsInstRepository nfvoNsInstRepository, final NfvoNfInstRepository nfvoNfInstRepository,
+ final NSLcmOpOccRepository nsLcmOpOccRepository) {
+ this.nfvoJobRepository = nfvoJobRepository;
+ this.nfvoNsInstRepository = nfvoNsInstRepository;
+ this.nfvoNfInstRepository = nfvoNfInstRepository;
+ this.nsLcmOpOccRepository = nsLcmOpOccRepository;
+ }
+
+ public boolean addJob(final NfvoJob job) {
+ logger.info("Adding NfvoJob: {} to database", job);
+ return nfvoJobRepository.save(job) != null;
+ }
+
+ public Optional<NfvoJob> getJob(final String jobId) {
+ logger.info("Querying database for NfvoJob using jobId: {}", jobId);
+ return nfvoJobRepository.findById(jobId);
+ }
+
+ public Optional<NfvoJob> getJobByResourceId(final String resourceId) {
+ logger.info("Querying database for NfvoJob using resourceId: {}", resourceId);
+ return nfvoJobRepository.findByResourceId(resourceId);
+ }
+
+ public boolean isNsInstExists(final String name) {
+ logger.info("Checking if NfvoNsInst entry exists in database using name: {}", name);
+ return nfvoNsInstRepository.existsNfvoNsInstByName(name);
+ }
+
+ public boolean isNsInstExists(final String nsInstId, final String nfName) {
+ logger.info("Checking if NfvoNfInst entry exists in database using nsInstId: {} and nfName: {}", nsInstId,
+ nfName);
+ return nfvoNfInstRepository.findByNsInstNsInstIdAndName(nsInstId, nfName).isEmpty();
+ }
+
+ public boolean saveNfvoNsInst(final NfvoNsInst nfvoNsInst) {
+ logger.info("Saving NfvoNsInst: {} to database", nfvoNsInst);
+ return nfvoNsInstRepository.save(nfvoNsInst) != null;
+ }
+
+ public Optional<NfvoNsInst> getNfvoNsInst(final String nsInstId) {
+ logger.info("Querying database for NfvoNsInst using nsInstId: {}", nsInstId);
+ return nfvoNsInstRepository.findById(nsInstId);
+ }
+
+ public Optional<NfvoNsInst> getNfvoNsInstByName(final String name) {
+ logger.info("Querying database for NfvoNsInst using name: {}", name);
+ return nfvoNsInstRepository.findByName(name);
+ }
+
+ public boolean saveNfvoNfInst(final NfvoNfInst nfvoNfInst) {
+ logger.info("Saving NfvoNfInst: {} to database", nfvoNfInst);
+ 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);
+ }
+
+ public List<NfvoNfInst> getNfvoNfInstByNsInstIdAndNfName(final String nsInstId, final String name) {
+ logger.info("Querying database for NfvoNfInst using nsInstId: {} and name : {} ", nsInstId, name);
+ return nfvoNfInstRepository.findByNsInstNsInstIdAndName(nsInstId, name);
+ }
+
+ public Optional<NfvoNfInst> getNfvoNfInst(final String nfInstId) {
+ logger.info("Querying database for NfvoNfInst using nfInstId: {}", nfInstId);
+ return nfvoNfInstRepository.findByNfInstId(nfInstId);
+ }
+
+ public boolean addNSLcmOpOcc(final NsLcmOpOcc nsLcmOpOcc) {
+ logger.info("Adding NSLcmOpOcc: {} to database", nsLcmOpOcc);
+ return nsLcmOpOccRepository.save(nsLcmOpOcc) != null;
+ }
+
+ public Optional<NsLcmOpOcc> getNsLcmOpOcc(final String id) {
+ logger.info("Querying database for NsLcmOpOcc using id: {}", id);
+ return nsLcmOpOccRepository.findById(id);
+ }
+
+
+}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/resources/db/migration/V1_1__create_nfvo_tables.sql b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/resources/db/migration/V1_1__create_nfvo_tables.sql
new file mode 100644
index 0000000000..f41a8206e0
--- /dev/null
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/resources/db/migration/V1_1__create_nfvo_tables.sql
@@ -0,0 +1,74 @@
+use nfvo;
+
+CREATE TABLE IF NOT EXISTS `JOB` (
+ `JOB_ID` varchar(255) NOT NULL,
+ `JOB_TYPE` varchar(255) NOT NULL,
+ `JOB_ACTION` varchar(255) NOT NULL,
+ `RESOURCE_ID` varchar(255) NOT NULL,
+ `RESOURCE_NAME` varchar(255) DEFAULT NULL,
+ `STATUS` varchar(255) NOT NULL,
+ `START_TIME` DATETIME DEFAULT NULL,
+ `END_TIME` DATETIME DEFAULT NULL,
+ `PROGRESS` int(11) DEFAULT NULL,
+ `PROCESS_INSTANCE_ID` varchar(255) DEFAULT NULL,
+ PRIMARY KEY (`JOB_ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+
+
+CREATE TABLE IF NOT EXISTS `JOB_STATUS` (
+ `ID` INT NOT NULL AUTO_INCREMENT,
+ `UPDATED_TIME` DATETIME NOT NULL,
+ `DESCRIPTION` longtext DEFAULT NULL,
+ `STATUS` varchar(255) NOT NULL,
+ `JOB_ID` varchar(255) NOT NULL,
+ PRIMARY KEY (`ID`),
+ FOREIGN KEY (JOB_ID)
+ REFERENCES JOB(JOB_ID)
+ ON UPDATE CASCADE ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `NS_INST` (
+ `NS_INST_ID` varchar(255) NOT NULL,
+ `NAME` varchar(255) NOT NULL,
+ `NS_PACKAGE_ID` varchar(255) DEFAULT NULL,
+ `NSD_ID` varchar(255) NOT NULL,
+ `NSD_INVARIANT_ID` varchar(255) NOT NULL,
+ `DESCRIPTION` longtext DEFAULT NULL,
+ `STATUS` varchar(255) NOT NULL,
+ `STATUS_UPDATED_TIME` DATETIME NOT NULL,
+ `GLOBAL_CUSTOMER_ID` varchar(255) DEFAULT NULL,
+ `SERVICE_TYPE` varchar(255) DEFAULT NULL,
+ PRIMARY KEY (`NS_INST_ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `NF_INST` (
+ `NF_INST_ID` varchar(255) NOT NULL,
+ `NAME` varchar(255) DEFAULT NULL,
+ `VNFD_ID` varchar(255) DEFAULT NULL,
+ `PACKAGE_ID` varchar(255) DEFAULT NULL,
+ `NS_INST_ID` varchar(255) NOT NULL,
+ `STATUS` varchar(255) NOT NULL,
+ `CREATE_TIME` DATETIME DEFAULT NULL,
+ `LAST_UPDATE_TIME` DATETIME DEFAULT NULL,
+ PRIMARY KEY (`NF_INST_ID`),
+ FOREIGN KEY (NS_INST_ID)
+ REFERENCES NS_INST(NS_INST_ID)
+ ON UPDATE CASCADE ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `NS_LCM_OP_OCCS` (
+ `ID` varchar(255) NOT NULL,
+ `OPERATION_STATE` varchar(255) NOT NULL,
+ `STATE_ENTERED_TIME` DATETIME DEFAULT NULL,
+ `START_TIME` DATETIME DEFAULT NULL,
+ `NS_INST_ID` varchar(255) NOT NULL,
+ `OPERATION` varchar(255) NOT NULL,
+ `IS_AUTO_INNOVATION` varchar(255) NOT NULL,
+ `OPERATION_PARAMS` longtext NOT NULL,
+ `IS_CANCEL_PENDING` varchar(255) NOT NULL,
+ PRIMARY KEY (`ID`),
+ FOREIGN KEY (NS_INST_ID)
+ REFERENCES NS_INST(NS_INST_ID)
+ ON UPDATE CASCADE ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/DatabaseServiceProviderTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/DatabaseServiceProviderTest.java
new file mode 100644
index 0000000000..42579fd5e8
--- /dev/null
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/DatabaseServiceProviderTest.java
@@ -0,0 +1,176 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.database;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.Optional;
+import java.util.UUID;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobAction;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJobStatus;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpType;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.OperationStateEnum;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State;
+import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("test")
+public class DatabaseServiceProviderTest {
+
+ private static final String RANDOM_ID = UUID.randomUUID().toString();
+ private static final String DUMMY_NAME = "NAME";
+ private static final LocalDateTime CURRENT_DATE_TIME = LocalDateTime.now();
+ @Autowired
+ private DatabaseServiceProvider databaseServiceProvider;
+
+ @Test
+ public void testAddJob_StoredInDatabase() {
+ final NfvoJob expected = new NfvoJob().jobType("TYPE").jobAction(JobAction.CREATE).resourceId(RANDOM_ID)
+ .resourceName(DUMMY_NAME).startTime(CURRENT_DATE_TIME).status(JobStatusEnum.STARTED);
+ databaseServiceProvider.addJob(expected);
+
+ final Optional<NfvoJob> actual = databaseServiceProvider.getJob(expected.getJobId());
+ assertEquals(expected, actual.get());
+ }
+
+ @Test
+ public void testAddJobWithJobStatus_StoredInDatabase() {
+ final NfvoJob job = new NfvoJob().jobType("TYPE").jobAction(JobAction.CREATE).resourceId(RANDOM_ID)
+ .resourceName(DUMMY_NAME).startTime(CURRENT_DATE_TIME).status(JobStatusEnum.STARTED);
+ databaseServiceProvider.addJob(job);
+
+ final NfvoJobStatus jobStatus = new NfvoJobStatus().status(JobStatusEnum.STARTED)
+ .description("Create NS workflow process started").updatedTime(CURRENT_DATE_TIME);
+ databaseServiceProvider.addJob(job.nfvoJobStatus(jobStatus));
+
+ final Optional<NfvoJob> actual = databaseServiceProvider.getJob(job.getJobId());
+ final NfvoJob actualNfvoJob = actual.get();
+
+ assertEquals(job.getJobId(), actualNfvoJob.getJobId());
+ assertFalse(actualNfvoJob.getNfvoJobStatuses().isEmpty());
+ assertEquals(job.getJobId(), actualNfvoJob.getNfvoJobStatuses().get(0).getNfvoJob().getJobId());
+
+ }
+
+ @Test
+ public void testAddNsInst_StoredInDatabase_ableTofindByQuery() {
+
+ final NfvoNsInst nsInst = new NfvoNsInst().name(DUMMY_NAME).nsdId(RANDOM_ID).status(State.NOT_INSTANTIATED)
+ .nsdInvariantId(RANDOM_ID).statusUpdatedTime(CURRENT_DATE_TIME);
+
+ databaseServiceProvider.saveNfvoNsInst(nsInst);
+
+ Optional<NfvoNsInst> actual = databaseServiceProvider.getNfvoNsInst(nsInst.getNsInstId());
+ NfvoNsInst actualNfvoNsInst = actual.get();
+ assertEquals(nsInst.getNsInstId(), actualNfvoNsInst.getNsInstId());
+ assertEquals(RANDOM_ID, actualNfvoNsInst.getNsdId());
+ assertEquals(State.NOT_INSTANTIATED, actualNfvoNsInst.getStatus());
+ assertEquals(RANDOM_ID, actualNfvoNsInst.getNsdInvariantId());
+ assertEquals(CURRENT_DATE_TIME, actualNfvoNsInst.getStatusUpdatedTime());
+
+ actual = databaseServiceProvider.getNfvoNsInstByName(DUMMY_NAME);
+ actualNfvoNsInst = actual.get();
+
+ assertEquals(nsInst.getNsInstId(), actualNfvoNsInst.getNsInstId());
+ assertEquals(RANDOM_ID, actualNfvoNsInst.getNsdId());
+ assertEquals(State.NOT_INSTANTIATED, actualNfvoNsInst.getStatus());
+ assertEquals(RANDOM_ID, actualNfvoNsInst.getNsdInvariantId());
+ assertEquals(CURRENT_DATE_TIME, actualNfvoNsInst.getStatusUpdatedTime());
+
+
+ assertTrue(databaseServiceProvider.isNsInstExists(DUMMY_NAME));
+ }
+
+ @Test
+ public void testAddNfInst_StoredInDatabase_ableTofindByQuery() {
+
+ final NfvoNsInst nsInst = new NfvoNsInst().name(DUMMY_NAME).nsdId(RANDOM_ID).status(State.NOT_INSTANTIATED)
+ .nsdInvariantId(RANDOM_ID).statusUpdatedTime(CURRENT_DATE_TIME);
+
+ databaseServiceProvider.saveNfvoNsInst(nsInst);
+
+ final NfvoNfInst nfInst = new NfvoNfInst().nfvoNsInst(nsInst).name(DUMMY_NAME).vnfdId(RANDOM_ID)
+ .status(State.NOT_INSTANTIATED).createTime(CURRENT_DATE_TIME).lastUpdateTime(CURRENT_DATE_TIME);
+ databaseServiceProvider.saveNfvoNfInst(nfInst);
+
+ final Optional<NfvoNfInst> actual = databaseServiceProvider.getNfvoNfInstByNfInstId(nfInst.getNfInstId());
+ final NfvoNfInst actualNfvoNfInst = actual.get();
+ assertEquals(nsInst.getNsInstId(), actualNfvoNfInst.getNsInst().getNsInstId());
+ assertEquals(nfInst.getNfInstId(), actualNfvoNfInst.getNfInstId());
+ assertEquals(nfInst.getName(), actualNfvoNfInst.getName());
+ assertEquals(nfInst.getVnfdId(), actualNfvoNfInst.getVnfdId());
+ assertEquals(nfInst.getStatus(), actualNfvoNfInst.getStatus());
+ assertEquals(nfInst.getCreateTime(), actualNfvoNfInst.getCreateTime());
+ assertEquals(nfInst.getLastUpdateTime(), actualNfvoNfInst.getLastUpdateTime());
+
+
+ List<NfvoNfInst> nfvoNfInstList = databaseServiceProvider.getNfvoNfInstByNsInstId(nsInst.getNsInstId());
+ assertFalse(nfvoNfInstList.isEmpty());
+ assertEquals(nsInst.getNsInstId(), nfvoNfInstList.get(0).getNsInst().getNsInstId());
+
+ nfvoNfInstList = databaseServiceProvider.getNfvoNfInstByNsInstIdAndNfName(nsInst.getNsInstId(), DUMMY_NAME);
+
+ assertFalse(nfvoNfInstList.isEmpty());
+ assertEquals(nsInst.getNsInstId(), nfvoNfInstList.get(0).getNsInst().getNsInstId());
+ assertEquals(DUMMY_NAME, nfvoNfInstList.get(0).getName());
+ }
+
+ @Test
+ public void testAddNsLcmOpOcc_StoredInDatabase_ableTofindByQuery() {
+
+ final NfvoNsInst nsInst = new NfvoNsInst().name(DUMMY_NAME).nsdId(RANDOM_ID).status(State.NOT_INSTANTIATED)
+ .nsdInvariantId(RANDOM_ID).statusUpdatedTime(CURRENT_DATE_TIME);
+
+ databaseServiceProvider.saveNfvoNsInst(nsInst);
+
+ final NsLcmOpOcc nsLcmOpOcc = new NsLcmOpOcc().nfvoNsInst(nsInst).operationState(OperationStateEnum.PROCESSING)
+ .isCancelPending(false).isAutoInnovation(false).operation(NsLcmOpType.INSTANTIATE)
+ .startTime(CURRENT_DATE_TIME).stateEnteredTime(CURRENT_DATE_TIME).operationParams("");
+
+
+ databaseServiceProvider.addNSLcmOpOcc(nsLcmOpOcc);
+
+ final Optional<NsLcmOpOcc> actual = databaseServiceProvider.getNsLcmOpOcc(nsLcmOpOcc.getId());
+ final NsLcmOpOcc actualLcmOpOcc = actual.get();
+ assertEquals(nsLcmOpOcc.getId(), actualLcmOpOcc.getId());
+
+ assertEquals(nsInst.getNsInstId(), actualLcmOpOcc.getNfvoNsInst().getNsInstId());
+
+ }
+}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/TestApplication.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/TestApplication.java
new file mode 100644
index 0000000000..921cae2343
--- /dev/null
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/TestApplication.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.etsi.nfvo.ns.lcm.database;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.FilterType;
+import org.springframework.context.annotation.ComponentScan.Filter;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@SpringBootApplication(scanBasePackages = {"org.onap.so"})
+@EnableAutoConfiguration(exclude = {JacksonAutoConfiguration.class})
+@ComponentScan(basePackages = {"org.onap"},
+ excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)})
+public class TestApplication {
+
+ public static void main(final String[] args) {
+ new SpringApplication(TestApplication.class).run(args);
+ }
+
+}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/UtilsTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/UtilsTest.java
new file mode 100644
index 0000000000..632bda937c
--- /dev/null
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/UtilsTest.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import java.util.Arrays;
+import java.util.Collections;
+import org.junit.Test;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class UtilsTest {
+
+ @Test
+ public void testTwoEmptyLists_equal() {
+ assertTrue(Utils.isEquals(Collections.emptyList(), Collections.emptyList()));
+ }
+
+ @Test
+ public void testEmptyListAndNonEmpty_notEqual() {
+ assertFalse(Utils.isEquals(Collections.emptyList(), Arrays.asList("A")));
+ }
+
+ @Test
+ public void testTwoNullLists_equal() {
+ assertTrue(Utils.isEquals(null, null));
+ }
+
+ @Test
+ public void testNullListAndEmptyList_notEqual() {
+ assertFalse(Utils.isEquals(null, Collections.emptyList()));
+ }
+
+ @Test
+ public void testTwoNotEmptyListsContainSameObjects_equal() {
+ assertTrue(Utils.isEquals(Arrays.asList("A"), Arrays.asList("A")));
+ }
+
+ @Test
+ public void testTwoNotEmptyListsContainsDifferentObjects_equal() {
+ assertFalse(Utils.isEquals(Arrays.asList("A"), Arrays.asList(1)));
+ }
+
+
+}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/resources/application.yaml b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/resources/application.yaml
new file mode 100644
index 0000000000..adc36aca1d
--- /dev/null
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/resources/application.yaml
@@ -0,0 +1,31 @@
+# Copyright © 2020 Nordix Foundation
+#
+# 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.
+spring:
+ main:
+ web-application-type: none
+ datasource:
+ hikari:
+ nfvo:
+ jdbcUrl: jdbc:h2:mem:nfvo;DB_CLOSE_DELAY=-1;INIT=CREATE SCHEMA IF NOT EXISTS nfvo;
+ driver-class-name: org.h2.Driver
+ pool-name: ns-lcm-bpmn-pool
+ registerMbeans: true
+ jpa:
+ generate-ddl: true
+ hibernate:
+ ddl-auto: create
+hibernate:
+ dialect: org.hibernate.dialect.H2Dialect
+ hbm2ddl:
+ auto: create \ No newline at end of file