import { StageMock } from "../stage/stage.mock" ; export class ProcessManagerMock implements Xrm . ProcessFlow . ProcessManager { public enabledProcesses : Xrm . Page . Process [ ] | Xrm . ProcessFlow . ProcessDictionary ; constructor ( enabledProcesses ) { this . enabledProcesses = enabledProcesses ; } public addOnPreProcessStatusChange ( handler ) { throw new Error ( "Method not implemented." ) ; } public addOnPreStageChange ( handler ) { throw new Error ( "Method not implemented." ) ; } public removeOnPreProcessStatusChange ( handler ) { throw new Error ( "Method not implemented." ) ; } public removeOnPreStageChange ( handler ) { throw new Error ( "Method not implemented." ) ; } public getActiveProcess ( ) { return ( this . enabledProcesses as Xrm . ProcessFlow . Process [ ] ) . filter ( ( p ) => { return p . isRendered ( ) ; } ) [ 0 ] || undefined ; } public setActiveProcess ( processId , callbackFunction ? ) { const activeProcess = this . getActiveProcess ( ) ; if ( activeProcess ) { const newProcess = ( this . enabledProcesses as Xrm . ProcessFlow . Process [ ] ) . filter ( ( p ) => { return p . getId ( ) === processId ; } ) [ 0 ] || undefined ; if ( newProcess ) { activeProcess . isRendered = ( ) => false ; newProcess . isRendered = ( ) => true ; } } } public setActiveProcessInstance ( processInstanceId , callbackFunction ) { throw new Error ( "set active process instance not implemented." ) ; } public getProcessInstances ( callbackFunction ) { throw new Error ( "get process instances not implemented." ) ; } public addOnProcessStatusChange ( handler ) { throw new Error ( "add on process status change not implemented." ) ; } public removeOnProcessStatusChange ( handler ) { throw new Error ( "remove on process status change not implemented." ) ; } public getInstanceId ( ) { const activeProcess = this . getActiveProcess ( ) ; const instanceId = activeProcess . getId ( ) || "" ; return instanceId ; } public getInstanceName ( ) { const activeProcess = this . getActiveProcess ( ) ; const instanceName = activeProcess . getName ( ) ; return instanceName ; } public getStatus ( ) { throw new Error ( "get status not implemented." ) ; } public setStatus ( status , callbackFunction ) { throw new Error ( "set status not implemented." ) ; } public getActiveStage ( ) { const activeProcess = this . getActiveProcess ( ) ; const stages = activeProcess . getStages ( ) ; const activeStages = [ ] ; stages . forEach ( ( s ) : void => { if ( s . getStatus ( ) === "active" ) { activeStages . push ( s ) ; } } ) ; return activeStages [ 0 ] || undefined ; } public setActiveStage ( stageId , callbackFunction ? ) { const activeProcess = this . getActiveProcess ( ) ; const stages = activeProcess . getStages ( ) ; let setStatus = "" ; stages . forEach ( ( s ) : void => { if ( s . getId ( ) === stageId ) { s . _setStatus ( "active" ) ; setStatus = "active" ; } else { s . _setStatus ( "inactive" ) ; } } ) ; if ( callbackFunction ) { callbackFunction ( setStatus ) ; } } public getActivePath ( ) { throw new Error ( "get active path not implemented" ) ; } public getEnabledProcesses ( callbackFunction ) { callbackFunction ( this . enabledProcesses as Xrm . ProcessFlow . ProcessDictionary ) ; } public getSelectedStage ( ) { throw new Error ( "get selected not implemented" ) ; } public addOnStageChange ( handler ) { throw new Error ( "add on stage change not implemented" ) ; } public addOnStageSelected ( handler ) { throw new Error ( "add on stage selected not implemented" ) ; } public removeOnStageChange ( handler ) { throw new Error ( "remove on stage change not implemented" ) ; } public removeOnStageSelected ( handler ) { throw new Error ( "remove on stage selected not implemented" ) ; } public moveNext ( callbackFunction ? ) { throw new Error ( "move next not implemented" ) ; } public movePrevious ( callbackFunction ? ) { throw new Error ( "move previous not implemented" ) ; } }