Search in sources :

Example 1 with DecisionTaskHandler

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());
}
Also used : StickyExecutionAttributes(com.uber.cadence.StickyExecutionAttributes) TestWorkflowService(com.uber.cadence.internal.testservice.TestWorkflowService) DecisionTaskHandler(com.uber.cadence.internal.worker.DecisionTaskHandler) Test(org.junit.Test)

Example 2 with DecisionTaskHandler

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());
}
Also used : TestWorkflowService(com.uber.cadence.internal.testservice.TestWorkflowService) DecisionTaskHandler(com.uber.cadence.internal.worker.DecisionTaskHandler) Test(org.junit.Test)

Example 3 with DecisionTaskHandler

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());
}
Also used : StickyExecutionAttributes(com.uber.cadence.StickyExecutionAttributes) TestWorkflowService(com.uber.cadence.internal.testservice.TestWorkflowService) DecisionTaskHandler(com.uber.cadence.internal.worker.DecisionTaskHandler) PollForDecisionTaskResponse(com.uber.cadence.PollForDecisionTaskResponse) Test(org.junit.Test)

Aggregations

TestWorkflowService (com.uber.cadence.internal.testservice.TestWorkflowService)3 DecisionTaskHandler (com.uber.cadence.internal.worker.DecisionTaskHandler)3 Test (org.junit.Test)3 StickyExecutionAttributes (com.uber.cadence.StickyExecutionAttributes)2 PollForDecisionTaskResponse (com.uber.cadence.PollForDecisionTaskResponse)1