aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleCommand.kt61
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java138
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AAIServiceTreeIntegrativeTest.java6
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java5
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java19
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule__payload_to_mso.json (renamed from vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule.json)0
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule_fe_input.json92
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json6
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__payload_to_mso.json54
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__target_newest_service_model.json160
10 files changed, 298 insertions, 243 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleCommand.kt
index 276b00e6f..25373d4ac 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleCommand.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleCommand.kt
@@ -78,23 +78,6 @@ class VfmoduleCommand @Autowired constructor(
return false
}
- private fun planReplaceMyselfRestCall3(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String, testApi: String?): MsoRestCallPlan {
- val serviceInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.SERVICE_INSTANCE_ID)
- val serviceModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.SERVICE_MODEL_INFO)
- val vnfModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.VNF_MODEL_INFO)
- val vnfInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.VNF_INSTANCE_ID)
- val replacePath = asyncInstantiationBL.getVfModuleReplacePath(serviceInstanceId, vnfInstanceId, getRequest().instanceId)
-
- amendModelInfoWithNewestModel(serviceModelInfo, vnfModelInfo, (request as VfModule).modelInfo)
-
- val requestDetailsWrapper = msoRequestBuilder.generateVfModuleInstantiationRequest(
- request as VfModule, serviceModelInfo, serviceInstanceId,vnfModelInfo, vnfInstanceId,null,userId, testApi)
-
- val actionDescription = "replace vfmodule ${request.instanceId}"
-
- return MsoRestCallPlan(HttpMethod.POST, replacePath, Optional.of(requestDetailsWrapper), Optional.of(userId), actionDescription)
- }
-
private fun planReplaceMyselfRestCall(commandParentData: CommandParentData): MsoRestCallPlan {
val newestModel = fetchNewestServiceModel()
@@ -139,19 +122,21 @@ class VfmoduleCommand @Autowired constructor(
private fun newestVfmModelInfo(newestModel: ServiceModel): ModelInfo? {
val vfmModelInfo = getRequest().modelInfo
- val newestVfm = selectVfm(newestModel, vfmModelInfo)
- return toModelInfo(newestVfm)
+ val matchingVfms = selectVfms(newestModel, vfmModelInfo)
+ return toModelInfo(matchingVfms.getOrNull(0))
}
private fun newestVnfModelInfo(newestModel: ServiceModel, commandParentData: CommandParentData): ModelInfo? {
val vnfModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.VNF_MODEL_INFO)
- val newestVnf = selectVnf(newestModel, vnfModelInfo)
- return toModelInfo(newestVnf)
+ val matchingVnfs = selectVnfs(newestModel, vnfModelInfo)
+ return toModelInfo(matchingVnfs.getOrNull(0))
}
- private fun selectVfm(newestModel: ServiceModel, modelInfo: ModelInfo) = newestModel.vfModules[modelInfo.modelCustomizationId]
+ private fun selectVfms(newestModel: ServiceModel, modelInfo: ModelInfo) =
+ newestModel.vfModules.values.filter { it.modelCustomizationName == modelInfo.modelCustomizationName }
- private fun selectVnf(newestModel: ServiceModel, modelInfo: ModelInfo) = newestModel.vnfs[modelInfo.modelCustomizationId]
+ private fun selectVnfs(newestModel: ServiceModel, modelInfo: ModelInfo) =
+ newestModel.vnfs.values.filter { it.modelCustomizationName == modelInfo.modelCustomizationName }
private fun toModelInfo(toBeConverted: VNF?): ModelInfo? = toBeConverted?.let { toModelInfo(it, "vnf") }
@@ -192,42 +177,12 @@ class VfmoduleCommand @Autowired constructor(
targetModelInfo.modelVersionId = toBeConverted.uuid
targetModelInfo.modelInvariantId = toBeConverted.invariantUuid
targetModelInfo.modelVersion = toBeConverted.version
- //targetModelInfo.modelCustomizationId = toBeConverted.customizationUuid
- //targetModelInfo.modelCustomizationName = toBeConverted.modelCustomizationName
targetModelInfo.modelType = "service"
targetModelInfo.modelName = toBeConverted.name
return targetModelInfo
}
- private fun amendModelInfoWithNewestModel(serviceModelInfo: ModelInfo, vnfModelInfo: ModelInfo, vfmModelInfo: ModelInfo) {
- val newestModel = fetchNewestServiceModel()
- val newestService = newestModel.service
-
- val newestVfm = newestModel.vfModules[vfmModelInfo.modelCustomizationId]
- val newestVnf = newestModel.vnfs[vnfModelInfo.modelCustomizationId]
-
- if (!(newestService == null || newestVnf == null || newestVfm == null)) {
-
- serviceModelInfo.modelName = newestService.name
- serviceModelInfo.modelVersionId = newestService.uuid
- serviceModelInfo.modelVersion = newestService.version
-
- vnfModelInfo.modelName = newestVnf.name
- vnfModelInfo.modelVersionId = newestVnf.uuid
- vnfModelInfo.modelVersion = newestVnf.version
- vnfModelInfo.modelCustomizationId = newestVnf.customizationUuid
- vnfModelInfo.modelCustomizationName = newestVnf.modelCustomizationName
-
- vfmModelInfo.modelName = newestVfm.name
- vfmModelInfo.modelVersionId = newestVfm.uuid
- vfmModelInfo.modelVersion = newestVfm.version
- vfmModelInfo.modelCustomizationId = newestVfm.customizationUuid
- vfmModelInfo.modelCustomizationName = newestVfm.modelCustomizationName
- }
- }
-
-
override fun replaceMyself(): Job.JobStatus {
try {
val replaceMyselfCommand = planReplaceMyselfRestCall(commandParentData)
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java b/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java
index fdc416a3b..cd4045b8d 100644
--- a/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java
@@ -25,8 +25,10 @@ import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.joining;
import static net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals;
import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonNodePresent;
import static net.javacrumbs.jsonunit.JsonMatchers.jsonPartEquals;
import static net.javacrumbs.jsonunit.JsonMatchers.jsonPartMatches;
+import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
@@ -56,6 +58,7 @@ import static org.onap.vid.job.Job.JobStatus.RESOURCE_IN_PROGRESS;
import static org.onap.vid.job.Job.JobStatus.STOPPED;
import static org.onap.vid.job.impl.JobSchedulerInitializer.WORKERS_TOPICS;
import static org.onap.vid.model.JobAuditStatus.SourceStatus.VID;
+import static org.onap.vid.testUtils.TestUtils.readJsonResourceFileAsObject;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertTrue;
@@ -67,7 +70,6 @@ import java.io.IOException;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -103,11 +105,8 @@ import org.onap.vid.model.Action;
import org.onap.vid.model.JobAuditStatus;
import org.onap.vid.model.NameCounter;
import org.onap.vid.model.RequestReferencesContainer;
-import org.onap.vid.model.Service;
import org.onap.vid.model.ServiceInfo;
import org.onap.vid.model.ServiceModel;
-import org.onap.vid.model.VNF;
-import org.onap.vid.model.VfModule;
import org.onap.vid.model.serviceInstantiation.BaseResource;
import org.onap.vid.model.serviceInstantiation.InstanceGroup;
import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
@@ -955,7 +954,7 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
RestObject<AsyncRequestStatus> createStatusResponse,
RestObject<AsyncRequestStatus> deleteStatusResponse,
JobStatus expectedJobStatus,
- int getStatusCounter) throws IOException {
+ int getStatusCounter) {
UUID jobUUID = createAndDeleteIntegrationTest("/payload_jsons/VnfGroupCreate1Delete1None1Request.json",
"/serviceInstantiation/v7/instanceGroups",
@@ -992,7 +991,7 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
RestObject<AsyncRequestStatus> createStatusResponse,
RestObject<AsyncRequestStatus> deleteStatusResponse,
JobStatus expectedJobStatus,
- int getStatusCounter) throws IOException {
+ int getStatusCounter) {
createAndDeleteIntegrationTest("/payload_jsons/vnfDelete1Create1Request.json",
"/serviceInstantiation/v7/serviceInstances/f8791436-8d55-4fde-b4d5-72dd2cf13cfb/vnfs",
@@ -1041,7 +1040,7 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
RestObject<AsyncRequestStatus> createStatusResponse,
RestObject<AsyncRequestStatus> deleteStatusResponse,
JobStatus expectedJobStatus,
- int getStatusCounter) throws IOException {
+ int getStatusCounter) {
createAndDeleteIntegrationTest("/payload_jsons/networkDelete1Create1Request.json",
"/serviceInstantiation/v7/serviceInstances/f8791436-8d55-4fde-b4d5-72dd2cf13cfb/networks",
@@ -1062,9 +1061,9 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
RestObject<AsyncRequestStatus> createStatusResponse,
RestObject<AsyncRequestStatus> deleteStatusResponse,
JobStatus expectedJobStatus,
- int getStatusCounter) throws IOException {
+ int getStatusCounter) {
UUID jobUUID = asyncInstantiationBL.pushBulkJob(
- TestUtils.readJsonResourceFileAsObject(payload, ServiceInstantiation.class), "userId")
+ readJsonResourceFileAsObject(payload, ServiceInstantiation.class), "userId")
.get(0);
when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), eq(createPath), any())).thenReturn(createResponse);
@@ -1086,7 +1085,7 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
}
@Test
- public void whenCreateTransportService_thanExpectedPre1806MacroRequestSent() throws IOException {
+ public void whenCreateTransportService_thanExpectedPre1806MacroRequestSent() {
UUID jobUUID = asyncInstantiationBL.pushBulkJob(generatePre1806MacroTransportServiceInstantiationPayload(null, null),"az2016").get(0);
RestObject<RequestReferencesContainer> createResponse = createResponseRandomIds(202);
@@ -1096,7 +1095,7 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
.thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
processJobsCountTimesAndAssertStatus(jobUUID, 20, COMPLETED);
- JsonNode expectedJson = TestUtils.readJsonResourceFileAsObject("/payload_jsons/pre_1806_macro_without_cloudConfiguration.json", JsonNode.class);
+ JsonNode expectedJson = readJsonResourceFileAsObject("/payload_jsons/pre_1806_macro_without_cloudConfiguration.json", JsonNode.class);
ArgumentCaptor<RequestDetailsWrapper> requestCaptor = ArgumentCaptor.forClass(RequestDetailsWrapper.class);
verify(restMso).restCall(any(), any(), requestCaptor.capture(), any(), any());
requestCaptor.getAllValues().forEach(x->assertJsonEquals(expectedJson, x));
@@ -1184,7 +1183,7 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
}
@Test
- public void whenResumeService_thanExpectedResumeRequestSent() throws IOException {
+ public void whenResumeService_thanExpectedResumeRequestSent() {
String instanceId = "a565e6ad-75d1-4493-98f1-33234b5c17e2"; //from feRequestResumeMacroService.json
String originalRequestId = "894089b8-f7f4-418d-81da-34186fd32670"; //from msoResponseGetRequestsOfServiceInstance.json
String resumeRequestId = randomUuid();
@@ -1218,15 +1217,15 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
}
@Test
- public void givenResumeRequest_whenMsoReturnBadResponse_thanJobIsFailed() throws IOException {
+ public void givenResumeRequest_whenMsoReturnBadResponse_thanJobIsFailed() {
//there is no mocks for restMSO which means restMso return bad response...
UUID jobUUID = asyncInstantiationBL.pushBulkJob(generateResumeMacroPayload(), "abc").get(0);
processJobsCountTimesAndAssertStatus(jobUUID, 20, FAILED);
}
@NotNull
- private RestObject<AsyncRequestStatusList> createAsyncRequestStatusListByInstanceId() throws IOException {
- AsyncRequestStatusList asyncRequestStatusList = TestUtils.readJsonResourceFileAsObject(
+ private RestObject<AsyncRequestStatusList> createAsyncRequestStatusListByInstanceId() {
+ AsyncRequestStatusList asyncRequestStatusList = readJsonResourceFileAsObject(
"/payload_jsons/resume/msoResponseGetRequestsOfServiceInstance.json",
AsyncRequestStatusList.class);
RestObject<AsyncRequestStatusList> getRequestByIdResponse = new RestObject<>();
@@ -1235,96 +1234,79 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
return getRequestByIdResponse;
}
- private ServiceInstantiation generateResumeMacroPayload() throws IOException {
- return TestUtils.readJsonResourceFileAsObject("/payload_jsons/resume/feRequestResumeMacroService.json", ServiceInstantiation.class);
+ private ServiceInstantiation generateResumeMacroPayload() {
+ return readJsonResourceFileAsObject("/payload_jsons/resume/feRequestResumeMacroService.json", ServiceInstantiation.class);
}
@Test
- public void whenUpgradingAvfModule_thanExpectedReplaceRequestSent() throws IOException, AsdcCatalogException {
- String instanceId = "5d49c3b1-fc90-4762-8c98-e800170baa55"; //from replace_vfmodule_fe_input.json
+ public void whenUpgradingVfModule_thenExpectedReplaceRequestSent() throws AsdcCatalogException {
+ String currentServiceInstanceId = "6196ab1f-2349-4b32-9b6c-cffeb0ccc79c";
+ String currentVnfInstanceId = "d520268f-7489-4662-be59-f81495b3a069";
+ String currentVfModuleInstanceId = "b0732bed-3ddf-43cc-b193-7f18db84e476";
+
+ assertTestPayloadFitsExpectedIds(upgradeVfModulePayload(), currentServiceInstanceId, currentVnfInstanceId, currentVfModuleInstanceId);
+
String replaceRequestId = randomUuid();
String userId = "az2016";
+ String modelInvariantId = "b3a1a119-dede-4ed0-b077-2a617fa519a3";
+ String newestModelUuid = "d9a5b318-187e-476d-97f7-a15687a927a9";
- //prepare mocks for newest model
- String newestModelUuid = "newest-model-uuid";
- when(commandUtils.getNewestModelUuid(eq("b16a9398-ffa3-4041-b78c-2956b8ad9c7b"))).thenReturn(newestModelUuid);
+ String expectedMsoReplacePath = "/serviceInstantiation/v7/serviceInstances/"
+ + currentServiceInstanceId + "/vnfs/" + currentVnfInstanceId + "/vfModules/" + currentVfModuleInstanceId + "/replace";
- when(commandUtils.getServiceModel(eq(newestModelUuid))).thenReturn(generateMockLatestModelForUpgrade());
-
- //prepare mocks resume request
- when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), eq("/serviceInstantiation/v7/serviceInstances/e9993045-cc96-4f3f-bf9a-71b2a400a956/vnfs/5c9c2896-1fe6-4055-b7ec-d0a01e5f9bf5/vfModules/5d49c3b1-fc90-4762-8c98-e800170baa55/replace"), eq(Optional.of(userId))))
- .thenReturn(createResponse(202, instanceId, replaceRequestId));
+ when(commandUtils.getNewestModelUuid(eq(modelInvariantId))).thenReturn(newestModelUuid);
+ when(commandUtils.getServiceModel(eq(newestModelUuid))).thenReturn(newestServiceModel());
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), eq(expectedMsoReplacePath), eq(Optional.of(userId))))
+ .thenReturn(createResponse(202, currentVfModuleInstanceId, replaceRequestId));
when(restMso.GetForObject(eq("/orchestrationRequests/v7/" + replaceRequestId), eq(AsyncRequestStatus.class)))
.thenReturn(asyncRequestStatusResponseAsRestObject(IN_PROGRESS_STR),
asyncRequestStatusResponseAsRestObject(IN_PROGRESS_STR),
asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
- ///orchestrationRequests/v7/0174b25a-dd81-45b7-b4af-0057bcc30857
-
when(featureManager.isActive(Features.FLAG_ASYNC_ALACARTE_VFMODULE)).thenReturn(true);
enableAddCloudOwnerOnMsoRequest();
- UUID jobUUID = asyncInstantiationBL.pushBulkJob(generateReplaceVfModulePayload(), userId).get(0);
- processJobsCountTimesAndAssertStatus(jobUUID, 20, COMPLETED);
+ UUID jobUUID = asyncInstantiationBL.pushBulkJob(upgradeVfModulePayload(), userId).get(0);
+ processJobsCountTimesAndAssertStatus(jobUUID, 20, COMPLETED);
- JsonNode expectedJson = TestUtils.readJsonResourceFileAsObject("/payload_jsons/vfmodule/replace_vfmodule.json", JsonNode.class);
ArgumentCaptor<RequestDetailsWrapper> requestCaptor = ArgumentCaptor.forClass(RequestDetailsWrapper.class);
- verify(restMso).restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), requestCaptor.capture(), eq("/serviceInstantiation/v7/serviceInstances/e9993045-cc96-4f3f-bf9a-71b2a400a956/vnfs/5c9c2896-1fe6-4055-b7ec-d0a01e5f9bf5/vfModules/5d49c3b1-fc90-4762-8c98-e800170baa55/replace"), eq(Optional.of(userId)));
- requestCaptor.getAllValues().forEach(x->assertJsonEquals(expectedJson, x));
- }
-
- private ServiceModel generateMockLatestModelForUpgrade() {
- ServiceModel expectedNewestModel = new ServiceModel();
-
-
- VfModule vfm = new VfModule();
- vfm.setModelCustomizationName("newest-model-customization-name-vfm");
- vfm.setCustomizationUuid("newest-model-customization-uuid-vfm");
- vfm.setVersion("newest-model-version-vfm");
- vfm.setUuid("newest-model-uuid-vfm");
- vfm.setName("newest-model-name-vfm");
- vfm.setInvariantUuid("f7a867f2-596b-4f4a-a128-421e825a6190");
-
-
- Map<String,VfModule> vfms = new HashMap<>();
- vfms.put("074c64d0-7e13-4bcc-8bdb-ea922331102d", vfm);
-
-
- VNF vnf = new VNF();
- vnf.setModelCustomizationName("newest-model-customization-name-vnf");
- vnf.setCustomizationUuid("newest-model-customization-uuid-vnf");
- vnf.setVersion("newest-model-version-vnf");
- vnf.setUuid("newest-model-uuid-vnf");
- vnf.setName("newest-model-name-vnf");
- vnf.setInvariantUuid("23122c9b-dd7f-483f-bf0a-e069303db2f7");
- vnf.setVfModules(vfms);
- expectedNewestModel.setVfModules(vfms);
-
- Map<String,VNF> vnfs = new HashMap<>();
- vnfs.put("96c23a4a-6887-4b2c-9cce-1e4ea35eaade", vnf);
-
- Service svc = new Service();
- svc.setInvariantUuid("b16a9398-ffa3-4041-b78c-2956b8ad9c7b");
- svc.setUuid("newest-model-uuid-service");
- svc.setVersion("newest-model-version-service");
- svc.setName("newest-model-name-service");
-
- expectedNewestModel.setService(svc);
-
- expectedNewestModel.setVnfs(vnfs);
+ verify(restMso, times(1)).restCall(
+ eq(HttpMethod.POST),
+ eq(RequestReferencesContainer.class),
+ requestCaptor.capture(),
+ eq(expectedMsoReplacePath),
+ eq(Optional.of(userId))
+ );
- return expectedNewestModel;
+ JsonNode expectedPayloadToMso = readJsonResourceFileAsObject("/payload_jsons/vfmodule/upgrade_vfmodule_e2e__payload_to_mso.json", JsonNode.class);
+ assertThat(requestCaptor.getValue(), jsonEquals(expectedPayloadToMso).when(IGNORING_ARRAY_ORDER));
+ }
+ private void assertTestPayloadFitsExpectedIds(ServiceInstantiation upgradeVfModulePayload, String serviceInstanceId,
+ String vnfInstanceId, String vfModuleInstanceId) {
+ /*
+ Just verifies the test and the input-file are using the same set of instance IDs
+ */
+ assertThat(upgradeVfModulePayload, jsonPartEquals("instanceId", serviceInstanceId));
+ assertThat(upgradeVfModulePayload, jsonNodePresent(
+ "vnfs"
+ + "." + vnfInstanceId
+ + ".vfModules"
+ + ".xbitestmodulereplace0\\.\\.XbiTestModuleReplace\\.\\.base_ocg\\.\\.module-0"
+ + "." + vfModuleInstanceId));
+ }
+ private ServiceModel newestServiceModel() {
+ return readJsonResourceFileAsObject("/payload_jsons/vfmodule/upgrade_vfmodule_e2e__target_newest_service_model.json", ServiceModel.class);
}
- private ServiceInstantiation generateReplaceVfModulePayload() throws IOException {
- return TestUtils.readJsonResourceFileAsObject("/payload_jsons/vfmodule/replace_vfmodule_fe_input.json", ServiceInstantiation.class);
+ private ServiceInstantiation upgradeVfModulePayload() {
+ return readJsonResourceFileAsObject("/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json", ServiceInstantiation.class);
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AAIServiceTreeIntegrativeTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AAIServiceTreeIntegrativeTest.java
index 8c33e7f64..a956468f3 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AAIServiceTreeIntegrativeTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AAIServiceTreeIntegrativeTest.java
@@ -331,11 +331,7 @@ public class AAIServiceTreeIntegrativeTest {
}
private void mockAaiGetCall(String aaiPath, String jsonFilePath) {
- try {
- when(aaiClient.typedAaiRest(URI.create(aaiPath), JsonNode.class, null, HttpMethod.GET, false)).thenReturn(TestUtils.readJsonResourceFileAsObject(jsonFilePath, JsonNode.class));
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
+ when(aaiClient.typedAaiRest(URI.create(aaiPath), JsonNode.class, null, HttpMethod.GET, false)).thenReturn(TestUtils.readJsonResourceFileAsObject(jsonFilePath, JsonNode.class));
}
@Test
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java b/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java
index e28ea304f..a7e2d553d 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java
@@ -86,7 +86,6 @@ import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import org.togglz.core.manager.FeatureManager;
@ContextConfiguration(classes = {DataSourceConfig.class, SystemProperties.class, MockedAaiClientAndFeatureManagerConfig.class})
public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
@@ -611,8 +610,8 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
}
@Test
- public void generateReplaceVfModuleRequest_verifyResultAsExpected() throws IOException {
- String expected = TestUtils.readFileAsString("/payload_jsons/vfmodule/replace_vfmodule.json");
+ public void generateReplaceVfModuleRequest_verifyResultAsExpected() {
+ String expected = TestUtils.readFileAsString("/payload_jsons/vfmodule/replace_vfmodule__payload_to_mso.json");
when(featureManager.isActive(Features.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST)).thenReturn(true);
when(aaiClient.getCloudOwnerByCloudRegionId("regionOne")).thenReturn("irma-aic");
diff --git a/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java b/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java
index 6cdb1bdb3..857221a2a 100644
--- a/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java
+++ b/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java
@@ -150,18 +150,19 @@ public class TestUtils {
}
}
- public static <T> T readJsonResourceFileAsObject(String pathInResource, Class<T> valueType) throws IOException {
+ public static <T> T readJsonResourceFileAsObject(String pathInResource, Class<T> valueType) {
return readJsonResourceFileAsObject(pathInResource, valueType, false);
}
- public static <T> T readJsonResourceFileAsObject(String pathInResource, Class<T> valueType,
- boolean failOnUnknownProperties)
- throws IOException {
- ObjectMapper objectMapper = jacksonObjectMapper()
- .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, failOnUnknownProperties);
- return objectMapper.readValue(
- TestUtils.class.getResource(pathInResource),
- valueType);
+ public static <T> T readJsonResourceFileAsObject(String pathInResource, Class<T> valueType, boolean failOnUnknownProperties) {
+ ObjectMapper objectMapper =
+ jacksonObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, failOnUnknownProperties);
+
+ try {
+ return objectMapper.readValue(TestUtils.class.getResource(pathInResource), valueType);
+ } catch (IOException e) {
+ return ExceptionUtils.rethrow(e);
+ }
}
public static String readFileAsString(String pathInResource) {
diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule__payload_to_mso.json
index 103985c96..103985c96 100644
--- a/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule.json
+++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule__payload_to_mso.json
diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule_fe_input.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule_fe_input.json
deleted file mode 100644
index a31610d49..000000000
--- a/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule_fe_input.json
+++ /dev/null
@@ -1,92 +0,0 @@
-{
- "action": "None_Upgrade",
- "isDirty": true,
- "vnfs": {
- "Vf zolson5bpxmc02092017-VF 0": {
- "vfModules": {
- "VfZrdm5bpxmc02092017Vf..CORNELIUS_base..module-0": {
- "VfZrdm5bpxmc02092017Vf..CORNELIUS_base..module-0-?": {
- "instanceName": "replace_module",
- "instanceId": "5d49c3b1-fc90-4762-8c98-e800170baa55",
- "action": "None_Upgrade",
- "orchStatus": "Create",
- "provStatus": "Prov Status",
- "inMaint": false,
- "rollbackOnFailure": true,
- "lcpCloudRegionId": "regionOne",
- "tenantId": "0422ffb57ba042c0800a29dc85ca70f8",
- "modelInfo": {
- "modelInvariantId": "f7a867f2-596b-4f4a-a128-421e825a6190",
- "modelVersionId": "eb5de6fb-9ecf-4009-b922-fae3a9ae7d46",
- "modelName": "VfZrdm5bpxmc02092017Vf..CORNELIUS_base..module-0",
- "modelVersion": "1",
- "modelCustomizationId": "074c64d0-7e13-4bcc-8bdb-ea922331102d",
- "modelCustomizationName" : "VfZrdm5bpxmc02092017Vf..CORNELIUS_base..module-0",
- "uuid": "eb5de6fb-9ecf-4009-b922-fae3a9ae7d46"
- },
- "uuid": "eb5de6fb-9ecf-4009-b922-fae3a9ae7d46"
- }
- }
- },
- "uuid": "d326f424-2312-4dd6-b7fe-364fadbd1ef5",
- "productFamilyId": "bad955c3-29b2-4a27-932e-28e942cc6480",
- "lcpCloudRegionId": "regionOne",
- "tenantId": "0422ffb57ba042c0800a29dc85ca70f8",
- "lineOfBusiness": "ONAP",
- "platformName": "platform",
- "modelInfo": {
- "modelInvariantId": "23122c9b-dd7f-483f-bf0a-e069303db2f7",
- "modelVersionId": "d326f424-2312-4dd6-b7fe-364fadbd1ef5",
- "modelName": "Vf zolson5bpxmc02092017-VF",
- "modelVersion": "1",
- "modelCustomizationId": "96c23a4a-6887-4b2c-9cce-1e4ea35eaade",
- "modelCustomizationName": "Vf zolson5bpxmc02092017-VF 0",
- "uuid": "d326f424-2312-4dd6-b7fe-364fadbd1ef5"
- },
- "orchStatus": "Created",
- "inMaint": false,
- "rollbackOnFailure": true,
- "instanceId": "5c9c2896-1fe6-4055-b7ec-d0a01e5f9bf5",
- "instanceName": "vnf_of_replace_module",
- "action": "None_Upgrade",
- "legacyRegion": "some legacy region"
- }
- },
- "instanceParams": [],
- "validationCounter": 0,
- "existingNames": {
- "mcankinstancename": ""
- },
- "existingVNFCounterMap": {
- "d326f424-2312-4dd6-b7fe-364fadbd1ef5": 1
- },
- "existingVnfGroupCounterMap": {},
- "existingNetworksCounterMap": {},
- "networks": {},
- "vnfGroups": {},
- "bulkSize": 1,
- "instanceId": "e9993045-cc96-4f3f-bf9a-71b2a400a956",
- "instanceName": "service_of_replace_module",
- "globalSubscriberId": "e433710f-9217-458d-a79d-1c7aff376d89",
- "subscriptionServiceType": "TYLER SILVIA",
- "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
- "productFamilyId": "bad955c3-29b2-4a27-932e-28e942cc6480",
- "lcpCloudRegionId": "regionOne",
- "tenantId": "0422ffb57ba042c0800a29dc85ca70f8",
- "aicZoneId": "NFT1",
- "projectName": "WATKINS",
- "rollbackOnFailure": true,
- "aicZoneName": "NFTJSSSS-NFT1",
- "owningEntityName": "WayneHolland",
- "tenantName": "tenant_name",
- "modelInfo": {
- "modelInvariantId": "b16a9398-ffa3-4041-b78c-2956b8ad9c7b",
- "modelVersionId": "bad955c3-29b2-4a27-932e-28e942cc6480",
- "modelName": "Vf zolson5bpxmc02092017-Service",
- "modelVersion": "1",
- "uuid": "bad955c3-29b2-4a27-932e-28e942cc6480"
- },
- "isALaCarte": true,
- "orchStatus": "Active",
- "testApi": "GR_API"
-} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json
index 477e47bb7..9571a2d13 100644
--- a/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json
+++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json
@@ -37,9 +37,9 @@
"instanceId": "b0732bed-3ddf-43cc-b193-7f18db84e476",
"orchStatus": "Active",
"productFamilyId": null,
- "lcpCloudRegionId": null,
- "tenantId": null,
- "cloudOwner": null,
+ "lcpCloudRegionId": "olson5a",
+ "tenantId": "7ff7b1a4fe954f71ab79d3160ec3eb08",
+ "cloudOwner": "irma-aic",
"modelInfo": {
"modelCustomizationName": "XbiTestModuleReplace..base_ocg..module-0",
"modelCustomizationId": "3f1f0fcb-8a88-4612-a794-3912613ed9e8",
diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__payload_to_mso.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__payload_to_mso.json
new file mode 100644
index 000000000..a9a9eda7d
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__payload_to_mso.json
@@ -0,0 +1,54 @@
+{
+ "requestDetails": {
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "az2016",
+ "instanceName": "PST-VfMod-Replace-5-Vfmod",
+ "suppressRollback": true
+ },
+ "relatedInstanceList": [{
+ "relatedInstance": {
+ "instanceId": "6196ab1f-2349-4b32-9b6c-cffeb0ccc79c",
+ "modelInfo": {
+ "modelType": "service",
+ "modelName": "xbi test module replace",
+ "modelVersion": "2.0",
+ "modelVersionId": "d9a5b318-187e-476d-97f7-a15687a927a9",
+ "modelInvariantId": "b3a1a119-dede-4ed0-b077-2a617fa519a3"
+ }
+ }
+ }, {
+ "relatedInstance": {
+ "instanceId": "d520268f-7489-4662-be59-f81495b3a069",
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelName": "xbi test module replace",
+ "modelVersion": "2.0",
+ "modelVersionId": "b726207d-12ad-4245-90e0-bb9f71824b01",
+ "modelInvariantId": "5626a5ec-7dce-4cc1-b025-bdb7abb2f058",
+ "modelCustomizationId": "b2fea30c-3794-44c1-9d62-1103319a4c44",
+ "modelCustomizationName": "xbi test module replace 0"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "userParams": [],
+ "testApi": "VNF_API"
+ },
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "XbiTestModuleReplace..base_ocg..module-0",
+ "modelVersion": "1",
+ "modelVersionId": "04b21d26-9780-4956-8329-b22b049329f4",
+ "modelInvariantId": "d887658e-2a89-4baf-83e2-b189601a1a7c",
+ "modelCustomizationId": "51f9acf5-4ab3-4041-bb0d-b022e747dc6b",
+ "modelCustomizationName": "XbiTestModuleReplace..base_ocg..module-0"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "olson5a",
+ "cloudOwner": "irma-aic",
+ "tenantId": "7ff7b1a4fe954f71ab79d3160ec3eb08"
+ }
+ }
+}
diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__target_newest_service_model.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__target_newest_service_model.json
new file mode 100644
index 000000000..6d2ec3a30
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__target_newest_service_model.json
@@ -0,0 +1,160 @@
+{
+ "service": {
+ "uuid": "d9a5b318-187e-476d-97f7-a15687a927a9",
+ "invariantUuid": "b3a1a119-dede-4ed0-b077-2a617fa519a3",
+ "name": "xbi test module replace",
+ "version": "2.0",
+ "toscaModelURL": null,
+ "category": "Emanuel",
+ "serviceType": "",
+ "serviceRole": "",
+ "description": "test module replacement feature",
+ "serviceEcompNaming": "true",
+ "instantiationType": "A-La-Carte",
+ "inputs": {},
+ "vidNotions": {
+ "instantiationUI": "legacy",
+ "modelCategory": "other",
+ "viewEditUI": "legacy",
+ "instantiationType": "ALaCarte"
+ }
+ },
+ "vnfs": {
+ "xbi test module replace 0": {
+ "uuid": "b726207d-12ad-4245-90e0-bb9f71824b01",
+ "invariantUuid": "5626a5ec-7dce-4cc1-b025-bdb7abb2f058",
+ "description": "VSP for testing module replacement feature",
+ "name": "xbi test module replace",
+ "version": "2.0",
+ "customizationUuid": "b2fea30c-3794-44c1-9d62-1103319a4c44",
+ "inputs": {},
+ "commands": {},
+ "properties": {},
+ "type": "VF",
+ "modelCustomizationName": "xbi test module replace 0",
+ "vfModules": {
+ "xbitestmodulereplace0..XbiTestModuleReplace..base_ocg..module-0": {
+ "uuid": "04b21d26-9780-4956-8329-b22b049329f4",
+ "invariantUuid": "d887658e-2a89-4baf-83e2-b189601a1a7c",
+ "customizationUuid": "51f9acf5-4ab3-4041-bb0d-b022e747dc6b",
+ "description": null,
+ "name": "XbiTestModuleReplace..base_ocg..module-0",
+ "version": "1",
+ "modelCustomizationName": "XbiTestModuleReplace..base_ocg..module-0",
+ "properties": {
+ "minCountInstances": 1,
+ "maxCountInstances": 1,
+ "initialCount": 1,
+ "vfModuleLabel": "base_ocg",
+ "baseModule": true
+ },
+ "inputs": {},
+ "volumeGroupAllowed": false
+ },
+ "xbitestmodulereplace0..XbiTestModuleReplace..ocgmgr..module-1": {
+ "uuid": "17dc819b-6cae-40e6-aea0-3afb856646f6",
+ "invariantUuid": "9fe2a0bb-e1e2-4dfd-9566-a7dfc3adc07d",
+ "customizationUuid": "73b88d25-b8e9-41bc-bba5-18c9b07750a3",
+ "description": null,
+ "name": "XbiTestModuleReplace..ocgmgr..module-1",
+ "version": "1",
+ "modelCustomizationName": "XbiTestModuleReplace..ocgmgr..module-1",
+ "properties": {
+ "minCountInstances": 0,
+ "maxCountInstances": null,
+ "initialCount": 0,
+ "vfModuleLabel": "ocgmgr",
+ "baseModule": false
+ },
+ "inputs": {},
+ "volumeGroupAllowed": true
+ }
+ },
+ "volumeGroups": {
+ "xbitestmodulereplace0..XbiTestModuleReplace..ocgmgr..module-1": {
+ "uuid": "17dc819b-6cae-40e6-aea0-3afb856646f6",
+ "invariantUuid": "9fe2a0bb-e1e2-4dfd-9566-a7dfc3adc07d",
+ "customizationUuid": "73b88d25-b8e9-41bc-bba5-18c9b07750a3",
+ "description": null,
+ "name": "XbiTestModuleReplace..ocgmgr..module-1",
+ "version": "1",
+ "modelCustomizationName": "XbiTestModuleReplace..ocgmgr..module-1",
+ "properties": {
+ "minCountInstances": 0,
+ "maxCountInstances": null,
+ "initialCount": 0,
+ "vfModuleLabel": "ocgmgr",
+ "baseModule": false
+ },
+ "inputs": {}
+ }
+ },
+ "vfcInstanceGroups": {}
+ }
+ },
+ "networks": {},
+ "collectionResources": {},
+ "configurations": {},
+ "fabricConfigurations": {},
+ "serviceProxies": {},
+ "vfModules": {
+ "xbitestmodulereplace0..XbiTestModuleReplace..base_ocg..module-0": {
+ "uuid": "04b21d26-9780-4956-8329-b22b049329f4",
+ "invariantUuid": "d887658e-2a89-4baf-83e2-b189601a1a7c",
+ "customizationUuid": "51f9acf5-4ab3-4041-bb0d-b022e747dc6b",
+ "description": null,
+ "name": "XbiTestModuleReplace..base_ocg..module-0",
+ "version": "1",
+ "modelCustomizationName": "XbiTestModuleReplace..base_ocg..module-0",
+ "properties": {
+ "minCountInstances": 1,
+ "maxCountInstances": 1,
+ "initialCount": 1,
+ "vfModuleLabel": "base_ocg",
+ "baseModule": true
+ },
+ "inputs": {},
+ "volumeGroupAllowed": false
+ },
+ "xbitestmodulereplace0..XbiTestModuleReplace..ocgmgr..module-1": {
+ "uuid": "17dc819b-6cae-40e6-aea0-3afb856646f6",
+ "invariantUuid": "9fe2a0bb-e1e2-4dfd-9566-a7dfc3adc07d",
+ "customizationUuid": "73b88d25-b8e9-41bc-bba5-18c9b07750a3",
+ "description": null,
+ "name": "XbiTestModuleReplace..ocgmgr..module-1",
+ "version": "1",
+ "modelCustomizationName": "XbiTestModuleReplace..ocgmgr..module-1",
+ "properties": {
+ "minCountInstances": 0,
+ "maxCountInstances": null,
+ "initialCount": 0,
+ "vfModuleLabel": "ocgmgr",
+ "baseModule": false
+ },
+ "inputs": {},
+ "volumeGroupAllowed": true
+ }
+ },
+ "volumeGroups": {
+ "xbitestmodulereplace0..XbiTestModuleReplace..ocgmgr..module-1": {
+ "uuid": "17dc819b-6cae-40e6-aea0-3afb856646f6",
+ "invariantUuid": "9fe2a0bb-e1e2-4dfd-9566-a7dfc3adc07d",
+ "customizationUuid": "73b88d25-b8e9-41bc-bba5-18c9b07750a3",
+ "description": null,
+ "name": "XbiTestModuleReplace..ocgmgr..module-1",
+ "version": "1",
+ "modelCustomizationName": "XbiTestModuleReplace..ocgmgr..module-1",
+ "properties": {
+ "minCountInstances": 0,
+ "maxCountInstances": null,
+ "initialCount": 0,
+ "vfModuleLabel": "ocgmgr",
+ "baseModule": false
+ },
+ "inputs": {}
+ }
+ },
+ "pnfs": {},
+ "vnfGroups": {},
+ "vrfs": {}
+}