summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master
diff options
context:
space:
mode:
Diffstat (limited to 'vid-webpack-master')
-rw-r--r--vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts8
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board.modes.ts3
-rw-r--r--vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.spec.ts90
-rw-r--r--vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.ts38
-rw-r--r--vid-webpack-master/src/app/shared/services/templateService/instantiationTemplates.service.ts3
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/main.reducer.ts4
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/useTemplate/useTemplate.action.ts17
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/useTemplate/useTemplate.reducer.spec.ts18
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/useTemplate/useTemplate.reducer.ts20
9 files changed, 151 insertions, 50 deletions
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 5f423f8c2..0b19b667c 100644
--- a/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts
@@ -47,10 +47,10 @@ describe('Drawing Board: Instantiation Templates', function () {
// Then...
cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
- // cy.readFile('cypress/support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__instance_template.json').then((expectedResult) => {
- // convertRollbackOnFailureValueFromStringToBoolean(expectedResult);
- // cy.deepCompare(xhr.request.body, expectedResult);
- // });
+ cy.readFile('cypress/support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__instance_template.json').then((expectedResult) => {
+ convertRollbackOnFailureValueFromStringToBoolean(expectedResult);
+ cy.deepCompare(xhr.request.body, expectedResult);
+ });
});
});
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board.modes.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board.modes.ts
index 452666f91..78e2b629e 100644
--- a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board.modes.ts
+++ b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board.modes.ts
@@ -4,5 +4,6 @@ export enum DrawingBoardModes {
VIEW = 'VIEW',
EDIT = 'EDIT',
OLD_VIEW_EDIT = 'OLD_VIEW_EDIT',
- CREATE = 'CREATE'
+ CREATE = 'CREATE',
+ RECREATE = 'RECREATE'
}
diff --git a/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.spec.ts b/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.spec.ts
index 27d3f419b..29adfa9e0 100644
--- a/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.spec.ts
+++ b/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.spec.ts
@@ -1,16 +1,5 @@
import {getTestBed, TestBed} from '@angular/core/testing';
-import {
- COMPLETED_WITH_ERRORS,
- INPROGRESS,
- InstantiationStatusComponentService,
- PAUSE,
- PENDING,
- ServiceStatus,
- STOPPED,
- SUCCESS_CIRCLE,
- UNKNOWN,
- X_O
-} from './instantiationStatus.component.service';
+import {COMPLETED_WITH_ERRORS, INPROGRESS, InstantiationStatusComponentService, PAUSE, PENDING, ServiceStatus, STOPPED, SUCCESS_CIRCLE, UNKNOWN, X_O} from './instantiationStatus.component.service';
import {ServiceInfoModel} from '../shared/server/serviceInfo/serviceInfo.model';
import {AaiService} from "../shared/services/aaiService/aai.service";
import {MsoService} from "../shared/services/msoService/mso.service";
@@ -21,6 +10,8 @@ import {DrawingBoardModes} from "../drawingBoard/service-planning/drawing-board.
import {RouterTestingModule} from "@angular/router/testing";
import {of} from "rxjs";
import {UrlTree} from "@angular/router";
+import each from "jest-each";
+import {ServiceAction} from "../shared/models/serviceInstanceActions";
class MockAppStore<T> {
@@ -101,33 +92,48 @@ describe('Instantiation Status Service', () => {
});
});
- test('click on "Open" button should open new view edit' , ()=>{
- const item = {
- serviceModelId : 'serviceModelId',
- serviceInstanceId : 'serviceInstanceId',
- serviceType : 'serviceType',
- subscriberId : 'subscriberId'
- };
- let params:UrlTree = service.getNewViewEditUrlTree(<any>item, DrawingBoardModes.VIEW);
- expect(params.toString().startsWith('/servicePlanning/VIEW')).toBeTruthy();
- expect(params.queryParams).toEqual(
- {
- serviceModelId: item.serviceModelId,
- serviceInstanceId: item.serviceInstanceId,
- serviceType : item.serviceType,
- subscriberId : item.subscriberId
- });
- });
+ describe('navigations tests:', () => {
- test('build the View Edit url' , ()=>{
const item = {
- serviceModelId : '28aeb8f6-5620-4148-8bfb-a5fb406f0309',
+ serviceModelId: '28aeb8f6-5620-4148-8bfb-a5fb406f0309',
+ serviceInstanceId: 'myInstanceId',
+ serviceType: 'myService',
+ subscriberId: 'mySubscriber',
+ jobId: 'aJobId'
};
- let serviceModelUrl: string = '/servicePlanning/EDIT?serviceModelId=28aeb8f6-5620-4148-8bfb-a5fb406f0309';
- let suffix:string = '../../serviceModels.htm#';
- let tree:UrlTree = service.getNewViewEditUrlTree(<any>item, DrawingBoardModes.EDIT);
- let result = service.getViewEditUrl(tree);
- expect (suffix + serviceModelUrl).toEqual(result);
+
+ test('click on "Open" button should open new view edit', () => {
+ let params: UrlTree = service.getNewViewEditUrlTree(<any>item, DrawingBoardModes.VIEW);
+ expect(params.toString().startsWith('/servicePlanning/VIEW')).toBeTruthy();
+ expect(params.queryParams).toEqual(
+ {
+ serviceModelId: item.serviceModelId,
+ serviceInstanceId: item.serviceInstanceId,
+ serviceType: item.serviceType,
+ subscriberId: item.subscriberId,
+ jobId: item.jobId
+ });
+ });
+
+ test('build the View Edit url', () => {
+
+ let serviceModelUrl: string = '/servicePlanning/EDIT?serviceModelId=28aeb8f6-5620-4148-8bfb-a5fb406f0309' +
+ '&serviceInstanceId=myInstanceId&serviceType=myService&subscriberId=mySubscriber&jobId=aJobId';
+ let prefix: string = '../../serviceModels.htm#';
+ let tree: UrlTree = service.getNewViewEditUrlTree(<any>item, DrawingBoardModes.EDIT);
+ let result = service.getViewEditUrl(tree);
+ expect(result).toEqual(prefix + serviceModelUrl);
+ });
+
+ test('recreate url shall contains mode RECREATE and only jobId and serviceModelId', () =>{
+ let params: UrlTree = service.getNewViewEditUrlTree(<any>item, DrawingBoardModes.RECREATE);
+ expect(params.toString().startsWith('/servicePlanning/RECREATE')).toBeTruthy();
+ expect(params.queryParams).toEqual(
+ {
+ serviceModelId: item.serviceModelId,
+ jobId: item.jobId
+ });
+ });
});
for (let [status, tooltip] of Object.entries({
@@ -154,6 +160,18 @@ describe('Instantiation Status Service', () => {
expect(statusResult.iconClassName).toEqual(UNKNOWN);
});
+
+ each([
+ [true, ServiceAction.INSTANTIATE],
+ [false, ServiceAction.UPDATE],
+ [false, ServiceAction.DELETE],
+ ]).
+ test('isRecreateEnabled: should be %s if action is %s', (expected:boolean, action:ServiceAction) => {
+ let serviceInfoModel = new ServiceInfoModel();
+ serviceInfoModel.action = action;
+ expect(service.isRecreateEnabled(serviceInfoModel)).toBe(expected);
+ });
+
test('getStatusTooltip should return correct icon per job status', () => {
let result : ServiceStatus = service.getStatus('pending');
expect(result.iconClassName).toEqual(PENDING);
diff --git a/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.ts b/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.ts
index ffc2e681a..227fff10d 100644
--- a/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.ts
+++ b/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.ts
@@ -12,6 +12,7 @@ import {updateDrawingBoardStatus} from "../shared/storeUtil/utils/global/global.
import {Router, UrlTree} from "@angular/router";
import {of} from "rxjs";
import {MsoService} from "../shared/services/msoService/mso.service";
+import {ServiceAction} from "../shared/models/serviceInstanceActions";
export let PENDING : string = "pending";
export let INPROGRESS : string = "in_progress";
@@ -122,19 +123,31 @@ export class InstantiationStatusComponentService {
['/servicePlanning/' + mode],
{
queryParams:
- {
- serviceModelId: item.serviceModelId,
- serviceInstanceId: item.serviceInstanceId,
- serviceType : item.serviceType,
- subscriberId : item.subscriberId,
- jobId: item.jobId
- }
+ mode==DrawingBoardModes.RECREATE ?
+ this.getRecreateQueryParams(item) :
+ this.getDefaultViewEditQueryParams(item)
});
}
+ private getDefaultViewEditQueryParams(item: ServiceInfoModel) {
+ return {
+ serviceModelId: item.serviceModelId,
+ serviceInstanceId: item.serviceInstanceId,
+ serviceType: item.serviceType,
+ subscriberId: item.subscriberId,
+ jobId: item.jobId
+ };
+ }
+
+ private getRecreateQueryParams(item: ServiceInfoModel) {
+ return {
+ serviceModelId: item.serviceModelId,
+ jobId: item.jobId
+ };
+ }
+
getViewEditUrl(viewEditUrlTree:UrlTree): string {
return '../../serviceModels.htm#' + viewEditUrlTree.toString();
-
}
getStatus(status : string) : ServiceStatus {
@@ -162,6 +175,15 @@ export class InstantiationStatusComponentService {
retry(item: ServiceInfoModel): void {
this.navigateToNewViewEdit(item, DrawingBoardModes.RETRY_EDIT);
}
+
+ recreate(item: ServiceInfoModel): void {
+ this.navigateToNewViewEdit(item, DrawingBoardModes.RECREATE);
+ }
+
+ isRecreateEnabled(item: ServiceInfoModel): boolean {
+ return item.action === ServiceAction.INSTANTIATE;
+ }
+
}
diff --git a/vid-webpack-master/src/app/shared/services/templateService/instantiationTemplates.service.ts b/vid-webpack-master/src/app/shared/services/templateService/instantiationTemplates.service.ts
index 21cdc9296..018e0d367 100644
--- a/vid-webpack-master/src/app/shared/services/templateService/instantiationTemplates.service.ts
+++ b/vid-webpack-master/src/app/shared/services/templateService/instantiationTemplates.service.ts
@@ -6,6 +6,7 @@ import {Observable} from "rxjs";
import {ServiceInstance} from "../../models/serviceInstance";
import {Constants} from "../../utils/constants";
import {createServiceInstance} from "../../storeUtil/utils/service/service.actions";
+import {createServiceInstanceFromTemplate} from "../../storeUtil/utils/useTemplate/useTemplate.action";
@Injectable()
export class InstantiationTemplatesService {
@@ -19,7 +20,7 @@ export class InstantiationTemplatesService {
public retrieveAndStoreInstantiationTemplateTopology(jobId: string, serviceModelId: string): Observable<ServiceInstance> {
return this.retrieveInstantiationTemplateTopology(jobId).do((instantiationTemplate: ServiceInstance) => {
- this.store.dispatch(createServiceInstance(instantiationTemplate, serviceModelId));
+ this.store.dispatch(createServiceInstanceFromTemplate(instantiationTemplate, serviceModelId));
});
};
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/main.reducer.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/main.reducer.ts
index c02049eb9..a135563eb 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/main.reducer.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/main.reducer.ts
@@ -9,9 +9,11 @@ import {VNFActions} from "./vnf/vnf.actions";
import {vnfReducer} from "./vnf/vnf.reducers";
import {generalReducer} from "./general/general.reducers";
import {serviceReducer} from "./service/service.reducers";
+import {useTemplateReducer} from "./useTemplate/useTemplate.reducer";
import {networkReducer} from "./network/network.reducers";
import {vfModuleReducer} from "./vfModule/vfModule.reducers";
import {ServiceInstance} from "../../models/serviceInstance";
+import {UseTemplateActions} from "./useTemplate/useTemplate.action";
import {SelectOptionInterface} from "../../models/selectOption";
import {ServiceType} from "../../models/serviceType";
import {VnfGroupActions} from "./vnfGroup/vnfGroup.actions";
@@ -72,6 +74,8 @@ export const MainReducer = function (state: ServiceState = initialState, action:
return crReducer(state, action);
}else if(Object.values(NcfActions).includes(action.type)){
return ncfReducer(state, action);
+ } else if(Object.values(UseTemplateActions).includes(action.type)) {
+ return useTemplateReducer(state, action);
} else {
return Object.assign({}, state);
}
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/useTemplate/useTemplate.action.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/useTemplate/useTemplate.action.ts
new file mode 100644
index 000000000..2cfd38482
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/useTemplate/useTemplate.action.ts
@@ -0,0 +1,17 @@
+import {Action, ActionCreator} from "redux";
+import {ServiceInstance} from "../../../models/serviceInstance";
+
+export enum UseTemplateActions {
+ CREATE_SERVICE_INSTANCE_FROM_TEMPLATE = 'CREATE_SERVICE_INSTANCE_FROM_TEMPLATE',
+}
+
+export interface CreateServiceInstanceFromTemplate extends Action {
+ serviceInstantiationTemplate?: ServiceInstance;
+ serviceModelId?: string;
+}
+
+export const createServiceInstanceFromTemplate: ActionCreator<CreateServiceInstanceFromTemplate> = (serviceInstantiationTemplate, serviceModelId) => ({
+ type: UseTemplateActions.CREATE_SERVICE_INSTANCE_FROM_TEMPLATE,
+ serviceInstantiationTemplate: serviceInstantiationTemplate,
+ serviceModelId: serviceModelId
+});
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/useTemplate/useTemplate.reducer.spec.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/useTemplate/useTemplate.reducer.spec.ts
new file mode 100644
index 000000000..e0f46e13a
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/useTemplate/useTemplate.reducer.spec.ts
@@ -0,0 +1,18 @@
+import {ServiceInstance} from "../../../models/serviceInstance";
+import {useTemplateReducer} from "./useTemplate.reducer";
+import {CreateServiceInstanceFromTemplate, UseTemplateActions} from "./useTemplate.action";
+
+test('#CREATE_SERVICE_INSTANCE_FROM_TEMPLATE should add new service instance from template to redux ', () => {
+ let serviceFromTemplateInstance: ServiceInstance = <any>{
+ instanceName: 'templateInstanceName'
+ };
+ let serviceState = useTemplateReducer(<any>{
+ serviceInstance:{}},
+ <CreateServiceInstanceFromTemplate> {
+ type: UseTemplateActions.CREATE_SERVICE_INSTANCE_FROM_TEMPLATE,
+ serviceModelId: 'serviceModelID',
+ serviceInstantiationTemplate: serviceFromTemplateInstance,
+ })
+ expect (serviceState).toBeDefined();
+ expect (serviceState.serviceInstance['serviceModelID'].instanceName).toEqual('templateInstanceName');
+});
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/useTemplate/useTemplate.reducer.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/useTemplate/useTemplate.reducer.ts
new file mode 100644
index 000000000..5a06d6e0a
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/useTemplate/useTemplate.reducer.ts
@@ -0,0 +1,20 @@
+import {ServiceState} from "../main.reducer";
+import {Action} from "redux";
+import {
+ createServiceInstanceFromTemplate,
+ CreateServiceInstanceFromTemplate,
+ UseTemplateActions
+} from "./useTemplate.action";
+import * as _ from "lodash";
+
+export function useTemplateReducer(state: ServiceState, action: Action) : ServiceState {
+ switch (action.type) {
+ case UseTemplateActions.CREATE_SERVICE_INSTANCE_FROM_TEMPLATE : {
+ const updateServiceInstanceFromTemplateAction = <CreateServiceInstanceFromTemplate>action;
+ const uuid = updateServiceInstanceFromTemplateAction.serviceModelId;
+ let newState = _.cloneDeep(state);
+ newState.serviceInstance[uuid] = updateServiceInstanceFromTemplateAction.serviceInstantiationTemplate;
+ return newState;
+ }
+ }
+}