pull out logical changes from @salaboy's PR to release it (#1420)

Signed-off-by: Cassandra Coyle <cassie@diagrid.io>
Signed-off-by: Cassie Coyle <cassie.i.coyle@gmail.com>
Signed-off-by: siri-varma <siri.varma@outlook.com>
This commit is contained in:
Cassie Coyle 2025-06-11 15:48:10 -05:00 committed by siri-varma
parent fab2fa05ff
commit 963cb77952
3 changed files with 18 additions and 12 deletions

View File

@ -347,10 +347,7 @@ public interface WorkflowContext {
* @param zonedDateTime timestamp with specific zone when the timer should expire * @param zonedDateTime timestamp with specific zone when the timer should expire
* @return a new {@code Task} that completes after the specified delay * @return a new {@code Task} that completes after the specified delay
*/ */
default Task<Void> createTimer(ZonedDateTime zonedDateTime) { Task<Void> createTimer(ZonedDateTime zonedDateTime);
throw new UnsupportedOperationException("This method is not implemented.");
}
/** /**
* Gets the deserialized input of the current task orchestration. * Gets the deserialized input of the current task orchestration.

View File

@ -33,6 +33,7 @@ import javax.annotation.Nullable;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -189,6 +190,11 @@ public class DefaultWorkflowContext implements WorkflowContext {
return this.innerContext.createTimer(duration); return this.innerContext.createTimer(duration);
} }
@Override
public Task<Void> createTimer(ZonedDateTime zonedDateTime) {
return this.innerContext.createTimer(zonedDateTime);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -39,14 +39,10 @@ import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.*;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class DefaultWorkflowContextTest { public class DefaultWorkflowContextTest {
private DefaultWorkflowContext context; private DefaultWorkflowContext context;
@ -124,6 +120,11 @@ public class DefaultWorkflowContextTest {
return null; return null;
} }
@Override
public Task<Void> createTimer(ZonedDateTime zonedDateTime) {
return null;
}
@Override @Override
public <V> V getInput(Class<V> targetType) { public <V> V getInput(Class<V> targetType) {
return null; return null;
@ -269,8 +270,10 @@ public class DefaultWorkflowContextTest {
} }
@Test @Test
public void createTimerWithZonedDateTimeThrowsTest() { public void createTimerWithZonedDateTimeTest() {
assertThrows(UnsupportedOperationException.class, () -> context.createTimer(ZonedDateTime.now())); ZonedDateTime now = ZonedDateTime.now();
context.createTimer(now);
verify(mockInnerContext, times(1)).createTimer(now);
} }
@Test @Test