mirror of https://github.com/dapr/java-sdk.git
Pull out createTimer logic (#1419)
* pull out logical changes from @salaboy's PR to release it Signed-off-by: Cassandra Coyle <cassie@diagrid.io> * add missing import Signed-off-by: Cassandra Coyle <cassie@diagrid.io> --------- Signed-off-by: Cassandra Coyle <cassie@diagrid.io> Signed-off-by: sirivarma <siri.varma@outlook.com>
This commit is contained in:
parent
f291658a8c
commit
d7e7205c17
|
|
@ -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.
|
||||||
|
|
|
||||||
|
|
@ -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}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue