Skip to content

feature: add the repo's first test suite (43 JUnit 5 tests) - #73

Merged
devin-ai-integration[bot] merged 1 commit into
devin/1786033413-java21-boot3-basefrom
devin/1786033690-test-suite
Aug 6, 2026
Merged

devin-ai-integration[bot] merged 1 commit into
devin/1786033413-java21-boot3-basefrom
devin/1786033690-test-suite

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

Summary

The repo had no src/test at all, so nothing protected the Java 21 / Boot 3 upgrade or the refactors landing on this base branch. This adds 43 JUnit 5 tests (2 intentionally @Disabled) that pin the observable behaviour — HTTP status codes and JSON field names — so the parallel modernization work has something to be validated against. No production file, pom.xml, or workflow is touched.

What is covered

Area Class
Context starts (incl. the CommandLineRunner and the unreachable quote service) hello.ApplicationContextLoadTest
/topic CRUD lifecycle, /topic/sort, /topic/minimum/length/{n} hello.controller.TopicControllerWebTest
/, /datetime, /topic/string/operation, /topic/file/operation GreetingControllerWebTest, HelloControllerWebTest
unknown-id status code TopicNotFoundStatusTest
stream / IntStream / regex / NIO service methods hello.service.TopicServiceTest
default + static interface methods hello.declaration.TimeClientTest

Deliberate design decisions (the interesting part of the diff):

  • Shared mutable state. TopicService is a singleton wrapping a mutable List<Topic>, so writes leak between tests. Unit tests sidestep the container entirely (new TopicService() per test in @BeforeEach) — no cleanup to forget and no context restart cost. The web tests can't do that, so the only two that mutate the list (the CRUD lifecycle, and /topic/sort, which sorts in place) carry @DirtiesContext(methodMode = AFTER_METHOD); every other test may then assume the three seeded topics. Verified order-independent by re-running with MethodOrderer$Random + ClassOrderer$Random.
  • Records migration. Web assertions use jsonPath rather than model getters, because the JSON field names are the actual contract and survive getId() → id(). The only getter usage in the unit tests is funnelled through a single idsOf(List<Topic>) helper plus two getSubjectName() calls, so the record conversion is a two-line mechanical fix here.
  • Unknown topic id. getTopicWithId calls Optional.get() on a miss. That is asserted as-is (NoSuchElementException in the unit test, HTTP 500 in TopicNotFoundStatusTest), with a @Disabled sibling in each place spelling out the 404 replacement — enable those and delete the current-behaviour ones when the 404 change merges. This one case runs over a real port (webEnvironment = RANDOM_PORT) because MockMvc rethrows unhandled exceptions instead of running the error dispatch, so it cannot observe the 500.
  • Working-directory-dependent file operations. findAllFilesInPathAndSort / findParticularFileInPathAndSort* walk the process CWD and readFileWithStreamFunction reads temp.txt from it, so exact output changes whenever anyone adds or deletes a file. These assert loosely — non-null, "not the IO-error sentinel", contains pom.xml — and the temp.txt test is guarded by Assumptions.assumeTrue(Files.exists(...)).
  • setDate(int day, int month, int year) actually delegates positionally to LocalDate.of(year, month, day), i.e. the parameter names lie. Asserted as implemented, with a comment; not fixed, as src/main is out of scope for this slice.

Verification

  • ./mvnw clean verify on JDK 21: Tests run: 43, Failures: 0, Errors: 0, Skipped: 2, BUILD SUCCESS. Re-run green with randomized method and class ordering.
  • Ran ./mvnw spring-boot:run and curled every endpoint. JSON shapes unchanged:
    • GET /topic/spring → {"id":"spring","subjectName":"Spring Framework","subjectDescription":"Spring Framework Description"}
    • GET / → {"id":1,"content":"Hello, World!"}
    • POST → GET → PUT → DELETE round trip all 200, list back to 3 topics
    • GET /topic/nope → 500
    • /topic/sort, /topic/minimum/length/4, /datetime, /topic/string/operation, /topic/file/operation all 200 with the expected content
  • Startup still logs WARN ... Could not fetch a quote from http://gturnquist-quoters.cfapps.io/api/random and does not fail — the context-load test passes through it.

Files I do not own

None changed. Nothing in src/main/, pom.xml, README.md or .github/ was modified, and no change to them is needed for these tests to pass.

Link to Devin session: https://app.devin.ai/sessions/52db8735a170458cbcffcb224418987d


Devin Review

Status Commit
⚪ Not started —

Run Devin Review

Open in Devin Review (Staging)

… TopicService and TimeClient

Co-Authored-By: alex.vyshetsky <alex.vyshetsky@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, CI, and merge conflict monitoring

@devin-ai-integration
devin-ai-integration Bot merged commit 2c8283c into devin/1786033413-java21-boot3-base Aug 6, 2026
1 check failed
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.

0 participants