aboutsummaryrefslogtreecommitdiffstats
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.ts2
-rw-r--r--vid-webpack-master/src/app/drawingBoard/drawingBoard.routing.ts3
-rw-r--r--vid-webpack-master/src/app/shared/resolvers/recreate/recreate.resolver.spec.ts66
-rw-r--r--vid-webpack-master/src/app/shared/resolvers/recreate/recreate.resolver.ts29
-rw-r--r--vid-webpack-master/src/app/shared/services/templateService/instantiationTemplates.service.spec.ts51
-rw-r--r--vid-webpack-master/src/app/shared/services/templateService/instantiationTemplates.service.ts26
-rw-r--r--vid-webpack-master/src/app/shared/shared.module.ts4
-rw-r--r--vid-webpack-master/src/app/shared/utils/constants.ts1
8 files changed, 180 insertions, 2 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 be029a1fc..e01ccfda1 100644
--- a/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts
@@ -21,7 +21,7 @@ describe('Drawing Board: Instantiation Templates', function () {
const templateUuid = "46390edd-7100-46b2-9f18-419bd24fb60b";
const drawingBoardAction = `RECREATE`;
- const templateTopologyEndpoint = "bulkForRetry"; // will be: "templateTopology"
+ const templateTopologyEndpoint = "templateTopology";
// Given...
diff --git a/vid-webpack-master/src/app/drawingBoard/drawingBoard.routing.ts b/vid-webpack-master/src/app/drawingBoard/drawingBoard.routing.ts
index 6564746b7..aebbdee5a 100644
--- a/vid-webpack-master/src/app/drawingBoard/drawingBoard.routing.ts
+++ b/vid-webpack-master/src/app/drawingBoard/drawingBoard.routing.ts
@@ -4,6 +4,7 @@ import {FlagsResolve} from "../shared/resolvers/flag/flag.resolver";
import {ViewEditResolver} from "../shared/resolvers/viewEdit/viewEdit.resolver";
import {DrawingBoardGuard} from "./guards/servicePlanningGuard/drawingBoardGuard";
import {RetryResolver} from "../shared/resolvers/retry/retry.resolver";
+import {RecreateResolver} from "../shared/resolvers/recreate/recreate.resolver";
export const DrawingBoardRoutes: Route[] = [
{
@@ -31,7 +32,7 @@ export const DrawingBoardRoutes: Route[] = [
component: ServicePlanningComponent,
resolve: {
flags: FlagsResolve,
- viewEditResolver: RetryResolver
+ viewEditResolver: RecreateResolver
}
},
{
diff --git a/vid-webpack-master/src/app/shared/resolvers/recreate/recreate.resolver.spec.ts b/vid-webpack-master/src/app/shared/resolvers/recreate/recreate.resolver.spec.ts
new file mode 100644
index 000000000..1a3a1ab3f
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/resolvers/recreate/recreate.resolver.spec.ts
@@ -0,0 +1,66 @@
+import {RecreateResolver} from "./recreate.resolver";
+import {getTestBed, TestBed} from '@angular/core/testing';
+import {NgRedux} from "@angular-redux/store";
+import {InstantiationTemplatesService} from "../../services/templateService/instantiationTemplates.service";
+import {AaiService} from "../../services/aaiService/aai.service";
+import {mock} from "ts-mockito";
+import {ServiceInstance} from "../../models/serviceInstance";
+import {HttpClientTestingModule} from "@angular/common/http/testing";
+import {FeatureFlagsService} from "../../services/featureFlag/feature-flags.service";
+import {convertToParamMap} from "@angular/router";
+import {of} from 'rxjs/observable/of'
+
+class MockAppStore<T> {
+ getState() {}
+}
+
+describe('Recreate resolver', () => {
+
+ let injector;
+ let recreateResolver: RecreateResolver;
+ let aaiService: AaiService;
+ let instantiationTemplatesService: InstantiationTemplatesService;
+
+ beforeAll(done => (async () => {
+ TestBed.configureTestingModule({
+ imports: [HttpClientTestingModule],
+ providers: [
+ FeatureFlagsService,
+ InstantiationTemplatesService,
+ RecreateResolver,
+ AaiService,
+ {provide: NgRedux, useClass: MockAppStore},
+ ]
+ });
+ await TestBed.compileComponents();
+
+ injector = getTestBed();
+ recreateResolver = injector.get(RecreateResolver);
+ aaiService = injector.get(AaiService);
+ instantiationTemplatesService = injector.get(InstantiationTemplatesService);
+ })().then(done).catch(done.fail));
+
+ test("when resolve() invoked -> then getServiceModelById and retrieveAndStoreInstantiationTemplateTopology are called", done => {
+ jest.spyOn(aaiService, 'getServiceModelById')
+ .mockReturnValue(of({}));
+ jest.spyOn(instantiationTemplatesService, 'retrieveAndStoreInstantiationTemplateTopology')
+ .mockReturnValue(of(mock(ServiceInstance)));
+
+ recreateResolver.resolve(<any>{
+ queryParamMap:
+ convertToParamMap({
+ serviceModelId: "someServiceModelId",
+ jobId: "someJobId",
+ })
+ })
+
+ .subscribe(() => {
+ expect(aaiService.getServiceModelById)
+ .toHaveBeenCalledWith("someServiceModelId");
+ expect(instantiationTemplatesService.retrieveAndStoreInstantiationTemplateTopology)
+ .toHaveBeenCalledWith("someJobId", "someServiceModelId");
+ done();
+ });
+ })
+
+});
diff --git a/vid-webpack-master/src/app/shared/resolvers/recreate/recreate.resolver.ts b/vid-webpack-master/src/app/shared/resolvers/recreate/recreate.resolver.ts
new file mode 100644
index 000000000..b7e952a64
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/resolvers/recreate/recreate.resolver.ts
@@ -0,0 +1,29 @@
+import {Injectable} from "@angular/core";
+import {NgRedux} from "@angular-redux/store";
+
+import {ActivatedRouteSnapshot, Resolve} from "@angular/router";
+import {Observable} from "rxjs";
+import {AppState} from "../../store/reducers";
+import {InstantiationTemplatesService} from "../../services/templateService/instantiationTemplates.service";
+import {forkJoin} from "rxjs/observable/forkJoin";
+import {AaiService} from "../../services/aaiService/aai.service";
+import {ServiceInstance} from "../../models/serviceInstance";
+
+@Injectable()
+export class RecreateResolver implements Resolve<Observable<[any, ServiceInstance]>> {
+ constructor(private _templateService: InstantiationTemplatesService,
+ private _aaiService: AaiService,
+ private _store: NgRedux<AppState>) {
+ }
+
+ resolve(route: ActivatedRouteSnapshot): Observable<[any, ServiceInstance]> {
+ const serviceModelId: string = route.queryParamMap.get("serviceModelId");
+ const jobId: string = route.queryParamMap.get("jobId");
+
+ let serviceModelApi = this._aaiService.getServiceModelById(serviceModelId);
+ let instantiationTemplateApi = this._templateService.retrieveAndStoreInstantiationTemplateTopology(jobId, serviceModelId);
+
+ return forkJoin([serviceModelApi, instantiationTemplateApi])
+ }
+
+}
diff --git a/vid-webpack-master/src/app/shared/services/templateService/instantiationTemplates.service.spec.ts b/vid-webpack-master/src/app/shared/services/templateService/instantiationTemplates.service.spec.ts
new file mode 100644
index 000000000..80b113bde
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/services/templateService/instantiationTemplates.service.spec.ts
@@ -0,0 +1,51 @@
+import {HttpClientTestingModule, HttpTestingController} from "@angular/common/http/testing";
+import {InstantiationTemplatesService} from "./instantiationTemplates.service";
+import {mock} from "ts-mockito";
+import {NgRedux} from "@angular-redux/store";
+import {getTestBed, TestBed} from "@angular/core/testing";
+import {ServiceInstance} from "../../models/serviceInstance";
+import {Constants} from "../../utils/constants";
+
+class MockAppStore<T> {
+ dispatch() {}
+ getState() {}
+}
+
+describe("TemplateService", ()=>{
+ let injector;
+ let httpMock: HttpTestingController;
+ let templateService: InstantiationTemplatesService;
+
+ beforeAll( done => (async () => {
+ TestBed.configureTestingModule({
+ imports: [HttpClientTestingModule],
+ providers: [
+ InstantiationTemplatesService,
+ {provide: NgRedux, useClass: MockAppStore},
+ ]
+ });
+ await TestBed.compileComponents();
+
+ injector = getTestBed();
+ httpMock = injector.get(HttpTestingController);
+ templateService = injector.get(InstantiationTemplatesService);
+ })().then(done).catch(done.fail));
+
+ describe ('#retrieveInstantiationTemplateTopology tests', () => {
+ test('when called -> retrieve template from backend', done => {
+ const mockedTemplate = mock(ServiceInstance);
+ const jobId: string = "some-random-job-id";
+
+ templateService.retrieveInstantiationTemplateTopology(jobId)
+ .subscribe((result: ServiceInstance) => {
+ expect(Object.is(result, mockedTemplate)).toBe(true);
+ done();
+ });
+
+ httpMock
+ .expectOne(`${Constants.Path.INSTANTIATION_TEMPLATE_TOPOLOGY}/${jobId}`)
+ .flush(mockedTemplate);
+ })
+ })
+});
+
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
new file mode 100644
index 000000000..21cdc9296
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/services/templateService/instantiationTemplates.service.ts
@@ -0,0 +1,26 @@
+import {Injectable} from "@angular/core";
+import {HttpClient} from "@angular/common/http";
+import {NgRedux} from "@angular-redux/store";
+import {AppState} from "../../store/reducers";
+import {Observable} from "rxjs";
+import {ServiceInstance} from "../../models/serviceInstance";
+import {Constants} from "../../utils/constants";
+import {createServiceInstance} from "../../storeUtil/utils/service/service.actions";
+
+@Injectable()
+export class InstantiationTemplatesService {
+ constructor(private http: HttpClient, private store: NgRedux<AppState>) {
+ }
+
+ retrieveInstantiationTemplateTopology(jobId: string): Observable<ServiceInstance> {
+ let pathQuery: string = `${Constants.Path.INSTANTIATION_TEMPLATE_TOPOLOGY}/${jobId}`;
+ return this.http.get<ServiceInstance>(pathQuery)
+ }
+
+ public retrieveAndStoreInstantiationTemplateTopology(jobId: string, serviceModelId: string): Observable<ServiceInstance> {
+ return this.retrieveInstantiationTemplateTopology(jobId).do((instantiationTemplate: ServiceInstance) => {
+ this.store.dispatch(createServiceInstance(instantiationTemplate, serviceModelId));
+ });
+ };
+
+}
diff --git a/vid-webpack-master/src/app/shared/shared.module.ts b/vid-webpack-master/src/app/shared/shared.module.ts
index b12ac435d..a8b45c99a 100644
--- a/vid-webpack-master/src/app/shared/shared.module.ts
+++ b/vid-webpack-master/src/app/shared/shared.module.ts
@@ -75,6 +75,8 @@ import {DynamicInputLabelPipe} from "./pipes/dynamicInputLabel/dynamic-input-lab
import {ModelInformationService} from "./components/model-information/model-information.service";
import {MultiselectFormControlService} from "./components/formControls/component/multiselect/multiselect.formControl.service";
import {SearchFilterPipe} from "./pipes/searchFilter/search-filter.pipe";
+import {RecreateResolver} from "./resolvers/recreate/recreate.resolver";
+import {InstantiationTemplatesService} from "./services/templateService/instantiationTemplates.service";
@NgModule({
@@ -178,6 +180,8 @@ import {SearchFilterPipe} from "./pipes/searchFilter/search-filter.pipe";
FlagsResolve,
ViewEditResolver,
RetryResolver,
+ RecreateResolver,
+ InstantiationTemplatesService,
ServiceControlGenerator,
ServicePopupService,
VnfControlGenerator,
diff --git a/vid-webpack-master/src/app/shared/utils/constants.ts b/vid-webpack-master/src/app/shared/utils/constants.ts
index 6172320a4..4f11cd1be 100644
--- a/vid-webpack-master/src/app/shared/utils/constants.ts
+++ b/vid-webpack-master/src/app/shared/utils/constants.ts
@@ -94,6 +94,7 @@ export module Constants {
public static SERVICES_JOB_INFO_PATH = '../../asyncInstantiation';
public static SERVICE_MODEL_ID = 'serviceModelId';
public static SERVICES_RETRY_TOPOLOGY = '../../asyncInstantiation/bulkForRetry';
+ public static INSTANTIATION_TEMPLATE_TOPOLOGY = '../../asyncInstantiation/templateTopology';
public static CONFIGURATION_PATH = '../../get_property/{name}/defaultvalue';
public static SERVICES_JOB_AUDIT_PATH = '/auditStatus';
public static SERVICES_PROBE_PATH = "../../probe";