Skip to content

Refactor batch retry tests to verify behavior instead of implementation details#165

Merged
jwijgerd merged 4 commits intofeature/batch-too-large-retriesfrom
copilot/sub-pr-122-another-one
Mar 17, 2026
Merged

Refactor batch retry tests to verify behavior instead of implementation details#165
jwijgerd merged 4 commits intofeature/batch-too-large-retriesfrom
copilot/sub-pr-122-another-one

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 26, 2025

The batch retry tests in PersistentActorUpdateEventProcessorTest were verifying internal method call counts (e.g., insertStatement.bind() called exactly 6 times) rather than actual behavior. This makes tests brittle and prone to breaking when refactoring implementation while preserving functionality.

Changes

  • Removed bind() call count assertions from testProcessBatchTooLargeWithTwoEvents, testProcessBatchTooLargeWithThreeEvents, and testProcessBatchTooLargeWithNineEvents
  • Tests now verify batch retry mechanism triggers correctly and appropriate execute methods are called with expected statement types
  • Created distinct mock instances for each event instead of reusing a single mock, improving test isolation
  • Fixed variable shadowing where loop variable event shadowed class field

Before

verify(insertStatement, times(6)).bind("key1", "key2", "actorId", ByteBuffer.wrap(new byte[1024]));

After

verify(cqlSession, times(2)).execute(any(BatchStatement.class));
verify(cqlSession, times(1)).execute(any(BoundStatement.class));

Tests now assert on observable behavior (retry mechanism splits batch and processes events) rather than internal implementation details.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 26, 2025 17:01
Co-authored-by: jwijgerd <914840+jwijgerd@users.noreply.github.com>
Co-authored-by: jwijgerd <914840+jwijgerd@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for retries with smaller batch sizes Refactor batch retry tests to verify behavior instead of implementation details Dec 26, 2025
Copilot AI requested a review from jwijgerd December 26, 2025 17:06
@jwijgerd jwijgerd marked this pull request as ready for review March 17, 2026 14:02
@jwijgerd jwijgerd merged commit 4c49d10 into feature/batch-too-large-retries Mar 17, 2026
@jwijgerd jwijgerd deleted the copilot/sub-pr-122-another-one branch March 17, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants