mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
AAE-40657 Support multiple integration contexts in task service (#11463)
This commit is contained in:
@@ -47,3 +47,52 @@ export interface ServiceTaskIntegrationContextCloudModel extends ServiceTaskQuer
|
||||
errorCode?: string;
|
||||
errorMessage?: string;
|
||||
}
|
||||
|
||||
export interface StackTraceElement {
|
||||
className: string;
|
||||
fileName: string;
|
||||
lineNumber: number;
|
||||
}
|
||||
|
||||
export interface IntegrationContextsPaginationModel {
|
||||
skipCount: number;
|
||||
maxItems: number;
|
||||
count: number;
|
||||
hasMoreItems: boolean;
|
||||
totalItems: number;
|
||||
}
|
||||
|
||||
export interface IntegrationContext {
|
||||
id: string;
|
||||
serviceName: string;
|
||||
serviceFullName: string;
|
||||
serviceVersion: string;
|
||||
appName: string;
|
||||
inBoundVariables: Record<string, any>;
|
||||
outBoundVariables: Record<string, any>;
|
||||
rootProcessInstanceId: string;
|
||||
processInstanceId: string;
|
||||
executionId: string;
|
||||
processDefinitionId: string;
|
||||
processDefinitionKey: string;
|
||||
processDefinitionVersion: number;
|
||||
clientId: string;
|
||||
clientName: string;
|
||||
clientType: string;
|
||||
connectorType: string;
|
||||
requestDate: string;
|
||||
resultDate?: string;
|
||||
stackTraceElements: StackTraceElement[];
|
||||
status: string;
|
||||
errorDate?: string;
|
||||
errorClassName?: string;
|
||||
errorCode?: string;
|
||||
errorMessage?: string;
|
||||
}
|
||||
|
||||
export interface IntegrationContextsRequestModel {
|
||||
appName: string;
|
||||
maxItems: number;
|
||||
skipCount: number;
|
||||
sorting?: TaskListCloudSortingModel[];
|
||||
}
|
||||
|
||||
+79
-1
@@ -17,7 +17,7 @@
|
||||
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { ServiceTaskListCloudService } from './service-task-list-cloud.service';
|
||||
import { ServiceTaskQueryCloudRequestModel } from '../models/service-task-cloud.model';
|
||||
import { ServiceTaskQueryCloudRequestModel, IntegrationContextsRequestModel } from '../models/service-task-cloud.model';
|
||||
import { firstValueFrom, of } from 'rxjs';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
@@ -31,6 +31,8 @@ describe('Activiti ServiceTaskList Cloud Service', () => {
|
||||
|
||||
const returnCallUrl = (queryUrl) => Promise.resolve(queryUrl);
|
||||
|
||||
const returnMockResponse = (response) => (_queryUrl, _options) => Promise.resolve(response);
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule]
|
||||
@@ -152,4 +154,80 @@ describe('Activiti ServiceTaskList Cloud Service', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getServiceTaskIntegrationContexts method', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(service, 'getBasePath').and.returnValue('http://localhost/fakeName');
|
||||
});
|
||||
|
||||
it('should append pagination parameters to the call', async () => {
|
||||
const requestModel: IntegrationContextsRequestModel = {
|
||||
appName: 'fakeName',
|
||||
maxItems: 5,
|
||||
skipCount: 10
|
||||
};
|
||||
const mockResponse = {
|
||||
list: {
|
||||
entries: [{ entry: { id: '1' } }],
|
||||
pagination: {
|
||||
skipCount: 10,
|
||||
maxItems: 5,
|
||||
totalItems: 1
|
||||
}
|
||||
}
|
||||
};
|
||||
requestSpy.and.callFake(returnMockResponse(mockResponse));
|
||||
const result = await firstValueFrom(service.getServiceTaskIntegrationContexts('fakeName', 'serviceTaskId', requestModel));
|
||||
expect(requestSpy).toHaveBeenCalled();
|
||||
const callArgs = requestSpy.calls.mostRecent().args;
|
||||
expect(callArgs[1].queryParams.maxItems).toBe(5);
|
||||
expect(callArgs[1].queryParams.skipCount).toBe(10);
|
||||
expect(result.list.entries).toBeDefined();
|
||||
});
|
||||
|
||||
it('should append sorting parameter to the call', async () => {
|
||||
const requestModel: IntegrationContextsRequestModel = {
|
||||
appName: 'fakeName',
|
||||
maxItems: 5,
|
||||
skipCount: 0,
|
||||
sorting: [{ orderBy: 'requestDate', direction: 'DESC' }]
|
||||
};
|
||||
requestSpy.and.callFake(returnCallQueryParameters);
|
||||
const result: any = await firstValueFrom(service.getServiceTaskIntegrationContexts('fakeName', 'serviceTaskId', requestModel));
|
||||
expect(result).toBeDefined();
|
||||
expect(result.sort).toBe('requestDate,DESC');
|
||||
expect(result.maxItems).toBe(5);
|
||||
expect(result.skipCount).toBe(0);
|
||||
});
|
||||
|
||||
it('should concat the app name and service task id to the request url', async () => {
|
||||
const requestModel: IntegrationContextsRequestModel = {
|
||||
appName: 'fakeName',
|
||||
maxItems: 5,
|
||||
skipCount: 0
|
||||
};
|
||||
requestSpy.and.callFake(returnCallUrl);
|
||||
const requestUrl = await firstValueFrom(service.getServiceTaskIntegrationContexts('fakeName', 'serviceTaskId123', requestModel));
|
||||
expect(requestUrl).toBeDefined();
|
||||
expect(requestUrl).toContain('/fakeName/query/admin/v1/service-tasks/serviceTaskId123/integration-contexts');
|
||||
});
|
||||
|
||||
it('should handle multiple sorting parameters', async () => {
|
||||
const requestModel: IntegrationContextsRequestModel = {
|
||||
appName: 'fakeName',
|
||||
maxItems: 5,
|
||||
skipCount: 0,
|
||||
sorting: [
|
||||
{ orderBy: 'requestDate', direction: 'DESC' },
|
||||
{ orderBy: 'status', direction: 'ASC' }
|
||||
]
|
||||
};
|
||||
requestSpy.and.callFake(returnCallQueryParameters);
|
||||
const result: any = await firstValueFrom(service.getServiceTaskIntegrationContexts('fakeName', 'serviceTaskId', requestModel));
|
||||
expect(result).toBeDefined();
|
||||
expect(result.sort).toBe('requestDate,DESC&status,ASC');
|
||||
expect(result.maxItems).toBe(5);
|
||||
expect(result.skipCount).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+30
-1
@@ -16,7 +16,13 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ServiceTaskQueryCloudRequestModel, ServiceTaskIntegrationContextCloudModel } from '../models/service-task-cloud.model';
|
||||
import {
|
||||
ServiceTaskQueryCloudRequestModel,
|
||||
ServiceTaskIntegrationContextCloudModel,
|
||||
IntegrationContext,
|
||||
IntegrationContextsRequestModel,
|
||||
IntegrationContextsPaginationModel
|
||||
} from '../models/service-task-cloud.model';
|
||||
import { Observable, throwError } from 'rxjs';
|
||||
import { TaskListCloudSortingModel } from '../../../models/task-list-sorting.model';
|
||||
import { BaseCloudService } from '../../../services/base-cloud.service';
|
||||
@@ -60,6 +66,29 @@ export class ServiceTaskListCloudService extends BaseCloudService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds service task integration contexts using pagination and sorting.
|
||||
*
|
||||
* @param appName string
|
||||
* @param serviceTaskId string
|
||||
* @param requestModel Request model with pagination and sorting
|
||||
* @returns Service Task Integration Contexts with pagination information
|
||||
*/
|
||||
getServiceTaskIntegrationContexts(
|
||||
appName: string,
|
||||
serviceTaskId: string,
|
||||
requestModel: IntegrationContextsRequestModel
|
||||
): Observable<{ list: { entries: IntegrationContext[]; pagination: IntegrationContextsPaginationModel } }> {
|
||||
const queryUrl = `${this.getBasePath(appName)}/query/admin/v1/service-tasks/${serviceTaskId}/integration-contexts`;
|
||||
const queryParams = this.buildQueryParams(requestModel);
|
||||
const sortingParams = this.buildSortingParam(requestModel.sorting);
|
||||
if (sortingParams) {
|
||||
queryParams['sort'] = sortingParams;
|
||||
}
|
||||
|
||||
return this.get(queryUrl, queryParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replay a service task based on the related execution id and flow-node id
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user