use of com.uber.cadence.internal.worker.DecisionTaskHandler in project cadence-client by uber-java.
the class ReplayDeciderTaskHandlerTests method ifCacheIsEvictedAndPartialHistoryIsReceivedThenTaskFailedIsReturned.
@Test
public void ifCacheIsEvictedAndPartialHistoryIsReceivedThenTaskFailedIsReturned() throws Throwable {
// Arrange
DeciderCache cache = new DeciderCache(10, NoopScope.getInstance());
StickyExecutionAttributes attributes = new StickyExecutionAttributes();
attributes.setWorkerTaskList(createStickyTaskList("sticky"));
DecisionTaskHandler taskHandler = new ReplayDecisionTaskHandler("domain", setUpMockWorkflowFactory(), cache, SingleWorkerOptions.newBuilder().build(), "sticky", Duration.ofSeconds(5), new TestWorkflowService(), null);
// Act
DecisionTaskHandler.Result result = taskHandler.handleDecisionTask(HistoryUtils.generateDecisionTaskWithPartialHistory());
// Assert
assertEquals(0, cache.size());
assertNull(result.getTaskCompleted());
assertNotNull(result.getTaskFailed());
}
use of com.uber.cadence.internal.worker.DecisionTaskHandler in project cadence-client by uber-java.
the class ReplayDeciderTaskHandlerTests method ifStickyExecutionAttributesAreNotSetThenWorkflowsAreNotCached.
@Test
public void ifStickyExecutionAttributesAreNotSetThenWorkflowsAreNotCached() throws Throwable {
// Arrange
DeciderCache cache = new DeciderCache(10, NoopScope.getInstance());
DecisionTaskHandler taskHandler = new ReplayDecisionTaskHandler("domain", setUpMockWorkflowFactory(), cache, SingleWorkerOptions.newBuilder().build(), null, Duration.ofSeconds(5), new TestWorkflowService(), null);
// Act
DecisionTaskHandler.Result result = taskHandler.handleDecisionTask(HistoryUtils.generateDecisionTaskWithInitialHistory());
// Assert
assertEquals(0, cache.size());
assertNotNull(result.getTaskCompleted());
assertNull(result.getTaskCompleted().getStickyAttributes());
}
use of com.uber.cadence.internal.worker.DecisionTaskHandler in project cadence-client by uber-java.
the class ReplayDeciderTaskHandlerTests method ifStickyExecutionAttributesAreSetThenWorkflowsAreCached.
@Test
public void ifStickyExecutionAttributesAreSetThenWorkflowsAreCached() throws Throwable {
// Arrange
DeciderCache cache = new DeciderCache(10, NoopScope.getInstance());
DecisionTaskHandler taskHandler = new ReplayDecisionTaskHandler("domain", setUpMockWorkflowFactory(), cache, SingleWorkerOptions.newBuilder().build(), "sticky", Duration.ofSeconds(5), new TestWorkflowService(), null);
PollForDecisionTaskResponse decisionTask = HistoryUtils.generateDecisionTaskWithInitialHistory();
// Act
DecisionTaskHandler.Result result = taskHandler.handleDecisionTask(decisionTask);
// Assert
assertEquals(1, cache.size());
assertNotNull(result.getTaskCompleted());
StickyExecutionAttributes attributes = result.getTaskCompleted().getStickyAttributes();
assertEquals("sticky", attributes.getWorkerTaskList().name);
assertEquals(5, attributes.getScheduleToStartTimeoutSeconds());
}
Aggregations