src/app/tests/mocks/tasks.ts
Mock for TasksService.
Create a mocked service: const tasksService = new MockTasksService(); TestBed.configureTestingModule({ providers: [ { provide: TasksService, useValue: tasksService } ] }).compileComponents();
Set app infos: tasksService.testAppInfos = { faketask: {name: 'fakename'}};
Set app registrations: tasksService.testTaskAppRegistrations = [ new AppRegistration('fakename', ApplicationType.task, 'fakeuri') ];
Properties |
|
Methods |
createDefinition |
createDefinition(definition: string, name: string)
|
Defined in src/app/tests/mocks/tasks.ts:70
|
Returns :
any
|
createSchedules |
createSchedules()
|
Defined in src/app/tests/mocks/tasks.ts:110
|
Returns :
any
|
destroyDefinitions | ||||||||
destroyDefinitions(taskDefinitions: TaskDefinition[])
|
||||||||
Defined in src/app/tests/mocks/tasks.ts:78
|
||||||||
Parameters :
Returns :
Observable | Observable
|
destroySchedules | ||||||||
destroySchedules(taskSchedules: TaskSchedule[])
|
||||||||
Defined in src/app/tests/mocks/tasks.ts:102
|
||||||||
Parameters :
Returns :
Observable<any>
|
getDefinition | ||||||||
getDefinition(name: string)
|
||||||||
Defined in src/app/tests/mocks/tasks.ts:98
|
||||||||
Parameters :
Returns :
Observable<any>
|
getDefinitions |
getDefinitions()
|
Defined in src/app/tests/mocks/tasks.ts:86
|
Returns :
Observable<Page<TaskDefinition>>
|
getExecution | ||||||||
getExecution(id: string)
|
||||||||
Defined in src/app/tests/mocks/tasks.ts:74
|
||||||||
Parameters :
Returns :
Observable<TaskExecution>
|
getExecutions |
getExecutions()
|
Defined in src/app/tests/mocks/tasks.ts:82
|
Returns :
Observable<Page<TaskExecution>>
|
getPlatforms |
getPlatforms()
|
Defined in src/app/tests/mocks/tasks.ts:114
|
Returns :
Observable<[]>
|
getSchedule | ||||||||
getSchedule(scheduleName: string)
|
||||||||
Defined in src/app/tests/mocks/tasks.ts:94
|
||||||||
Parameters :
Returns :
Observable<TaskSchedule>
|
getSchedules | ||||||||
getSchedules(taskListParams: TaskListParams)
|
||||||||
Defined in src/app/tests/mocks/tasks.ts:90
|
||||||||
Parameters :
Returns :
Observable<Page<TaskSchedule>>
|
getTaskExecutions | ||||||||
getTaskExecutions(taskScheduleListParams: ListDefaultParams)
|
||||||||
Defined in src/app/tests/mocks/tasks.ts:106
|
||||||||
Parameters :
Returns :
Observable<Page<TaskExecution>>
|
launchDefinition | ||||||||
launchDefinition(taskLaunchParams: TaskLaunchParams)
|
||||||||
Defined in src/app/tests/mocks/tasks.ts:121
|
||||||||
Parameters :
Returns :
Observable<any>
|
Public executionsContext |
executionsContext:
|
Defined in src/app/tests/mocks/tasks.ts:43
|
Public schedulesContext |
schedulesContext:
|
Defined in src/app/tests/mocks/tasks.ts:53
|
Public taskDefinitions |
taskDefinitions:
|
Defined in src/app/tests/mocks/tasks.ts:64
|
Public taskExecutions |
taskExecutions:
|
Defined in src/app/tests/mocks/tasks.ts:68
|
Public taskSchedules |
taskSchedules:
|
Defined in src/app/tests/mocks/tasks.ts:66
|
Public tasksContext |
tasksContext:
|
Defined in src/app/tests/mocks/tasks.ts:33
|
Public testExecutionDetails |
testExecutionDetails:
|
Type : literal type
|
Defined in src/app/tests/mocks/tasks.ts:62
|
import { Observable, of } from 'rxjs';
import { Page } from '../../shared/model/page';
import { TaskExecution } from '../../tasks/model/task-execution';
import { TaskDefinition } from '../../tasks/model/task-definition';
import { ListDefaultParams, OrderParams } from '../../shared/components/shared.interface';
import { TaskSchedule } from '../../tasks/model/task-schedule';
import { TaskLaunchParams, TaskListParams } from '../../tasks/components/tasks.interface';
import { Platform } from '../../shared/model/platform';
/**
* Mock for TasksService.
*
* Create a mocked service:
* const tasksService = new MockTasksService();
* TestBed.configureTestingModule({
* providers: [
* { provide: TasksService, useValue: tasksService }
* ]
* }).compileComponents();
*
* Set app infos:
* tasksService.testAppInfos = { faketask: {name: 'fakename'}};
*
* Set app registrations:
* tasksService.testTaskAppRegistrations = [
* new AppRegistration('fakename', ApplicationType.task, 'fakeuri')
* ];
*
* @author Janne Valkealahti
*/
export class MockTasksService {
public tasksContext = {
q: '',
page: 0,
size: 20,
sort: 'taskName',
order: OrderParams.ASC,
itemsSelected: [],
itemsExpanded: []
};
public executionsContext = {
q: '',
page: 0,
size: 10,
sort: 'TASK_EXECUTION_ID',
order: OrderParams.DESC,
itemsSelected: [],
itemsExpanded: []
};
public schedulesContext = {
q: '',
page: 0,
size: 30,
sort: 'SCHEDULE_NAME',
order: OrderParams.DESC,
itemsSelected: []
};
public testExecutionDetails: {};
public taskDefinitions;
public taskSchedules;
public taskExecutions;
createDefinition(definition: string, name: string) {
return of({});
}
getExecution(id: string): Observable<TaskExecution> {
return of(this.testExecutionDetails[id]);
}
destroyDefinitions(taskDefinitions: TaskDefinition[]): Observable<Response> | Observable<any> {
return of(Array.from({ length: taskDefinitions.length }));
}
getExecutions(): Observable<Page<TaskExecution>> {
return of(TaskExecution.pageFromJSON(this.taskExecutions));
}
getDefinitions(): Observable<Page<TaskDefinition>> {
return of(TaskDefinition.pageFromJSON(this.taskDefinitions));
}
getSchedules(taskListParams: TaskListParams): Observable<Page<TaskSchedule>> {
return of(TaskSchedule.pageFromJSON(this.taskSchedules));
}
getSchedule(scheduleName: string): Observable<TaskSchedule> {
return of(TaskSchedule.fromJSON(this.taskSchedules._embedded.scheduleInfoResourceList[0]));
}
getDefinition(name: string): Observable<any> {
return of(TaskDefinition.fromJSON(this.taskDefinitions._embedded.taskDefinitionResourceList[0]));
}
destroySchedules(taskSchedules: TaskSchedule[]): Observable<any> {
return of(Array.from({ length: taskSchedules.length }));
}
getTaskExecutions(taskScheduleListParams: ListDefaultParams): Observable<Page<TaskExecution>> {
return this.getExecutions();
}
createSchedules() {
return of([{}]);
}
getPlatforms(): Observable<Platform[]> {
return of([
Platform.fromJSON({name: 'default', type: 'local', description: ''}),
Platform.fromJSON({name: 'foo', type: 'bar', description: 'foobar'})
]);
}
launchDefinition(taskLaunchParams: TaskLaunchParams): Observable<any> {
return of({});
}
}