-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathInternalChannelTest.java
More file actions
45 lines (39 loc) · 2.01 KB
/
InternalChannelTest.java
File metadata and controls
45 lines (39 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package io.iworkflow.integ;
import io.iworkflow.core.Client;
import io.iworkflow.core.ClientOptions;
import io.iworkflow.integ.internalchannel.BasicInternalChannelWorkflow;
import io.iworkflow.integ.internalchannel.WaitingInternalChannelWorkflow;
import io.iworkflow.spring.TestSingletonWorkerService;
import io.iworkflow.spring.controller.WorkflowRegistry;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.concurrent.ExecutionException;
public class InternalChannelTest {
@BeforeEach
public void setup() throws ExecutionException, InterruptedException {
TestSingletonWorkerService.startWorkerIfNotUp();
}
@Test
public void testBasicInternalWorkflow() throws InterruptedException {
final Client client = new Client(WorkflowRegistry.registry, ClientOptions.localDefault);
final String wfId = "basic-internal-test-id" + System.currentTimeMillis() / 1000;
final Integer input = 1;
final String runId = client.startWorkflow(
BasicInternalChannelWorkflow.class, wfId, 10, input);
final Integer output = client.getSimpleWorkflowResultWithWait(Integer.class, wfId);
Assertions.assertEquals(3, output);
}
@Test
public void testWaitingInternalWorkflow() throws InterruptedException {
final Client client = new Client(WorkflowRegistry.registry, ClientOptions.localDefault);
final String wfId = "waiting-internal-test-id" + System.currentTimeMillis() / 1000;
final Integer input = 1;
final String runId = client.startWorkflow(
WaitingInternalChannelWorkflow.class, wfId, 10, input);
client.publishToInternalChannelBatch(WaitingInternalChannelWorkflow.class, wfId, runId, WaitingInternalChannelWorkflow.INTER_STATE_CHANNEL_NAME, Arrays.asList(2, 3));
final Integer output = client.getSimpleWorkflowResultWithWait(Integer.class, wfId);
Assertions.assertEquals(6, output);
}
}