Skip to content

Commit 559776a

Browse files
authored
More unit-tests to WorkflowExecutionUtils (#964)
Testing two more edge-cases of `WorkflowExecutionUtils.getHistoryPage`
1 parent bf25a2c commit 559776a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/test/java/com/uber/cadence/internal/common/WorkflowExecutionUtilsTest.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.util.concurrent.CancellationException;
3535
import java.util.concurrent.TimeUnit;
3636
import java.util.concurrent.TimeoutException;
37+
import org.apache.thrift.TException;
3738
import org.junit.Before;
3839
import org.junit.Test;
3940

@@ -362,4 +363,41 @@ public void testGetHistory_EmptyHistory() throws Exception {
362363
// Verify that hasNext() is false immediately
363364
assertFalse(iterator.hasNext());
364365
}
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+
}
365403
}

0 commit comments

Comments
 (0)