aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common
diff options
context:
space:
mode:
authorAmichai Hemli <amichai.hemli@intl.att.com>2019-11-25 08:45:29 +0000
committerGerrit Code Review <gerrit@onap.org>2019-11-25 08:45:29 +0000
commitd8f8033a6e6f5a8d724d4b94c4056d2660cc34f1 (patch)
tree059d72f67a7d1999297ccec2f01aba1e334a70ef /vid-app-common
parentc503cc0b974566128952084c7ea53134dc984403 (diff)
parent58c6808ac71bf5f771345e305b6d27e77af88780 (diff)
Merge "Replace vfmodule: expect optional retainAssignments param"
Diffstat (limited to 'vid-app-common')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/MsoRequestBuilder.kt3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java14
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleOrVolumeGroupRequestDetails.kt1
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java4
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java8
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java16
6 files changed, 33 insertions, 13 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/MsoRequestBuilder.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/MsoRequestBuilder.kt
index ecf7fc933..c392d0758 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/MsoRequestBuilder.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/MsoRequestBuilder.kt
@@ -140,7 +140,8 @@ class MsoRequestBuilder
vgInstanceId: String?, userId: String, testApi: String?
): RequestDetailsWrapper<VfModuleOrVolumeGroupRequestDetails> {
val requestParameters = { userParams: List<UserParamTypes> ->
- RequestParametersVfModuleUpgrade(userParams, vfModuleDetails.isUsePreload, testApi, nullSafeNegate(vfModuleDetails.isRetainVolumeGroups))
+ RequestParametersVfModuleUpgrade(userParams, vfModuleDetails.isUsePreload, testApi,
+ vfModuleDetails.isRetainAssignments, nullSafeNegate(vfModuleDetails.isRetainVolumeGroups))
}
return generateVfModuleRequestWithRequestParams(vfModuleDetails, serviceModelInfo, serviceInstanceId,
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java
index 5c847b87c..ad5b39e28 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java
@@ -44,9 +44,11 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
private Map<String, String> supplementaryParams;
@JsonInclude(NON_NULL)
- @Nullable
private final Boolean retainVolumeGroups;
+ @JsonInclude(NON_NULL)
+ private Boolean retainAssignments;
+
public VfModule(@JsonProperty("modelInfo") ModelInfo modelInfo,
@JsonProperty("instanceName") String instanceName,
@JsonProperty("volumeGroupName") String volumeGroupInstanceName,
@@ -62,13 +64,15 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
@JsonProperty("trackById") String trackById,
@JsonProperty("isFailed") Boolean isFailed,
@JsonProperty("statusMessage") String statusMessage,
- @JsonProperty("retainVolumeGroups") Boolean retainVolumeGroups,
+ @Nullable @JsonProperty("retainAssignments") Boolean retainAssignments,
+ @Nullable @JsonProperty("retainVolumeGroups") Boolean retainVolumeGroups,
@JsonProperty("position") Integer position) {
super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage,
position);
this.volumeGroupInstanceName = volumeGroupInstanceName;
this.usePreload = usePreload;
this.supplementaryParams = supplementaryParams;
+ this.retainAssignments = retainAssignments;
this.retainVolumeGroups = retainVolumeGroups;
}
@@ -101,6 +105,11 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
}
@Nullable
+ public Boolean isRetainAssignments() {
+ return retainAssignments;
+ }
+
+ @Nullable
public Boolean isRetainVolumeGroups() {
return retainVolumeGroups;
}
@@ -122,6 +131,7 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
this.getTrackById(),
this.getIsFailed(),
this.getStatusMessage(),
+ this.isRetainAssignments(),
this.isRetainVolumeGroups(),
this.getPosition());
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleOrVolumeGroupRequestDetails.kt b/vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleOrVolumeGroupRequestDetails.kt
index f4318719d..bba4081dd 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleOrVolumeGroupRequestDetails.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleOrVolumeGroupRequestDetails.kt
@@ -117,6 +117,7 @@ class RequestParametersVfModuleUpgrade(
userParams: List<UserParamTypes>,
usePreload: Boolean?,
testApi: String?,
+ @get:JsonInclude(NON_NULL) val retainAssignments: Boolean?,
@get:JsonInclude(NON_NULL) val rebuildVolumeGroups: Boolean?
) : RequestParametersVfModuleOrVolumeGroup(userParams, usePreload, testApi)
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java
index 525acf944..db856d757 100644
--- a/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java
@@ -319,8 +319,8 @@ public class ResourceCommandTest {
}
static VfModule createVfModule(Action action) {
- return new VfModule(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, false, false, null, null, null, null,
- null, null);
+ return new VfModule(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null,
+ false, false, null, null, null, null, null, null, null);
}
static Network createNetwork(Action action) {
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
index d6af2ad25..d1b76df77 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
@@ -172,12 +172,12 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
vfModuleInfo.setModelVersion("10.0");
return new VfModule(vfModuleInfo, instanceName, volumeGroupInstanceName, Action.Create.name(), "mdt1", null,
"88a6ca3ee0394ade9403f075db23167e", instanceParams, supplementaryParams, false, true, null, UUID.randomUUID().toString(), null, null,
- null, null);
+ null, null, null);
}
return new VfModule(vfModuleInfo, instanceName, volumeGroupInstanceName, Action.Create.name(), null, null, null,
instanceParams, supplementaryParams, false, false, null, UUID.randomUUID().toString(), null,
- null, null, null);
+ null, null, null, null);
}
protected ModelInfo createVfModuleModelInfo(String modelName, String modelVersion, String modelVersionId, String modelInvariantId, String modelCustomizationId, String modelCustomizationName) {
@@ -185,9 +185,9 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
}
protected VfModule createVfModuleForReplace(ModelInfo vfModuleModelInfo, String instanceName,
- String lcpCloudRegionId, String tenantId, Boolean retainVolumeGroups) {
+ String lcpCloudRegionId, String tenantId, Boolean retainAssignments, Boolean retainVolumeGroups) {
return new VfModule( vfModuleModelInfo, instanceName, null, Action.Upgrade.name(), lcpCloudRegionId, null, tenantId,
- null, null, true, null, null, UUID.randomUUID().toString(), null, null, retainVolumeGroups, null);
+ null, null, true, null, null, UUID.randomUUID().toString(), null, null, retainAssignments, retainVolumeGroups, null);
}
protected ModelInfo createVnfModelInfo(boolean isAlacarte) {
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 059e2e9db..d2370af5e 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
@@ -611,24 +611,32 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
assertThat(result, jsonEquals(expected).when(IGNORING_ARRAY_ORDER));
}
+ @Test(dataProvider = "trueAndFalse", dataProviderClass = TestUtils.class)
+ public void generateReplaceVfModuleRequest_whenRetainAssignmentsProvidedFromFrontend_retainAssignmentsToMsoIsTheSame(boolean retainAssignments) {
+
+ assertThat(generatedVfModuleReplaceRequest(retainAssignments, null),
+ jsonPartEquals("requestDetails.requestParameters.retainAssignments", retainAssignments));
+ }
+
@Test
public void generateReplaceVfModuleRequest_whenRetainVolumeGroupIsTrue_rebuildVolumeGroupIsFalse() {
boolean retainVolumeGroups = true;
- assertThat(generatedVfModuleReplaceRequest(retainVolumeGroups),
+ assertThat(generatedVfModuleReplaceRequest(null, retainVolumeGroups),
jsonPartEquals("requestDetails.requestParameters.rebuildVolumeGroups", false));
}
@Test
public void generateReplaceVfModuleRequest_verifyResultAsExpected() {
Boolean retainVolumeGroups = null;
+ Boolean retainAssignments = null;
String expected = TestUtils.readFileAsString("/payload_jsons/vfmodule/replace_vfmodule__payload_to_mso.json");
- assertThat(generatedVfModuleReplaceRequest(retainVolumeGroups), jsonEquals(expected).when(IGNORING_ARRAY_ORDER));
+ assertThat(generatedVfModuleReplaceRequest(retainAssignments, retainVolumeGroups), jsonEquals(expected).when(IGNORING_ARRAY_ORDER));
}
private RequestDetailsWrapper<VfModuleOrVolumeGroupRequestDetails> generatedVfModuleReplaceRequest(
- Boolean retainVolumeGroups) {
+ Boolean retainAssignments, Boolean retainVolumeGroups) {
when(featureManager.isActive(Features.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST)).thenReturn(true);
when(aaiClient.getCloudOwnerByCloudRegionId("regionOne")).thenReturn("irma-aic");
@@ -636,7 +644,7 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
"f7a867f2-596b-4f4a-a128-421e825a6190", "newest-model-customization-uuid-vfm","newest-model-customization-name-vfm" );
VfModule vfModuleDetails = createVfModuleForReplace(vfModuleModelInfo, "replace_module", "regionOne", "0422ffb57ba042c0800a29dc85ca70f8",
- retainVolumeGroups);
+ retainAssignments, retainVolumeGroups);
ModelInfo serviceModelInfo = createServiceModelInfo("newest-model-name-service", "newest-model-version-service", "newest-model-uuid-service", "b16a9398-ffa3-4041-b78c-2956b8ad9c7b", null, null );