|
21 | 21 | import com.uber.cadence.common.CronSchedule; |
22 | 22 | import com.uber.cadence.common.MethodRetry; |
23 | 23 | import com.uber.cadence.common.RetryOptions; |
| 24 | +import com.uber.cadence.workflow.ChildWorkflowOptions; |
24 | 25 | import com.uber.cadence.workflow.WorkflowMethod; |
25 | 26 | import java.lang.reflect.Method; |
26 | 27 | import java.time.Duration; |
@@ -116,6 +117,37 @@ public void testBothPresent() throws NoSuchMethodException { |
116 | 117 | Assert.assertEquals("* 1 * * *", merged.getCronSchedule()); |
117 | 118 | } |
118 | 119 |
|
| 120 | + @Test |
| 121 | + public void testChildWorkflowOptionMerge() throws NoSuchMethodException { |
| 122 | + RetryOptions retryOptions = |
| 123 | + new RetryOptions.Builder() |
| 124 | + .setDoNotRetry(IllegalArgumentException.class) |
| 125 | + .setMaximumAttempts(11111) |
| 126 | + .setBackoffCoefficient(1.55) |
| 127 | + .setMaximumInterval(Duration.ofDays(3)) |
| 128 | + .setExpiration(Duration.ofDays(365)) |
| 129 | + .setInitialInterval(Duration.ofMinutes(12)) |
| 130 | + .build(); |
| 131 | + |
| 132 | + ChildWorkflowOptions o = |
| 133 | + new ChildWorkflowOptions.Builder() |
| 134 | + .setTaskList("foo") |
| 135 | + .setExecutionStartToCloseTimeout(Duration.ofSeconds(321)) |
| 136 | + .setTaskStartToCloseTimeout(Duration.ofSeconds(13)) |
| 137 | + .setWorkflowIdReusePolicy(WorkflowIdReusePolicy.RejectDuplicate) |
| 138 | + .setWorkflowId("bar") |
| 139 | + .setRetryOptions(retryOptions) |
| 140 | + .setCronSchedule("* 1 * * *") |
| 141 | + .build(); |
| 142 | + Method method = WorkflowOptionsTest.class.getMethod("defaultWorkflowOptions"); |
| 143 | + WorkflowMethod a = method.getAnnotation(WorkflowMethod.class); |
| 144 | + MethodRetry r = method.getAnnotation(MethodRetry.class); |
| 145 | + CronSchedule c = method.getAnnotation(CronSchedule.class); |
| 146 | + ChildWorkflowOptions merged = ChildWorkflowOptions.merge(a, r, c, o); |
| 147 | + Assert.assertEquals(retryOptions, merged.getRetryOptions()); |
| 148 | + Assert.assertEquals("* 1 * * *", merged.getCronSchedule()); |
| 149 | + } |
| 150 | + |
119 | 151 | @WorkflowMethod |
120 | 152 | @CronSchedule("asdf * * * *") |
121 | 153 | public void invalidCronScheduleAnnotation() {} |
|
0 commit comments