Skip to content

Commit ef6071a

Browse files
authored
Merge pull request #3 from antmendoza/add_methods_workflowBuilder
added methods to workflowbuilder
2 parents 400debd + 8177a7b commit ef6071a

File tree

5 files changed

+408
-387
lines changed

5 files changed

+408
-387
lines changed

spec/workflow.builder.spec.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,62 @@ describe("workflow builder", () => {
5151
});
5252

5353

54+
it("should create a workflow with all fields", () => {
55+
const workflow: Workflow =
56+
new WorkflowBuilder()
57+
.withId("helloworld")
58+
.withName("hello world")
59+
.withVersion("0.6")
60+
.withStart("hello builder")
61+
.withStates([new InjectStateBuilder()
62+
.withName("Hello State")
63+
.withData({
64+
"result": "Hello World!",
65+
})
66+
.withEnd(true).build()])
67+
.withDescription("hello builder description")
68+
.withSchemaVersion("0.6")
69+
.withSchemaVersion("1.0")
70+
.withExpressionLang("jq")
71+
.withExecTimeout({duration: 'PT2M'})
72+
.withKeepActive(true)
73+
.withMetadata({
74+
"key1": "value1",
75+
"key2": "value2",
76+
})
77+
.withEvents("http://myhost:8080/eventsdefs.json")
78+
.withFunctions("http://myhost:8080/functionsdefs.json")
79+
.withRetries("http://myhost:8080/retriesdefs.json")
80+
.build();
81+
82+
expect(workflow).toEqual({
83+
"id": "helloworld",
84+
"name": "hello world",
85+
"version": "0.6",
86+
"start": "hello builder",
87+
"states": [{
88+
"type": "inject", "name": "Hello State",
89+
"data": {"result": "Hello World!"},
90+
"end": true,
91+
}],
92+
"description": "hello builder description",
93+
"schemaVersion": "1.0",
94+
"expressionLang": "jq",
95+
"execTimeout": {duration: 'PT2M'},
96+
"keepActive": true,
97+
"metadata": {
98+
"key1": "value1",
99+
"key2": "value2",
100+
},
101+
"events": "http://myhost:8080/eventsdefs.json",
102+
"functions": "http://myhost:8080/functionsdefs.json",
103+
"retries": "http://myhost:8080/retriesdefs.json",
104+
},
105+
);
106+
107+
});
108+
109+
54110
it("should invoke validator class", () => {
55111

56112
const workflowValidator = new WorkflowValidator({});

src/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2021-Present The Serverless Workflow Specification Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
117
export {BaseWorkflow} from "./base-workflow";
218
export {ActionBuilder} from "./model/action.builder";
319
export {DatabasedSwitchBuilder} from "./model/databased-switch.builder";

0 commit comments

Comments
 (0)