diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-01-31 22:56:35 -0500 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-01-31 22:56:50 -0500 |
commit | 71c4708528c635dcc12575d5e3118e01b32d46cc (patch) | |
tree | a6c4d4b172d353520eb71f2b13a5d1515f95a6b3 /mso-api-handlers/mso-api-handler-infra/src/test/java/org | |
parent | cd0963d829a73dc22b345be12379a2f8dd3a83e8 (diff) |
use OE from AAI with sdc
Updated the SDC API call with the ECOMP OE from AAI relationship
instead of VNF OE value.
Change-Id: I576ed83364f11213f36781c033f7c2d56f98f1c6
Issue-ID: SO-1451
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test/java/org')
4 files changed, 23 insertions, 19 deletions
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)); |