Skip to content

Commit f6d4d46

Browse files
Make sure user metadata is set on WorkflowExecutionStartedEvent (#2496)
1 parent 04fe25a commit f6d4d46

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

temporal-sdk/src/test/java/io/temporal/workflow/childWorkflowTests/ChildWorkflowMetadataTest.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,27 @@ public void testChildWorkflowWithMetaData() {
7070

7171
WorkflowExecution exec = WorkflowStub.fromTyped(stub).getExecution();
7272
assertWorkflowMetadata(exec.getWorkflowId(), summary, details);
73-
assertWorkflowMetadata(childWorkflowId, childSummary, childDetails);
7473

7574
WorkflowExecutionHistory workflowExecutionHistory =
75+
testWorkflowRule.getWorkflowClient().fetchHistory(exec.getWorkflowId());
76+
List<HistoryEvent> workflowStartedEvents =
77+
workflowExecutionHistory.getEvents().stream()
78+
.filter(HistoryEvent::hasWorkflowExecutionStartedEventAttributes)
79+
.collect(Collectors.toList());
80+
assertEventMetadata(workflowStartedEvents.get(0), summary, details);
81+
82+
assertWorkflowMetadata(childWorkflowId, childSummary, childDetails);
83+
84+
WorkflowExecutionHistory childWorkflowExecutionHistory =
7685
testWorkflowRule.getWorkflowClient().fetchHistory(childWorkflowId);
86+
List<HistoryEvent> childWorkflowStartedEvents =
87+
childWorkflowExecutionHistory.getEvents().stream()
88+
.filter(HistoryEvent::hasWorkflowExecutionStartedEventAttributes)
89+
.collect(Collectors.toList());
90+
assertEventMetadata(childWorkflowStartedEvents.get(0), childSummary, childDetails);
91+
7792
List<HistoryEvent> timerStartedEvents =
78-
workflowExecutionHistory.getEvents().stream()
93+
childWorkflowExecutionHistory.getEvents().stream()
7994
.filter(HistoryEvent::hasTimerStartedEventAttributes)
8095
.collect(Collectors.toList());
8196
assertEventMetadata(timerStartedEvents.get(0), childTimerSummary, null);

temporal-test-server/src/main/java/io/temporal/internal/testservice/StateMachines.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,9 @@ private static void startWorkflow(
13631363
if (request.getLinksCount() > 0) {
13641364
event.addAllLinks(request.getLinksList());
13651365
}
1366+
if (request.hasUserMetadata()) {
1367+
event.setUserMetadata(request.getUserMetadata());
1368+
}
13661369
ctx.addEvent(event.build());
13671370
}
13681371

0 commit comments

Comments
 (0)