summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java25
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java5
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json2
-rw-r--r--vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts86
-rw-r--r--vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json2
5 files changed, 89 insertions, 31 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
diff --git a/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts
index 3c53d262f..0075dc240 100644
--- a/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts
@@ -1,3 +1,6 @@
+import * as _ from "lodash";
+import {PropertyPath} from "lodash";
+
describe('Drawing Board: Instantiation Templates', function () {
describe('Instantiation templates ', () => {
@@ -78,30 +81,66 @@ describe('Drawing Board: Instantiation Templates', function () {
});
+ [
+ {desc: "with changes", modifySomeValues: true},
+ {desc: "without changes", modifySomeValues: false},
+ ].forEach((testCase) => {
+
+ it(`Given a stored template - edit service vnf and vfmodule ${testCase.desc} - deploy request should be ${testCase.desc}`, function () {
+
+ loadDrawingBoardWithRecreateMode();
+
+ //edit service
+ cy.openServiceContextMenu();
+ cy.getElementByDataTestsId("context-menu-header-edit-item").click();
+ if (testCase.modifySomeValues) {
+ cy.clearInput("instanceName");
+ cy.typeToInput("instanceName", "different.instance.name");
+ }
+ cy.getElementByDataTestsId('form-set').click();
+
+ // edit vnf
+ editNode("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0");
+ if (testCase.modifySomeValues) {
+ cy.selectPlatformValue('platform');
+ cy.selectDropdownOptionByText("tenant", "CESAR-100-D-spjg61909");
+ }
+ cy.getElementByDataTestsId('form-set').click();
+
+ //edit vf module
+ editNode("node-c5b26cc1-a66f-4b69-aa23-6abc7c647c88-vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0");
+ if (testCase.modifySomeValues) {
+ cy.getElementByDataTestsId('sdncPreLoad').click();
+ }
+ cy.getElementByDataTestsId('form-set').click();
+
+ // Then...
+ let vnfPath = [
+ "vnfs", "vProbe_NC_VNF 0"
+ ];
+ let vfModule_0Path = [
+ ...vnfPath, "vfModules",
+ "vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0",
+ "vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0ahubg",
+ ];
+
+ assertThatBodyFromDeployRequestEqualsToFile(testCase.modifySomeValues ? [
+ {path: ["instanceName"], value: "different.instance.name"},
+ {path: ["existingNames", "vprobe_nc_service_dg_new_si"], value: undefined},
+ {path: ["existingNames", "different.instance.name"], value: ""},
+
+ {path: [...vnfPath, "platformName"], value: "xxx1,platform"},
+ {path: [...vnfPath, "tenantId"], value: "f2f3830e4c984d45bcd00e1a04158a79"},
+
+ {path: [...vfModule_0Path, "sdncPreLoad"], value: true},
+ ] : []);
+ })
- it('Given a stored template - edit service vnf and vfmodule without changes - deploy request should be without changes', function () {
-
- loadDrawingBoardWithRecreateMode();
-
- //open - set edit service
- cy.openServiceContextMenu()
- .getElementByDataTestsId("context-menu-header-edit-item").click()
- .getElementByDataTestsId('form-set').click();
-
- //open - set edit vnf
- editNode("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0")
- .getElementByDataTestsId('form-set').click();
-
- //open - set edit vf
- editNode("node-c5b26cc1-a66f-4b69-aa23-6abc7c647c88-vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0")
- .getElementByDataTestsId('form-set').click();
-
- assertThatBodyFromDeployRequestEqualsToFile();
});
- });
});
});
+});
function loadDrawingBoardWithRecreateMode() {
const serviceModelId = '6cfeeb18-c2b0-49df-987a-da47493c8e38';
@@ -145,17 +184,24 @@ function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd() {
}
-function assertThatBodyFromDeployRequestEqualsToFile() {
+function assertThatBodyFromDeployRequestEqualsToFile(deviationFromExpected: { path: PropertyPath, value: any }[] = []) {
cy.getDrawingBoardDeployBtn().click();
cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/templates__instance_from_template__set_without_modify1.json').then((expectedResult) => {
+ setDeviationInExpected(expectedResult, deviationFromExpected);
cy.deepCompare(xhr.request.body, expectedResult);
});
});
}
+function setDeviationInExpected(expectedResult: any, deviation: { path: PropertyPath; value: any }[]) {
+ for (const caveat of deviation) {
+ _.set(expectedResult, caveat.path, caveat.value);
+ }
+}
+
//We use this function because the deployService() on drawing-board-header.component class
// changes rollbackOnFailure value from string type to boolean.
function convertRollbackOnFailureValueFromStringToBoolean(expectedResult: any) {
diff --git a/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json b/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json
index 42ac805e9..5ac833dca 100644
--- a/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json
+++ b/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json
@@ -80,7 +80,7 @@
"platformName": null,
"trackById": "b0732bed-3ddf-43cc-b193-7f18db84e476",
"isBase": true,
- "volumeGroupName": "xbitestmodulereplace0..XbiTestModuleReplace..base_ocg..module-0_vol"
+ "volumeGroupName": null
}
}
},