aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java8
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java42
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java8
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java14
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.java11
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java13
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/vnfoperenv/ecompOperationalEnvironmentWithRelationship.json27
10 files changed, 96 insertions, 43 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java
index 6fd33a6afc..6a5de77c73 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java
@@ -26,6 +26,7 @@ import java.util.Map;
import javax.ws.rs.NotFoundException;
+import org.onap.aai.domain.yang.OperationalEnvironment;
import org.onap.so.apihandlerinfra.tenantisolation.exceptions.AAIClientCallFailed;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient;
@@ -33,7 +34,6 @@ import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.graphinventory.entities.uri.Depth;
-import org.onap.so.client.aai.objects.AAIOperationalEnvironment;
import org.onap.so.logger.MsoLogger;
import org.springframework.stereotype.Component;
@@ -51,7 +51,7 @@ public class AAIClientHelper {
public AAIResultWrapper getAaiOperationalEnvironment(String id){
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, id);
- uri.depth(Depth.ZERO); //Do not return relationships if any
+ uri.depth(Depth.ZERO);
AAIResourcesClient client = this.getClient();
return client.get(uri, NotFoundException.class);
}
@@ -62,7 +62,7 @@ public class AAIClientHelper {
* @param id = operationalEnvironmentId
* @param AAIOperationalEnvironment object
*/
- public void updateAaiOperationalEnvironment(String id, AAIOperationalEnvironment aaiRequest){
+ public void updateAaiOperationalEnvironment(String id, OperationalEnvironment aaiRequest){
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, id);
AAIResourcesClient client = this.getClient();
@@ -87,7 +87,7 @@ public class AAIClientHelper {
* Create an Operational Environment object in A&AI
* @param AAIOperationalEnvironment object
*/
- public void createOperationalEnvironment(AAIOperationalEnvironment operationalEnvironment){
+ public void createOperationalEnvironment(OperationalEnvironment operationalEnvironment){
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, operationalEnvironment.getOperationalEnvironmentId());
AAIResourcesClient client = this.getClient();
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java
index 23642bdfb4..dc6019c9cb 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java
@@ -20,15 +20,15 @@
package org.onap.so.apihandlerinfra.tenantisolation.helpers;
+import org.onap.aai.domain.yang.OperationalEnvironment;
import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.onap.so.client.aai.objects.AAIOperationalEnvironment;
import org.springframework.stereotype.Component;
@Component
public class AAIClientObjectBuilder {
- public AAIOperationalEnvironment buildAAIOperationalEnvironment(String status, CloudOrchestrationRequest cloudOrchestrationRequest) {
- AAIOperationalEnvironment env = new AAIOperationalEnvironment();
+ public OperationalEnvironment buildAAIOperationalEnvironment(String status, CloudOrchestrationRequest cloudOrchestrationRequest) {
+ OperationalEnvironment env = new OperationalEnvironment();
env.setOperationalEnvironmentId(cloudOrchestrationRequest.getOperationalEnvironmentId());
env.setOperationalEnvironmentName(cloudOrchestrationRequest.getRequestDetails().getRequestInfo().getInstanceName());
env.setOperationalEnvironmentType(cloudOrchestrationRequest.getRequestDetails().getRequestParameters().getOperationalEnvironmentType().toString());
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
index ac9a000d3b..1d2a445c40 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
@@ -21,11 +21,16 @@
package org.onap.so.apihandlerinfra.tenantisolation.process;
import java.util.List;
+import java.util.Optional;
import javax.ws.rs.core.Response;
import org.apache.http.HttpStatus;
import org.json.JSONObject;
+import org.onap.aai.domain.yang.OperationalEnvironment;
+import org.onap.aai.domain.yang.RelationshipList;
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.aai.domain.yang.RelationshipData;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
@@ -36,8 +41,10 @@ import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper;
import org.onap.so.apihandlerinfra.tenantisolation.helpers.ActivateVnfDBHelper;
import org.onap.so.apihandlerinfra.tenantisolation.helpers.SDCClientHelper;
import org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList;
+import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.entities.AAIResultWrapper;
-import org.onap.so.client.aai.objects.AAIOperationalEnvironment;
+import org.onap.so.client.aai.entities.Relationships;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.db.request.beans.OperationalEnvDistributionStatus;
import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
import org.onap.so.logger.MessageEnum;
@@ -54,6 +61,7 @@ public class ActivateVnfOperationalEnvironment {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, ActivateVnfOperationalEnvironment.class);
private static final int DEFAULT_ACTIVATE_RETRY_COUNT = 3;
private static final String DISTRIBUTION_STATUS_SENT = "SENT";
+ private static final String OPER_ENVIRONMENT_ID_KEY = "operational-environment-id";
@Autowired
private ActivateVnfDBHelper dbHelper;
@@ -77,24 +85,39 @@ public class ActivateVnfOperationalEnvironment {
* @return void - nothing
*/
public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException{
- String operationalEnvironmentId = request.getOperationalEnvironmentId();
+ String vnfOperationalEnvironmentId = request.getOperationalEnvironmentId();
String vidWorkloadContext = request.getRequestDetails().getRequestParameters().getWorkloadContext();
List<ServiceModelList> serviceModelVersionIdList = request.getRequestDetails().getRequestParameters().getManifest().getServiceModelList();
-
+
+ String ecompOperationalEnvironmentId = null;
+ AAIResultWrapper wrapper = getAAIOperationalEnvironment(vnfOperationalEnvironmentId);
+ Optional<Relationships> optRelationships = wrapper.getRelationships();
+ if (optRelationships.isPresent()) {
+ Relationships relationships = optRelationships.get();
+ List<AAIResourceUri> operationalEnvironments = relationships.getRelatedAAIUris(AAIObjectType.OPERATIONAL_ENVIRONMENT);
+ if (!operationalEnvironments.isEmpty()) {
+ ecompOperationalEnvironmentId = operationalEnvironments.get(0).getURIKeys().get(OPER_ENVIRONMENT_ID_KEY);
+ }
+ }
+ msoLogger.debug(" vnfOperationalEnvironmentId : " + vnfOperationalEnvironmentId);
+ msoLogger.debug(" ecompOperationalEnvironmentId : " + ecompOperationalEnvironmentId);
- AAIOperationalEnvironment operationalEnv = getAAIOperationalEnvironment(operationalEnvironmentId);
+ OperationalEnvironment operationalEnv = wrapper.asBean(OperationalEnvironment.class).get();
String workloadContext = operationalEnv.getWorkloadContext();
msoLogger.debug(" aai workloadContext: " + workloadContext);
if (!vidWorkloadContext.equals(workloadContext)) {
-
-
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.BusinessProcesssError).build();
throw new ValidateException.Builder(" The vid workloadContext did not match from aai record. " + " vid workloadContext:" + vidWorkloadContext + " aai workloadContext:" + workloadContext,
HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
}
+ if (ecompOperationalEnvironmentId==null) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.BusinessProcesssError).build();
+ throw new ValidateException.Builder(" The ECOMP OE was not in aai record; the value of relationship.relationship-data key: " + OPER_ENVIRONMENT_ID_KEY,
+ HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
+ }
- processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext);
+ processActivateSDCRequest(requestId, ecompOperationalEnvironmentId, serviceModelVersionIdList, workloadContext);
}
@@ -171,9 +194,8 @@ public class ActivateVnfOperationalEnvironment {
* @param operationalEnvironmentId - String
* @return operationalEnv - AAIOperationalEnvironment object
*/
- public AAIOperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) {
- AAIResultWrapper aaiResult = aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId);
- return aaiResult.asBean(AAIOperationalEnvironment.class).orElse(new AAIOperationalEnvironment());
+ public AAIResultWrapper getAAIOperationalEnvironment(String operationalEnvironmentId) {
+ return aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId);
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java
index e95db6b188..36226aae68 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java
@@ -27,6 +27,7 @@ import javax.ws.rs.NotFoundException;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpStatus;
+import org.onap.aai.domain.yang.OperationalEnvironment;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
import org.onap.so.apihandlerinfra.exceptions.ValidateException;
@@ -37,7 +38,6 @@ import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper;
import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientObjectBuilder;
import org.onap.so.apihandlerinfra.tenantisolationbeans.RelatedInstanceList;
import org.onap.so.client.aai.entities.AAIResultWrapper;
-import org.onap.so.client.aai.objects.AAIOperationalEnvironment;
import org.onap.so.client.grm.GRMClient;
import org.onap.so.client.grm.beans.OperationalInfo;
import org.onap.so.client.grm.beans.Property;
@@ -75,7 +75,7 @@ public class CreateVnfOperationalEnvironment {
if (aaiResultWrapper.isEmpty()) {
throw new NotFoundException(getEcompManagingEnvironmentId() + " not found in A&AI");
}
- AAIOperationalEnvironment aaiEnv = objectMapper.readValue(aaiResultWrapper.getJson(), AAIOperationalEnvironment.class);
+ OperationalEnvironment aaiEnv = aaiResultWrapper.asBean(OperationalEnvironment.class).get();
//Find ECOMP environments in GRM
msoLogger.debug(" Start of GRM findRunningServicesAsString");
@@ -209,7 +209,7 @@ public class CreateVnfOperationalEnvironment {
return tenantContext + "." + workloadContext + "." + serviceName;
}
- protected String getSearchKey(AAIOperationalEnvironment aaiEnv) {
+ protected String getSearchKey(OperationalEnvironment aaiEnv) {
return aaiEnv.getTenantContext() + "." + aaiEnv.getWorkloadContext() + ".*";
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java
index 2096011caa..977184e2c5 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java
@@ -24,6 +24,7 @@ import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpStatus;
+import org.onap.aai.domain.yang.OperationalEnvironment;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
import org.onap.so.apihandlerinfra.exceptions.ValidateException;
@@ -31,7 +32,6 @@ import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper;
import org.onap.so.client.aai.entities.AAIResultWrapper;
-import org.onap.so.client.aai.objects.AAIOperationalEnvironment;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoLogger;
import org.onap.so.requestsdb.RequestsDBHelper;
@@ -51,7 +51,7 @@ public class DeactivateVnfOperationalEnvironment {
public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException {
String operationalEnvironmentId = request.getOperationalEnvironmentId();
- AAIOperationalEnvironment aaiOpEnv = getAAIOperationalEnvironment(operationalEnvironmentId);
+ OperationalEnvironment aaiOpEnv = getAAIOperationalEnvironment(operationalEnvironmentId);
if (aaiOpEnv != null) {
String operationalEnvironmentStatus = aaiOpEnv.getOperationalEnvironmentStatus();
@@ -81,9 +81,9 @@ public class DeactivateVnfOperationalEnvironment {
}
}
- private AAIOperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) {
+ private OperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) {
AAIResultWrapper aaiResult = aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId);
- Optional<AAIOperationalEnvironment> operationalEnvironmentOpt = aaiResult.asBean(AAIOperationalEnvironment.class);
+ Optional<OperationalEnvironment> operationalEnvironmentOpt = aaiResult.asBean(OperationalEnvironment.class);
return operationalEnvironmentOpt.isPresent() ? operationalEnvironmentOpt.get() : null;
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java
index 0a57b4f245..b799394b7a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java
@@ -41,10 +41,10 @@ import java.util.Optional;
import org.apache.http.HttpStatus;
import org.junit.Test;
+import org.onap.aai.domain.yang.OperationalEnvironment;
import org.onap.so.apihandlerinfra.BaseTest;
import org.onap.so.client.aai.AAIVersion;
import org.onap.so.client.aai.entities.AAIResultWrapper;
-import org.onap.so.client.aai.objects.AAIOperationalEnvironment;
import org.springframework.beans.factory.annotation.Autowired;
@@ -60,7 +60,7 @@ public class AAIClientHelperTest extends BaseTest{
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED)));
AAIResultWrapper wrapper = clientHelper.getAaiOperationalEnvironment("EMOE-001");
- Optional<AAIOperationalEnvironment> aaiOpEnv = wrapper.asBean(AAIOperationalEnvironment.class);
+ Optional<OperationalEnvironment> aaiOpEnv = wrapper.asBean(OperationalEnvironment.class);
assertEquals("EMOE-001", aaiOpEnv.get().getOperationalEnvironmentId());
}
@@ -69,13 +69,13 @@ public class AAIClientHelperTest extends BaseTest{
stubFor(post(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
- AAIOperationalEnvironment ecompEnv = new AAIOperationalEnvironment();
+ OperationalEnvironment ecompEnv = new OperationalEnvironment();
ecompEnv.setTenantContext("Test");
ecompEnv.setWorkloadContext("ECOMPL_PSL");
try {
AAIClientHelper clientHelper = mock(AAIClientHelper.class);
- doNothing().when(clientHelper).updateAaiOperationalEnvironment(any(String.class), any(AAIOperationalEnvironment.class));
+ doNothing().when(clientHelper).updateAaiOperationalEnvironment(any(String.class), any(OperationalEnvironment.class));
clientHelper.updateAaiOperationalEnvironment("EMOE-001", ecompEnv);
verify(clientHelper, times(1)).updateAaiOperationalEnvironment("EMOE-001", ecompEnv);
@@ -109,14 +109,14 @@ public class AAIClientHelperTest extends BaseTest{
stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
- AAIOperationalEnvironment ecompEnv = new AAIOperationalEnvironment();
+ OperationalEnvironment ecompEnv = new OperationalEnvironment();
ecompEnv.setOperationalEnvironmentId("opeEvnId");
ecompEnv.setTenantContext("Test");
ecompEnv.setWorkloadContext("ECOMPL_PSL");
try {
AAIClientHelper clientHelper = mock(AAIClientHelper.class);
- doNothing().when(clientHelper).createOperationalEnvironment(any(AAIOperationalEnvironment.class));
+ doNothing().when(clientHelper).createOperationalEnvironment(any(OperationalEnvironment.class));
clientHelper.createOperationalEnvironment(ecompEnv);
verify(clientHelper, times(1)).createOperationalEnvironment(ecompEnv);
@@ -130,7 +130,7 @@ public class AAIClientHelperTest extends BaseTest{
stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
- AAIOperationalEnvironment ecompEnv = new AAIOperationalEnvironment();
+ OperationalEnvironment ecompEnv = new OperationalEnvironment();
ecompEnv.setTenantContext("Test");
ecompEnv.setWorkloadContext("ECOMPL_PSL");
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.java
index cf6facc59f..3915fc8928 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.java
@@ -35,7 +35,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public class AAIClientObjectBuilderTest extends BaseTest{
- private String expectedAAIObject = "{\"operational-environment-name\":\"TEST_ECOMP_ENVIRONMENT\",\"operational-environment-type\":\"ECOMP\",\"operational-environment-status\":\"Active\",\"tenant-context\":\"TEST\",\"workload-context\":\"ECOMP_TEST\"}";
private CloudOrchestrationRequest request;
private ObjectMapper mapper = new ObjectMapper();
@@ -62,8 +61,12 @@ public class AAIClientObjectBuilderTest extends BaseTest{
@Test
public void testGetAaiClientObjectBuilder() throws Exception {
AAIClientObjectBuilder builder = new AAIClientObjectBuilder();
- assertEquals(expectedAAIObject, mapper.writeValueAsString(builder.buildAAIOperationalEnvironment("Active", request)));
+ org.onap.aai.domain.yang.OperationalEnvironment operEnv = builder.buildAAIOperationalEnvironment("Active", request);
+ assertEquals("TEST", operEnv.getTenantContext());
+ assertEquals("ECOMP_TEST", operEnv.getWorkloadContext());
+ assertEquals("TEST_ECOMP_ENVIRONMENT", operEnv.getOperationalEnvironmentName());
+ assertEquals(OperationalEnvironment.ECOMP.toString(), operEnv.getOperationalEnvironmentType());
}
-
-
+
+
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java
index c36eb2b063..18af7fbaa0 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java
@@ -42,6 +42,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.onap.aai.domain.yang.OperationalEnvironment;
import org.onap.so.apihandlerinfra.BaseTest;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
import org.onap.so.apihandlerinfra.exceptions.ValidateException;
@@ -54,7 +55,6 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.RecoveryAction;
import org.onap.so.apihandlerinfra.tenantisolationbeans.Manifest;
import org.onap.so.client.aai.AAIVersion;
import org.onap.so.client.aai.entities.AAIResultWrapper;
-import org.onap.so.client.aai.objects.AAIOperationalEnvironment;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.springframework.beans.factory.annotation.Autowired;
@@ -99,16 +99,17 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{
@Test
public void getAAIOperationalEnvironmentTest() {
- AAIOperationalEnvironment aaiOpEnv;
+ OperationalEnvironment aaiOpEnv;
stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED)));
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironmentWithRelationship.json").withStatus(HttpStatus.SC_ACCEPTED)));
AAIResultWrapper wrapper = clientHelper.getAaiOperationalEnvironment("EMOE-001");
- aaiOpEnv = wrapper.asBean(AAIOperationalEnvironment.class).get();
+ aaiOpEnv = wrapper.asBean(OperationalEnvironment.class).get();
assertEquals("EMOE-001", aaiOpEnv.getOperationalEnvironmentId());
+ assertEquals("1dfe7154-eae0-44f2-8e7a-8e5e7882e55d", aaiOpEnv.getRelationshipList().getRelationship().get(0).getRelationshipData().get(0).getRelationshipValue());
assertNotNull(activateVnf.getAAIOperationalEnvironment(operationalEnvironmentId));
- assertEquals( "EMOE-001", activateVnf.getAAIOperationalEnvironment(operationalEnvironmentId).getOperationalEnvironmentId());
+ assertEquals( "EMOE-001", activateVnf.getAAIOperationalEnvironment(operationalEnvironmentId).asBean(OperationalEnvironment.class).get().getOperationalEnvironmentId());
}
@@ -138,7 +139,7 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{
jsonObject.put("distributionId", sdcDistributionId);
stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED)));
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironmentWithRelationship.json").withStatus(HttpStatus.SC_ACCEPTED)));
stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
activateVnf.execute(requestId, request);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java
index 100bc82f7a..ac274dc8dc 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java
@@ -32,11 +32,11 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import org.apache.http.HttpStatus;
import org.junit.Before;
import org.junit.Test;
+import org.onap.aai.domain.yang.OperationalEnvironment;
import org.onap.so.apihandlerinfra.BaseTest;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
import org.onap.so.client.aai.AAIVersion;
-import org.onap.so.client.aai.objects.AAIOperationalEnvironment;
import org.onap.so.client.grm.beans.Property;
import org.onap.so.client.grm.beans.ServiceEndPointList;
import org.onap.so.db.request.beans.InfraActiveRequests;
@@ -102,7 +102,7 @@ public class CreateVnfOperationalEnvironmentTest extends BaseTest{
@Test
public void testGetSearchKey() {
createVnfOpEnv.setRequest(request);
- AAIOperationalEnvironment ecompEnv = new AAIOperationalEnvironment();
+ OperationalEnvironment ecompEnv = new OperationalEnvironment();
ecompEnv.setTenantContext("Test");
ecompEnv.setWorkloadContext("ECOMPL_PSL");
assertEquals("Test.ECOMPL_PSL.*", createVnfOpEnv.getSearchKey(ecompEnv));
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/vnfoperenv/ecompOperationalEnvironmentWithRelationship.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/vnfoperenv/ecompOperationalEnvironmentWithRelationship.json
new file mode 100644
index 0000000000..0a34cb385e
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/vnfoperenv/ecompOperationalEnvironmentWithRelationship.json
@@ -0,0 +1,27 @@
+{
+ "operational-environment-id": "EMOE-001",
+ "operational-environment-name": "Test Managing ECOMP Environment",
+ "operational-environment-type": "ECOMP",
+ "operational-environment-status": "ACTIVE",
+ "tenant-context": "Test",
+ "workload-context": "PVT",
+ "resource-version": "1505228226913",
+ "relationship-list": {
+ "relationship": [{
+ "related-to": "operational-environment",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v13/cloud-infrastructure/operational-environments/operational-environment/1dfe7154-eae0-44f2-8e7a-8e5e7882e55d",
+ "relationship-data": [{
+ "relationship-key": "operational-environment.operational-environment-id",
+ "relationship-value": "1dfe7154-eae0-44f2-8e7a-8e5e7882e55d"
+ }
+ ],
+ "related-to-property": [{
+ "property-key": "operational-environment.operational-environment-name",
+ "property-value": "myOpEnv_IST_un577h_0119"
+ }
+ ]
+ }
+ ]
+ }
+} \ No newline at end of file