Skip to content

add missing support for contextAttributes in ProduceEvent #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/src/main/resources/schema/produce/produceevent.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
"data": {
"type": "string",
"description": "Workflow expression which selects parts of the states data output to become the data of the produced event"
},
"contextAttributes": {
"type": "object",
"description": "Add additional event extension context attributes",
"existingJavaType": "java.util.Map<String, String>"
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import io.serverlessworkflow.api.timeouts.WorkflowExecTimeout;
import io.serverlessworkflow.api.workflow.*;
import java.util.List;
import java.util.Map;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

Expand Down Expand Up @@ -260,6 +262,11 @@ public void testTransitions(String workflowLocation) {
assertEquals("RejectApplication", cond2.getTransition().getNextState());
assertNotNull(cond2.getTransition().getProduceEvents());
assertEquals(1, cond2.getTransition().getProduceEvents().size());
assertNotNull(cond2.getTransition().getProduceEvents().get(0).getContextAttributes());
Map<String, String> contextAttributes = cond2.getTransition().getProduceEvents().get(0).getContextAttributes();
assertEquals(2, contextAttributes.size());
assertEquals("IN", contextAttributes.get("order_location"));
assertEquals("online", contextAttributes.get("order_type"));
assertFalse(cond2.getTransition().isCompensate());

assertNotNull(switchState.getDefaultCondition());
Expand Down
6 changes: 5 additions & 1 deletion api/src/test/resources/features/transitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
"produceEvents": [
{
"eventRef": "provisioningCompleteEvent",
"data": "${ .provisionedOrders }"
"data": "${ .provisionedOrders }",
"contextAttributes": {
"order_location": "IN",
"order_type": "online"
}
}
]
}
Expand Down
3 changes: 3 additions & 0 deletions api/src/test/resources/features/transitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ states:
produceEvents:
- eventRef: provisioningCompleteEvent
data: "${ .provisionedOrders }"
contextAttributes:
"order_location": "IN"
"order_type": "online"
defaultCondition:
transition:
nextState: RejectApplication
Expand Down