Skip to content

Commit

Permalink
More unit-tests to WorkflowExecutionUtils (#964)
Browse files Browse the repository at this point in the history
Testing two more edge-cases of `WorkflowExecutionUtils.getHistoryPage`
  • Loading branch information
dkrotx authored Nov 25, 2024
1 parent bf25a2c commit 559776a
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.concurrent.CancellationException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.apache.thrift.TException;
import org.junit.Before;
import org.junit.Test;

Expand Down Expand Up @@ -362,4 +363,41 @@ public void testGetHistory_EmptyHistory() throws Exception {
// Verify that hasNext() is false immediately
assertFalse(iterator.hasNext());
}

// ===========================
// Test for null history returned to GetHistoryPage
// ===========================
@Test
public void testGetHistoryPage_HistoryIsNull() throws Exception {
when(mockService.GetWorkflowExecutionHistory(any())).thenReturn(null);

IllegalArgumentException exception =
assertThrows(
IllegalArgumentException.class,
() -> {
WorkflowExecutionUtils.getHistoryPage(
"page-token".getBytes(), mockService, "testDomain", workflowExecution);
});

assertTrue(exception.getMessage().contains(workflowExecution.toString()));
}

// ===========================
// Test for exception thrown on GetWorkflowExecutionHistory
// ===========================
@Test
public void testGetHistoryPage_ExceptionWhileRetrievingExecutionHistory() throws Exception {
final String errMessage = "thrift comm exception";
when(mockService.GetWorkflowExecutionHistory(any())).thenThrow(new TException(errMessage));

Error exception =
assertThrows(
Error.class,
() -> {
WorkflowExecutionUtils.getHistoryPage(
"page-token".getBytes(), mockService, "testDomain", workflowExecution);
});

assertTrue(exception.getMessage().contains(errMessage));
}
}

0 comments on commit 559776a

Please sign in to comment.