Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package io.temporal.client;

import static io.temporal.testUtils.Eventually.assertEventually;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;

import io.temporal.common.interceptors.WorkflowClientCallsInterceptor;
import io.temporal.common.interceptors.WorkflowClientCallsInterceptorBase;
import io.temporal.common.interceptors.WorkflowClientInterceptorBase;
import io.temporal.testing.internal.SDKTestWorkflowRule;
import io.temporal.workflow.shared.TestWorkflows;
import java.time.Duration;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Rule;
import org.junit.Test;
Expand All @@ -21,7 +24,7 @@ public class ListWorkflowExecutionsInterceptorTest {
.build();

@Test
public void listExecutions_isIntercepted() throws InterruptedException {
public void listExecutions_isIntercepted() {
assumeTrue(
"Test Server doesn't support listWorkflowExecutions endpoint yet",
SDKTestWorkflowRule.useExternalService);
Expand Down Expand Up @@ -51,12 +54,16 @@ public ListWorkflowExecutionsOutput listWorkflowExecutions(
WorkflowStub.fromTyped(testWorkflowRule.newWorkflowStub(TestWorkflows.NoArgsWorkflow.class))
.start();

// Visibility API is eventually consistent
Thread.sleep(2_000);
String query = "TaskQueue='" + testWorkflowRule.getTaskQueue() + "'";
// Wait through the unintercepted client so the assertion below still verifies exactly one
// intercepted call.
assertEventually(
Duration.ofSeconds(10),
() ->
assertTrue(
testWorkflowRule.getWorkflowClient().listExecutions(query).findAny().isPresent()));
java.util.List<WorkflowExecutionMetadata> result =
workflowClient
.listExecutions("TaskQueue='" + testWorkflowRule.getTaskQueue() + "'")
.collect(java.util.stream.Collectors.toList());
workflowClient.listExecutions(query).collect(java.util.stream.Collectors.toList());
assertFalse(result.isEmpty());
assertEquals(1, intercepted.get());
}
Expand Down
Loading