Skip to content

fix example tests#2610

Merged
predic8 merged 5 commits into
masterfrom
fix-example-tests
Jan 13, 2026
Merged

fix example tests#2610
predic8 merged 5 commits into
masterfrom
fix-example-tests

Conversation

@rrayst
Copy link
Copy Markdown
Member

@rrayst rrayst commented Jan 13, 2026

Summary by CodeRabbit

  • Refactor

    • Improved registry initialization to ensure a consistent startup and component interaction flow.
  • Tests

    • Updated integration tests to request and validate resource id 12 (was 7).
  • Documentation

    • Updated example curl commands and tutorial comments to use /fruits/12 for consistency with tests.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 13, 2026

📝 Walkthrough

Walkthrough

Router initialization wiring changed: RouterCLI now assigns a BeanRegistryImplementation to the Router before bean registration; KubernetesWatcher now obtains the registry from router.getRegistry() instead of creating one.

Changes

Cohort / File(s) Summary
Bean registry wiring
core/src/main/java/com/predic8/membrane/core/cli/RouterCLI.java, core/src/main/java/com/predic8/membrane/core/kubernetes/KubernetesWatcher.java
RouterCLI calls router.setRegistry(reg) prior to bean registration. KubernetesWatcher replaces new BeanRegistryImplementation(...) with router.getRegistry() and casts to BeanCollector where needed.
Tests — path id updates
distribution/src/test/java/com/predic8/membrane/tutorials/advanced/PathParameterRoutingTutorialTest.java, distribution/src/test/java/com/predic8/membrane/tutorials/advanced/PathRewritingTutorialTest.java
Updated test requests and assertions to use /fruits/12 and expect id: 12 (was 7).
Tutorial example comments
distribution/tutorials/advanced/20-Path-Parameter-Routing.yaml, distribution/tutorials/advanced/30-Path-Rewriting.yaml
Updated commented curl examples from /fruits/7 to /fruits/12.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

7.x

Suggested reviewers

  • predic8
  • christiangoerdes

Poem

🐇 I hopped through lines of code so spry,

Found one registry, gave a cheerful cry.
Router holds beans, no duplicates to fear,
My little hops made the startup clear.
🥕 Cheers from the rabbit — the path is dear!

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'fix example tests' is overly vague and generic. It uses non-descriptive language that doesn't convey the actual nature of the changes, which involve both code refactoring in RouterCLI and KubernetesWatcher, as well as updating test data. Consider a more specific title like 'Update example tests to use fruit ID 12 and refactor registry initialization' that better describes the actual changes made.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f9410d1 and 5ca13a6.

📒 Files selected for processing (1)
  • distribution/tutorials/advanced/30-Path-Rewriting.yaml
✅ Files skipped from review due to trivial changes (1)
  • distribution/tutorials/advanced/30-Path-Rewriting.yaml
⏰ 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: Automated tests
  • GitHub Check: Analyze (java)

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.

@rrayst
Copy link
Copy Markdown
Member Author

rrayst commented Jan 13, 2026

/ok-to-test

Copy link
Copy Markdown
Contributor

@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: 0

🧹 Nitpick comments (1)
core/src/main/java/com/predic8/membrane/core/kubernetes/KubernetesWatcher.java (1)

20-20: Unused import: BeanRegistryImplementation.

This import is no longer needed since the code now obtains the registry from router.getRegistry() rather than instantiating BeanRegistryImplementation directly.

🧹 Suggested cleanup
-import com.predic8.membrane.annot.beanregistry.BeanRegistryImplementation;
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0067476 and 0131555.

📒 Files selected for processing (2)
  • core/src/main/java/com/predic8/membrane/core/cli/RouterCLI.java
  • core/src/main/java/com/predic8/membrane/core/kubernetes/KubernetesWatcher.java
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-03T19:24:51.595Z
Learnt from: predic8
Repo: membrane/api-gateway PR: 2529
File: annot/src/main/java/com/predic8/membrane/annot/beanregistry/BeanRegistryImplementation.java:168-172
Timestamp: 2026-01-03T19:24:51.595Z
Learning: In BeanRegistryImplementation, the `getOrCreate(BeanRegistry, Grammar)` method on BeanContainer is guaranteed to always return a non-null object or throw an exception, so null filtering after calling getOrCreate is not necessary.

Applied to files:

  • core/src/main/java/com/predic8/membrane/core/cli/RouterCLI.java
  • core/src/main/java/com/predic8/membrane/core/kubernetes/KubernetesWatcher.java
⏰ 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: Automated tests
  • GitHub Check: Analyze (java)
🔇 Additional comments (2)
core/src/main/java/com/predic8/membrane/core/cli/RouterCLI.java (1)

166-179: LGTM! Registry initialization ordering is correct.

Setting the registry on the router before bean registration ensures that router.getRegistry() returns the correct instance when called by other components (e.g., KubernetesWatcher). The initialization sequence is sound: create registry → set on router → register beans → parse config → finalize → start.

core/src/main/java/com/predic8/membrane/core/kubernetes/KubernetesWatcher.java (1)

50-52: The null safety and type safety concerns are not valid. DefaultMainComponents.getRegistry() includes an explicit null guard (lines 179-182) that initializes the registry if needed, guaranteeing a non-null return. Additionally, BeanRegistryImplementation implements both BeanRegistry and BeanCollector interfaces, so the cast on line 52 is safe.

Likely an incorrect or invalid review comment.

@rrayst rrayst changed the title set registry on router before initing fix example tests Jan 13, 2026
@rrayst rrayst requested a review from predic8 January 13, 2026 18:47
@predic8 predic8 merged commit b924d94 into master Jan 13, 2026
5 checks passed
@predic8 predic8 deleted the fix-example-tests branch January 13, 2026 20:14
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