Skip to content

Commit

Permalink
Add message assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinn-With-Two-Ns committed Jan 6, 2025
1 parent fd755e3 commit 0f466a5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
import org.junit.*;
import org.junit.rules.Timeout;
import org.junit.runner.RunWith;

/**
Expand All @@ -70,13 +69,11 @@
*/
@RunWith(JUnitParamsRunner.class)
public class ActivityTimeoutTest {
@Rule
public SDKTestWorkflowRule testWorkflowRule =
SDKTestWorkflowRule.newBuilder().setDoNotStart(true).build();

// TODO This test takes longer than it should to complete because
// of the cached heartbeat that prevents a quick shutdown
public @Rule Timeout timeout = Timeout.seconds(15);
@Rule
public SDKTestWorkflowRule testWorkflowRule =
SDKTestWorkflowRule.newBuilder().setTestTimeoutSeconds(15).setDoNotStart(true).build();

/**
* An activity reaches startToClose timeout once, max retries are set to 1. o
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ public void getIncompleteUpdateOfCompletedWorkflow() {
Assert.assertEquals(
UpdateWorkflowExecutionLifecycleStage.UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_COMPLETED,
response.getStage());
assertUpdateOutcomeIsAcceptedUpdateCompletedWorkflow(response.getOutcome());

response =
updateWorkflow(
Expand All @@ -635,6 +636,7 @@ public void getIncompleteUpdateOfCompletedWorkflow() {
Assert.assertEquals(
UpdateWorkflowExecutionLifecycleStage.UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_COMPLETED,
response.getStage());
assertUpdateOutcomeIsAcceptedUpdateCompletedWorkflow(response.getOutcome());

PollWorkflowExecutionUpdateResponse pollResponse =
pollWorkflowUpdate(
Expand All @@ -645,6 +647,7 @@ public void getIncompleteUpdateOfCompletedWorkflow() {
Assert.assertEquals(
UpdateWorkflowExecutionLifecycleStage.UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_COMPLETED,
pollResponse.getStage());
assertUpdateOutcomeIsAcceptedUpdateCompletedWorkflow(pollResponse.getOutcome());

pollResponse =
pollWorkflowUpdate(
Expand All @@ -655,6 +658,16 @@ public void getIncompleteUpdateOfCompletedWorkflow() {
Assert.assertEquals(
UpdateWorkflowExecutionLifecycleStage.UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_COMPLETED,
pollResponse.getStage());
assertUpdateOutcomeIsAcceptedUpdateCompletedWorkflow(pollResponse.getOutcome());
}

private void assertUpdateOutcomeIsAcceptedUpdateCompletedWorkflow(Outcome outcome) {
Assert.assertEquals(
"Workflow Update failed because the Workflow completed before the Update completed.",
outcome.getFailure().getMessage());
Assert.assertEquals(
"AcceptedUpdateCompletedWorkflow",
outcome.getFailure().getApplicationFailureInfo().getType());
}

private UpdateWorkflowExecutionResponse updateWorkflow(
Expand Down

0 comments on commit 0f466a5

Please sign in to comment.