Skip to content
This repository has been archived by the owner on Nov 22, 2019. It is now read-only.

Commit

Permalink
Now using TestDataService for dataservices.
Browse files Browse the repository at this point in the history
  • Loading branch information
elvisisking committed Mar 21, 2018
1 parent a104a6f commit 2fa5ba3
Show file tree
Hide file tree
Showing 6 changed files with 311 additions and 100 deletions.
Expand Up @@ -43,7 +43,7 @@ export class MockConnectionService extends ConnectionService {
super(http, appSettings, logger);

// Inject service for test data
let injector = ReflectiveInjector.resolveAndCreate([TestDataService]);
const injector = ReflectiveInjector.resolveAndCreate([TestDataService]);
const testDataService = injector.get(TestDataService);

// Get test data
Expand Down
Expand Up @@ -107,13 +107,7 @@ export class DataserviceCardComponent implements DoCheck, OnInit {
* @returns {string[]} the names of the views
*/
public getViews(): string[] {
const result: string[] = [];

for (const viewName of this.dataservice.getServiceViewNames()) {
result.push(viewName);
}

return result;
return this.dataservice.getServiceViewNames();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions ngapp/src/app/dataservices/shared/dataservice.model.ts
Expand Up @@ -116,10 +116,10 @@ export class Dataservice implements Identifiable< string > {
*/
public getServiceViewNames(): string[] {
if ( this.serviceViews ) {
this.serviceViews = [];
return this.serviceViews;
}

return this.serviceViews;
return [];
}

/**
Expand Down
45 changes: 18 additions & 27 deletions ngapp/src/app/dataservices/shared/mock-dataservice.service.ts
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { Injectable } from "@angular/core";
import { Injectable, ReflectiveInjector } from "@angular/core";
import { Http, Response } from "@angular/http";
import { AppSettingsService } from "@core/app-settings.service";
import { LoggerService } from "@core/logger.service";
Expand All @@ -25,6 +25,7 @@ import { NewDataservice } from "@dataservices/shared/new-dataservice.model";
import { NotifierService } from "@dataservices/shared/notifier.service";
import { Table } from "@dataservices/shared/table.model";
import { VdbService } from "@dataservices/shared/vdb.service";
import { TestDataService } from "@shared/test-data.service";
import "rxjs/add/observable/of";
import "rxjs/add/observable/throw";
import "rxjs/add/operator/catch";
Expand All @@ -35,28 +36,18 @@ import { ErrorObservable } from "rxjs/observable/ErrorObservable";
@Injectable()
export class MockDataserviceService extends DataserviceService {

private serv1 = new Dataservice();
private serv2 = new Dataservice();
private serv3 = new Dataservice();
private services: Dataservice[] = [this.serv1, this.serv2, this.serv3];
private services: Dataservice[];

constructor(http: Http, vdbService: VdbService, appSettings: AppSettingsService,
notifierService: NotifierService, logger: LoggerService ) {
super(http, vdbService, appSettings, notifierService, logger);
this.serv1.setId("serv1");
this.serv1.setServiceViewTables(["table1", "table2"]);
this.serv1.setServiceViewModel("viewModel");
const viewNames: string[] = [];
viewNames.push("views");
this.serv1.setServiceViewNames(viewNames);
this.serv2.setId("serv2");
this.serv2.setServiceViewTables(["table1", "table2"]);
this.serv2.setServiceViewModel("viewModel");
this.serv2.setServiceViewNames(viewNames);
this.serv3.setId("serv3");
this.serv3.setServiceViewTables(["table1", "table2"]);
this.serv3.setServiceViewModel("viewModel");
this.serv3.setServiceViewNames(viewNames);

// Inject service for test data
const injector = ReflectiveInjector.resolveAndCreate([TestDataService]);
const testDataService = injector.get(TestDataService);

// Get test data
this.services = testDataService.getDataservices();
}

/**
Expand Down Expand Up @@ -89,14 +80,14 @@ export class MockDataserviceService extends DataserviceService {
public deleteDataservice(dataserviceId: string): Observable<boolean> {
return Observable.of(true);
}

/**
* Get the current Dataservice selection
* @returns {Dataservice} the selected Dataservice
*/
public getSelectedDataservice( ): Dataservice {
return this.serv1;
}
//
// /**
// * Get the current Dataservice selection
// * @returns {Dataservice} the selected Dataservice
// */
// public getSelectedDataservice( ): Dataservice {
// return this.serv1;
// }

/**
* Get the views for the selected Dataservice
Expand Down
36 changes: 12 additions & 24 deletions ngapp/src/app/dataservices/shared/mock-vdb.service.ts
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { Injectable } from "@angular/core";
import { Injectable, ReflectiveInjector } from "@angular/core";
import { Http } from "@angular/http";
import { AppSettingsService } from "@core/app-settings.service";
import { LoggerService } from "@core/logger.service";
Expand All @@ -26,6 +26,7 @@ import { VdbModel } from "@dataservices/shared/vdb-model.model";
import { VdbStatus } from "@dataservices/shared/vdb-status.model";
import { Vdb } from "@dataservices/shared/vdb.model";
import { VdbService } from "@dataservices/shared/vdb.service";
import { TestDataService } from "@shared/test-data.service";
import "rxjs/add/observable/of";
import "rxjs/add/observable/throw";
import "rxjs/add/operator/catch";
Expand All @@ -35,32 +36,19 @@ import { Observable } from "rxjs/Observable";
@Injectable()
export class MockVdbService extends VdbService {

private vdb1 = new Vdb();
private vdb2 = new Vdb();
private vdb3 = new Vdb();
private vdbs: Vdb[] = [this.vdb1, this.vdb2, this.vdb3];

private vdbStatus1 = new VdbStatus();
private vdbStatus2 = new VdbStatus();
private vdbStatus3 = new VdbStatus();
private statuses: VdbStatus[] = [this.vdbStatus1, this.vdbStatus3, this.vdbStatus3];
private vdbs: Vdb[];
private statuses: VdbStatus[];

constructor(http: Http, appSettings: AppSettingsService, notifierService: NotifierService, logger: LoggerService ) {
super(http, appSettings, notifierService, logger);
this.vdb1.setId("serv1");
this.vdbStatus1.setName( "serv1" );
this.vdbStatus1.setLoading( false );
this.vdbStatus1.setActive( true );

this.vdb2.setId("serv2");
this.vdbStatus2.setName("serv2");
this.vdbStatus2.setLoading( false );
this.vdbStatus2.setActive( true );

this.vdb3.setId("serv3");
this.vdbStatus3.setName("serv2");
this.vdbStatus3.setLoading( false );
this.vdbStatus3.setActive( true );

// Inject service for test data
const injector = ReflectiveInjector.resolveAndCreate([TestDataService]);
const testDataService = injector.get(TestDataService);

// Get test data
this.statuses = testDataService.getVdbStatuses();
this.vdbs = testDataService.getVdbs();
}

/**
Expand Down

0 comments on commit 2fa5ba3

Please sign in to comment.