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 3bda4070fb
commit 47da86d971
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
* @return a new {@code Task} that completes after the specified delay
*/
default Task<Void> createTimer(ZonedDateTime zonedDateTime) {
throw new UnsupportedOperationException("This method is not implemented.");
}
Task<Void> createTimer(ZonedDateTime zonedDateTime);
/**
* 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.Instant;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.UUID;
@ -189,6 +190,11 @@ public class DefaultWorkflowContext implements WorkflowContext {
return this.innerContext.createTimer(duration);
}
@Override
public Task<Void> createTimer(ZonedDateTime zonedDateTime) {
return this.innerContext.createTimer(zonedDateTime);
}
/**
* {@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.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
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;
import static org.mockito.Mockito.*;
public class DefaultWorkflowContextTest {
private DefaultWorkflowContext context;
@ -124,6 +120,11 @@ public class DefaultWorkflowContextTest {
return null;
}
@Override
public Task<Void> createTimer(ZonedDateTime zonedDateTime) {
return null;
}
@Override
public <V> V getInput(Class<V> targetType) {
return null;
@ -269,8 +270,10 @@ public class DefaultWorkflowContextTest {
}
@Test
public void createTimerWithZonedDateTimeThrowsTest() {
assertThrows(UnsupportedOperationException.class, () -> context.createTimer(ZonedDateTime.now()));
public void createTimerWithZonedDateTimeTest() {
ZonedDateTime now = ZonedDateTime.now();
context.createTimer(now);
verify(mockInnerContext, times(1)).createTimer(now);
}
@Test