|
17 | 17 |
|
18 | 18 | package com.uber.cadence.internal.testservice;
|
19 | 19 |
|
| 20 | +import static com.uber.cadence.internal.testservice.TestWorkflowMutableStateAttrUtil.*; |
| 21 | + |
20 | 22 | import com.cronutils.model.Cron;
|
21 | 23 | import com.cronutils.model.CronType;
|
22 | 24 | import com.cronutils.model.definition.CronDefinition;
|
|
72 | 74 | import com.uber.cadence.RespondDecisionTaskCompletedRequest;
|
73 | 75 | import com.uber.cadence.RespondDecisionTaskFailedRequest;
|
74 | 76 | import com.uber.cadence.RespondQueryTaskCompletedRequest;
|
75 |
| -import com.uber.cadence.RetryPolicy; |
76 | 77 | import com.uber.cadence.ScheduleActivityTaskDecisionAttributes;
|
77 | 78 | import com.uber.cadence.SignalExternalWorkflowExecutionDecisionAttributes;
|
78 | 79 | import com.uber.cadence.SignalExternalWorkflowExecutionFailedCause;
|
@@ -592,87 +593,19 @@ private void processScheduleActivityTask(
|
592 | 593 | ctx.lockTimer();
|
593 | 594 | }
|
594 | 595 |
|
595 |
| - private void validateScheduleActivityTask(ScheduleActivityTaskDecisionAttributes a) |
596 |
| - throws BadRequestError { |
597 |
| - if (a == null) { |
598 |
| - throw new BadRequestError("ScheduleActivityTaskDecisionAttributes is not set on decision."); |
599 |
| - } |
600 |
| - |
601 |
| - if (a.getTaskList() == null || a.getTaskList().getName().isEmpty()) { |
602 |
| - throw new BadRequestError("TaskList is not set on decision."); |
603 |
| - } |
604 |
| - if (a.getActivityId() == null || a.getActivityId().isEmpty()) { |
605 |
| - throw new BadRequestError("ActivityId is not set on decision."); |
606 |
| - } |
607 |
| - if (a.getActivityType() == null |
608 |
| - || a.getActivityType().getName() == null |
609 |
| - || a.getActivityType().getName().isEmpty()) { |
610 |
| - throw new BadRequestError("ActivityType is not set on decision."); |
611 |
| - } |
612 |
| - if (a.getStartToCloseTimeoutSeconds() <= 0) { |
613 |
| - throw new BadRequestError("A valid StartToCloseTimeoutSeconds is not set on decision."); |
614 |
| - } |
615 |
| - if (a.getScheduleToStartTimeoutSeconds() <= 0) { |
616 |
| - throw new BadRequestError("A valid ScheduleToStartTimeoutSeconds is not set on decision."); |
617 |
| - } |
618 |
| - if (a.getScheduleToCloseTimeoutSeconds() <= 0) { |
619 |
| - throw new BadRequestError("A valid ScheduleToCloseTimeoutSeconds is not set on decision."); |
620 |
| - } |
621 |
| - if (a.getHeartbeatTimeoutSeconds() < 0) { |
622 |
| - throw new BadRequestError("Ac valid HeartbeatTimeoutSeconds is not set on decision."); |
623 |
| - } |
624 |
| - } |
625 |
| - |
626 | 596 | private void processStartChildWorkflow(
|
627 | 597 | RequestContext ctx,
|
628 | 598 | StartChildWorkflowExecutionDecisionAttributes a,
|
629 | 599 | long decisionTaskCompletedId)
|
630 | 600 | throws BadRequestError, InternalServiceError {
|
631 | 601 | validateStartChildExecutionAttributes(a);
|
| 602 | + inheritUnsetPropertiesFromParentWorkflow(startRequest, a); |
632 | 603 | StateMachine<ChildWorkflowData> child = StateMachines.newChildWorkflowStateMachine(service);
|
633 | 604 | childWorkflows.put(ctx.getNextEventId(), child);
|
634 | 605 | child.action(StateMachines.Action.INITIATE, ctx, a, decisionTaskCompletedId);
|
635 | 606 | ctx.lockTimer();
|
636 | 607 | }
|
637 | 608 |
|
638 |
| - /** Clone of the validateStartChildExecutionAttributes from historyEngine.go */ |
639 |
| - private void validateStartChildExecutionAttributes( |
640 |
| - StartChildWorkflowExecutionDecisionAttributes a) throws BadRequestError { |
641 |
| - if (a == null) { |
642 |
| - throw new BadRequestError( |
643 |
| - "StartChildWorkflowExecutionDecisionAttributes is not set on decision."); |
644 |
| - } |
645 |
| - |
646 |
| - if (a.getWorkflowId().isEmpty()) { |
647 |
| - throw new BadRequestError("Required field WorkflowID is not set on decision."); |
648 |
| - } |
649 |
| - |
650 |
| - if (a.getWorkflowType() == null || a.getWorkflowType().getName().isEmpty()) { |
651 |
| - throw new BadRequestError("Required field WorkflowType is not set on decision."); |
652 |
| - } |
653 |
| - |
654 |
| - // Inherit tasklist from parent workflow execution if not provided on decision |
655 |
| - if (a.getTaskList() == null || a.getTaskList().getName().isEmpty()) { |
656 |
| - a.setTaskList(startRequest.getTaskList()); |
657 |
| - } |
658 |
| - |
659 |
| - // Inherit workflow timeout from parent workflow execution if not provided on decision |
660 |
| - if (a.getExecutionStartToCloseTimeoutSeconds() <= 0) { |
661 |
| - a.setExecutionStartToCloseTimeoutSeconds( |
662 |
| - startRequest.getExecutionStartToCloseTimeoutSeconds()); |
663 |
| - } |
664 |
| - |
665 |
| - // Inherit decision task timeout from parent workflow execution if not provided on decision |
666 |
| - if (a.getTaskStartToCloseTimeoutSeconds() <= 0) { |
667 |
| - a.setTaskStartToCloseTimeoutSeconds(startRequest.getTaskStartToCloseTimeoutSeconds()); |
668 |
| - } |
669 |
| - |
670 |
| - RetryPolicy retryPolicy = a.getRetryPolicy(); |
671 |
| - if (retryPolicy != null) { |
672 |
| - RetryState.validateRetryPolicy(retryPolicy); |
673 |
| - } |
674 |
| - } |
675 |
| - |
676 | 609 | private void processSignalExternalWorkflowExecution(
|
677 | 610 | RequestContext ctx,
|
678 | 611 | SignalExternalWorkflowExecutionDecisionAttributes a,
|
|
0 commit comments