VID - Feature flag for PNF in modern UI
[vid.git] / vid-webpack-master / src / app / drawingBoard / service-planning / objectsToTree / shared.tree.service.spec.ts
index c0a1591..9a35d48 100644 (file)
@@ -44,7 +44,7 @@ import {VfModuleUpgradePopupService} from "../../../shared/components/genericFor
 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 {instance} from "ts-mockito";
+import { PnfPopupService } from "../../../shared/components/genericFormPopup/genericFormServices/pnf/pnf.popup.service";
 
 class MockAppStore<T> {
   getState() {
@@ -92,6 +92,7 @@ describe('Shared Tree Service', () => {
         DefaultDataGeneratorService,
         DialogService,
         VnfPopupService,
+        PnfPopupService,
         ControlGeneratorUtil,
         AaiService,
         LogService,
@@ -289,24 +290,79 @@ describe('Shared Tree Service', () => {
       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([
@@ -1534,7 +1590,9 @@ function getStore() {
 function getNetworkModelInfoFromHierarchy(){
   return {
     "version": "2.0",
-    "customizationUuid":"customization-id-from-hierarchy"
+    "customizationUuid":"customization-id-from-hierarchy",
+    "uuid": "UUID-from-hierarchy",
+    "invariantUuid": "invariantId-from-hierarchy"
   }
 }
 
@@ -1542,7 +1600,9 @@ function getSelectedModelInfo() {
   return {
     "instanceModelInfo": {
       "modelVersion": "5.0",
-      "modelCustomizationId": "model-customization-id-from-instance"
+      "modelCustomizationId": "model-customization-id-from-instance",
+      "modelVersionId": "UUID-from-instance",
+      "modelInvariantId": "invariantId-from-instance"
     }
   }
 }