Search in sources :

Example 11 with TestWorkflowService

use of com.uber.cadence.internal.testservice.TestWorkflowService 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)11 Test (org.junit.Test)8 PollForDecisionTaskResponse (com.uber.cadence.PollForDecisionTaskResponse)6 Level (ch.qos.logback.classic.Level)3 LoggerContext (ch.qos.logback.classic.LoggerContext)3 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)3 ListAppender (ch.qos.logback.core.read.ListAppender)3 TaskList (com.uber.cadence.TaskList)3 DecisionTaskHandler (com.uber.cadence.internal.worker.DecisionTaskHandler)3 IWorkflowService (com.uber.cadence.serviceclient.IWorkflowService)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 Consumer (java.util.function.Consumer)3 TestCase (junit.framework.TestCase)3 Matchers.any (org.mockito.Matchers.any)3 Mockito (org.mockito.Mockito)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 StickyExecutionAttributes (com.uber.cadence.StickyExecutionAttributes)2 NoopScope (com.uber.cadence.internal.metrics.NoopScope)1 RootScopeBuilder (com.uber.m3.tally.RootScopeBuilder)1