use of com.uber.cadence.internal.testservice.TestWorkflowService in project cadence-client by uber-java.
the class ReplayDeciderCacheTests method whenHistoryIsFullNewReplayDeciderIsReturned_InitiallyCached.
@Test
public void whenHistoryIsFullNewReplayDeciderIsReturned_InitiallyCached() throws Exception {
TestWorkflowService service = new TestWorkflowService();
// Arrange
DeciderCache replayDeciderCache = new DeciderCache(10, NoopScope.getInstance());
PollForDecisionTaskResponse decisionTask1 = HistoryUtils.generateDecisionTaskWithInitialHistory("domain", "taskList", "workflowType", service);
Decider decider = replayDeciderCache.getOrCreate(decisionTask1, () -> createFakeDecider(decisionTask1));
replayDeciderCache.addToCache(decisionTask1, decider);
PollForDecisionTaskResponse decisionTask2 = HistoryUtils.generateDecisionTaskWithPartialHistoryFromExistingTask(decisionTask1, "domain", "stickyTaskList", service);
assertEquals(decider, replayDeciderCache.getOrCreate(decisionTask2, () -> doNotCreateFakeDecider(decisionTask2)));
// Act
Decider decider2 = replayDeciderCache.getOrCreate(decisionTask2, () -> createFakeDecider(decisionTask2));
// Assert
assertEquals(decider2, replayDeciderCache.getOrCreate(decisionTask2, () -> createFakeDecider(decisionTask2)));
assertSame(decider2, decider);
service.close();
}
use of com.uber.cadence.internal.testservice.TestWorkflowService 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.testservice.TestWorkflowService in project cadence-client by uber-java.
the class HistoryUtils method generateDecisionTaskWithPartialHistory.
public static PollForDecisionTaskResponse generateDecisionTaskWithPartialHistory(String domain, String tasklistName, String workflowType) throws Exception {
TestWorkflowService service = new TestWorkflowService();
service.lockTimeSkipping(CALLER);
PollForDecisionTaskResponse response = generateDecisionTaskWithInitialHistory(domain, tasklistName, workflowType, service);
return generateDecisionTaskWithPartialHistoryFromExistingTask(response, domain, HOST_TASK_LIST, service);
}
use of com.uber.cadence.internal.testservice.TestWorkflowService 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.testservice.TestWorkflowService in project cadence-client by uber-java.
the class WorkflowStickynessTest method setUp.
@Before
public void setUp() {
service = new TestWorkflowService();
service.lockTimeSkipping(CALLER);
}
Aggregations