Repository navigation
feature: add the repo's first test suite (43 JUnit 5 tests) - #73
Merged
devin-ai-integration[bot] merged 1 commit intoAug 6, 2026
Conversation
… TopicService and TimeClient Co-Authored-By: alex.vyshetsky <alex.vyshetsky@cognition.ai>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
devin-ai-integration
Bot
merged commit Aug 6, 2026
2c8283c
into
devin/1786033413-java21-boot3-base
1 check failed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The repo had no
src/testat 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
CommandLineRunnerand the unreachable quote service)hello.ApplicationContextLoadTest/topicCRUD lifecycle,/topic/sort,/topic/minimum/length/{n}hello.controller.TopicControllerWebTest/,/datetime,/topic/string/operation,/topic/file/operationGreetingControllerWebTest,HelloControllerWebTestTopicNotFoundStatusTesthello.service.TopicServiceTestdefault+staticinterface methodshello.declaration.TimeClientTestDeliberate design decisions (the interesting part of the diff):
TopicServiceis a singleton wrapping a mutableList<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 withMethodOrderer$Random+ClassOrderer$Random.jsonPathrather than model getters, because the JSON field names are the actual contract and survivegetId()→id(). The only getter usage in the unit tests is funnelled through a singleidsOf(List<Topic>)helper plus twogetSubjectName()calls, so the record conversion is a two-line mechanical fix here.getTopicWithIdcallsOptional.get()on a miss. That is asserted as-is (NoSuchElementExceptionin the unit test, HTTP 500 inTopicNotFoundStatusTest), with a@Disabledsibling 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.findAllFilesInPathAndSort/findParticularFileInPathAndSort*walk the process CWD andreadFileWithStreamFunctionreadstemp.txtfrom it, so exact output changes whenever anyone adds or deletes a file. These assert loosely — non-null, "not the IO-error sentinel", containspom.xml— and thetemp.txttest is guarded byAssumptions.assumeTrue(Files.exists(...)).setDate(int day, int month, int year)actually delegates positionally toLocalDate.of(year, month, day), i.e. the parameter names lie. Asserted as implemented, with a comment; not fixed, assrc/mainis out of scope for this slice.Verification
./mvnw clean verifyon JDK 21:Tests run: 43, Failures: 0, Errors: 0, Skipped: 2, BUILD SUCCESS. Re-run green with randomized method and class ordering../mvnw spring-boot:runand curled every endpoint. JSON shapes unchanged:GET /topic/spring→{"id":"spring","subjectName":"Spring Framework","subjectDescription":"Spring Framework Description"}GET /→{"id":1,"content":"Hello, World!"}200, list back to 3 topicsGET /topic/nope→500/topic/sort,/topic/minimum/length/4,/datetime,/topic/string/operation,/topic/file/operationall200with the expected contentWARN ... Could not fetch a quote from http://gturnquist-quoters.cfapps.io/api/randomand does not fail — the context-load test passes through it.Files I do not own
None changed. Nothing in
src/main/,pom.xml,README.mdor.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