[SO] Generate and replace values file based on instance variable
Initial DB setup for lifecycle params
Create As Instance record in DB
Instantiate lifecycle param check
Rebase
Review changes
Rebase
Success Test Case Amended
Fail Test Case Added
Issue-Id: SO-3900
Signed-off-by: egernug <gerard.nugent@est.tech>
Change-Id: I68ef0562008d2d811e3fd64c81c3b6000561cb06
diff --git a/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/main/java/org/onap/so/cnfm/lcm/bpmn/flows/extclients/sdc/DeploymentItem.java b/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/main/java/org/onap/so/cnfm/lcm/bpmn/flows/extclients/sdc/DeploymentItem.java
index e0795c4..609a3fb 100644
--- a/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/main/java/org/onap/so/cnfm/lcm/bpmn/flows/extclients/sdc/DeploymentItem.java
+++ b/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/main/java/org/onap/so/cnfm/lcm/bpmn/flows/extclients/sdc/DeploymentItem.java
@@ -21,6 +21,7 @@
import static org.onap.so.cnfm.lcm.database.beans.utils.Utils.toIndentedString;
import java.io.Serializable;
+import java.util.List;
import java.util.Objects;
/**
@@ -36,6 +37,9 @@
private String itemId;
private String deploymentOrder;
+ private List<String> lifecycleParameters;
+
+
public String getName() {
return name;
}
@@ -90,9 +94,23 @@
return this;
}
+
+ public List<String> getLifecycleParameters() {
+ return lifecycleParameters;
+ }
+
+ public void setLifecycleParameters(final List<String> lifecycleParameters) {
+ this.lifecycleParameters = lifecycleParameters;
+ }
+
+ public DeploymentItem lifecycleParameters(final List<String> lifecycleParameters) {
+ this.lifecycleParameters = lifecycleParameters;
+ return this;
+ }
+
@Override
public int hashCode() {
- return Objects.hash(name, file, itemId, deploymentOrder);
+ return Objects.hash(name, file, itemId, deploymentOrder, lifecycleParameters);
}
@Override
@@ -104,7 +122,8 @@
if (obj instanceof DeploymentItem) {
final DeploymentItem other = (DeploymentItem) obj;
return Objects.equals(name, other.name) && Objects.equals(file, other.file)
- && Objects.equals(itemId, other.itemId) && Objects.equals(deploymentOrder, other.deploymentOrder);
+ && Objects.equals(itemId, other.itemId) && Objects.equals(deploymentOrder, other.deploymentOrder)
+ && Objects.equals(lifecycleParameters, other.lifecycleParameters);
}
return false;
}
@@ -117,6 +136,7 @@
sb.append(" file: ").append(toIndentedString(file)).append("\n");
sb.append(" itemId: ").append(toIndentedString(itemId)).append("\n");
sb.append(" deploymentOrder: ").append(toIndentedString(deploymentOrder)).append("\n");
+ sb.append(" lifecycleParameters: ").append(toIndentedString(lifecycleParameters)).append("\n");
sb.append("}");
return sb.toString();
}
diff --git a/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/main/java/org/onap/so/cnfm/lcm/bpmn/flows/extclients/sdc/SdcCsarPackageParser.java b/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/main/java/org/onap/so/cnfm/lcm/bpmn/flows/extclients/sdc/SdcCsarPackageParser.java
index ca14651..206226a 100644
--- a/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/main/java/org/onap/so/cnfm/lcm/bpmn/flows/extclients/sdc/SdcCsarPackageParser.java
+++ b/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/main/java/org/onap/so/cnfm/lcm/bpmn/flows/extclients/sdc/SdcCsarPackageParser.java
@@ -35,12 +35,15 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+
+import com.google.gson.JsonArray;
import org.onap.so.cnfm.lcm.bpmn.flows.exceptions.FileNotFoundInCsarException;
import org.onap.so.cnfm.lcm.bpmn.flows.exceptions.PropertyNotFoundException;
import org.slf4j.Logger;
@@ -120,13 +123,26 @@
artifacts.keySet().forEach(key -> {
final JsonObject element = artifacts.getAsJsonObject(key);
final JsonObject artifactsProperties = child(element, "properties");
+ List<String> lcp = getLifecycleParameters(artifactsProperties);
items.add(new DeploymentItem().name(key).itemId(getStringValue(artifactsProperties, "itemId"))
.file(getStringValue(element, "file"))
- .deploymentOrder(getStringValue(artifactsProperties, "deployment_order")));
+ .deploymentOrder(getStringValue(artifactsProperties, "deployment_order")).lifecycleParameters(lcp));
});
return items;
}
+ private List<String> getLifecycleParameters(JsonObject artifactsProperties) {
+ final JsonArray lcParameters = childElement(artifactsProperties, "lifecycle_parameters").getAsJsonArray();
+ final List<String> lifecycleParameters = new ArrayList<>();
+ if(lcParameters != null) {
+ final Iterator<JsonElement> it = lcParameters.iterator();
+ while(it.hasNext()){
+ lifecycleParameters.add(it.next().getAsString());
+ }
+ }
+ return lifecycleParameters;
+ }
+
private String getAsdLocation(final ZipInputStream zipInputStream) throws IOException {
try (final ByteArrayOutputStream fileContent = getFileInZip(zipInputStream, TOCSA_METADATA_FILE_PATH);) {
diff --git a/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/main/java/org/onap/so/cnfm/lcm/bpmn/flows/tasks/CreateAsTask.java b/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/main/java/org/onap/so/cnfm/lcm/bpmn/flows/tasks/CreateAsTask.java
index f19703d..b24965e 100644
--- a/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/main/java/org/onap/so/cnfm/lcm/bpmn/flows/tasks/CreateAsTask.java
+++ b/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/main/java/org/onap/so/cnfm/lcm/bpmn/flows/tasks/CreateAsTask.java
@@ -36,11 +36,13 @@
import static org.onap.so.cnfm.lcm.model.utils.AdditionalParamsConstants.SERVICE_INSTANCE_NAME_PARAM_KEY;
import static org.onap.so.cnfm.lcm.model.utils.AdditionalParamsConstants.TENANT_ID_PARAM_KEY;
import java.util.Arrays;
+import java.util.ArrayList;
import java.util.List;
-import java.time.LocalDateTime;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
+import java.time.LocalDateTime;
+
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.so.cnfm.lcm.bpmn.flows.extclients.aai.AaiServiceProvider;
@@ -51,6 +53,7 @@
import org.onap.so.cnfm.lcm.database.beans.AsInst;
import org.onap.so.cnfm.lcm.database.beans.JobStatusEnum;
import org.onap.so.cnfm.lcm.database.beans.State;
+import org.onap.so.cnfm.lcm.database.beans.AsLifecycleParam;
import org.onap.so.cnfm.lcm.database.service.DatabaseServiceProvider;
import org.onap.so.cnfm.lcm.model.AsInstance;
import org.onap.so.cnfm.lcm.model.AsInstance.InstantiationStateEnum;
@@ -219,6 +222,8 @@
.artifactFilePath(item.getFile()).status(State.NOT_INSTANTIATED)
.createTime(LocalDateTime.now()).lastUpdateTime(LocalDateTime.now())
.releaseName(generateReleaseName(asInst, item));
+ List<AsLifecycleParam> lifecycleParams = getLifeCycleParams(asDeploymentItem, item);
+ asDeploymentItem.setAsLifecycleParams(lifecycleParams);
asInst.asdeploymentItems(asDeploymentItem);
});
}
@@ -232,6 +237,18 @@
}
+ private List<AsLifecycleParam> getLifeCycleParams(AsDeploymentItem asDeploymentItem, DeploymentItem deploymentItem) {
+ List<AsLifecycleParam> asLifecycleParams = new ArrayList<>();
+ if (deploymentItem.getLifecycleParameters()!= null){
+ for(String lifecycleParam: deploymentItem.getLifecycleParameters()){
+ asLifecycleParams.add(new AsLifecycleParam().asDeploymentItemInst(asDeploymentItem).asLifecycleParam(lifecycleParam));
+ }
+
+
+ }
+ return asLifecycleParams;
+ }
+
private String generateReleaseName(AsInst asInst, DeploymentItem item) {
return String.join("-", Arrays.asList(asInst.getName(), item.getName(), item.getItemId()))
.toLowerCase().replaceAll("[\\s\\_]", "-");
diff --git a/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/main/java/org/onap/so/cnfm/lcm/bpmn/flows/tasks/InstantiateAsTask.java b/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/main/java/org/onap/so/cnfm/lcm/bpmn/flows/tasks/InstantiateAsTask.java
index 4800a5a..743c52c 100644
--- a/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/main/java/org/onap/so/cnfm/lcm/bpmn/flows/tasks/InstantiateAsTask.java
+++ b/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/main/java/org/onap/so/cnfm/lcm/bpmn/flows/tasks/InstantiateAsTask.java
@@ -37,6 +37,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
@@ -55,6 +56,7 @@
import org.onap.so.cnfm.lcm.bpmn.flows.service.KubConfigProvider;
import org.onap.so.cnfm.lcm.database.beans.AsDeploymentItem;
import org.onap.so.cnfm.lcm.database.beans.AsInst;
+import org.onap.so.cnfm.lcm.database.beans.AsLifecycleParam;
import org.onap.so.cnfm.lcm.database.beans.State;
import org.onap.so.cnfm.lcm.database.service.DatabaseServiceProvider;
import org.onap.so.cnfm.lcm.model.AsInfoModificationRequestDeploymentItems;
@@ -229,7 +231,6 @@
final Map<String, Object> lifeCycleParamMap = instantiateAsRequest.getDeploymentItems().stream()
.collect(Collectors.toMap(AsInfoModificationRequestDeploymentItems::getDeploymentItemsId,
AsInfoModificationRequestDeploymentItems::getLifecycleParameterKeyValues));
-
asDeploymentItems.forEach(asDeploymentItem -> {
final String asDeploymentItemInstId = asDeploymentItem.getAsDeploymentItemInstId();
@@ -242,10 +243,14 @@
abortOperation(execution, message);
}
+
@SuppressWarnings("unchecked")
final Map<String, String> lifeCycleParams =
(Map<String, String>) lifeCycleParamMap.get(asDeploymentItem.getItemId());
+ final List<AsLifecycleParam> requiredParams = asDeploymentItem.getAsLifecycleParams();
+
+ checkForLifecycleParametersAbort(execution, lifeCycleParams, requiredParams);
requests.add(new InstantiateDeploymentItemRequest().asInstId(asInstId)
.asDeploymentItemInstId(asDeploymentItemInstId).asDeploymentItemName(asDeploymentItem.getName())
.helmArtifactFilePath(artifactFilePath).deploymentOrder(asDeploymentItem.getDeploymentOrder())
@@ -259,6 +264,25 @@
}
+ private void checkForLifecycleParametersAbort(final DelegateExecution execution, Map<String, String> lifeCycleParams, List<AsLifecycleParam> requiredParams){
+ if (!requiredParams.isEmpty()){
+ if (isNullOrEmptyMap(lifeCycleParams)){
+ abortOnLifecycleParams(execution, "no lifecycle parameters in request");
+ }
+ final Iterator<AsLifecycleParam> it = requiredParams.iterator();
+ while (it.hasNext()) {
+ final String next = it.next().getLifecycleParam();
+ if (!lifeCycleParams.containsKey(next)) {
+ abortOnLifecycleParams(execution, "parameter missing: " + next);
+ }
+ }
+ }
+ }
+ private void abortOnLifecycleParams(final DelegateExecution execution, String reason) {
+ final String message =
+ "Lifecycle parameter error, " + reason;
+ abortOperation(execution, message);
+ }
public void checkIfDeploymentItemsInstantiationWasSuccessful(final DelegateExecution execution) {
logger.info("Executing checkIfDeploymentItemsInstantiationWasSuccessful");
@@ -375,4 +399,8 @@
}
return dir;
}
+
+ public static boolean isNullOrEmptyMap(Map <? , ?> map) {
+ return (map == null || map.isEmpty());
+}
}
diff --git a/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/tasks/InstantiateAsTaskTest.java b/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/tasks/InstantiateAsTaskTest.java
index 74327a7..411465a 100644
--- a/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/tasks/InstantiateAsTaskTest.java
+++ b/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/tasks/InstantiateAsTaskTest.java
@@ -20,48 +20,6 @@
package org.onap.so.cnfm.lcm.bpmn.flows.tasks;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.notFound;
-import static com.github.tomakehurst.wiremock.client.WireMock.ok;
-import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
-import static org.onap.aaiclient.client.aai.AAIVersion.V19;
-import static org.springframework.http.HttpHeaders.ACCEPT;
-import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
-import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE;
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.time.LocalDateTime;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.UUID;
-import org.camunda.bpm.engine.history.HistoricProcessInstance;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.so.cnfm.lcm.bpmn.flows.BaseTest;
-import org.onap.so.cnfm.lcm.bpmn.flows.GsonProvider;
-import org.onap.so.cnfm.lcm.bpmn.flows.exceptions.AsRequestProcessingException;
-import org.onap.so.cnfm.lcm.bpmn.flows.service.JobExecutorService;
-import org.onap.so.cnfm.lcm.database.beans.AsDeploymentItem;
-import org.onap.so.cnfm.lcm.database.beans.AsInst;
-import org.onap.so.cnfm.lcm.database.beans.AsLcmOpOcc;
-import org.onap.so.cnfm.lcm.database.beans.Job;
-import org.onap.so.cnfm.lcm.database.beans.JobStatusEnum;
-import org.onap.so.cnfm.lcm.database.beans.OperationStateEnum;
-import org.onap.so.cnfm.lcm.database.beans.State;
-import org.onap.so.cnfm.lcm.model.InstantiateAsRequest;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.gson.Gson;
import io.kubernetes.client.custom.IntOrString;
@@ -97,16 +55,66 @@
import io.kubernetes.client.openapi.models.V1StatefulSetStatus;
import io.kubernetes.client.openapi.models.V1StatefulSetUpdateStrategy;
import io.kubernetes.client.util.Watch;
+import org.camunda.bpm.engine.history.HistoricProcessInstance;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.so.cnfm.lcm.bpmn.flows.BaseTest;
+import org.onap.so.cnfm.lcm.bpmn.flows.GsonProvider;
+import org.onap.so.cnfm.lcm.bpmn.flows.exceptions.AsRequestProcessingException;
+import org.onap.so.cnfm.lcm.bpmn.flows.service.JobExecutorService;
+import org.onap.so.cnfm.lcm.database.beans.AsDeploymentItem;
+import org.onap.so.cnfm.lcm.database.beans.AsInst;
+import org.onap.so.cnfm.lcm.database.beans.AsLcmOpOcc;
+import org.onap.so.cnfm.lcm.database.beans.AsLifecycleParam;
+import org.onap.so.cnfm.lcm.database.beans.Job;
+import org.onap.so.cnfm.lcm.database.beans.JobStatusEnum;
+import org.onap.so.cnfm.lcm.database.beans.OperationStateEnum;
+import org.onap.so.cnfm.lcm.database.beans.State;
+import org.onap.so.cnfm.lcm.model.InstantiateAsRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.notFound;
+import static com.github.tomakehurst.wiremock.client.WireMock.ok;
+import static com.github.tomakehurst.wiremock.client.WireMock.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
+import static org.onap.aaiclient.client.aai.AAIVersion.V19;
+import static org.springframework.http.HttpHeaders.ACCEPT;
+import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
+import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE;
/**
- *
* @author Waqas Ikram (waqas.ikram@est.tech)
- *
*/
public class InstantiateAsTaskTest extends BaseTest {
private static final String RANDOM_UUID = UUID.randomUUID().toString();
private static final String SERVICE_INSTANCE_ID = UUID.randomUUID().toString();
private static final String AS_INST_ID = SERVICE_INSTANCE_ID;
+
+ private static final String SERVICE_INSTANCE_ID2 = UUID.randomUUID().toString();
+ private static final String AS_INST_ID2 = SERVICE_INSTANCE_ID2;
private static final String ASD_NAME = "InstantiateCnfService";
private static final String AS_INST_NAME = ASD_NAME + "-" + System.currentTimeMillis();
private static final String ASD_ID = AS_INST_ID;
@@ -118,6 +126,8 @@
private static final String AS_DEPLOYMENT_ITEM_1_INST_ID = UUID.randomUUID().toString();
private static final String AS_DEPLOYMENT_ITEM_2_INST_ID = UUID.randomUUID().toString();
+ private static final String AS_DEPLOYMENT_ITEM_1_INST_ID2 = UUID.randomUUID().toString();
+ private static final String AS_DEPLOYMENT_ITEM_2_INST_ID2 = UUID.randomUUID().toString();
@Value("${cnfm.csar.dir}")
private String dir;
@@ -176,27 +186,7 @@
.willReturn(aResponse().withBody(getFileContent(getAbsolutePath(RESOURCE_ASD_PACKAGE_CSAR_PATH)))
.withHeader(ACCEPT, APPLICATION_OCTET_STREAM_VALUE)));
- final AsInst asInst = new AsInst().asInstId(AS_INST_ID).name(AS_INST_NAME).asdId(ASD_ID)
- .asdInvariantId(AS_INST_ID).status(State.NOT_INSTANTIATED).statusUpdatedTime(LocalDateTime.now())
- .asApplicationName("asApplicationName").asApplicationVersion("asApplicationVersion")
- .asProvider("asProvider").serviceInstanceId(SERVICE_INSTANCE_ID)
- .serviceInstanceName("serviceInstanceName").cloudOwner("cloudOwner").cloudRegion("cloudRegion")
- .tenantId("tenantId");
-
- final String helmFile1 = "Artifacts/Deployment/HELM/sampleapp-db-operator-helm.tgz";
- final AsDeploymentItem item1 = new AsDeploymentItem().asDeploymentItemInstId(AS_DEPLOYMENT_ITEM_1_INST_ID)
- .asInst(asInst).status(State.NOT_INSTANTIATED).name("sampleapp-db").itemId("1").deploymentOrder(1)
- .artifactFilePath(helmFile1).createTime(LocalDateTime.now()).lastUpdateTime(LocalDateTime.now())
- .releaseName("testOne");
-
- final String helmFile2 = "Artifacts/Deployment/HELM/sampleapp-services-helm.tgz";
- final AsDeploymentItem item2 = new AsDeploymentItem().asDeploymentItemInstId(AS_DEPLOYMENT_ITEM_2_INST_ID)
- .asInst(asInst).status(State.NOT_INSTANTIATED).name("sampleapp-services").itemId("2").deploymentOrder(2)
- .artifactFilePath(helmFile2).createTime(LocalDateTime.now()).lastUpdateTime(LocalDateTime.now())
- .releaseName("testTwo");
-
- asInst.asdeploymentItems(item1);
- asInst.asdeploymentItems(item2);
+ AsInst asInst = createAsInst(AS_INST_ID, AS_DEPLOYMENT_ITEM_1_INST_ID, AS_DEPLOYMENT_ITEM_2_INST_ID);
databaseServiceProvider.saveAsInst(asInst);
@@ -215,11 +205,6 @@
assertNotNull(historicProcessInstance);
assertEquals(HistoricProcessInstance.STATE_COMPLETED, historicProcessInstance.getState());
- assertTrue(Files.exists(Paths.get(dir, AS_INST_ID, item1.getAsDeploymentItemInstId())
- .resolve(Paths.get(helmFile1).getFileName())));
- assertTrue(Files.exists(Paths.get(dir, AS_INST_ID, item2.getAsDeploymentItemInstId())
- .resolve(Paths.get(helmFile2).getFileName())));
-
final Optional<AsInst> asInstOptional = databaseServiceProvider.getAsInst(asInst.getAsInstId());
final AsInst actualAsInst = asInstOptional.get();
assertEquals(State.INSTANTIATED, actualAsInst.getStatus());
@@ -238,12 +223,31 @@
final Map<String, Integer> counter = mockedHelmClient.getCounter();
assertEquals(2, counter.size());
- assertEquals(Integer.valueOf(3), counter.get(item1.getReleaseName()));
- assertEquals(Integer.valueOf(3), counter.get(item2.getReleaseName()));
+ assertEquals(Integer.valueOf(3), counter.get(asInst.getAsdeploymentItems().get(0).getReleaseName()));
+ assertEquals(Integer.valueOf(3), counter.get(asInst.getAsdeploymentItems().get(1).getReleaseName()));
}
+ @Test(expected = AsRequestProcessingException.class)
+ public void testInstantiateAsWorkflow_LifecycleParametersMissing_Fail() throws InterruptedException, IOException {
+
+ wireMockServer.stubFor(get(SDC_GET_RESOURCE_URL)
+ .willReturn(aResponse().withBody(getFileContent(getAbsolutePath(RESOURCE_ASD_PACKAGE_CSAR_PATH)))
+ .withHeader(ACCEPT, APPLICATION_OCTET_STREAM_VALUE)));
+
+ AsLifecycleParam lcp3 = new AsLifecycleParam().asLifecycleParam(".Values.extra.missing");
+ AsInst asInst1 = createAsInst(AS_INST_ID2, AS_DEPLOYMENT_ITEM_1_INST_ID2, AS_DEPLOYMENT_ITEM_2_INST_ID2);
+ asInst1.getAsdeploymentItems().get(0).asLifecycleParams(lcp3);
+
+ databaseServiceProvider.saveAsInst(asInst1);
+
+ createKubeConfigFile(asInst1);
+
+ objUnderTest.runInstantiateAsJob(asInst1.getAsInstId(), getInstantiateAsRequest());
+
+ }
+
@Test
public void testInstantiateAsWorkflow_UpdateAsInstState_ExceptionCase() {
@@ -268,6 +272,7 @@
assertEquals(State.FAILED, asInstOptional.get().getStatus());
}
+
private void mockKubernetesClientEndpoint() {
wireMockServer.stubFor(get(urlMatching("/apis/batch/v1/jobs\\?labelSelector.*&watch=true"))
.willReturn(aResponse().withBody(getJobResponse()).withHeader(ACCEPT, APPLICATION_JSON_VALUE)));
@@ -455,9 +460,40 @@
}
+ private AsInst createAsInst(String as_inst_id, String as_deployment_item_1_id, String as_deployment_item_2_id) {
+ final AsInst asInst = new AsInst().asInstId(as_inst_id).name(AS_INST_NAME).asdId(ASD_ID)
+ .asdInvariantId(as_inst_id).status(State.NOT_INSTANTIATED).statusUpdatedTime(LocalDateTime.now())
+ .asApplicationName("asApplicationName").asApplicationVersion("asApplicationVersion")
+ .asProvider("asProvider").serviceInstanceId(as_inst_id)
+ .serviceInstanceName("serviceInstanceName").cloudOwner("cloudOwner").cloudRegion("cloudRegion")
+ .tenantId("tenantId");
- private InstantiateAsRequest getInstantiateAsRequest() {
- return new InstantiateAsRequest();
+ final String helmFile1 = "Artifacts/Deployment/HELM/sampleapp-db-operator-helm.tgz";
+ List<AsLifecycleParam> asLifecycleParams = new ArrayList<>();
+ AsLifecycleParam lcp1 = new AsLifecycleParam().asLifecycleParam(".Values.primary.service.ports.mysql");
+ AsLifecycleParam lcp2 = new AsLifecycleParam().asLifecycleParam(".Values.primary.service.nodePorts.mysql");
+ asLifecycleParams.add(lcp1);
+ asLifecycleParams.add(lcp2);
+ final AsDeploymentItem item1 = new AsDeploymentItem().asDeploymentItemInstId(as_deployment_item_1_id)
+ .asInst(asInst).status(State.NOT_INSTANTIATED).name("sampleapp-db").itemId("1").deploymentOrder(1)
+ .artifactFilePath(helmFile1).createTime(LocalDateTime.now()).lastUpdateTime(LocalDateTime.now())
+ .releaseName("testOne").asLifecycleParams(lcp1).asLifecycleParams(lcp2);
+
+ final String helmFile2 = "Artifacts/Deployment/HELM/sampleapp-services-helm.tgz";
+ final AsDeploymentItem item2 = new AsDeploymentItem().asDeploymentItemInstId(as_deployment_item_2_id)
+ .asInst(asInst).status(State.NOT_INSTANTIATED).name("sampleapp-services").itemId("2").deploymentOrder(2)
+ .artifactFilePath(helmFile2).createTime(LocalDateTime.now()).lastUpdateTime(LocalDateTime.now())
+ .releaseName("testTwo");
+
+ asInst.asdeploymentItems(item1);
+ asInst.asdeploymentItems(item2);
+ return asInst;
+ }
+
+ private InstantiateAsRequest getInstantiateAsRequest() throws FileNotFoundException {
+ BufferedReader br = new BufferedReader(new FileReader("src/test/resources/request.json"));
+ InstantiateAsRequest request = new Gson().fromJson(br, InstantiateAsRequest.class);
+ return request;
}
private Path getAbsolutePath(final String path) {
diff --git a/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/resources/request.json b/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/resources/request.json
new file mode 100644
index 0000000..042247f
--- /dev/null
+++ b/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/resources/request.json
@@ -0,0 +1,25 @@
+{
+ "deploymentItems": [
+ {
+ "deploymentItemsId": "1",
+ "lifecycleParameterKeyValues": {
+ ".Values.primary.service.ports.mysql": "dummy",
+ ".Values.primary.service.nodePorts.mysql": "dummy"
+ }
+ },
+ {
+ "deploymentItemsId": "2",
+ "lifecycleParameterKeyValues": {
+
+ }
+ }
+ ],
+ "asdExtCpdInputParams": {
+ "extCpdId": null,
+ "loadbalanceIP": null,
+ "externalIPs": [],
+ "nadNames": [],
+ "nadNamespace": null
+ },
+ "additionalParams": {}
+}
\ No newline at end of file
diff --git a/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsDeploymentItem.java b/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsDeploymentItem.java
index 58fae21..ef310da 100644
--- a/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsDeploymentItem.java
+++ b/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsDeploymentItem.java
@@ -21,8 +21,11 @@
import static org.onap.so.cnfm.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;
@@ -31,8 +34,10 @@
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
import javax.persistence.Table;
+
/**
*
* @author Waqas Ikram (waqas.ikram@est.tech)
@@ -75,6 +80,9 @@
@Column(name = "RELEASE_NAME", nullable = false)
private String releaseName;
+ @OneToMany(mappedBy = "asDeploymentItemInst", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
+ private List<AsLifecycleParam> asLifecycleParams = new ArrayList<>();
+
public AsDeploymentItem() {
this.asDeploymentItemInstId = UUID.randomUUID().toString();
}
@@ -209,26 +217,39 @@
this.releaseName = releaseName;
return this;
}
- @Override
- public int hashCode() {
- return Objects.hash(asDeploymentItemInstId, name, itemId, deploymentOrder, artifactFilePath,
- asInst != null ? asInst.getAsInstId() : 0, status, createTime, lastUpdateTime, releaseName);
+
+ public List<AsLifecycleParam> getAsLifecycleParams() {
+ return asLifecycleParams;
+ }
+
+ public void setAsLifecycleParams(List<AsLifecycleParam> asLifecycleParams) {
+ this.asLifecycleParams = asLifecycleParams;
+ }
+
+ public AsDeploymentItem asLifecycleParams(final AsLifecycleParam asLifecycleParam){
+ asLifecycleParam.asDeploymentItemInst(this);
+ this.asLifecycleParams.add(asLifecycleParam);
+ return this;
}
@Override
- public boolean equals(final Object object) {
- if (this == object)
- return true;
- if (object == null || getClass() != object.getClass())
- return false;
- final AsDeploymentItem that = (AsDeploymentItem) object;
+ public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ final AsDeploymentItem that = (AsDeploymentItem) o;
return Objects.equals(asDeploymentItemInstId, that.asDeploymentItemInstId) && Objects.equals(name, that.name)
&& Objects.equals(itemId, that.itemId) && Objects.equals(deploymentOrder, that.deploymentOrder)
&& Objects.equals(artifactFilePath, that.artifactFilePath)
&& (asInst == null ? that.asInst == null : that.asInst != null && Objects.equals(asInst, that.asInst))
&& Objects.equals(status, that.status) && Objects.equals(createTime, that.createTime)
&& Objects.equals(lastUpdateTime, that.lastUpdateTime)
- && Objects.equals(releaseName, that.releaseName);
+ && Objects.equals(releaseName, that.releaseName)
+ && Objects.equals(asLifecycleParams, that.asLifecycleParams);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(asDeploymentItemInstId, name, itemId, deploymentOrder, artifactFilePath, status, asInst, createTime, lastUpdateTime, releaseName, asLifecycleParams);
}
@Override
@@ -245,7 +266,7 @@
sb.append(" createTime: ").append(toIndentedString(createTime)).append("\n");
sb.append(" lastUpdateTime: ").append(toIndentedString(lastUpdateTime)).append("\n");
sb.append(" releaseName: ").append(toIndentedString(releaseName)).append("\n");
-
+ sb.append(" asLifecycleParams").append(toIndentedString(asLifecycleParams)).append("\n");
sb.append("}");
return sb.toString();
}
diff --git a/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsLifecycleParam.java b/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsLifecycleParam.java
new file mode 100644
index 0000000..89193d1
--- /dev/null
+++ b/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsLifecycleParam.java
@@ -0,0 +1,125 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 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.cnfm.lcm.database.beans;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+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;
+import java.util.Objects;
+import static org.onap.so.cnfm.lcm.database.beans.utils.Utils.toIndentedString;
+/**
+ *
+ * @author Gerard Nugent (gerard.nugent@est.tech)
+ *
+ */
+@Entity
+@Table(name = "AS_LIFECYCLE_PARAM")
+public class AsLifecycleParam {
+
+ @Id
+ @Column(name = "AS_LCP_ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Integer asLifecycleParamId;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "AS_DEP_ITEM_INST_ID", nullable = false)
+ private AsDeploymentItem asDeploymentItemInst;
+
+ @Column(name = "LIFECYCLE_PARAM")
+ private String lifecycleParam;
+
+ public AsLifecycleParam() {
+
+ }
+
+ public void setAsLifecycleParamId(final Integer asLifecycleParamId) {
+ this.asLifecycleParamId = asLifecycleParamId;
+ }
+
+ public Integer getAsLifecycleParamId() {
+ return asLifecycleParamId;
+ }
+
+ public AsLifecycleParam asLifecycleParamId(final Integer asLifecycleParamId) {
+ this.asLifecycleParamId = asLifecycleParamId;
+ return this;
+ }
+
+ public AsDeploymentItem getAsDeploymentItemInst() {
+ return asDeploymentItemInst;
+ }
+
+ public void setAsDeploymentItemInst(final AsDeploymentItem asDeploymentItemInst) {
+ this.asDeploymentItemInst = asDeploymentItemInst;
+ }
+
+ public AsLifecycleParam asDeploymentItemInst(final AsDeploymentItem asDeploymentItemInst) {
+ this.asDeploymentItemInst = asDeploymentItemInst;
+ return this;
+ }
+
+ public String getLifecycleParam() {
+ return lifecycleParam;
+ }
+
+ public void setLifecycleParam(final String lifecycleParam) {
+ this.lifecycleParam = lifecycleParam;
+ }
+
+ public AsLifecycleParam asLifecycleParam(final String lifecycleParam) {
+ this.lifecycleParam = lifecycleParam;
+ return this;
+ }
+
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("class AslifecycleParam {\n");
+ sb.append(" asLifecycleParamId: ").append(toIndentedString(asLifecycleParamId)).append("\n");
+ sb.append(" asDeploymentItemInstId: ").append(asDeploymentItemInst != null ? toIndentedString(asDeploymentItemInst.getAsDeploymentItemInstId()) : null).append("\n");
+ sb.append(" lifecycleParam: ").append(toIndentedString(lifecycleParam)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ AsLifecycleParam that = (AsLifecycleParam) o;
+ return Objects.equals(asLifecycleParamId, that.asLifecycleParamId) && Objects.equals(asDeploymentItemInst, that.asDeploymentItemInst) && Objects.equals(lifecycleParam, that.lifecycleParam);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(asLifecycleParamId, asDeploymentItemInst, lifecycleParam);
+ }
+
+
+}
diff --git a/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/AsLifecycleParamRepository.java b/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/AsLifecycleParamRepository.java
new file mode 100644
index 0000000..035c25e
--- /dev/null
+++ b/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/AsLifecycleParamRepository.java
@@ -0,0 +1,14 @@
+package org.onap.so.cnfm.lcm.database.repository;
+
+import org.onap.so.cnfm.lcm.database.beans.AsLifecycleParam;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+public interface AsLifecycleParamRepository extends JpaRepository<AsLifecycleParam, Integer> {
+
+ List<AsLifecycleParam> findByAsDeploymentItemInstAsDeploymentItemInstId(final String asDeploymentItemId);
+
+ Optional<AsLifecycleParam> findByAsLifecycleParamId(Integer asLifecycleParamId);
+}
diff --git a/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/service/DatabaseServiceProvider.java b/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/service/DatabaseServiceProvider.java
index 850eaff..93d1527 100644
--- a/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/service/DatabaseServiceProvider.java
+++ b/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/service/DatabaseServiceProvider.java
@@ -19,17 +19,19 @@
*/
package org.onap.so.cnfm.lcm.database.service;
-import java.util.List;
-import java.util.Optional;
+
+
import org.onap.so.cnfm.lcm.database.beans.AsDeploymentItem;
import org.onap.so.cnfm.lcm.database.beans.AsInst;
import org.onap.so.cnfm.lcm.database.beans.AsLcmOpOcc;
+import org.onap.so.cnfm.lcm.database.beans.AsLifecycleParam;
import org.onap.so.cnfm.lcm.database.beans.Job;
import org.onap.so.cnfm.lcm.database.beans.OperationStateEnum;
import org.onap.so.cnfm.lcm.database.beans.State;
import org.onap.so.cnfm.lcm.database.repository.AsDeploymentItemRepository;
import org.onap.so.cnfm.lcm.database.repository.AsInstRepository;
import org.onap.so.cnfm.lcm.database.repository.AsLcmOpOccRepository;
+import org.onap.so.cnfm.lcm.database.repository.AsLifecycleParamRepository;
import org.onap.so.cnfm.lcm.database.repository.JobRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,6 +41,9 @@
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
+import java.util.List;
+import java.util.Optional;
+
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
*
@@ -54,15 +59,18 @@
private final AsDeploymentItemRepository asdeploymentItemRepository;
+ private final AsLifecycleParamRepository aslifecyleParamRepository;
+
private final AsLcmOpOccRepository asLcmOpOccRepository;
@Autowired
public DatabaseServiceProvider(final JobRepository jobRepository, final AsInstRepository asInstRepository,
- final AsDeploymentItemRepository asdeploymentItemRepository,
+ final AsDeploymentItemRepository asdeploymentItemRepository, final AsLifecycleParamRepository aslifecyleParamRepository,
final AsLcmOpOccRepository asLcmOpOccRepository) {
this.jobRepository = jobRepository;
this.asInstRepository = asInstRepository;
this.asdeploymentItemRepository = asdeploymentItemRepository;
+ this.aslifecyleParamRepository = aslifecyleParamRepository;
this.asLcmOpOccRepository = asLcmOpOccRepository;
}
@@ -160,6 +168,22 @@
asdeploymentItemRepository.deleteAsDeploymentItemUsingAsInstId(asInstId);
}
+ public boolean saveAsLifecycleParam(final AsLifecycleParam aslifecyleparam) {
+ logger.info("Saving AsLifecycleParam: {} to database", aslifecyleparam);
+ return aslifecyleParamRepository.saveAndFlush(aslifecyleparam) != null;
+ }
+
+ public List<AsLifecycleParam> getAsLifecycleParamByAsDeploymentItemId(final String asDeploymentItemId) {
+ logger.info("Querying database for Aslifecycleparam using asDeploymentItemId: {}", asDeploymentItemId);
+ //NEXT
+ return aslifecyleParamRepository.findByAsDeploymentItemInstAsDeploymentItemInstId(asDeploymentItemId);
+ }
+
+ public Optional<AsLifecycleParam> getAsLifecycleParam(final Integer asLifecycleParamId) {
+ logger.info("Querying database for Aslifecycleparam using AslifecycleParamId: {}", asLifecycleParamId);
+ return aslifecyleParamRepository.findByAsLifecycleParamId(asLifecycleParamId);
+ }
+
public boolean addAsLcmOpOcc(final AsLcmOpOcc asLcmOpOcc) {
logger.info("Adding AsLcmOpOcc: {} to database", asLcmOpOcc);
return asLcmOpOccRepository.saveAndFlush(asLcmOpOcc) != null;
diff --git a/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/resources/db/migration/V1_1__create_cnfm_tables.sql b/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/resources/db/migration/V1_1__create_cnfm_tables.sql
index e6bf0a1..5e75171 100644
--- a/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/resources/db/migration/V1_1__create_cnfm_tables.sql
+++ b/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/resources/db/migration/V1_1__create_cnfm_tables.sql
@@ -62,6 +62,16 @@
ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+CREATE TABLE IF NOT EXISTS `AS_LIFECYCLE_PARAM` (
+ `AS_LCP_ID` INT NOT NULL AUTO_INCREMENT,
+ `AS_DEP_ITEM_INST_ID` varchar(255) NOT NULL,
+ `LIFECYCLE_PARAM` varchar(255) DEFAULT NULL,
+ PRIMARY KEY (`AS_LCP_ID`),
+ FOREIGN KEY (AS_DEP_ITEM_INST_ID)
+ REFERENCES AS_DEPLOYMENT_ITEM(AS_DEP_ITEM_INST_ID)
+ ON UPDATE CASCADE ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
CREATE TABLE IF NOT EXISTS `AS_LCM_OP_OCCS` (
`ID` varchar(255) NOT NULL,
`OPERATION_STATE` varchar(255) NOT NULL,
diff --git a/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/PojoClassesTests.java b/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/PojoClassesTests.java
index db05146..58130ee 100644
--- a/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/PojoClassesTests.java
+++ b/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/PojoClassesTests.java
@@ -21,14 +21,15 @@
import javax.persistence.Entity;
import javax.persistence.Id;
+
import org.junit.Test;
+import nl.jqno.equalsverifier.EqualsVerifier;
+import nl.jqno.equalsverifier.Warning;
import org.onap.so.cnfm.lcm.database.beans.AsDeploymentItem;
import org.onap.so.cnfm.lcm.database.beans.AsInst;
import org.onap.so.cnfm.lcm.database.beans.AsLcmOpOcc;
import org.onap.so.cnfm.lcm.database.beans.Job;
import org.onap.so.cnfm.lcm.database.beans.JobStatus;
-import nl.jqno.equalsverifier.EqualsVerifier;
-import nl.jqno.equalsverifier.Warning;
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
@@ -65,6 +66,7 @@
EqualsVerifier.forClass(AsDeploymentItem.class)
.suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT)
.withPrefabValues(AsInst.class, new AsInst(), new AsInst())
+ .withPrefabValues(AsDeploymentItem.class, new AsDeploymentItem(), new AsDeploymentItem())
.withIgnoredAnnotations(Entity.class, Id.class).verify();
}
diff --git a/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/service/DatabaseServiceProviderTest.java b/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/service/DatabaseServiceProviderTest.java
index 067b0f1..d353ea6 100644
--- a/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/service/DatabaseServiceProviderTest.java
+++ b/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/service/DatabaseServiceProviderTest.java
@@ -34,6 +34,7 @@
import org.onap.so.cnfm.lcm.database.beans.AsInst;
import org.onap.so.cnfm.lcm.database.beans.AsLcmOpOcc;
import org.onap.so.cnfm.lcm.database.beans.AsLcmOpType;
+import org.onap.so.cnfm.lcm.database.beans.AsLifecycleParam;
import org.onap.so.cnfm.lcm.database.beans.Job;
import org.onap.so.cnfm.lcm.database.beans.JobAction;
import org.onap.so.cnfm.lcm.database.beans.JobStatus;
@@ -167,6 +168,22 @@
assertFalse(asdeploymentItemList.isEmpty());
assertEquals(asInst.getAsInstId(), asdeploymentItemList.get(0).getAsInst().getAsInstId());
assertEquals(DUMMY_NAME, asdeploymentItemList.get(0).getName());
+
+ final AsLifecycleParam aslifecycleparam =
+ new AsLifecycleParam().asDeploymentItemInst(asdeploymentItem).asLifecycleParam("TEST");
+ databaseServiceProvider.saveAsLifecycleParam(aslifecycleparam);
+
+ final Optional<AsLifecycleParam> actualLP =
+ databaseServiceProvider.getAsLifecycleParam(aslifecycleparam.getAsLifecycleParamId());
+ final AsLifecycleParam actualLifecycleParam = actualLP.get();
+ assertEquals(aslifecycleparam.getLifecycleParam(), actualLifecycleParam.getLifecycleParam());
+ assertEquals(asdeploymentItem.getAsDeploymentItemInstId(), actualLifecycleParam.getAsDeploymentItemInst().getAsDeploymentItemInstId());
+ assertEquals(aslifecycleparam.getAsLifecycleParamId(), actualLifecycleParam.getAsLifecycleParamId());
+
+ List<AsLifecycleParam> aslifecycleParamsList =
+ databaseServiceProvider.getAsLifecycleParamByAsDeploymentItemId(asdeploymentItem.getAsDeploymentItemInstId());
+ assertFalse(aslifecycleParamsList.isEmpty());
+ assertEquals(asdeploymentItem.getAsDeploymentItemInstId(), aslifecycleParamsList.get(0).getAsDeploymentItemInst().getAsDeploymentItemInstId());
}
@Test