Skip to content

Conversation

@sacOO7
Copy link
Collaborator

@sacOO7 sacOO7 commented Sep 3, 2025

Summary by CodeRabbit

  • Tests
    • Reactivated multiple previously disabled tests for realtime channels, delta decoding, and REST presence history, improving coverage and reliability.
    • Modernized assertions and exception handling; channel mode checks are now order-insensitive.
    • Added verifications for channel parameters (e.g., delta) after attach and simplified test setup via options.
    • One internal test helper signature was updated; no user-facing runtime behavior changes.

@coderabbitai
Copy link

coderabbitai bot commented Sep 3, 2025

Walkthrough

Re-enabled and modernized unit tests across realtime and rest suites, moved delta codec configuration from channel-name encoding to ChannelOptions.params with runtime verification, tightened generics, and updated assertions (including assertThrows and order-insensitive checks). No public API signatures changed except Channels#get overload usage in tests.

Changes

Cohort / File(s) Summary
Realtime channel tests modernization
lib/src/test/java/io/ably/lib/test/realtime/RealtimeChannelTest.java
Re-enabled tests (@test); replaced try/catch with assertThrows; tightened generics (diamond operator); swapped expected/actual in assertions; adjusted error message expectation; made channel-modes assertions order-insensitive; used inline ChannelOptions param maps.
Delta codec tests: options-based configuration
lib/src/test/java/io/ably/lib/test/realtime/RealtimeDeltaDecoderTest.java
Configures delta via ChannelOptions.params instead of name-encoded syntax; updated imports; changed channel acquisition to Channels#get(String, ChannelOptions); added channel.getParams() verifications after attach.
REST presence tests re-enabled
lib/src/test/java/io/ably/lib/test/rest/RestPresenceTest.java
Restored six presence-history tests by converting commented annotations to active @Test; no logic changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Test as Test
  participant Ably as Ably Client
  participant Channels as Channels
  participant Channel as Channel

  Note over Test,Ably: Setup
  Test->>Ably: create client
  Note over Test,Channels: Acquire channel using options (new)
  Test->>Channels: get(name, ChannelOptions{ params: { delta: "vcdiff" } })
  Channels->>Channel: return Channel instance
  Test->>Channel: attach()
  Channel-->>Test: attached
  Test->>Channel: getParams()
  Channel-->>Test: { delta: "vcdiff", ... }
  Note right of Test: Assert params include delta=vcdiff
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks (2 passed, 2 warnings, 1 inconclusive)

❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning The pull request also re-enables and modernizes tests in RealtimeChannelTest and RestPresenceTest that are unrelated to vcdiff encoding validation, introducing changes outside the scope of the linked VCDiff objectives. Split out the generic test re-enablement and assertion modernization into a separate PR so that this PR remains focused solely on VCDiff-related test work.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description Check ❓ Inconclusive The description “- Fixed #1160” references the linked issue but provides no context or summary of the actual changes, making it too vague to convey the PR’s scope or impact. Please expand the description to include a brief overview of the changes made, such as which tests were re-enabled and how vcdiff encoding behavior is now validated, to give reviewers clear context.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly summarizes the main change by indicating that the omitted tests for vcdiff encoding have been fixed, focusing on the primary update without extraneous file listings or unrelated details.
Linked Issues Check ✅ Passed The PR implements the missing VCDiff tests by updating RealtimeDeltaDecoderTest with ChannelOptions for delta=vcdiff and validating channel parameters, thereby fulfilling the primary objective of issue #1160 and aligning with the relevant specification requirements.

Poem

I thump my paws—tests awake with cheer,
Delta moved to params, hopping near.
Assertions tidy, throws now caught,
Channels attach and prove the thought.
A rabbit applauds the coverage here. 🐇✨

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/vcdiff-encoding

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot temporarily deployed to staging/pull/1161/features September 3, 2025 12:19 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1161/javadoc September 3, 2025 12:22 Inactive
@sacOO7 sacOO7 force-pushed the fix/vcdiff-encoding branch from 8d48be7 to a12d9cb Compare September 3, 2025 12:22
@github-actions github-actions bot temporarily deployed to staging/pull/1161/features September 3, 2025 12:23 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1161/javadoc September 3, 2025 12:25 Inactive
@sacOO7 sacOO7 force-pushed the fix/vcdiff-encoding branch from a12d9cb to f22a0f8 Compare September 3, 2025 12:43
@github-actions github-actions bot temporarily deployed to staging/pull/1161/features September 3, 2025 12:43 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1161/javadoc September 3, 2025 12:45 Inactive
@sacOO7 sacOO7 force-pushed the fix/vcdiff-encoding branch from f22a0f8 to 8c85761 Compare September 3, 2025 12:56
@github-actions github-actions bot temporarily deployed to staging/pull/1161/features September 3, 2025 12:56 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1161/javadoc September 3, 2025 12:59 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1161/features September 4, 2025 11:28 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1161/javadoc September 4, 2025 11:30 Inactive
@sacOO7 sacOO7 force-pushed the fix/vcdiff-encoding branch from 2442315 to 754a064 Compare September 4, 2025 11:36
@github-actions github-actions bot temporarily deployed to staging/pull/1161/features September 4, 2025 11:36 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1161/javadoc September 4, 2025 11:38 Inactive
@sacOO7 sacOO7 marked this pull request as ready for review September 4, 2025 12:05
@sacOO7 sacOO7 requested a review from ttypic September 4, 2025 12:08
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (8)
lib/src/test/java/io/ably/lib/test/rest/RestPresenceTest.java (6)

90-106: Re-enabled test looks good; swap expected/actual in size assert for clearer failures

Use expected first to improve assertion diffs.

-            assertEquals("Expected 4 messages", members.items().length, 4);
+            assertEquals("Expected 4 messages", 4, members.items().length);

117-133: Same here: reverse the order in the size assert

Keeps assertion messages consistent project-wide.

-            assertEquals("Expected 4 messages", members.items().length, 4);
+            assertEquals("Expected 4 messages", 4, members.items().length);

144-160: Forward/limit: fix assert order

Minor readability tweak only.

-            assertEquals("Expected 2 messages", members.items().length, 2);
+            assertEquals("Expected 2 messages", 2, members.items().length);

171-187: Backward/limit: fix assert order

Same reasoning as above.

-            assertEquals("Expected 2 messages", members.items().length, 2);
+            assertEquals("Expected 2 messages", 2, members.items().length);

198-260: Paginate forwards: normalize assertion ordering across pages

Also fix the terminal page check.

-            assertEquals("Expected 1 message", members.items().length, 1);
+            assertEquals("Expected 1 message", 1, members.items().length);

-            assertEquals("Expected 1 message", members.items().length, 1);
+            assertEquals("Expected 1 message", 1, members.items().length);

-            assertEquals("Expected 1 message", members.items().length, 1);
+            assertEquals("Expected 1 message", 1, members.items().length);

-            assertEquals("Expected 1 message", members.items().length, 1);
+            assertEquals("Expected 1 message", 1, members.items().length);

-                    assertEquals("Expected no further members", members.items().length, 0);
+                    assertEquals("Expected no further members", 0, members.items().length);

266-328: Paginate backwards: assertion order + tiny grammar and fail-name fixes

  • Put expected first.
  • “1 messages” → “1 message”.
  • Fail message suffix should match the test name (“…_text_b”).
-            assertEquals("Expected 1 message", members.items().length, 1);
+            assertEquals("Expected 1 message", 1, members.items().length);

-            assertEquals("Expected 1 messages", members.items().length, 1);
+            assertEquals("Expected 1 message", 1, members.items().length);

-            assertEquals("Expected 1 message", members.items().length, 1);
+            assertEquals("Expected 1 message", 1, members.items().length);

-            assertEquals("Expected 1 message", members.items().length, 1);
+            assertEquals("Expected 1 message", 1, members.items().length);

-            fail("rest_presencehistory_paginate_text_f: Unexpected exception");
+            fail("rest_presencehistory_paginate_text_b: Unexpected exception");
lib/src/test/java/io/ably/lib/test/realtime/RealtimeDeltaDecoderTest.java (1)

57-58: Prefer ChannelOptions over bracketed channel name for delta=vcdiff

Align this test with others and avoid the legacy “[?param=…]” syntax.

-            Channel channel = ably.channels.get("[?delta=vcdiff]" + testName);
+            ChannelOptions options = new ChannelOptions();
+            options.params = Map.of("delta", "vcdiff");
+            Channel channel = ably.channels.get(testName, options);
lib/src/test/java/io/ably/lib/test/realtime/RealtimeChannelTest.java (1)

287-291: Swap expected/actual in params assert for consistency

Everywhere else uses expected first.

-            assertEquals("Verify channel params", channel.getParams(), options.params);
+            assertEquals("Verify channel params", options.params, channel.getParams());
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 993b308 and 754a064.

📒 Files selected for processing (3)
  • lib/src/test/java/io/ably/lib/test/realtime/RealtimeChannelTest.java (17 hunks)
  • lib/src/test/java/io/ably/lib/test/realtime/RealtimeDeltaDecoderTest.java (4 hunks)
  • lib/src/test/java/io/ably/lib/test/rest/RestPresenceTest.java (6 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
lib/src/test/java/io/ably/lib/test/realtime/RealtimeDeltaDecoderTest.java (1)
lib/src/main/java/io/ably/lib/types/ChannelOptions.java (1)
  • ChannelOptions (13-131)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: check-realtime-okhttp
  • GitHub Check: check-realtime
🔇 Additional comments (8)
lib/src/test/java/io/ably/lib/test/realtime/RealtimeDeltaDecoderTest.java (1)

97-108: Good move to ChannelOptions and param verification

This matches TB2c intent and keeps tests consistent. LGTM.

lib/src/test/java/io/ably/lib/test/realtime/RealtimeChannelTest.java (7)

35-35: Import Arrays: OK

Needed for containsInAnyOrder assertions on modes.


50-50: Static assertThrows import: OK

Modernizes exception assertions cleanly.


167-178: Attach with params via channels.get: OK

Param and modes assertions look correct.


200-212: setOptions path: OK

Validates setOptions flow; assertions are sound.


234-252: Re-get should throw when it would reattach: verify error codes are stable

The message check is good; codes 400/40000 may vary by transport/runtime. Please confirm across CI targets.


324-329: Modes order-insensitive check: OK

Length + containsInAnyOrder is robust.


351-358: Delta param + modes together: OK

Covers params+modes interplay well.

Also applies to: 365-368

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
lib/src/test/java/io/ably/lib/test/realtime/RealtimeDeltaDecoderTest.java (1)

49-58: Prefer configuring delta via ChannelOptions over bracketed channel names.

To keep tests consistent with the rest of the suite and future-proof against deprecated “[?...]” name-params, set params on ChannelOptions here too.

-            Channel channel = ably.channels.get("[?delta=vcdiff]" + testName);
+            ChannelOptions chOpts = new ChannelOptions();
+            chOpts.params = Collections.singletonMap("delta", "vcdiff");
+            Channel channel = ably.channels.get(testName, chOpts);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 754a064 and 55bfe11.

📒 Files selected for processing (2)
  • lib/src/test/java/io/ably/lib/test/realtime/RealtimeChannelTest.java (18 hunks)
  • lib/src/test/java/io/ably/lib/test/realtime/RealtimeDeltaDecoderTest.java (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
lib/src/test/java/io/ably/lib/test/realtime/RealtimeDeltaDecoderTest.java (1)
lib/src/main/java/io/ably/lib/types/ChannelOptions.java (1)
  • ChannelOptions (13-131)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: check
  • GitHub Check: check-liveobjects
  • GitHub Check: check-rest
  • GitHub Check: check-realtime-okhttp
  • GitHub Check: check-rest-okhttp
  • GitHub Check: check (29)
  • GitHub Check: check-realtime
  • GitHub Check: check (19)
  • GitHub Check: check (29)
  • GitHub Check: check (24)
  • GitHub Check: build
  • GitHub Check: check (21)
🔇 Additional comments (11)
lib/src/test/java/io/ably/lib/test/realtime/RealtimeDeltaDecoderTest.java (3)

14-24: Imports look good and Java 8–compatible.

Switch to ChannelOptions and Collections avoids Map.of and keeps tests Java 8–safe.


97-101: LGTM: ChannelOptions-based delta configuration.

Clear, minimal, and aligns with the direction taken elsewhere in the PR.


107-107: LGTM: Param assertion.

Asserting getParams() against a singletonMap is correct and order-agnostic.

lib/src/test/java/io/ably/lib/test/realtime/RealtimeChannelTest.java (8)

34-34: Import Arrays is appropriate.

Used for containsInAnyOrder assertions and list comparisons below.


167-178: LGTM: Channels#get with ChannelOptions + params.

Good use of params and modes; assertion order is expected vs actual.


200-213: LGTM: setOptions path mirrors Channels#get path.

Covers both ways of applying params; assertions are consistent.


289-291: LGTM: Modes precedence covered.

Good assertion that params.modes overrides options.modes; order-insensitive check is correct.


324-328: LGTM: Exact modes set validated.

Length + containsInAnyOrder makes the assertion robust.


351-368: LGTM: Combining delta param with modes.

Param equality and mode checks look correct.


2564-2573: LGTM: Explicit state transition sequences.

The list-based assertions document expected sequences crisply.


50-50: No action needed: The version catalog (gradle/libs.versions.toml) defines JUnit as 4.13.2, so assertThrows is supported.

Copy link
Contributor

@ttypic ttypic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sacOO7 sacOO7 merged commit 3f9d007 into main Sep 9, 2025
14 checks passed
@sacOO7 sacOO7 deleted the fix/vcdiff-encoding branch September 9, 2025 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

VCDiff: Validate implementation and implement missing tests

3 participants