summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src
diff options
context:
space:
mode:
authorAmir Skalka <amir.skalka@intl.att.com>2019-11-06 18:19:16 +0200
committerAmir Skalka <amir.skalka@intl.att.com>2019-11-14 15:28:49 +0200
commit5b00e6be70ccca6fb93080022304e718d10108bc (patch)
treed5c373258542c08a9b2bd7e98aa8c0d28c7cd35a /vid-webpack-master/src
parent31e625a118836d02a95b18ff806903ed23deb25d (diff)
Modify code to take care of missing scenario in US 832
Take under consideration the instance type (Macro/Alacarte) when determining visibility over UI and default value. Refactor tests to include more params to anticipate the visibility and default value. Issue-ID: VID-700 Signed-off-by: Amir Skalka <amir.skalka@intl.att.com> Change-Id: I8dfa2e13fed3f5f863cc979970afc2ac66dbd82f
Diffstat (limited to 'vid-webpack-master/src')
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts42
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts40
2 files changed, 64 insertions, 18 deletions
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts
index 351f8393c..f8a2da711 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts
@@ -13,6 +13,8 @@ import {
} from "../../../../models/formControlModels/formControl.model";
import {FormControlNames, VfModuleControlGenerator} from "./vfModule.control.generator";
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
+import {VfModuleInstance} from "../../../../models/vfModuleInstance";
+import {VfModule} from "../../../../models/vfModule";
class MockAppStore<T> {
getState() {
@@ -978,6 +980,46 @@ describe('VFModule Control Generator', () => {
}
});
+
+ const cases = [
+ [true, true, true, null, true, true],
+ [true, true, false, null, true, false], //Scenario to check that UI field doesn't appear.
+ [false, true, false, "vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0_vol", true, true],
+ [false, true, true, "vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0_vol", true, true],
+ [false, false, true, null, false, false],
+ ];
+
+ test.each(cases)('Given Ecomp Gen Name: %p and VG Name %p , ' +
+ 'is A La Carte %p - expect the name value for VG to be %p , ' +
+ 'VG Name should be defined: %p , and should the field be visible: %p',
+ (ecomGenName, vGName, isALaCarte, expectedName, shouldWeVerifyDefinitionOfField, isVisible) => {
+ const moduleName = "vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0";
+ service.vfModuleModel = new VfModule();
+ service.vfModuleModel.name = moduleName;
+ service.vfModuleModel.volumeGroupAllowed = vGName;
+ let vnf : Object = {isEcompGeneratedNaming: ecomGenName};
+ const serviceId: string = "6e59c5de-f052-46fa-aa7e-2fca9d674c44";
+ const vnfStoreKey: string = 'VF_vGeraldine 0';
+ const uuidData: Object = {
+ modelName : moduleName,
+ vFModuleStoreKey : "vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0vmvzo",
+ };
+ const vfModuleModel :VfModuleInstance = service.getVfModuleInstance(serviceId, vnfStoreKey, uuidData,true);
+ let existingMatchingFieldInForm = buildVfModuleFormControlModel(vfModuleModel ,serviceId, vnf, isALaCarte);
+ if (shouldWeVerifyDefinitionOfField) {
+ expect(existingMatchingFieldInForm).toBeDefined();
+ expect(existingMatchingFieldInForm.value).toEqual(expectedName);
+ expect(existingMatchingFieldInForm.isVisible).toEqual(isVisible);
+ } else {
+ expect(existingMatchingFieldInForm).toBeUndefined();
+ }
+ });
+
+ let buildVfModuleFormControlModel = function(vfModuleModel :any, serviceId: string, vnf, isALaCarte) :FormControlModel {
+ let controls: FormControlModel[] = service.pushInstanceAndVGToForm([], vfModuleModel, serviceId, vnf, isALaCarte);
+ return controls.find(ctrl => ctrl.controlName === FormControlNames.VOLUME_GROUP_NAME);
+ };
+
test('getMacroFormControls check for mandatory controls', () => {
const serviceId: string = "6e59c5de-f052-46fa-aa7e-2fca9d674c44";
const vnfStoreKey: string = 'VF_vGeraldine 0';
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts
index 3012c139c..d939a3d17 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts
@@ -46,7 +46,6 @@ export enum FormControlNames {
export class VfModuleControlGenerator {
aaiService: AaiService;
vfModuleModel: VfModule;
- vfModuleName : string;
isUpdateMode : boolean;
constructor(private genericFormService: GenericFormService,
@@ -63,7 +62,6 @@ export class VfModuleControlGenerator {
const vfModulesKeys = Object.keys(vfModules);
for(let key of vfModulesKeys){
if(vfModules[key].uuid === vfModuleUuid){
- this.vfModuleName = key;
return;
}
}
@@ -105,10 +103,7 @@ export class VfModuleControlGenerator {
let result: FormControlModel[] = [];
if (!_.isNil(vfModuleModel)) {
- result.push(this.getInstanceName(vfModuleInstance, serviceId, vnfModel.isEcompGeneratedNaming));
- if (this.vfModuleModel.volumeGroupAllowed) {
- result.push(this.getVolumeGroupName(vfModuleInstance, serviceId, vnfStoreKey, vfModuleInstance && vfModuleInstance.volumeGroupName, vnfModel.isEcompGeneratedNaming));
- }
+ result = this.pushInstanceAndVGToForm(result, vfModuleInstance, serviceId, vnfModel, false);
}
if(this.store.getState().global.flags['FLAG_SUPPLEMENTARY_FILE']) {
let suppFileInput:FileFormControl = <FileFormControl>(this.getSupplementaryFile(vfModuleInstance));
@@ -118,6 +113,14 @@ export class VfModuleControlGenerator {
return result;
}
+ pushInstanceAndVGToForm(result: FormControlModel[], vfModuleElement: any, serviceId: string, vnfModel: any, isALaCarte: boolean) :FormControlModel[]{
+ result.push(this.getInstanceName(vfModuleElement, serviceId, vnfModel.isEcompGeneratedNaming));
+ if (this.vfModuleModel.volumeGroupAllowed) {
+ result.push(this.getVolumeGroupData(vfModuleElement, serviceId, vnfModel.isEcompGeneratedNaming, isALaCarte));
+ }
+ return result;
+ }
+
getAlaCarteFormControls(serviceId: string, vnfStoreKey: string, vfModuleStoreKey: string, uuidData : Object, isUpdateMode: boolean): FormControlModel[] {
this.isUpdateMode = isUpdateMode;
this.extractVfAccordingToVfModuleUuid(serviceId, uuidData);
@@ -133,11 +136,7 @@ export class VfModuleControlGenerator {
const vfModuleInstance = this.getVfModuleInstance(serviceId, vnfStoreKey, uuidData, isUpdateMode);
let result: FormControlModel[] = [];
- result.push(this.getInstanceName(vfModuleInstance, serviceId, vnfModel.isEcompGeneratedNaming));
-
- if (this.vfModuleModel.volumeGroupAllowed) {
- result.push(this.getVolumeGroupName(vfModuleInstance, serviceId, vnfStoreKey, this.vfModuleName, vnfModel.isEcompGeneratedNaming));
- }
+ this.pushInstanceAndVGToForm(result, vfModuleInstance, serviceId, vnfModel, true);
result.push(this.getLcpRegionControl(serviceId, vfModuleInstance, result));
result.push(this._basicControlGenerator.getLegacyRegion(vfModuleInstance));
result.push(this.getTenantControl(serviceId, vfModuleInstance, result));
@@ -163,17 +162,14 @@ export class VfModuleControlGenerator {
return formControlModel;
}
- getDefaultVolumeGroupName(instance: any, vfModuleName: string, isEcompGeneratedNaming: boolean): string {
- if ((!_.isNil(instance) && instance.volumeGroupName)) {
- return instance.volumeGroupName;
- }
+ getDefaultVolumeGroupName(instance: any, isEcompGeneratedNaming: boolean): string {
if (isEcompGeneratedNaming) {
return null;
}
return this._basicControlGenerator.getDefaultInstanceName(instance, this.vfModuleModel) + "_vol";
}
- getVolumeGroupName(instance: any, serviceId: string, vnfStoreKey: string, vfModuleName: string, isEcompGeneratedNaming: boolean): FormControlModel {
+ getVolumeGroupData(instance: any, serviceId: string, isEcompGeneratedNaming: boolean, isALaCarte: boolean): FormControlModel {
let validations: ValidatorModel[] = [
new ValidatorModel(ValidatorOptions.pattern, 'Instance name may include only alphanumeric characters and underscore.', BasicControlGenerator.INSTANCE_NAME_REG_EX),
new ValidatorModel(CustomValidatorOptions.uniqueInstanceNameValidator, 'Volume Group instance name is already in use, please pick another name', [this.store, serviceId, instance && instance.volumeGroupName])
@@ -190,8 +186,8 @@ export class VfModuleControlGenerator {
validations: validations,
tooltip : 'When filled, VID will create a Volume Group by this name and associate with this module.\n' +
'When empty, the module is created without a Volume Group.',
- isVisible: true,
- value: this.getDefaultVolumeGroupName(instance, vfModuleName, isEcompGeneratedNaming),
+ isVisible: this.shouldVGNameBeVisible(isEcompGeneratedNaming,isALaCarte),
+ value: this.getDefaultVolumeGroupName(instance, isEcompGeneratedNaming),
onKeypress: (event) => {
const pattern:RegExp = BasicControlGenerator.INSTANCE_NAME_REG_EX;
if (pattern) {
@@ -204,6 +200,14 @@ export class VfModuleControlGenerator {
});
}
+ private shouldVGNameBeVisible(isEcompGeneratedNaming: boolean, isALaCarte: boolean) {
+ if((!isALaCarte && !isEcompGeneratedNaming) || isALaCarte){
+ return true;
+ }
+ return false;
+
+ }
+
getSupplementaryFile(instance: any): FormControlModel {
return new FileFormControl({
controlName: FormControlNames.SUPPLEMENTARY_FILE,