|
34 | 34 | import java.util.concurrent.CancellationException;
|
35 | 35 | import java.util.concurrent.TimeUnit;
|
36 | 36 | import java.util.concurrent.TimeoutException;
|
| 37 | +import org.apache.thrift.TException; |
37 | 38 | import org.junit.Before;
|
38 | 39 | import org.junit.Test;
|
39 | 40 |
|
@@ -362,4 +363,41 @@ public void testGetHistory_EmptyHistory() throws Exception {
|
362 | 363 | // Verify that hasNext() is false immediately
|
363 | 364 | assertFalse(iterator.hasNext());
|
364 | 365 | }
|
| 366 | + |
| 367 | + // =========================== |
| 368 | + // Test for null history returned to GetHistoryPage |
| 369 | + // =========================== |
| 370 | + @Test |
| 371 | + public void testGetHistoryPage_HistoryIsNull() throws Exception { |
| 372 | + when(mockService.GetWorkflowExecutionHistory(any())).thenReturn(null); |
| 373 | + |
| 374 | + IllegalArgumentException exception = |
| 375 | + assertThrows( |
| 376 | + IllegalArgumentException.class, |
| 377 | + () -> { |
| 378 | + WorkflowExecutionUtils.getHistoryPage( |
| 379 | + "page-token".getBytes(), mockService, "testDomain", workflowExecution); |
| 380 | + }); |
| 381 | + |
| 382 | + assertTrue(exception.getMessage().contains(workflowExecution.toString())); |
| 383 | + } |
| 384 | + |
| 385 | + // =========================== |
| 386 | + // Test for exception thrown on GetWorkflowExecutionHistory |
| 387 | + // =========================== |
| 388 | + @Test |
| 389 | + public void testGetHistoryPage_ExceptionWhileRetrievingExecutionHistory() throws Exception { |
| 390 | + final String errMessage = "thrift comm exception"; |
| 391 | + when(mockService.GetWorkflowExecutionHistory(any())).thenThrow(new TException(errMessage)); |
| 392 | + |
| 393 | + Error exception = |
| 394 | + assertThrows( |
| 395 | + Error.class, |
| 396 | + () -> { |
| 397 | + WorkflowExecutionUtils.getHistoryPage( |
| 398 | + "page-token".getBytes(), mockService, "testDomain", workflowExecution); |
| 399 | + }); |
| 400 | + |
| 401 | + assertTrue(exception.getMessage().contains(errMessage)); |
| 402 | + } |
365 | 403 | }
|
0 commit comments