aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/resolvers
diff options
context:
space:
mode:
authorAlexey Sandler <alexey.sandler@intl.att.com>2019-12-03 13:04:42 +0200
committerIttay Stern <ittay.stern@att.com>2019-12-03 17:40:32 +0200
commit9e65dc01257d59b78f89077b94cc6393efef1893 (patch)
treec08fc893af8efd88a1d3e691cde9e565e0314674 /vid-webpack-master/src/app/shared/resolvers
parent2a8f0ba72f2c449d2048674a22820d4f8385f8ca (diff)
Drawing Board RECREATE will use a new route that retrieves a template
Use endpoint "templateTopology" instead of "bulkForRetry" Issue-ID: VID-724 Change-Id: Ic92971e29d1f78768aeb82158ce424ff31bfbbb0 Signed-off-by: Alexey Sandler <alexey.sandler@intl.att.com>
Diffstat (limited to 'vid-webpack-master/src/app/shared/resolvers')
-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
2 files changed, 95 insertions, 0 deletions
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])
+ }
+
+}