src/app/tests/mocks/streams.ts
Mock for StreamsService.
Create a mocked service: const streamsService = new MockStreamsService(); TestBed.configureTestingModule({ providers: [ { provide: StreamsService, useValue: streamsService } ] }).compileComponents();
Set streamDefinition app infos: runtimeAppsService._testRuntimeApps = STREAM_DEFINITIONS;//Stream Definitions json
Properties |
|
Methods |
deployMultipleStreamDefinitions | ||||||||
deployMultipleStreamDefinitions(streamDefinitions: StreamDefinition[])
|
||||||||
Defined in src/app/tests/mocks/streams.ts:56
|
||||||||
Parameters :
Returns :
Observable<Array<any>>
|
destroyMultipleStreamDefinitions | ||||||||
destroyMultipleStreamDefinitions(streamDefinitions: StreamDefinition[])
|
||||||||
Defined in src/app/tests/mocks/streams.ts:52
|
||||||||
Parameters :
Returns :
Observable<Array<any>>
|
getDefinition | ||||||||
getDefinition(name: string)
|
||||||||
Defined in src/app/tests/mocks/streams.ts:44
|
||||||||
Parameters :
Returns :
Observable<any>
|
getDefinitions |
getDefinitions()
|
Defined in src/app/tests/mocks/streams.ts:40
|
Returns :
Observable<Page<StreamDefinition>>
|
getHistory | ||||||||
getHistory(streamDefinition: string)
|
||||||||
Defined in src/app/tests/mocks/streams.ts:77
|
||||||||
Parameters :
Returns :
Observable<[]>
|
getPlatforms |
getPlatforms()
|
Defined in src/app/tests/mocks/streams.ts:64
|
Returns :
Observable<[]>
|
getRelatedDefinitions |
getRelatedDefinitions(streamDefinitionName: String, nested?: boolean)
|
Defined in src/app/tests/mocks/streams.ts:60
|
Returns :
Observable<[]>
|
getRuntimeStreamStatuses | ||||||||
getRuntimeStreamStatuses(streamNames?: string[])
|
||||||||
Defined in src/app/tests/mocks/streams.ts:73
|
||||||||
Parameters :
Returns :
Observable<[]>
|
historyRollback | ||||||||
historyRollback(streamHistory: StreamHistory)
|
||||||||
Defined in src/app/tests/mocks/streams.ts:94
|
||||||||
Parameters :
Returns :
Observable<any>
|
undeployMultipleStreamDefinitions | ||||||||
undeployMultipleStreamDefinitions(streamDefinitions: StreamDefinition[])
|
||||||||
Defined in src/app/tests/mocks/streams.ts:48
|
||||||||
Parameters :
Returns :
Observable<Array<any>>
|
Public streamDefinitions |
streamDefinitions:
|
Defined in src/app/tests/mocks/streams.ts:38
|
Public streamsContext |
streamsContext:
|
Defined in src/app/tests/mocks/streams.ts:28
|
import { Page } from '../../shared/model/page';
import { StreamDefinition } from '../../streams/model/stream-definition';
import { StreamStatuses } from '../../streams/model/stream-metrics';
import { OrderParams } from '../../shared/components/shared.interface';
import { StreamHistory } from '../../streams/model/stream-history';
import { Observable, of } from 'rxjs';
import { Platform } from '../../shared/model/platform';
/**
* Mock for StreamsService.
*
* Create a mocked service:
* const streamsService = new MockStreamsService();
* TestBed.configureTestingModule({
* providers: [
* { provide: StreamsService, useValue: streamsService }
* ]
* }).compileComponents();
*
* Set streamDefinition app infos:
* runtimeAppsService._testRuntimeApps = STREAM_DEFINITIONS;//Stream Definitions json
*
* @author Glenn Renfro
* @author Damien Vitrac
*/
export class MockStreamsService {
public streamsContext = {
q: '',
page: 0,
size: 30,
sort: 'name',
order: OrderParams.ASC,
itemsSelected: [],
itemsExpanded: []
};
public streamDefinitions;
getDefinitions(): Observable<Page<StreamDefinition>> {
return of(StreamDefinition.pageFromJSON(this.streamDefinitions));
}
getDefinition(name: string): Observable<any> {
return of(StreamDefinition.fromJSON(this.streamDefinitions._embedded.streamDefinitionResourceList[0]));
}
undeployMultipleStreamDefinitions(streamDefinitions: StreamDefinition[]): Observable<Array<any>> {
return of(Array.from({ length: streamDefinitions.length }));
}
destroyMultipleStreamDefinitions(streamDefinitions: StreamDefinition[]): Observable<Array<any>> {
return of(Array.from({ length: streamDefinitions.length }));
}
deployMultipleStreamDefinitions(streamDefinitions: StreamDefinition[]): Observable<Array<any>> {
return of(Array.from({ length: streamDefinitions.length }));
}
getRelatedDefinitions(streamDefinitionName: String, nested?: boolean): Observable<StreamDefinition[]> {
return of([]);
}
getPlatforms(): Observable<Platform[]> {
return of([
Platform.fromJSON({name: 'default', type: 'local', description: '',
options: [{id: 'spring.cloud.deployer.local.opt1', name: 'opt1'}]
}),
Platform.fromJSON({name: 'foo', type: 'bar', description: 'foobar'})
]);
}
getRuntimeStreamStatuses(streamNames?: string[]): Observable<StreamStatuses[]> {
return of([]);
}
getHistory(streamDefinition: string): Observable<StreamHistory[]> {
return of([
StreamHistory.fromJSON({
name: streamDefinition,
version: 2,
platformName: 'default',
info: { firstDeployed: new Date(), status: { statusCode: 'DEPLOYED' }, description: 'Upgrade complete' }
}),
StreamHistory.fromJSON({
name: streamDefinition,
version: 1,
platformName: 'default',
info: { firstDeployed: new Date(), status: { statusCode: 'DELETED' }, description: 'Delete complete' }
})
]);
}
historyRollback(streamHistory: StreamHistory): Observable<any> {
return of([]);
}
}