diff options
author | Ittay Stern <ittay.stern@att.com> | 2019-12-18 12:56:02 +0200 |
---|---|---|
committer | Ittay Stern <ittay.stern@att.com> | 2019-12-18 13:30:35 +0200 |
commit | 50f08102564af0938a66071af6c1d1fbf6667943 (patch) | |
tree | 866689e98821af2d84df33ca0725d64ebcf77a1f /vid-app-common | |
parent | b9d4788fc441a516e4bdbeef54982362354944da (diff) |
Restore the reference instance of Upgrade's test
Restored file upgrade_vfmodule_e2e__service_instance, and
adjust upgrade_vfmodule_e2e__fe_input_cypress accordingly.
Also hardening MsoRequestBuilderTest to check for every
true/false/null Boolean option.
Issue-ID: VID-603
Change-Id: Ib82afcecaa57cb06896f7175d48aa8d6a314fdfa
Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-app-common')
3 files changed, 22 insertions, 10 deletions
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 cb59129c3..efd9e2b27 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 @@ -22,6 +22,7 @@ package org.onap.vid.services; import static com.google.common.collect.Maps.newHashMap; import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals; +import static net.javacrumbs.jsonunit.JsonMatchers.jsonNodeAbsent; import static net.javacrumbs.jsonunit.JsonMatchers.jsonPartEquals; import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER; import static org.hamcrest.MatcherAssert.assertThat; @@ -47,7 +48,9 @@ import java.util.Map; import java.util.UUID; import java.util.stream.Collectors; import javax.inject.Inject; +import net.javacrumbs.jsonunit.ConfigurableJsonMatcher; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.BooleanUtils; import org.hibernate.SessionFactory; import org.mockito.Mock; import org.mockito.Mockito; @@ -611,19 +614,23 @@ 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) { - + @Test(dataProvider = "trueAndFalseAndNull", dataProviderClass = TestUtils.class) + public void generateReplaceVfModuleRequest_whenRetainAssignmentsProvidedFromFrontend_retainAssignmentsToMsoIsTheSame(Boolean retainAssignments) { assertThat(generatedVfModuleReplaceRequest(retainAssignments, null, null), - jsonPartEquals("requestDetails.requestParameters.retainAssignments", retainAssignments)); + jsonPartEqualsOrUndefined( + "requestDetails.requestParameters.retainAssignments", retainAssignments)); } - @Test - public void generateReplaceVfModuleRequest_whenRetainVolumeGroupIsTrue_rebuildVolumeGroupIsFalse() { - boolean retainVolumeGroups = true; - + @Test(dataProvider = "trueAndFalseAndNull", dataProviderClass = TestUtils.class) + public void generateReplaceVfModuleRequest_whenRetainVolumeGroupIsGiven_rebuildVolumeGroupIsNegated(Boolean retainVolumeGroups) { assertThat(generatedVfModuleReplaceRequest(null, retainVolumeGroups, null), - jsonPartEquals("requestDetails.requestParameters.rebuildVolumeGroups", false)); + jsonPartEqualsOrUndefined("requestDetails.requestParameters.rebuildVolumeGroups", BooleanUtils.negate(retainVolumeGroups))); + } + + private <T> ConfigurableJsonMatcher<T> jsonPartEqualsOrUndefined(String path, Boolean expected) { + return (expected != null) + ? jsonPartEquals(path, expected) + : jsonNodeAbsent(path); } @Test 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 857221a2a..862b8db8f 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 @@ -389,4 +389,9 @@ public class TestUtils { return new Object[][]{{true}, {false}}; } + @DataProvider + public static Object[][] trueAndFalseAndNull() { + return new Boolean[][]{{Boolean.TRUE}, {Boolean.FALSE}, {null}}; + } + } 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 b1c9d9b9a..d215a4331 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 @@ -59,7 +59,7 @@ "platformName": null, "trackById": "b0732bed-3ddf-43cc-b193-7f18db84e476", "isBase": true, - "volumeGroupName": "xbitestmodulereplace0..XbiTestModuleReplace..base_ocg..module-0_vol", + "volumeGroupName": null, "supplementaryFile": null, "supplementaryFile_hidden": null, "supplementaryFile_hidden_content" : null |