[test-improver] Add @DataJpaTest tests for TaskRepository (14 tests, 2 bug-pins)#82
Draft
github-actions[bot] wants to merge 1 commit into
Draft
Conversation
- findByStatus, findByAssigneeId, findByProjectCode, findByType: functional coverage - findHighPriorityTasks: verifies priority >= 3 threshold - findActiveTasks + findActiveTasksByAssignee: 2 bug-pin tests documenting that cancelled tasks (status=3) are incorrectly returned by both queries (FIXME comment in TaskRepository acknowledges the bug) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
🤖 Test Improver — automated AI assistant focused on improving tests.
Goal & Rationale
TaskRepositoryhad zero tests despite containing custom JPQL queries with documented bugs. Two queries include FIXME comments stating they should also exclude cancelled tasks (status=3) but don't — this creates silent data integrity issues where cancelled tasks show up as "active".Key testing opportunities:
findActiveTasks()returns cancelled tasks (FIXME in source)findActiveTasksByAssignee()returns cancelled tasks (same root cause)Approach
Used
@DataJpaTest— a Spring slice test that boots only JPA/H2, no web layer. This is ~3× faster than@SpringBootTestand avoidsDataInitializerseeding interference. Each test callstaskRepository.deleteAll()in@BeforeEachfor full isolation.Tests added (14 total)
findByStatus_returnsOnlyMatchingStatusfindByStatus_returnsEmptyWhenNoneMatchfindByAssigneeId_returnsTasksForGivenAssignee@QueryfindByAssigneeId_returnsEmptyForUnknownAssigneefindByProjectCode_returnsTasksForProjectfindHighPriorityTasks_returnsPriority3AndAbovefindHighPriorityTasks_excludesLowAndMediumPriorityfindActiveTasks_includesTodoAndInProgressfindActiveTasks_excludesDoneTasksfindActiveTasks_bugPin_cancelledTasksAreIncorrectlyReturnedfindByType_returnsOnlyMatchingTypefindActiveTasksByAssignee_returnsAssigneesNonDoneTasksfindActiveTasksByAssignee_orderedByPriorityDescendingfindActiveTasksByAssignee_bugPin_cancelledTasksAreIncorrectlyReturnedBug Pins
Both
findActiveTasks()andfindActiveTasksByAssignee()have identical FIXME comments inTaskRepository.java:The bug-pin tests document that cancelled tasks (status=3) are currently returned by both methods. When this bug is fixed, these tests will fail — which is the intended signal.
Coverage Impact
@DataJpaTestslice tests instrument the JPA layer only. TheTaskRepositoryinterface itself is proxy-generated (no coverage number), but the custom@Queryannotations are exercised through integration with H2.Test Status
Reproducibility
mvn test -Dtest=TaskRepositoryTest -BAdd this agentic workflows to your repo
To install this agentic workflow, run