Skip to content

Test/http response - #102

Closed
eafalkens wants to merge 16 commits into
mainfrom
test/HttpResponse
Closed

Test/http response#102
eafalkens wants to merge 16 commits into
mainfrom
test/HttpResponse

Conversation

@eafalkens

@eafalkens eafalkens commented Feb 20, 2026

Copy link
Copy Markdown

HttpResponse is responsible for representing and mutating the HTTP response sent back to the client.

To ensure reliability and correctness, we should add unit tests that verify proper status handling, header storage and retrieval, and body handling. This will help guarantee a stable response system.

Summary by CodeRabbit

  • Tests
    • Expanded unit tests covering default response state (status code/text), empty headers and body, and null-status-text error handling.
    • Converted tests to a clearer, per-case structure with setup fixtures for consistency.
    • Minor test formatting cleanup with no behavioral impact.

@coderabbitai

coderabbitai Bot commented Feb 20, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Converts HttpResponseTest to JUnit 5 style with a public test class, adds a @BeforeEach fixture and discrete tests for default status/code/text, null handling, headers, and body; removes a trailing blank line in HttpResponseWriterTest.java.

Changes

Cohort / File(s) Summary
HttpResponse tests
src/test/java/org/juv25d/http/HttpResponseTest.java
Converted to JUnit 5, made class public, added @BeforeEach setup initializing HttpResponse, and introduced multiple focused tests: default statusCode()/statusText(), null-check for setStatusText(null), empty headers(), and empty body() assertions.
Formatting tweak
src/test/java/org/juv25d/http/HttpResponseWriterTest.java
Removed a trailing blank line before the final closing brace; no behavioral or API changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • feature/basic-http-responses #24 — Adds/updates unit tests for HttpResponse (default state, null-handling, accessors), directly touching the same API and tests.

Suggested reviewers

  • addee1
  • kristina0x7

Poem

🐰
I hopped through asserts, nose to the screen,
Set up a fixture, kept the tests clean.
Defaults I checked, and nulls I caught,
Headers empty, body naught.
A little hop for code serene.

🚥 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 'Test/http response' is vague and uses a generic format that doesn't clearly summarize the main change. It uses a slash-separated pattern without describing what was actually done (added/refactored tests). Revise the title to be more descriptive and specific, such as 'Refactor HttpResponse tests to use JUnit 5 with discrete test methods' or 'Add comprehensive unit tests for HttpResponse status, headers, and body handling'.
✅ 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.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test/HttpResponse

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 (4)
src/test/java/org/juv25d/http/HttpResponseTest.java (4)

6-65: Optional: Extract new HttpResponse() to a @BeforeEach field to reduce boilerplate.

Every test method instantiates HttpResponse independently. A shared @BeforeEach would remove repetition without affecting test isolation (JUnit creates a fresh test instance per test method by default).

♻️ Proposed refactor
+import org.junit.jupiter.api.BeforeEach;
+
 public class HttpResponseTest {
 
+    private HttpResponse response;
+
+    `@BeforeEach`
+    void setUp() {
+        response = new HttpResponse();
+    }
+
     `@Test`
     void shouldReturnDefaultStatusCode() {
-        HttpResponse response = new HttpResponse();
         assertEquals(0, response.statusCode());
     }
     // ... apply same removal to all other test methods
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/org/juv25d/http/HttpResponseTest.java` around lines 6 - 65,
Extract repeated new HttpResponse() instantiations into a shared field
initialized in a `@BeforeEach` method: add a private HttpResponse field to the
HttpResponseTest class and create a method annotated with `@BeforeEach` that
assigns this field = new HttpResponse(); then update each test to use the field
(e.g., response -> the shared field) to remove boilerplate while keeping test
isolation; reference HttpResponseTest, the HttpResponse type, and the
`@BeforeEach` initialization method when making the change.

9-11: Optional: Use a more specific test name.

shouldReturnDefaultValue is ambiguous — it doesn't indicate which property is being tested. Consider shouldReturnDefaultStatusCode for consistency with shouldSetAndReturnStatusCode.

♻️ Proposed rename
-    void shouldReturnDefaultValue() {
+    void shouldReturnDefaultStatusCode() {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/org/juv25d/http/HttpResponseTest.java` around lines 9 - 11,
Rename the ambiguous test method shouldReturnDefaultValue to
shouldReturnDefaultStatusCode to make it clear which property is being tested;
update the test method name in HttpResponseTest and any references (e.g., test
runner annotations or IDE run configurations) so it remains consistent with the
existing shouldSetAndReturnStatusCode test and continues to instantiate
HttpResponse and assertEquals(0, response.statusCode()).

3-4: JUnit 6.0.3 is the current stable release; 6.0.2 is one patch behind.

There is a newer version available. For the latest stable release, please see JUnit 6.0.3. Consider updating the dependency version in the build file.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/org/juv25d/http/HttpResponseTest.java` around lines 3 - 4,
Tests import JUnit APIs but project is pinned to JUnit 6.0.2; update the build
dependency for the JUnit Jupiter artifacts (e.g., groupId/org: org.junit.jupiter
or artifactId like junit-jupiter/junit-jupiter-engine) from version 6.0.2 to
6.0.3 in your build file (pom.xml or build.gradle) so the test imports in
HttpResponseTest.java use the current stable release.

60-65: Two optional improvements for shouldSetAndReturnBody.

  1. Platform-default charset: "Hello World".getBytes() uses the JVM's default charset, which may vary across environments. Prefer an explicit charset for reliable, portable tests.

  2. Defensive-copy contract not verified: The test should verify that HttpResponse correctly implements the defensive-copy pattern. While the implementation does perform body.clone() in both setBody() and body(), the test does not validate this contract, which is valuable to verify and maintain.

♻️ Proposed improvements
     void shouldSetAndReturnBody() {
         HttpResponse response = new HttpResponse();
-        byte[] body = "Hello World".getBytes();
+        byte[] body = "Hello World".getBytes(java.nio.charset.StandardCharsets.UTF_8);
         response.setBody(body);
         assertArrayEquals(body, response.body());
+        // Verify defensive copy: mutating the original should not affect the stored body
+        byte[] snapshot = response.body().clone();
+        body[0] = 0;
+        assertArrayEquals(snapshot, response.body());
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/org/juv25d/http/HttpResponseTest.java` around lines 60 - 65,
Update the test method shouldSetAndReturnBody to use an explicit charset (e.g.,
StandardCharsets.UTF_8) when creating the byte[] and to verify the
defensive-copy contract of HttpResponse: after calling response.setBody(byte[]),
mutate the original byte[] and assert the response.body() content did not
change, and after getting byte[] returned = response.body(), mutate returned and
assert a subsequent response.body() still returns the original content;
reference HttpResponse.setBody() and HttpResponse.body() in the test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/test/java/org/juv25d/http/HttpResponseTest.java`:
- Around line 54-57: The test shouldHaveEmptyBodyByDefault in HttpResponseTest
currently calls response.body().length which can NPE if body() returns null;
change the assertion to use assertArrayEquals to compare the actual byte[] from
HttpResponse.body() against an empty byte[] (e.g., new byte[0]) so a null or
non-empty body produces a clear assertion failure; update the assertion in the
test method (referencing HttpResponse and its body() method) accordingly.

---

Nitpick comments:
In `@src/test/java/org/juv25d/http/HttpResponseTest.java`:
- Around line 6-65: Extract repeated new HttpResponse() instantiations into a
shared field initialized in a `@BeforeEach` method: add a private HttpResponse
field to the HttpResponseTest class and create a method annotated with
`@BeforeEach` that assigns this field = new HttpResponse(); then update each test
to use the field (e.g., response -> the shared field) to remove boilerplate
while keeping test isolation; reference HttpResponseTest, the HttpResponse type,
and the `@BeforeEach` initialization method when making the change.
- Around line 9-11: Rename the ambiguous test method shouldReturnDefaultValue to
shouldReturnDefaultStatusCode to make it clear which property is being tested;
update the test method name in HttpResponseTest and any references (e.g., test
runner annotations or IDE run configurations) so it remains consistent with the
existing shouldSetAndReturnStatusCode test and continues to instantiate
HttpResponse and assertEquals(0, response.statusCode()).
- Around line 3-4: Tests import JUnit APIs but project is pinned to JUnit 6.0.2;
update the build dependency for the JUnit Jupiter artifacts (e.g., groupId/org:
org.junit.jupiter or artifactId like junit-jupiter/junit-jupiter-engine) from
version 6.0.2 to 6.0.3 in your build file (pom.xml or build.gradle) so the test
imports in HttpResponseTest.java use the current stable release.
- Around line 60-65: Update the test method shouldSetAndReturnBody to use an
explicit charset (e.g., StandardCharsets.UTF_8) when creating the byte[] and to
verify the defensive-copy contract of HttpResponse: after calling
response.setBody(byte[]), mutate the original byte[] and assert the
response.body() content did not change, and after getting byte[] returned =
response.body(), mutate returned and assert a subsequent response.body() still
returns the original content; reference HttpResponse.setBody() and
HttpResponse.body() in the test.

Comment thread src/test/java/org/juv25d/http/HttpResponseTest.java

@bamsemats bamsemats left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Look good to me - implement suggested change by the rabbit and it's clear for approval.

@lindaeskilsson

Copy link
Copy Markdown

Just a heads up 😊 We already have an existing HttpResponseTest in the project. Might be good to merge them together so we don’t end up maintaining two separate test suites. Otherwise, nicely done!

lindaeskilsson
lindaeskilsson previously approved these changes Feb 21, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
src/test/java/org/juv25d/http/HttpResponseTest.java (1)

33-36: body().length will throw NPE if body() returns null, masking the real failure.

This was flagged in a previous review and remains unaddressed.

🛡️ Proposed fix
-        assertEquals(0, response.body().length);
+        assertArrayEquals(new byte[0], response.body());
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/org/juv25d/http/HttpResponseTest.java` around lines 33 - 36,
The test should guard against a null body to avoid NPE masking failures: in
shouldHaveEmptyBodyByDefault() (class HttpResponseTest) replace the direct
length assertion on response.body() with assertions that the body is non-null
and empty (e.g., assertNotNull(response.body()) followed by asserting zero
length or assertArrayEquals(new byte[0], response.body())); this ensures
HttpResponse.body() being null is reported explicitly and validates the expected
empty-body behavior.
🧹 Nitpick comments (1)
src/test/java/org/juv25d/http/HttpResponseTest.java (1)

8-36: Extract a shared @BeforeEach to avoid repeating new HttpResponse() in every test.

All five tests independently instantiate HttpResponse. A setup method removes the boilerplate and makes it easier to add future tests.

♻️ Proposed refactor
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import static org.junit.jupiter.api.Assertions.*;

 public class HttpResponseTest {

+    private HttpResponse response;
+
+    `@BeforeEach`
+    void setUp() {
+        response = new HttpResponse();
+    }
+
     `@Test`
     void shouldReturnDefaultValue() {
-        HttpResponse response = new HttpResponse();
         assertEquals(0, response.statusCode());
     }

     `@Test`
     void shouldReturnDefaultText() {
-        HttpResponse response = new HttpResponse();
         assertNull(response.statusText());
     }

     `@Test`
     void shouldThrowExceptionWhenStatusTextIsNull() {
-        HttpResponse response = new HttpResponse();
         assertThrows(NullPointerException.class, () -> response.setStatusText(null));
     }

     `@Test`
     void shouldHaveEmptyHeaderByDefault() {
-        HttpResponse response = new HttpResponse();
         assertTrue(response.headers().isEmpty());
     }

     `@Test`
     void shouldHaveEmptyBodyByDefault() {
-        HttpResponse response = new HttpResponse();
         assertArrayEquals(new byte[0], response.body());
     }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/org/juv25d/http/HttpResponseTest.java` around lines 8 - 36,
Extract a shared fixture by adding a private HttpResponse field in
HttpResponseTest and initializing it in a `@BeforeEach` method (e.g., void setUp()
{ response = new HttpResponse(); }), then update all tests
(shouldReturnDefaultValue, shouldReturnDefaultText,
shouldThrowExceptionWhenStatusTextIsNull, shouldHaveEmptyHeaderByDefault,
shouldHaveEmptyBodyByDefault) to use the instance field instead of creating new
HttpResponse() locally—remove the duplicate instantiations so each test uses the
shared response set up by `@BeforeEach`.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/test/java/org/juv25d/http/HttpResponseTest.java`:
- Around line 14-24: Tests for HttpResponse are contradictory: statusText()
currently defaults to null but setStatusText(null) throws NPE; pick one contract
and make tests and implementation consistent. Option A: make null invalid
everywhere — change HttpResponse constructor to initialize the statusText field
to "" (or chosen non-null sentinel), update shouldReturnDefaultText to
assertEquals("", response.statusText()), and keep setStatusText throwing on
null. Option B: allow null as a valid reset — modify setStatusText to accept
null (remove the NullPointerException), ensure the internal field can be set to
null, and update shouldThrowExceptionWhenStatusTextIsNull to assertDoesNotThrow
or remove that test; apply the chosen change to the HttpResponse class
(constructor/field and setStatusText method) and adjust the tests
(shouldReturnDefaultText and shouldThrowExceptionWhenStatusTextIsNull)
accordingly so both reflect the same contract.

---

Duplicate comments:
In `@src/test/java/org/juv25d/http/HttpResponseTest.java`:
- Around line 33-36: The test should guard against a null body to avoid NPE
masking failures: in shouldHaveEmptyBodyByDefault() (class HttpResponseTest)
replace the direct length assertion on response.body() with assertions that the
body is non-null and empty (e.g., assertNotNull(response.body()) followed by
asserting zero length or assertArrayEquals(new byte[0], response.body())); this
ensures HttpResponse.body() being null is reported explicitly and validates the
expected empty-body behavior.

---

Nitpick comments:
In `@src/test/java/org/juv25d/http/HttpResponseTest.java`:
- Around line 8-36: Extract a shared fixture by adding a private HttpResponse
field in HttpResponseTest and initializing it in a `@BeforeEach` method (e.g.,
void setUp() { response = new HttpResponse(); }), then update all tests
(shouldReturnDefaultValue, shouldReturnDefaultText,
shouldThrowExceptionWhenStatusTextIsNull, shouldHaveEmptyHeaderByDefault,
shouldHaveEmptyBodyByDefault) to use the instance field instead of creating new
HttpResponse() locally—remove the duplicate instantiations so each test uses the
shared response set up by `@BeforeEach`.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4bd580e and 69fafc6.

📒 Files selected for processing (2)
  • src/test/java/org/juv25d/http/HttpResponseTest.java
  • src/test/java/org/juv25d/http/HttpResponseWriterTest.java
💤 Files with no reviewable changes (1)
  • src/test/java/org/juv25d/http/HttpResponseWriterTest.java

Comment thread src/test/java/org/juv25d/http/HttpResponseTest.java
@eafalkens

Copy link
Copy Markdown
Author

Updated tests per CodeRabbit feedback

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/test/java/org/juv25d/http/HttpResponseTest.java (1)

36-61: ⚠️ Potential issue | 🔴 Critical

Fix the malformed file: two class definitions are concatenated, causing all 8 compilation errors.

The shouldHaveEmptyBodyByDefault() method opened at line 37 is never closed — its } and the outer class } are both missing. Lines 39–61 are a second, separate class definition that was appended directly inside that open method body, injecting raw import statements and a class declaration where Java expects statements. This is the source of every compiler error reported in the pipeline.

Beyond the structural break, the two fragments assert contradictory defaults for HttpResponse:

Fragment 1 (lines 17–18, 22–23) Fragment 2 (lines 50–51)
statusCode() 0 200
statusText() "" "OK"

These cannot both be correct. Consolidate into a single, coherent class that matches the actual HttpResponse defaults, and pick one assertion style (AssertJ assertThat or JUnit Assertions.*) throughout.

🐛 Proposed consolidated class (adjust expected defaults to match the implementation)
 package org.juv25d.http;
 
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.BeforeEach;
-import static org.junit.jupiter.api.Assertions.*;
-
-public class HttpResponseTest {
-
-    private HttpResponse response;
-
-    `@BeforeEach`
-    void setUp() {
-        response = new HttpResponse();
-    }
-
-    `@Test`
-    void shouldReturnDefaultStatusCode() {
-        assertEquals(0, response.statusCode());
-    }
-
-    `@Test`
-    void shouldReturnDefaultText() {
-        assertEquals("", response.statusText());
-    }
-
-    `@Test`
-    void shouldThrowExceptionWhenStatusTextIsNull() {
-        assertThrows(NullPointerException.class, () -> response.setStatusText(null));
-    }
-
-    `@Test`
-    void shouldHaveEmptyHeaderByDefault() {
-        assertTrue(response.headers().isEmpty());
-    }
-
-    `@Test`
-    void shouldHaveEmptyBodyByDefault() {
-        assertArrayEquals(new byte[0], response.body());
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatCode;
-
-class HttpResponseTest {
-
-    `@Test`
-    void defaultConstructor_hasSafeDefaults_andSetHeaderDoesNotThrow() {
-        HttpResponse response = new HttpResponse();
-
-        assertThat(response.statusCode()).isEqualTo(200);
-        assertThat(response.statusText()).isEqualTo("OK");
-        assertThat(response.headers()).isNotNull();
-        assertThat(response.body()).isNotNull();
-        assertThat(response.body()).isEmpty();
-
-        assertThatCode(() -> response.setHeader("Content-Type", "text/plain"))
-            .doesNotThrowAnyException();
-
-        assertThat(response.headers()).containsEntry("Content-Type", "text/plain");
-    }
-}
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+class HttpResponseTest {
+
+    private HttpResponse response;
+
+    `@BeforeEach`
+    void setUp() {
+        response = new HttpResponse();
+    }
+
+    `@Test`
+    void shouldReturnDefaultStatusCode() {
+        // Adjust expected value to match the actual HttpResponse default (0 or 200)
+        assertThat(response.statusCode()).isEqualTo(200);
+    }
+
+    `@Test`
+    void shouldReturnDefaultStatusText() {
+        // Adjust expected value to match the actual HttpResponse default ("" or "OK")
+        assertThat(response.statusText()).isEqualTo("OK");
+    }
+
+    `@Test`
+    void shouldThrowExceptionWhenStatusTextIsNull() {
+        assertThrows(NullPointerException.class, () -> response.setStatusText(null));
+    }
+
+    `@Test`
+    void shouldHaveEmptyHeaderByDefault() {
+        assertThat(response.headers()).isNotNull().isEmpty();
+    }
+
+    `@Test`
+    void shouldHaveEmptyBodyByDefault() {
+        assertArrayEquals(new byte[0], response.body());
+    }
+
+    `@Test`
+    void setHeader_storesAndRetrievesValue() {
+        assertThatCode(() -> response.setHeader("Content-Type", "text/plain"))
+            .doesNotThrowAnyException();
+        assertThat(response.headers()).containsEntry("Content-Type", "text/plain");
+    }
+}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/org/juv25d/http/HttpResponseTest.java` around lines 36 - 61,
The file contains two concatenated test fragments: an unclosed test method
shouldHaveEmptyBodyByDefault and a duplicate class declaration
(HttpResponseTest) with imports and assertions, causing compile errors; fix by
removing the duplicate import/class fragment, close the
shouldHaveEmptyBodyByDefault() method and the outer class properly, and merge
the assertions into a single coherent HttpResponseTest class (choose one
assertion style and set expected values to match the real HttpResponse defaults
used by the implementation), ensuring methods
defaultConstructor_hasSafeDefaults_andSetHeaderDoesNotThrow and
shouldHaveEmptyBodyByDefault are both valid test methods inside the single
class.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/test/java/org/juv25d/http/HttpResponseTest.java`:
- Around line 36-61: The file contains two concatenated test fragments: an
unclosed test method shouldHaveEmptyBodyByDefault and a duplicate class
declaration (HttpResponseTest) with imports and assertions, causing compile
errors; fix by removing the duplicate import/class fragment, close the
shouldHaveEmptyBodyByDefault() method and the outer class properly, and merge
the assertions into a single coherent HttpResponseTest class (choose one
assertion style and set expected values to match the real HttpResponse defaults
used by the implementation), ensuring methods
defaultConstructor_hasSafeDefaults_andSetHeaderDoesNotThrow and
shouldHaveEmptyBodyByDefault are both valid test methods inside the single
class.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 69fafc6 and 052d32c.

📒 Files selected for processing (1)
  • src/test/java/org/juv25d/http/HttpResponseTest.java

@eafalkens eafalkens closed this Feb 23, 2026
@eafalkens eafalkens reopened this Feb 23, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 (2)
src/test/java/org/juv25d/http/HttpResponseTest.java (2)

17-40: Consider adding mutation/round-trip tests for complete coverage.

All five tests exercise only the constructor's default state. The PR description mentions "proper status handling, header storage and retrieval, and body handling" — none of those write paths are covered yet (e.g., setStatusCode, setStatusText, adding a header and retrieving it, setting the body).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/org/juv25d/http/HttpResponseTest.java` around lines 17 - 40,
Add mutation/round‑trip tests that exercise the write paths instead of only
defaults: call response.setStatusCode(...) and assert statusCode(), call
response.setStatusText(...) and assert statusText() (also assert that setting
null still throws), add a header using the class's header mutation API (e.g.,
addHeader or setHeader) and verify retrieval via response.headers(), and set a
non-empty body via response.setBody(...) and assert response.body() equals the
bytes you wrote; reference the existing test class/variable (response) and
methods setStatusCode, setStatusText, headers(), body(), and setBody (or the
concrete header mutation method) when adding these tests.

3-6: Upgrade JUnit Jupiter to 6.0.3 (current GA).

The project pins junit-jupiter at 6.0.2 in pom.xml (line 21). JUnit 6.0.3 was released on February 15, 2026 as the current GA. Update the junit.jupiter.version property in the build file.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/org/juv25d/http/HttpResponseTest.java` around lines 3 - 6,
Update the pinned JUnit Jupiter version in the build by changing the
junit.jupiter.version property in pom.xml from 6.0.2 to 6.0.3 so the project
uses JUnit Jupiter 6.0.3 (the current GA); ensure any dependencyManagement or
plugin references to junit-jupiter or junit-jupiter-api/junit-jupiter-engine
continue to resolve against the updated junit.jupiter.version property.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/test/java/org/juv25d/http/HttpResponseTest.java`:
- Around line 32-35: The test should guard against a null headers() to avoid an
NPE masking the real assertion: in shouldHaveEmptyHeaderByDefault, first
assertNotNull(response.headers()) (or equivalent null-check) and then
assertTrue(response.headers().isEmpty()); update the test method so it
explicitly checks response.headers() is non-null before asserting emptiness
(reference: shouldHaveEmptyHeaderByDefault and response.headers()).

---

Nitpick comments:
In `@src/test/java/org/juv25d/http/HttpResponseTest.java`:
- Around line 17-40: Add mutation/round‑trip tests that exercise the write paths
instead of only defaults: call response.setStatusCode(...) and assert
statusCode(), call response.setStatusText(...) and assert statusText() (also
assert that setting null still throws), add a header using the class's header
mutation API (e.g., addHeader or setHeader) and verify retrieval via
response.headers(), and set a non-empty body via response.setBody(...) and
assert response.body() equals the bytes you wrote; reference the existing test
class/variable (response) and methods setStatusCode, setStatusText, headers(),
body(), and setBody (or the concrete header mutation method) when adding these
tests.
- Around line 3-6: Update the pinned JUnit Jupiter version in the build by
changing the junit.jupiter.version property in pom.xml from 6.0.2 to 6.0.3 so
the project uses JUnit Jupiter 6.0.3 (the current GA); ensure any
dependencyManagement or plugin references to junit-jupiter or
junit-jupiter-api/junit-jupiter-engine continue to resolve against the updated
junit.jupiter.version property.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 052d32c and 338b354.

📒 Files selected for processing (1)
  • src/test/java/org/juv25d/http/HttpResponseTest.java

Comment thread src/test/java/org/juv25d/http/HttpResponseTest.java
@eafalkens
eafalkens force-pushed the test/HttpResponse branch 2 times, most recently from b01bc0f to f5ae02a Compare February 26, 2026 17:52
@eafalkens eafalkens closed this Feb 26, 2026
@eafalkens
eafalkens deleted the test/HttpResponse branch February 26, 2026 18:19
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.

4 participants