Skip to content

Commit

Permalink
Fix task manager tests and remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
WMXPY committed Nov 5, 2023
1 parent 5207039 commit ff0f829
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 22 deletions.
1 change: 0 additions & 1 deletion src/task/apply/task-resolve-succeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const applyTaskResolveSucceedOnTaskManager = (
.withTaskIdentifier(action.payload.taskIdentifier),
);


const combineResult: boolean = task.combineExecuteOutput(action.payload.output);

if (!combineResult) {
Expand Down
56 changes: 56 additions & 0 deletions test/e2e/just-run/param-mapping.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* @author WMXPY
* @namespace JustRun
* @description Param Mapping
* @override E2E Test
*/

import { expect } from 'chai';
import * as Chance from 'chance';
import { createPubAction } from '../../../src/action/create';
import { PUB_ACTION_TYPE } from '../../../src/action/definition/action';
import { initializeCreateTaskManager } from '../../../src/orchestration/initialize/create-tasks';
import { applyActionOnTaskManager } from '../../../src/task/apply/apply';
import { PubTaskManager } from '../../../src/task/task-manager';
import { PubCachedWorkflowConfiguration } from '../../../src/workflow/cache/configuration';
import { justRunExample, justRunExampleStartProcedure } from '../../example/just-run';
import { ExpectTaskManager } from '../../expect/expect-task-manager';

describe('Given (Just-Run Param Mapping) Use Case', (): void => {

const chance: Chance.Chance = new Chance('e2e-just-run-param-mapping');

const helloMessage: string = chance.string();

const justRunConfiguration: PubCachedWorkflowConfiguration =
PubCachedWorkflowConfiguration.fromWorkflowConfiguration(
justRunExample,
);

it('Should be able to map variable from start to first', (): void => {

const taskManager: PubTaskManager = initializeCreateTaskManager(justRunConfiguration);

const applyResult: boolean = applyActionOnTaskManager(
createPubAction(PUB_ACTION_TYPE.TASK_RESOLVE_SUCCEED, {
taskIdentifier: taskManager
.getTasksByProcedureIdentifier(
justRunExampleStartProcedure.identifier,
)[0]
.taskIdentifier,
output: {
hello: helloMessage,
},
}),
taskManager,
);

expect(applyResult).to.be.true;

ExpectTaskManager.with(taskManager)
.forSingleTaskWithProcedureIdentifier("JUST_RUN")
.toHasInput({
world: helloMessage,
});
});
});
2 changes: 1 addition & 1 deletion test/e2e/just-run/param-validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('Given (Just-Run Param Validate) Use Case', (): void => {
expect(applyResult).to.be.true;

ExpectTaskManager.with(taskManager)
.forTaskWithProcedureIdentifier(justRunExampleStartProcedure.identifier)
.forSingleTaskWithProcedureIdentifier(justRunExampleStartProcedure.identifier)
.toHasStatus(PUB_TASK_STATUS.RESOLVED)
.toNotHaveInput()
.toHasOutput({
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/many-to-one/execute-in-order.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('Given (Many-To-One Execute In Order) Use Case', (): void => {
.hasExecutableTaskLength(1);

ExpectTaskManager.with(taskManager)
.forTaskWithProcedureIdentifier("START")
.forSingleTaskWithProcedureIdentifier("START")
.toBeExecutable();
});

Expand All @@ -65,13 +65,13 @@ describe('Given (Many-To-One Execute In Order) Use Case', (): void => {
.hasExecutableTaskLength(3);

ExpectTaskManager.with(taskManager)
.forTaskWithProcedureIdentifier("FIRST")
.forSingleTaskWithProcedureIdentifier("FIRST")
.toBeExecutable();
ExpectTaskManager.with(taskManager)
.forTaskWithProcedureIdentifier("SECOND")
.forSingleTaskWithProcedureIdentifier("SECOND")
.toBeExecutable();
ExpectTaskManager.with(taskManager)
.forTaskWithProcedureIdentifier("THIRD")
.forSingleTaskWithProcedureIdentifier("THIRD")
.toBeExecutable();
});

Expand All @@ -91,10 +91,10 @@ describe('Given (Many-To-One Execute In Order) Use Case', (): void => {
.hasExecutableTaskLength(2);

ExpectTaskManager.with(taskManager)
.forTaskWithProcedureIdentifier("SECOND")
.forSingleTaskWithProcedureIdentifier("SECOND")
.toBeExecutable();
ExpectTaskManager.with(taskManager)
.forTaskWithProcedureIdentifier("THIRD")
.forSingleTaskWithProcedureIdentifier("THIRD")
.toBeExecutable();
});

Expand All @@ -114,7 +114,7 @@ describe('Given (Many-To-One Execute In Order) Use Case', (): void => {
.hasExecutableTaskLength(1);

ExpectTaskManager.with(taskManager)
.forTaskWithProcedureIdentifier("THIRD")
.forSingleTaskWithProcedureIdentifier("THIRD")
.toBeExecutable();
});

Expand All @@ -134,7 +134,7 @@ describe('Given (Many-To-One Execute In Order) Use Case', (): void => {
.hasExecutableTaskLength(1);

ExpectTaskManager.with(taskManager)
.forTaskWithProcedureIdentifier("END")
.forSingleTaskWithProcedureIdentifier("END")
.toBeExecutable();
});
});
Expand Down
22 changes: 11 additions & 11 deletions test/e2e/one-to-many/execute-in-order.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Given (One-To-Many Execute In Order) Use Case', (): void => {

ExpectTaskManager.with(taskManager)
.hasExecutableTaskLength(1)
.forTaskWithProcedureIdentifier("START")
.forSingleTaskWithProcedureIdentifier("START")
.toBeExecutable();
});

Expand All @@ -61,7 +61,7 @@ describe('Given (One-To-Many Execute In Order) Use Case', (): void => {

ExpectTaskManager.with(taskManager)
.hasExecutableTaskLength(1)
.forTaskWithProcedureIdentifier("INIT")
.forSingleTaskWithProcedureIdentifier("INIT")
.toBeExecutable();
});

Expand All @@ -81,13 +81,13 @@ describe('Given (One-To-Many Execute In Order) Use Case', (): void => {
.hasExecutableTaskLength(3);

ExpectTaskManager.with(taskManager)
.forTaskWithProcedureIdentifier("FIRST")
.forSingleTaskWithProcedureIdentifier("FIRST")
.toBeExecutable();
ExpectTaskManager.with(taskManager)
.forTaskWithProcedureIdentifier("SECOND")
.forSingleTaskWithProcedureIdentifier("SECOND")
.toBeExecutable();
ExpectTaskManager.with(taskManager)
.forTaskWithProcedureIdentifier("THIRD")
.forSingleTaskWithProcedureIdentifier("THIRD")
.toBeExecutable();
});

Expand All @@ -107,13 +107,13 @@ describe('Given (One-To-Many Execute In Order) Use Case', (): void => {
.hasExecutableTaskLength(3);

ExpectTaskManager.with(taskManager)
.forTaskWithProcedureIdentifier("END")
.forSingleTaskWithProcedureIdentifier("END")
.toBeExecutable();
ExpectTaskManager.with(taskManager)
.forTaskWithProcedureIdentifier("SECOND")
.forSingleTaskWithProcedureIdentifier("SECOND")
.toBeExecutable();
ExpectTaskManager.with(taskManager)
.forTaskWithProcedureIdentifier("THIRD")
.forSingleTaskWithProcedureIdentifier("THIRD")
.toBeExecutable();
});

Expand All @@ -133,10 +133,10 @@ describe('Given (One-To-Many Execute In Order) Use Case', (): void => {
.hasExecutableTaskLength(2);

ExpectTaskManager.with(taskManager)
.forTaskWithProcedureIdentifier("END")
.forSingleTaskWithProcedureIdentifier("END")
.toBeExecutable();
ExpectTaskManager.with(taskManager)
.forTaskWithProcedureIdentifier("THIRD")
.forSingleTaskWithProcedureIdentifier("THIRD")
.toBeExecutable();
});

Expand All @@ -156,7 +156,7 @@ describe('Given (One-To-Many Execute In Order) Use Case', (): void => {
.hasExecutableTaskLength(1);

ExpectTaskManager.with(taskManager)
.forTaskWithProcedureIdentifier("END")
.forSingleTaskWithProcedureIdentifier("END")
.toBeExecutable();
});
});
Expand Down
1 change: 1 addition & 0 deletions test/example/just-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const justRunExample: PubWorkflowConfiguration = {
nextProcedureWaypointType: PUB_CONNECTION_WAYPOINT_TYPE.PROCEDURE_SELF_START,

parametersMapping: {
hello: "world",
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion test/expect/expect-task-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class ExpectTaskManager {
return ExpectTask.with(task.getOrThrow());
}

public forTaskWithProcedureIdentifier(identifier: string): ExpectTask {
public forSingleTaskWithProcedureIdentifier(identifier: string): ExpectTask {

const tasks = this._taskManager.getTasksByProcedureIdentifier(identifier);

Expand Down

0 comments on commit ff0f829

Please sign in to comment.