Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [AAE-5958] added stories and mocks * [AAE-5958] arefactored mocks * [AAE-5958] added interface for mock and live process cloud service * [AAE-5958] added story and mock for header placeholders
- Loading branch information
Showing
8 changed files
with
242 additions
and
31 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
lib/process-services-cloud/src/lib/process/mock/process-cloud.service.mock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/*! | ||
* @license | ||
* Copyright 2019 Alfresco Software, Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { LogService } from '@alfresco/adf-core'; | ||
import { Injectable } from '@angular/core'; | ||
import { Observable, of, Subject, throwError } from 'rxjs'; | ||
import { ProcessInstanceCloud } from '../start-process/models/process-instance-cloud.model'; | ||
import { ProcessDefinitionCloud } from '../../models/process-definition-cloud.model'; | ||
import { ApplicationVersionModel } from '../../models/application-version.model'; | ||
import { processInstancePlaceholdersCloudMock, processInstanceDetailsCloudMock } from './process-instance-details-cloud.mock'; | ||
import { fakeProcessDefinitions } from '../start-process/mock/start-process.component.mock'; | ||
import { mockAppVersions } from '../process-filters/mock/process-filters-cloud.mock'; | ||
import { ProcessCloudInterface } from '../services/process-cloud.interface'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class ProcessCloudServiceMock implements ProcessCloudInterface { | ||
|
||
dataChangesDetected = new Subject<ProcessInstanceCloud>(); | ||
|
||
constructor(private logService: LogService) { } | ||
|
||
getProcessInstanceById(appName: string, processInstanceId: string): Observable<ProcessInstanceCloud> { | ||
if (appName === 'app-placeholders' && processInstanceId) { | ||
return of(processInstancePlaceholdersCloudMock); | ||
} | ||
|
||
if (appName && processInstanceId) { | ||
return of(processInstanceDetailsCloudMock); | ||
|
||
} else { | ||
this.logService.error('AppName and ProcessInstanceId are mandatory for querying a process'); | ||
return throwError('AppName/ProcessInstanceId not configured'); | ||
} | ||
} | ||
|
||
getProcessDefinitions(appName: string): Observable<ProcessDefinitionCloud[]> { | ||
if (appName || appName === '') { | ||
return of(fakeProcessDefinitions); | ||
|
||
} else { | ||
this.logService.error('AppName is mandatory for querying task'); | ||
return throwError('AppName not configured'); | ||
} | ||
} | ||
|
||
getApplicationVersions(appName: string): Observable<ApplicationVersionModel[]> { | ||
if (appName) { | ||
return of(mockAppVersions); | ||
} else { | ||
this.logService.error('AppName is mandatory for querying the versions of an application'); | ||
return throwError('AppName not configured'); | ||
} | ||
} | ||
|
||
cancelProcess(appName: string, processInstanceId: string): Observable<ProcessInstanceCloud> { | ||
if (appName && processInstanceId) { | ||
return of(); | ||
} else { | ||
this.logService.error('App name and Process id are mandatory for deleting a process'); | ||
return throwError('App name and process id not configured'); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
lib/process-services-cloud/src/lib/process/mock/process-instance-details-cloud.mock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/*! | ||
* @license | ||
* Copyright 2019 Alfresco Software, Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { ProcessInstanceCloud } from '../start-process/models/process-instance-cloud.model'; | ||
|
||
export const processInstanceDetailsCloudMock: ProcessInstanceCloud = { | ||
appName: 'app-form-mau', | ||
businessKey: 'MyBusinessKey', | ||
id: '00fcc4ab-4290-11e9-b133-0a586460016a', | ||
initiator: 'devopsuser', | ||
lastModified: new Date(1552152187081), | ||
name: 'new name', | ||
parentId: '00fcc4ab-4290-11e9-b133-0a586460016b', | ||
startDate: new Date(1552152187080), | ||
status: 'RUNNING' | ||
}; | ||
|
||
export const processInstancePlaceholdersCloudMock: ProcessInstanceCloud = { | ||
appName: 'app-placeholders', | ||
businessKey: '', | ||
id: '00fcc4ab-4290-11e9-b133-0a586460016a', | ||
initiator: 'devopsuser', | ||
lastModified: new Date(1552152187081), | ||
name: '', | ||
parentId: '', | ||
startDate: new Date(1552152187080), | ||
status: 'RUNNING' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...cloud/src/lib/process/process-header/components/process-header-cloud.component.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/*! | ||
* @license | ||
* Copyright 2019 Alfresco Software, Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { Meta, moduleMetadata, Story } from '@storybook/angular'; | ||
import { ProcessHeaderCloudModule } from '../process-header-cloud.module'; | ||
import { ProcessServicesCloudStoryModule } from '../../../testing/process-services-cloud-story.module'; | ||
import { ProcessHeaderCloudComponent } from './process-header-cloud.component'; | ||
import { ProcessCloudServiceMock } from '../../mock/process-cloud.service.mock'; | ||
import { ProcessCloudService } from '../../services/process-cloud.service'; | ||
|
||
export default { | ||
component: ProcessHeaderCloudComponent, | ||
title: 'Process Services Cloud/Components/Process Header', | ||
decorators: [ | ||
moduleMetadata({ | ||
imports: [ProcessServicesCloudStoryModule, ProcessHeaderCloudModule], | ||
providers: [{ provide: ProcessCloudService, useClass: ProcessCloudServiceMock }] | ||
}) | ||
], | ||
argTypes: { | ||
appName: { table: { disable: true } }, | ||
processInstanceId: { table: { disable: true } } | ||
} | ||
} as Meta; | ||
|
||
const template: Story<ProcessHeaderCloudComponent> = (args: ProcessHeaderCloudComponent) => ({ | ||
props: args | ||
}); | ||
|
||
export const primary = template.bind({}); | ||
primary.args = { | ||
appName: 'app', | ||
processInstanceId: 'mock-process-id' | ||
}; | ||
|
||
export const noParentAndBusinessAndName = template.bind({}); | ||
noParentAndBusinessAndName.args = { | ||
appName: 'app-placeholders', | ||
processInstanceId: 'mock-process-id' | ||
}; | ||
|
||
export const invalidOrMissingAppName = template.bind({}); | ||
invalidOrMissingAppName.args = { | ||
appName: undefined, | ||
processInstanceId: 'mock-process-id' | ||
}; | ||
|
||
export const invalidOrMissingProcessInstanceID = template.bind({}); | ||
invalidOrMissingProcessInstanceID.args = { | ||
appName: 'app', | ||
processInstanceId: undefined | ||
}; |
31 changes: 31 additions & 0 deletions
31
lib/process-services-cloud/src/lib/process/services/process-cloud.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/*! | ||
* @license | ||
* Copyright 2019 Alfresco Software, Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { Observable, Subject } from 'rxjs'; | ||
import { ProcessInstanceCloud } from '../start-process/models/process-instance-cloud.model'; | ||
import { ProcessDefinitionCloud } from '../../models/process-definition-cloud.model'; | ||
import { ApplicationVersionModel } from '../../models/application-version.model'; | ||
|
||
export interface ProcessCloudInterface { | ||
|
||
dataChangesDetected: Subject<ProcessInstanceCloud>; | ||
|
||
getProcessInstanceById(appName: string, processInstanceId: string): Observable<ProcessInstanceCloud>; | ||
getProcessDefinitions(appName: string): Observable<ProcessDefinitionCloud[]>; | ||
getApplicationVersions(appName: string): Observable<ApplicationVersionModel[]>; | ||
cancelProcess(appName: string, processInstanceId: string): Observable<ProcessInstanceCloud>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters