summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2020-02-09 16:33:23 +0000
committerGerrit Code Review <gerrit@onap.org>2020-02-09 16:33:23 +0000
commit5f441ea7520e585dd53f118b799626d53eb2d924 (patch)
tree52c03c3652d74b22df3dfe16309108f143b40a1a /vid-webpack-master
parent6aa7736f462384347108732018f8a1dd3b4c4da8 (diff)
parentd5de1ecc4aa6b626add001ce156b7dddf2943631 (diff)
Merge "remove lcpCloudRegionId, legacyRegion an tenantId from VFModule"
Diffstat (limited to 'vid-webpack-master')
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts85
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts12
2 files changed, 39 insertions, 58 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 49deb3a50..154c60f9e 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
@@ -4,7 +4,7 @@ import {NgRedux} from '@angular-redux/store';
import {ControlGeneratorUtil, SDN_C_PRE_LOAD} from "../control.generator.util.service";
import {AaiService} from "../../../../services/aaiService/aai.service";
import {GenericFormService} from "../../generic-form.service";
-import {FormBuilder, FormControl, FormGroup} from "@angular/forms";
+import {FormBuilder} from "@angular/forms";
import {LogService} from "../../../../utils/log/log.service";
import {
FormControlModel,
@@ -12,12 +12,14 @@ import {
ValidatorOptions
} from "../../../../models/formControlModels/formControl.model";
import {FormControlNames, VfModuleControlGenerator} from "./vfModule.control.generator";
-import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
+import {FeatureFlagsService, Features} from "../../../../services/featureFlag/feature-flags.service";
import {VfModuleInstance} from "../../../../models/vfModuleInstance";
import {VfModule} from "../../../../models/vfModule";
import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
import {AppState} from "../../../../store/reducers";
import {SharedTreeService} from "../../../../../drawingBoard/service-planning/objectsToTree/shared.tree.service";
+import {instance, mock, when} from "ts-mockito";
+import each from "jest-each";
class MockAppStore<T> {
getState() {
@@ -921,6 +923,8 @@ describe('VFModule Control Generator', () => {
let service: VfModuleControlGenerator;
let httpMock: HttpTestingController;
let store : NgRedux<AppState>;
+ let mockFeatureFlagsService: FeatureFlagsService = mock(FeatureFlagsService);
+
beforeAll(done => (async () => {
TestBed.configureTestingModule({
@@ -933,7 +937,7 @@ describe('VFModule Control Generator', () => {
FormBuilder,
LogService,
SharedTreeService,
- {provide:FeatureFlagsService, useClass: MockFeatureFlagsService},
+ {provide: FeatureFlagsService, useValue: instance(mockFeatureFlagsService)},
{provide: NgRedux, useClass: MockAppStore}]
});
await TestBed.compileComponents();
@@ -946,6 +950,23 @@ describe('VFModule Control Generator', () => {
})().then(done).catch(done.fail));
+ let formControlsWithoutLcpRegionTenantLegacy : string[] =
+ [FormControlNames.INSTANCE_NAME,
+ FormControlNames.VOLUME_GROUP_NAME,
+ FormControlNames.ROLLBACK_ON_FAILURE,
+ SDN_C_PRE_LOAD,];
+
+ let formControlsWithLcpRegionTenantLegacy : string[] =
+ [FormControlNames.INSTANCE_NAME,
+ FormControlNames.VOLUME_GROUP_NAME,
+ FormControlNames.LCPCLOUD_REGION_ID,
+ FormControlNames.LEGACY_REGION,
+ FormControlNames.TENANT_ID,
+ FormControlNames.ROLLBACK_ON_FAILURE,
+ SDN_C_PRE_LOAD,];
+
+
+
test(' getMacroFormControls gets vnfStoreKey === null', () => {
const serviceId: string = "6e59c5de-f052-46fa-aa7e-2fca9d674c44";
const vnfStoreKey: string = null;
@@ -1058,20 +1079,15 @@ describe('VFModule Control Generator', () => {
expect(console.error).toHaveBeenCalled();
});
- test('getAlaCarteFormControls should return the correct order of controls', () => {
+ each([
+ [true, 4, formControlsWithoutLcpRegionTenantLegacy],
+ [false, 7,formControlsWithLcpRegionTenantLegacy]
+ ]).
+ test('getAlaCarteFormControls should return the correct order of controls', (flag: boolean, controlAmount: number, orderedControls: string[]) => {
+ when(mockFeatureFlagsService.getFlagState(Features.FLAG_2006_VFMODULE_TAKES_TENANT_AND_REGION_FROM_VNF)).thenReturn(flag);
const controls:FormControlModel[] = getAlaCarteFormControls();
- const orderedControls : string[] = [
- FormControlNames.INSTANCE_NAME,
- FormControlNames.VOLUME_GROUP_NAME,
- FormControlNames.LCPCLOUD_REGION_ID,
- FormControlNames.LEGACY_REGION,
- FormControlNames.TENANT_ID,
- FormControlNames.ROLLBACK_ON_FAILURE,
- SDN_C_PRE_LOAD,
- ];
-
- expect(controls.length).toEqual(7);
+ expect(controls.length).toEqual(controlAmount);
for(let i = 0 ; i < orderedControls.length ; i++) {
expect(controls[i].controlName).toEqual(orderedControls[i]);
}
@@ -1093,26 +1109,6 @@ describe('VFModule Control Generator', () => {
return controls;
}
- test('getAlaCarteFormControls responce with wrong order of controls', () => {
- const controls:FormControlModel[] = getAlaCarteFormControls();
-
- const orderedControls : string[] = [
- FormControlNames.INSTANCE_NAME,
- FormControlNames.VOLUME_GROUP_NAME,
- FormControlNames.LCPCLOUD_REGION_ID,
- FormControlNames.TENANT_ID, // TENANT_ID must be after LEGACY_REGION
- FormControlNames.LEGACY_REGION,
- FormControlNames.ROLLBACK_ON_FAILURE,
- SDN_C_PRE_LOAD,
- ];
-
- for(let i = 0 ; i < orderedControls.length ; i++) {
- if (controls[i].controlName === 'legacyRegion') {
- expect(orderedControls[i]).toEqual('tenantId');
- }
- }
- });
-
test('getMacroFormControls should return the correct order of controls', () => {
const serviceId: string = "6e59c5de-f052-46fa-aa7e-2fca9d674c44";
const vnfStoreKey: string = 'VF_vGeraldine 0';
@@ -1149,25 +1145,6 @@ describe('VFModule Control Generator', () => {
expect(instanceNameValidator.validatorArg).toEqual(/^[a-zA-Z0-9._-]*$/);
});
- test(' getAlaCarteFormControls gets null service', () => {
- const controls:FormControlModel[] = getAlaCarteFormControls();
- expect(controls.length).toEqual(7);
-
- const orderedControls : string[] = [
- FormControlNames.INSTANCE_NAME,
- FormControlNames.VOLUME_GROUP_NAME,
- FormControlNames.LCPCLOUD_REGION_ID,
- FormControlNames.LEGACY_REGION,
- FormControlNames.TENANT_ID,
- FormControlNames.ROLLBACK_ON_FAILURE,
- SDN_C_PRE_LOAD,
- ];
-
- for(let i = 0 ; i < orderedControls.length ; i++) {
- expect(controls[i].controlName).toEqual(orderedControls[i]);
- }
- });
-
test('when flag is active - response should contains upload file', ()=>{
spyOn(store, 'getState').and.returnValue( {
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 702181581..b614ecf30 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
@@ -23,6 +23,7 @@ import {SharedControllersService} from "../sharedControlles/shared.controllers.s
import {MessageModal} from "../../../messageModal/message-modal.service";
import {ButtonType} from "../../../customModal/models/button.type";
import {SharedTreeService} from "../../../../../drawingBoard/service-planning/objectsToTree/shared.tree.service";
+import {FeatureFlagsService, Features} from "../../../../services/featureFlag/feature-flags.service";
export enum FormControlNames {
INSTANCE_NAME = 'instanceName',
@@ -47,7 +48,8 @@ export class VfModuleControlGenerator {
private store: NgRedux<AppState>,
private http: HttpClient,
private _aaiService: AaiService,
- private _logService: LogService) {
+ private _logService: LogService,
+ private _featureFlagsService:FeatureFlagsService) {
this.aaiService = _aaiService;
}
@@ -124,9 +126,11 @@ export class VfModuleControlGenerator {
const vfModuleInstance = this._basicControlGenerator.retrieveInstanceIfUpdateMode(this.store, this.getVfModuleInstance(serviceId, vnfStoreKey, uuidData, isUpdateMode));
let result: FormControlModel[] = [];
this.pushInstanceAndVGToForm(result, vfModuleInstance, serviceId, vnfModel, true);
- result.push(this._sharedControllersService.getLcpRegionControl(serviceId, vfModuleInstance, result));
- result.push(this._sharedControllersService.getLegacyRegion(vfModuleInstance));
- result.push(this._sharedControllersService.getTenantControl(serviceId, vfModuleInstance));
+ if( !this._featureFlagsService.getFlagState(Features.FLAG_2006_VFMODULE_TAKES_TENANT_AND_REGION_FROM_VNF)) {
+ result.push(this._sharedControllersService.getLcpRegionControl(serviceId, vfModuleInstance, result));
+ result.push(this._sharedControllersService.getLegacyRegion(vfModuleInstance));
+ result.push(this._sharedControllersService.getTenantControl(serviceId, vfModuleInstance));
+ }
result.push(this._sharedControllersService.getRollbackOnFailureControl(vfModuleInstance));
result.push(this._sharedControllersService.getSDNCControl(vfModuleInstance, this.getSdncExtraContents()));
if (this.store.getState().global.flags['FLAG_SUPPLEMENTARY_FILE']) {