Search in sources :

Example 1 with TestWorkflowService

use of io.temporal.internal.testservice.TestWorkflowService in project sdk-java by temporalio.

the class WorkflowCachingTest method setUp.

@Before
public void setUp() {
    testService = new TestWorkflowService();
    testService.lockTimeSkipping(CALLER);
    service = testService.newClientStub();
}
Also used : TestWorkflowService(io.temporal.internal.testservice.TestWorkflowService) Before(org.junit.Before)

Example 2 with TestWorkflowService

use of io.temporal.internal.testservice.TestWorkflowService in project sdk-java by temporalio.

the class PollWorkflowTaskDispatcherTests method setUp.

@Before
public void setUp() {
    testService = new TestWorkflowService();
    service = testService.newClientStub();
}
Also used : TestWorkflowService(io.temporal.internal.testservice.TestWorkflowService) Before(org.junit.Before)

Example 3 with TestWorkflowService

use of io.temporal.internal.testservice.TestWorkflowService in project sdk-java by temporalio.

the class HistoryUtils method generateWorkflowTaskWithPartialHistory.

public static PollWorkflowTaskQueueResponse generateWorkflowTaskWithPartialHistory(String namespace, String taskqueueName, String workflowType) throws Exception {
    TestWorkflowService testService = new TestWorkflowService(true);
    WorkflowServiceStubs service = testService.newClientStub();
    try {
        PollWorkflowTaskQueueResponse response = generateWorkflowTaskWithInitialHistory(namespace, taskqueueName, workflowType, service);
        return generateWorkflowTaskWithPartialHistoryFromExistingTask(response, namespace, HOST_TASK_QUEUE, service);
    } finally {
        service.shutdownNow();
        service.awaitTermination(1, TimeUnit.SECONDS);
        testService.close();
    }
}
Also used : PollWorkflowTaskQueueResponse(io.temporal.api.workflowservice.v1.PollWorkflowTaskQueueResponse) TestWorkflowService(io.temporal.internal.testservice.TestWorkflowService) WorkflowServiceStubs(io.temporal.serviceclient.WorkflowServiceStubs)

Example 4 with TestWorkflowService

use of io.temporal.internal.testservice.TestWorkflowService in project sdk-java by temporalio.

the class HistoryUtils method generateWorkflowTaskWithInitialHistory.

public static PollWorkflowTaskQueueResponse generateWorkflowTaskWithInitialHistory() throws Exception {
    TestWorkflowService testService = new TestWorkflowService(true);
    WorkflowServiceStubs service = testService.newClientStub();
    try {
        return generateWorkflowTaskWithInitialHistory(NAMESPACE, TASK_QUEUE, WORKFLOW_TYPE, service);
    } finally {
        service.shutdownNow();
        service.awaitTermination(1, TimeUnit.SECONDS);
        testService.close();
    }
}
Also used : TestWorkflowService(io.temporal.internal.testservice.TestWorkflowService) WorkflowServiceStubs(io.temporal.serviceclient.WorkflowServiceStubs)

Example 5 with TestWorkflowService

use of io.temporal.internal.testservice.TestWorkflowService in project sdk-java by temporalio.

the class ReplayWorkflowRunTaskHandlerCacheTests method whenHistoryIsFullNewWorkflowExecutorIsReturned_InitiallyCached.

@Test
public void whenHistoryIsFullNewWorkflowExecutorIsReturned_InitiallyCached() throws Exception {
    TestWorkflowService testService = new TestWorkflowService();
    WorkflowServiceStubs service = testService.newClientStub();
    // Arrange
    WorkflowExecutorCache cache = new WorkflowExecutorCache(10, new NoopScope());
    PollWorkflowTaskQueueResponse workflowTask1 = HistoryUtils.generateWorkflowTaskWithInitialHistory("namespace", "taskQueue", "workflowType", service);
    WorkflowRunTaskHandler workflowRunTaskHandler = cache.getOrCreate(workflowTask1, metricsScope, () -> createFakeExecutor(workflowTask1));
    cache.addToCache(workflowTask1.getWorkflowExecution(), workflowRunTaskHandler);
    PollWorkflowTaskQueueResponse workflowTask2 = HistoryUtils.generateWorkflowTaskWithPartialHistoryFromExistingTask(workflowTask1, "namespace", "stickyTaskQueue", service);
    assertEquals(workflowRunTaskHandler, cache.getOrCreate(workflowTask2, metricsScope, () -> doNotCreateFakeExecutor(workflowTask2)));
    // Act
    WorkflowRunTaskHandler workflowRunTaskHandler2 = cache.getOrCreate(workflowTask2, metricsScope, () -> createFakeExecutor(workflowTask2));
    // Assert
    assertEquals(workflowRunTaskHandler2, cache.getOrCreate(workflowTask2, metricsScope, () -> createFakeExecutor(workflowTask2)));
    assertSame(workflowRunTaskHandler2, workflowRunTaskHandler);
    testService.close();
}
Also used : PollWorkflowTaskQueueResponse(io.temporal.api.workflowservice.v1.PollWorkflowTaskQueueResponse) TestWorkflowService(io.temporal.internal.testservice.TestWorkflowService) NoopScope(com.uber.m3.tally.NoopScope) WorkflowServiceStubs(io.temporal.serviceclient.WorkflowServiceStubs) Test(org.junit.Test)

Aggregations

TestWorkflowService (io.temporal.internal.testservice.TestWorkflowService)7 WorkflowServiceStubs (io.temporal.serviceclient.WorkflowServiceStubs)4 PollWorkflowTaskQueueResponse (io.temporal.api.workflowservice.v1.PollWorkflowTaskQueueResponse)3 Before (org.junit.Before)3 NoopScope (com.uber.m3.tally.NoopScope)2 Test (org.junit.Test)2 Scope (com.uber.m3.tally.Scope)1 ImmutableMap (com.uber.m3.util.ImmutableMap)1