use of com.uber.cadence.internal.testservice.TestWorkflowService in project cadence-client by uber-java.
the class PollDecisionTaskDispatcherTests method handlersGetOverwrittenWhenRegisteredForTheSameTaskList.
@Test
public void handlersGetOverwrittenWhenRegisteredForTheSameTaskList() {
// Arrange
AtomicBoolean handled = new AtomicBoolean(false);
AtomicBoolean handled2 = new AtomicBoolean(false);
Consumer<PollForDecisionTaskResponse> handler = r -> handled.set(true);
Consumer<PollForDecisionTaskResponse> handler2 = r -> handled2.set(true);
PollDecisionTaskDispatcher dispatcher = new PollDecisionTaskDispatcher(new TestWorkflowService());
dispatcher.subscribe("tasklist1", handler);
dispatcher.subscribe("tasklist1", handler2);
// Act
PollForDecisionTaskResponse response = CreatePollForDecisionTaskResponse("tasklist1");
dispatcher.process(response);
// Assert
assertTrue(handled2.get());
assertFalse(handled.get());
}
use of com.uber.cadence.internal.testservice.TestWorkflowService in project cadence-client by uber-java.
the class PollDecisionTaskDispatcherTests method pollDecisionTasksAreDispatchedToTheCorrectHandler.
@Test
public void pollDecisionTasksAreDispatchedToTheCorrectHandler() {
// Arrange
AtomicBoolean handled = new AtomicBoolean(false);
AtomicBoolean handled2 = new AtomicBoolean(false);
Consumer<PollForDecisionTaskResponse> handler = r -> handled.set(true);
Consumer<PollForDecisionTaskResponse> handler2 = r -> handled2.set(true);
PollDecisionTaskDispatcher dispatcher = new PollDecisionTaskDispatcher(new TestWorkflowService());
dispatcher.subscribe("tasklist1", handler);
dispatcher.subscribe("tasklist2", handler2);
// Act
PollForDecisionTaskResponse response = CreatePollForDecisionTaskResponse("tasklist1");
dispatcher.process(response);
// Assert
assertTrue(handled.get());
assertFalse(handled2.get());
}
use of com.uber.cadence.internal.testservice.TestWorkflowService in project cadence-client by uber-java.
the class PollDecisionTaskDispatcherTests method pollDecisionTasksAreDispatchedBasedOnTaskListName.
@Test
public void pollDecisionTasksAreDispatchedBasedOnTaskListName() {
// Arrange
AtomicBoolean handled = new AtomicBoolean(false);
Consumer<PollForDecisionTaskResponse> handler = r -> handled.set(true);
PollDecisionTaskDispatcher dispatcher = new PollDecisionTaskDispatcher(new TestWorkflowService());
dispatcher.subscribe("tasklist1", handler);
// Act
PollForDecisionTaskResponse response = CreatePollForDecisionTaskResponse("tasklist1");
dispatcher.process(response);
// Assert
assertTrue(handled.get());
}
use of com.uber.cadence.internal.testservice.TestWorkflowService in project cadence-client by uber-java.
the class HistoryUtils method generateDecisionTaskWithInitialHistory.
public static PollForDecisionTaskResponse generateDecisionTaskWithInitialHistory() throws Exception {
TestWorkflowService service = new TestWorkflowService();
service.lockTimeSkipping(CALLER);
return generateDecisionTaskWithInitialHistory(DOMAIN, TASK_LIST, WORKFLOW_TYPE, new TestWorkflowService());
}
use of com.uber.cadence.internal.testservice.TestWorkflowService in project cadence-client by uber-java.
the class ReplayDeciderCacheTests method whenHistoryIsPartialCachedEntryIsReturned.
@Test(timeout = 2000)
public void whenHistoryIsPartialCachedEntryIsReturned() throws Exception {
// Arrange
Map<String, String> tags = new ImmutableMap.Builder<String, String>(2).put(MetricsTag.DOMAIN, "domain").put(MetricsTag.TASK_LIST, "stickyTaskList").build();
StatsReporter reporter = mock(StatsReporter.class);
Scope scope = new RootScopeBuilder().reporter(reporter).reportEvery(Duration.ofMillis(500)).tagged(tags);
DeciderCache replayDeciderCache = new DeciderCache(10, scope);
TestWorkflowService service = new TestWorkflowService();
service.lockTimeSkipping("test");
PollForDecisionTaskResponse decisionTask = HistoryUtils.generateDecisionTaskWithInitialHistory("domain", "taskList", "workflowType", service);
Decider decider = replayDeciderCache.getOrCreate(decisionTask, () -> createFakeDecider(decisionTask));
replayDeciderCache.addToCache(decisionTask, decider);
// Act
PollForDecisionTaskResponse decisionTask2 = HistoryUtils.generateDecisionTaskWithPartialHistoryFromExistingTask(decisionTask, "domain", "stickyTaskList", service);
Decider decider2 = replayDeciderCache.getOrCreate(decisionTask2, () -> doNotCreateFakeDecider(decisionTask2));
// Assert
// Wait for reporter
Thread.sleep(500);
verify(reporter, times(1)).reportCounter(MetricsType.STICKY_CACHE_HIT, tags, 1);
assertEquals(decider, decider2);
service.close();
}
Aggregations