Skip to content

Commit 7f95c93

Browse files
add missing support for contextAttributes in ProduceEvent
Signed-off-by: Vishesh Ruparelia <[email protected]>
1 parent 81f6928 commit 7f95c93

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

api/src/main/resources/schema/produce/produceevent.json

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
"data": {
1111
"type": "string",
1212
"description": "Workflow expression which selects parts of the states data output to become the data of the produced event"
13+
},
14+
"contextAttributes": {
15+
"type": "object",
16+
"description": "Add additional event extension context attributes",
17+
"existingJavaType": "java.util.Map<String, String>"
1318
}
1419
},
1520
"required": [

api/src/test/java/io/serverlessworkflow/api/test/MarkupToWorkflowTest.java

+7
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
import io.serverlessworkflow.api.timeouts.WorkflowExecTimeout;
4141
import io.serverlessworkflow.api.workflow.*;
4242
import java.util.List;
43+
import java.util.Map;
44+
4345
import org.junit.jupiter.params.ParameterizedTest;
4446
import org.junit.jupiter.params.provider.ValueSource;
4547

@@ -260,6 +262,11 @@ public void testTransitions(String workflowLocation) {
260262
assertEquals("RejectApplication", cond2.getTransition().getNextState());
261263
assertNotNull(cond2.getTransition().getProduceEvents());
262264
assertEquals(1, cond2.getTransition().getProduceEvents().size());
265+
assertNotNull(cond2.getTransition().getProduceEvents().get(0).getContextAttributes());
266+
Map<String, String> contextAttributes = cond2.getTransition().getProduceEvents().get(0).getContextAttributes();
267+
assertEquals(2, contextAttributes.size());
268+
assertEquals("IN", contextAttributes.get("order_location"));
269+
assertEquals("online", contextAttributes.get("order_type"));
263270
assertFalse(cond2.getTransition().isCompensate());
264271

265272
assertNotNull(switchState.getDefaultCondition());

api/src/test/resources/features/transitions.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
"produceEvents": [
2424
{
2525
"eventRef": "provisioningCompleteEvent",
26-
"data": "${ .provisionedOrders }"
26+
"data": "${ .provisionedOrders }",
27+
"contextAttributes": {
28+
"order_location": "IN",
29+
"order_type": "online"
30+
}
2731
}
2832
]
2933
}

api/src/test/resources/features/transitions.yml

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ states:
1818
produceEvents:
1919
- eventRef: provisioningCompleteEvent
2020
data: "${ .provisionedOrders }"
21+
contextAttributes:
22+
"order_location": "IN"
23+
"order_type": "online"
2124
defaultCondition:
2225
transition:
2326
nextState: RejectApplication

0 commit comments

Comments
 (0)