Scripting: JSON handling fix #2954#2956
Conversation
📝 WalkthroughWalkthroughScriptingUtils updates JSON parameter binding to deserialize request bodies to ChangesJSON Parameter Binding
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
core/src/test/java/com/predic8/membrane/core/lang/ScriptingUtilsTest.java (1)
22-43: ⚡ Quick winAdd boolean and null JSON binding tests.
The suite currently skips two JSON primitive cases (
true/falseandnull). Adding both keeps the newObject.classcontract fully covered.Proposed test additions
`@Test` void number() throws URISyntaxException { assertInstanceOf(Integer.class, createBinding("7").get("json")); } + `@Test` + void bool() throws URISyntaxException { + assertInstanceOf(Boolean.class, createBinding("true").get("json")); + } + + `@Test` + void nullValue() throws URISyntaxException { + var bindings = createBinding("null"); + assertNotNull(bindings); + org.junit.jupiter.api.Assertions.assertNull(bindings.get("json")); + } + private static `@NotNull` Map<String, Object> createBinding(String json) throws URISyntaxException {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@core/src/test/java/com/predic8/membrane/core/lang/ScriptingUtilsTest.java` around lines 22 - 43, Add two unit tests to cover the missing JSON primitives: create a test method (e.g., booleanValue) that calls createBinding("true").get("json") and assertInstanceOf(Boolean.class, ...) to verify boolean binding, and a test method (e.g., nullValue) that calls createBinding("null").get("json") and assertNull(...) to verify null binding; reference createBinding(...) and the test class ScriptingUtilsTest to insert these new `@Test` methods alongside the existing map/array/string/number tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@core/src/test/java/com/predic8/membrane/core/lang/ScriptingUtilsTest.java`:
- Around line 22-43: Add two unit tests to cover the missing JSON primitives:
create a test method (e.g., booleanValue) that calls
createBinding("true").get("json") and assertInstanceOf(Boolean.class, ...) to
verify boolean binding, and a test method (e.g., nullValue) that calls
createBinding("null").get("json") and assertNull(...) to verify null binding;
reference createBinding(...) and the test class ScriptingUtilsTest to insert
these new `@Test` methods alongside the existing map/array/string/number tests.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: dc1cc9af-c947-443e-9ae2-b39efb0f9e85
📒 Files selected for processing (2)
core/src/main/java/com/predic8/membrane/core/lang/ScriptingUtils.javacore/src/test/java/com/predic8/membrane/core/lang/ScriptingUtilsTest.java
Summary by CodeRabbit
Bug Fixes
Logging & Observability
Tests