|
6 | 6 |
|
7 | 7 | import io.temporal.api.common.v1.Link; |
8 | 8 | import io.temporal.api.enums.v1.EventType; |
| 9 | +import java.io.UnsupportedEncodingException; |
| 10 | +import java.net.URLDecoder; |
| 11 | +import java.nio.charset.StandardCharsets; |
9 | 12 | import org.junit.Test; |
10 | 13 |
|
11 | 14 | public class LinkConverterTest { |
@@ -98,6 +101,35 @@ public void testConvertWorkflowEventToNexus_ValidSlash() { |
98 | 101 | assertEquals(expected, actual); |
99 | 102 | } |
100 | 103 |
|
| 104 | + @Test |
| 105 | + public void testConvertWorkflowEventToNexus_ValidSpace() throws UnsupportedEncodingException { |
| 106 | + Link.WorkflowEvent input = |
| 107 | + Link.WorkflowEvent.newBuilder() |
| 108 | + .setNamespace("ns") |
| 109 | + .setWorkflowId("wf space+plus") |
| 110 | + .setRunId("run-id") |
| 111 | + .setEventRef( |
| 112 | + Link.WorkflowEvent.EventReference.newBuilder() |
| 113 | + .setEventId(1) |
| 114 | + .setEventType(EventType.EVENT_TYPE_WORKFLOW_EXECUTION_STARTED)) |
| 115 | + .build(); |
| 116 | + |
| 117 | + io.temporal.api.nexus.v1.Link expected = |
| 118 | + io.temporal.api.nexus.v1.Link.newBuilder() |
| 119 | + .setUrl( |
| 120 | + "temporal:///namespaces/ns/workflows/wf%20space%2Bplus/run-id/history?referenceType=EventReference&eventID=1&eventType=WorkflowExecutionStarted") |
| 121 | + .setType("temporal.api.common.v1.Link.WorkflowEvent") |
| 122 | + .build(); |
| 123 | + |
| 124 | + io.temporal.api.nexus.v1.Link actual = workflowEventToNexusLink(input); |
| 125 | + assertEquals(expected, actual); |
| 126 | + |
| 127 | + String decoded = URLDecoder.decode(actual.getUrl(), StandardCharsets.UTF_8.toString()); |
| 128 | + assertEquals( |
| 129 | + "temporal:///namespaces/ns/workflows/wf space+plus/run-id/history?referenceType=EventReference&eventID=1&eventType=WorkflowExecutionStarted", |
| 130 | + decoded); |
| 131 | + } |
| 132 | + |
101 | 133 | @Test |
102 | 134 | public void testConvertWorkflowEventToNexus_ValidEventIDMissing() { |
103 | 135 | Link.WorkflowEvent input = |
|
0 commit comments