Skip to content

Update test suite for Java 17 compatibility#556

Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1776282002-java17-test-compat
Open

Update test suite for Java 17 compatibility#556
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1776282002-java17-test-compat

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Apr 15, 2026

Summary

Replaces double-brace initialization (new HashMap<>() {{ put(...); }}) with Map.of() across 5 API test files as part of a Java 17 compatibility review of the full test suite (23 files).

Double-brace initialization creates anonymous inner subclasses of HashMap, which can cause issues under Java 17's stronger encapsulation (serialization edge cases, unnecessary class generation). Map.of() is cleaner and available since Java 9 (project targets Java 11+).

Files changed: ArticleApiTest, ArticlesApiTest, CommentsApiTest, CurrentUserApiTest, UsersApiTest

Other 18 test files reviewed — no issues found:

  • No reflection-based test utilities (setAccessible, getDeclaredField, etc.)
  • No deprecated JUnit 4 APIs — all tests already use JUnit Jupiter
  • No @SuppressWarnings for deprecated APIs
  • Mockito 4.0.0 (managed by Spring Boot 2.6.3) meets the minimum version for Java 17

Build note (not addressed here — out of scope): The Spotless plugin (Google Java Format) fails on Java 17 and the Mockito/ByteBuddy versions (4.0.0 / 1.11.22) may need --add-opens JVM args in build.gradle. These are build config issues to be handled separately.

Review & Testing Checklist for Human

  • Verify that Map.of() returning unmodifiable maps doesn't break RestAssured's .body() JSON serialization — the maps are only serialized, never mutated after creation, but worth a quick sanity check
  • Confirm no test parameter can be nullMap.of() throws NullPointerException on null keys/values, unlike HashMap.put()

Notes

  • All tests compile and pass on Java 17 (ran ./gradlew test -x spotlessJava successfully)
  • Net result: +16 lines / −131 lines — pure simplification with no behavioral change

Link to Devin session: https://app.devin.ai/sessions/906b3faf646a4e6b93024afe126b976b
Requested by: @shayanshafii


Open with Devin

- Replace double-brace initialization (anonymous HashMap subclasses) with
  Map.of() across 5 test files to avoid anonymous inner class issues under
  Java 17's stronger encapsulation
- Remove unused java.util.HashMap imports
- All tests verified to compile and pass on Java 17

Co-Authored-By: shayan <shayan@cognition.ai>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown
Author

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

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.

1 participant