import {SharedControllersService} from "../../../shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service";
import {ModalService} from "../../../shared/components/customModal/services/modal.service";
import {CreateDynamicComponentService} from "../../../shared/components/customModal/services/create-dynamic-component.service";
+import { PnfPopupService } from "../../../shared/components/genericFormPopup/genericFormServices/pnf/pnf.popup.service";
class MockAppStore<T> {
getState() {
DefaultDataGeneratorService,
DialogService,
VnfPopupService,
+ PnfPopupService,
ControlGeneratorUtil,
AaiService,
LogService,
let specificNetworkInfo = [
ModelInformationItem.createInstance('Network role', "network role 1, network role 2")
];
- const actualInfoModel: ComponentInfoModel = service.addGeneralInfoItems(specificNetworkInfo,ComponentInfoType.NETWORK, getNetworkModel(),getNetworkInstance());
+ const actualInfoModel: ComponentInfoModel = service.addGeneralInfoItems(specificNetworkInfo,ComponentInfoType.NETWORK, getNetworkModelInfoFromHierarchy(),getNetworkInstance());
let expectedGeneralInfo = [
- ModelInformationItem.createInstance('Model version', '37.0'),
- ModelInformationItem.createInstance('Model customization ID', '94fdd893-4a36-4d70-b16a-ec29c54c184f'),
+ ModelInformationItem.createInstance('Model version', '2.0'),
+ ModelInformationItem.createInstance('Model customization ID', 'customization-id-from-hierarchy'),
ModelInformationItem.createInstance('Instance ID', 'NETWORK4_INSTANCE_ID'),
ModelInformationItem.createInstance('Instance type', 'CONTRAIL30_HIMELGUARD'),
ModelInformationItem.createInstance('In maintenance', false),
expect(actualInfoModel.modelInfoItems).toEqual(expectedGeneralInfo);
});
+ each([
+ ['model version from hierarchy', null, getNetworkModelInfoFromHierarchy(), '2.0'],
+ ['undefined model', null, null, undefined],
+ ['model version from instance', getSelectedModelInfo(), null, '5.0'],
+ ['model version from instance', getSelectedModelInfo(), getNetworkModelInfoFromHierarchy(), '5.0'],
+ ]).
+ test ('getModelVersionEitherFromInstanceOrFromHierarchy should return %s ' ,
+ (description, instance, model, expectedResult) =>{
+ let actualResult = service.getModelVersionEitherFromInstanceOrFromHierarchy(instance, model);
+ expect(actualResult).toEqual(expectedResult);
+ });
+
+ each([
+ ['model CustomizationId from hierarchy', null, getNetworkModelInfoFromHierarchy(), 'customization-id-from-hierarchy'],
+ ['undefined model', null, null, undefined],
+ ['model CustomizationId from instance', getSelectedModelInfo(), null, 'model-customization-id-from-instance'],
+ ['model CustomizationId from instance', getSelectedModelInfo(), getNetworkModelInfoFromHierarchy(), 'model-customization-id-from-instance'],
+ ]).
+ test ('getCustomizationIdEitherFromInstanceOrFromHierarchy should return %s ' ,
+ (description, instance, model, expectedResult) =>{
+ let actualResult = service.getModelCustomizationIdEitherFromInstanceOrFromHierarchy(instance, model);
+ expect(actualResult).toEqual(expectedResult);
+ });
+
+ each([
+ ['UUID from instance', getSelectedModelInfo(), getNetworkModelInfoFromHierarchy(),"UUID-from-instance" ],
+ ['UUID from instance', getSelectedModelInfo(), null,"UUID-from-instance" ],
+ ['UUID from hierarchy', null, getNetworkModelInfoFromHierarchy(),"UUID-from-hierarchy" ],
+ ['UUID undefined', null, null, undefined],
+
+ ]).
+ test('getModelVersionIdEitherFromInstanceOrFromHierarchy should %s', (description, instance, model, expectedResult) => {
+ let actualUuid = service.getModelVersionIdEitherFromInstanceOrFromHierarchy(instance, model);
+ expect(actualUuid).toEqual(expectedResult);
+ });
+
+ each([
+ ['from instance', getSelectedModelInfo(), getNetworkModelInfoFromHierarchy(), 'invariantId-from-instance'],
+ ['from instance', getSelectedModelInfo(), null, 'invariantId-from-instance'],
+ ['from hierarchy', null, getNetworkModelInfoFromHierarchy(), 'invariantId-from-hierarchy'],
+ ['undefined', null, null, undefined],
+ ]).
+ test('getModelInvariantIdEitherFromInstanceOrFromHierarchy should return invariantId %s', (description, instance, model, expectedInvariantId) =>{
+ let actualInvariantId = service.getModelInvariantIdEitherFromInstanceOrFromHierarchy(instance, model);
+ expect(actualInvariantId).toEqual(expectedInvariantId);
+ });
test('statusProperties should be prop on node according to node properties', () => {
- let node = service.addingStatusProperty({orchStatus: 'completed', provStatus: 'inProgress', inMaint: false});
+
+ let node = service.addingStatusProperty({orchStatus: 'completed', provStatus: 'inProgress', type: 'VFmodule', instanceModelInfo:{modelVersion: '1'}, inMaint: false});
expect(node.statusProperties).toBeDefined();
expect(node.statusProperties).toEqual([Object({
- key: 'Prov Status:',
+ key: 'Prov Status: ',
value: 'inProgress',
testId: 'provStatus'
- }), Object({key: 'Orch Status:', value: 'completed', testId: 'orchStatus'})]);
- node = service.addingStatusProperty({orchStatus: 'completed', provStatus: 'inProgress', inMaint: true});
+ }), Object({
+ key: 'Orch Status: ',
+ value: 'completed',
+ testId: 'orchStatus'
+ }),
+ Object({
+ key: 'Model Version: ',
+ value: '1',
+ testId: 'modelVersion'
+ })]);
+ node = service.addingStatusProperty({orchStatus: 'completed', provStatus: 'inProgress',type: 'VFmodule', instanceModelInfo:{}, inMaint: true});
expect(node.statusProperties).toEqual([Object({
- key: 'Prov Status:',
+ key: 'Prov Status: ',
value: 'inProgress',
testId: 'provStatus'
- }), Object({key: 'Orch Status:', value: 'completed', testId: 'orchStatus'}), Object({
+ }), Object({
+ key: 'Orch Status: ',
+ value: 'completed',
+ testId: 'orchStatus'
+ }), Object({
+ key: 'Model Version: ',
+ value: undefined,
+ testId: 'modelVersion'
+ }), Object({
key: 'In-maintenance',
value: '',
testId: 'inMaint'
- })]);
+ })
+]);
+ });
+ each([
+ ['version 2', '2', '2'],
+ ['undefined', null, undefined]
+ ]).
+ test('getNodeModelVersion should return %s', (description, nodeVersion, expectedVersion) => {
+ let node = <any>{
+ instanceModelInfo:{
+ modelVersion: nodeVersion
+ }
+ };
+ let actualVersion = service.getNodeModelVersion(node);
+ expect(actualVersion).toEqual(expectedVersion);
});
each([
[true, false, true, true],
[true, false, false, false],
]).
- test('when flag is %s the UpdatedLatestVersion is %s and Vfmodule CustomizationUuid Differ is %s isShouldShowButtonGenericMustToBeCalled should return %s', (
+ test('when flag is %s the UpdatedLatestVersion is %s and Vfmodule not exists on hierarchy is %s isShouldShowButtonGenericMustToBeCalled should return %s', (
flag: boolean,
isThereAnUpdatedLatestVersion: boolean,
- isVfmoduleAlmostPartOfModelOnlyCustomizationUuidDiffer: boolean,
+ isVfModuleCustomizationIdNotExistsOnModel: boolean,
isShouldShowButtonGenericMustToBeCalled: boolean
) => {
let node = <any> {};
}
});
spyOn(service, 'isThereAnUpdatedLatestVersion').and.returnValue(isThereAnUpdatedLatestVersion);
- spyOn(service, 'isVfmoduleAlmostPartOfModelOnlyCustomizationUuidDiffer').and.returnValue(isVfmoduleAlmostPartOfModelOnlyCustomizationUuidDiffer);
+ spyOn(service, 'isVfModuleCustomizationIdNotExistsOnModel').and.returnValue(isVfModuleCustomizationIdNotExistsOnModel);
expect(service.isVfMoudleCouldBeUpgraded(node, serviceModelId)).toEqual(isShouldShowButtonGenericMustToBeCalled);
});
+ each([
+ ['Vfm customization uuid not exists in model', 'not-existing-customization-uuid', 'service-model-id', true],
+ ['Vfm customization uuid exists in model', 'existing-customization-uuid', 'service-model-id', false]
+ ]).
+ test('%s when vfModuleNode is %s and serviceModelId is %s ', (
+ description,
+ modelCustomizationId,
+ serviceModelId: string,
+ isExistsOnHierarchy: boolean,
+ ) => {
+
+ const vfModuleNode = { data: {
+ modelCustomizationId : modelCustomizationId
+ }};
+
+ jest.spyOn(store, 'getState').mockReturnValue(<any>{
+ service : {
+ "serviceHierarchy": {
+ [serviceModelId]: {
+ "vfModules": {
+ "module-1": {
+ "customizationUuid": "3d7f41c8-333b-4fee-b50d-5687e9c2170f",
+ },
+ "module-2": {
+ "customizationUuid": "existing-customization-uuid",
+ }
+ }
+ }
+ }
+ }
+ });
+ expect(service.isVfModuleCustomizationIdNotExistsOnModel(vfModuleNode, serviceModelId)).toEqual(isExistsOnHierarchy);
+
+
+ });
+
});
function getStore() {
}
}
-function getNetworkModel(){
- return {
- "customizationUuid":"94fdd893-4a36-4d70-b16a-ec29c54c184f",
- "name":"ExtVL",
- "version":"37.0",
- "description":"ECOMP generic virtual link (network) base type for all other service-level and global networks",
- "uuid":"ddc3f20c-08b5-40fd-af72-c6d14636b986",
- "invariantUuid":"379f816b-a7aa-422f-be30-17114ff50b7c",
- "max":1,
- "min":0,
- "isEcompGeneratedNaming":false,
- "type":"VL",
- "modelCustomizationName":"ExtVL 0",
- "roles":["network role 1"," network role 2"],
- "properties":{
- "network_role":"network role 1, network role 2",
- "network_assignments":
- "{is_external_network=false, ipv4_subnet_default_assignment={min_subnets_count=1}, ecomp_generated_network_assignment=false, ipv6_subnet_default_assignment={min_subnets_count=1}}",
- "exVL_naming":"{ecomp_generated_naming=true}","network_flows":"{is_network_policy=false, is_bound_to_vpn=false}",
- "network_homing":"{ecomp_selected_instance_node_target=false}"
- }
- };
+function getNetworkModelInfoFromHierarchy(){
+ return {
+ "version": "2.0",
+ "customizationUuid":"customization-id-from-hierarchy",
+ "uuid": "UUID-from-hierarchy",
+ "invariantUuid": "invariantId-from-hierarchy"
+ }
}
+function getSelectedModelInfo() {
+ return {
+ "instanceModelInfo": {
+ "modelVersion": "5.0",
+ "modelCustomizationId": "model-customization-id-from-instance",
+ "modelVersionId": "UUID-from-instance",
+ "modelInvariantId": "invariantId-from-instance"
+ }
+ }
+}
function getNetworkInstance() {
return {
- "modelCustomizationId": "94fdd893-4a36-4d70-b16a-ec29c54c184f",
- "modelId": "ddc3f20c-08b5-40fd-af72-c6d14636b986",
- "modelUniqueId": "94fdd893-4a36-4d70-b16a-ec29c54c184f",
- "missingData": true,
- "id": "NETWORK4_INSTANCE_ID",
- "action": "None",
- "orchStatus": "Created",
- "provStatus": "preprov",
"inMaint": false,
"instanceId": "NETWORK4_INSTANCE_ID",
"instanceType": "CONTRAIL30_HIMELGUARD",
- "instanceName": "NETWORK4_INSTANCE_NAME",
- "name": "NETWORK4_INSTANCE_NAME",
- "modelName": "ExtVL 0",
- "type": "VL",
- "isEcompGeneratedNaming": false,
- "networkStoreKey": "NETWORK4_INSTANCE_ID",
- "typeName": "N",
- "menuActions": {"edit": {}, "showAuditInfo": {}, "duplicate": {}, "remove": {}, "delete": {}, "undoDelete": {}},
- "isFailed": false,
- "statusMessage": "",
- "statusProperties": [{"key": "Prov Status:", "value": "preprov", "testId": "provStatus"}, {
- "key": "Orch Status:",
- "value": "Created",
- "testId": "orchStatus"
- }],
- "trackById": "1wvr73xl999",
- "parentType": "",
- "componentInfoType": "Network",
- "errors": {}
};
}