πŸ§ͺ Tester view

Untested behaviours, edge cases, test gap inventory  Β·  QA Engineer, SDET, Test Lead

Generated 3 days ago
⚑ Agent trace  Β·  13 steps  Β·  $0.0554  Β·  click to expand
search_claims(query='error handling exception caught swallowed', category='behavioral') β†’ search_claims(query='test coverage unit test', category='any') β†’ search_claims(category='behavioral', max_results=30) β†’ search_claims(category='behavioral', max_results=30) β†’ read_source_file(file_path='src/main/java/io/spring/core/article/Article.java', start_line=40) β†’ read_source_file(file_path='src/main/java/io/spring/application/DateTimeCursor.java', start_line=1) β†’ read_source_file(file_path='src/main/java/io/spring/infrastructure/service/DefaultJwtService.java', start_line=1) β†’ search_claims(category='behavioral', max_results=30) β†’ search_claims(category='behavioral', max_results=25) β†’ read_source_file(end_line=62, file_path='src/main/java/io/spring/api/security/JwtTokenFilter.java') β†’ search_claims(category='behavioral', max_results=30) β†’ read_source_file(end_line=100, file_path='src/main/java/io/spring/application/ArticleQueryService.java') β†’ read_source_file(end_line=44, file_path='src/main/java/io/spring/application/CursorPager.java') β†’ search_claims(category='behavioral', max_results=25) β†’ read_source_file(end_line=108, file_path='src/main/java/io/spring/api/exception/CustomizeExceptionHandler.java') β†’ read_source_file(end_line=105, file_path='src/main/java/io/spring/application/user/UserService.java') β†’ read_source_file(end_line=108, file_path='src/main/java/io/spring/graphql/exception/GraphQLCustomizeExceptionHandler.java') β†’ search_claims(category='behavioral', max_results=25) β†’ search_claims(category='behavioral', max_results=25) β†’ read_source_file(end_line=85, file_path='src/main/java/io/spring/api/CommentsApi.java') β†’ search_claims(category='behavioral', max_results=20) β†’ read_source_file(end_line=40, file_path='src/main/java/io/spring/api/ArticleFavoriteApi.java') β†’ read_source_file(end_line=45, file_path='src/main/java/io/spring/infrastructure/mybatis/DateTimeHandler.java') β†’ read_source_file(end_line=35, file_path='src/main/java/io/spring/infrastructure/repository/MyBatisArticleFavoriteRepository.java') β†’ read_source_file(end_line=160, file_path='src/main/java/io/spring/application/ArticleQueryService.java')

Test Intelligence Report

Codebase: Spring Boot "RealWorld" API (REST + GraphQL), 909 claims / 116 files. Focus: Risk-ranked behaviours, edge cases, error-handling gaps, and concrete test scenarios grounded in source.


High-Risk Untested Behaviours

Ranked by blast radius (auth β†’ data integrity β†’ pagination β†’ domain).

  1. JWT filter silently ignores malformed Authorization headers β€” no test for the split edge cases. JwtTokenFilter.getTokenString returns Optional.empty() when the header is null (line 51) or when split.length < 2 (line 55), and otherwise returns Optional.ofNullable(split[1]) (line 58). There is no test covering "Bearer" (no token), "Bearer " (trailing space β†’ split length 1), or a header with extra spaces. These all degrade to anonymous access rather than an error. src/main/java/io/spring/api/security/JwtTokenFilter.java:50-61

  2. getSubFromToken swallows all exceptions and returns Optional.empty(). catch (Exception e) { return Optional.empty(); } β€” expired, malformed, wrong-key, and null tokens are indistinguishable. Tests exist for "123" and one expired token (DefaultJwtServiceTest.java:29-40), but not for a token signed with a different secret, a token with a null subject, or a token whose subject is an empty string. src/main/java/io/spring/infrastructure/service/DefaultJwtService.java:40-49

  3. Article.update re-derives the slug on title change but leaves it stale on description/body-only updates. Only the title branch calls toSlug (line 54); description (57-60) and body (61-64) branches update updatedAt but not slug. No test asserts slug stability/change semantics across partial updates. src/main/java/io/spring/core/article/Article.java:51-65

  4. ArticleFavoriteRepository.save is a silent no-op on duplicate favorites. if (mapper.find(...) == null) { mapper.insert(...) } β€” favoriting twice is idempotent but untested for the duplicate case. src/main/java/io/spring/infrastructure/repository/MyBatisArticleFavoriteRepository.java:19-24

  5. unfavoriteArticle when no favorite exists. The claim notes it only removes ifPresent; the API still returns 200 with article data. No test covers "unfavorite something never favorited." src/main/java/io/spring/api/ArticleFavoriteApi.java:39-40, src/main/java/io/spring/graphql/ArticleMutation.java:72-83

  6. DateTimeCursor.parse throws on non-numeric cursors. Long.parseLong(cursor) (line 21) is unguarded β€” a client-supplied cursor like "abc" throws NumberFormatException, which is not mapped to a 4xx. Only the null case is handled (18-20). src/main/java/io/spring/application/DateTimeCursor.java:17-22

  7. CursorPageParameter.setLimit boundary behaviour. Caps at MAX_LIMIT (1000) and ignores non-positive limits (leaving the default). No test asserts limit=0, limit=-1, or limit=5000. src/main/java/io/spring/application/CursorPageParameter.java:33-39


Edge Case Inventory

Area Boundary / special input Source
Slug generation &, CJK punctuation \uFE30-\uFFA0, curly quotes ’ ”, whitespace, ?, ,, . all collapse to -; lowercased Article.java:67-69
Slug generation Title with only special chars β†’ slug becomes "-" (or empty-ish); no test Article.java:68
Slug generation Leading/trailing spaces β†’ leading/trailing hyphens; no trimming Article.java:68
Article update Empty/blank title/description/body are ignored (no-op) via Util.isEmpty Article.java:51-65
User update Same conditional-update semantics per field User.java:29-49
Util.isEmpty null or length-0 β†’ true; whitespace-only string β†’ false (not trimmed) Util.java:5
Cursor parse null β†’ null; non-numeric β†’ NumberFormatException DateTimeCursor.java:17-22
Cursor limit >1000 capped; <=0 ignored (default retained) CursorPageParameter.java:33-39
Cursor query limit getQueryLimit() returns limit + 1 (fetch-one-extra pattern) CursorPageParameter.java:25-27
Pagination Empty result β†’ getStartCursor()/getEndCursor() return null CursorPager.java:32-38
Pagination PREV direction reverses the list; NEXT does not ArticleQueryService.java:69-71, 92-94
Pagination Both first and last null β†’ IllegalArgumentException ArticleDatafetcher.java:42-86, CommentDatafetcher.java:50-100
Favorite count countMap.get(id) may return null if no count row β†’ favoritesCount set to null ArticleQueryService.java:157-158
JWT sessionTime * 1000L β€” intΓ—long, safe; but sessionTime from config unvalidated DefaultJwtService.java:51-53
DateTime null DateTime β†’ setTimestamp(..., null) DateTimeHandler.java:20-25
GraphQL error path getParam on a 1-segment path returns the whole string; on β‰₯2 segments drops the first two GraphQLCustomizeExceptionHandler.java:95-102

Error Handling Gaps

HIGH β€” Silent failures (exceptions caught and swallowed):

  1. DefaultJwtService.getSubFromToken β€” catch (Exception e) { return Optional.empty(); }. Every failure mode (expired, tampered, wrong key, malformed) collapses to "no subject," which the filter treats as anonymous. A tampered token is indistinguishable from no token. DefaultJwtService.java:46-48

  2. JwtTokenFilter β€” getTokenString returns empty for malformed headers with no logging; userRepository.findById(id).ifPresent(...) silently does nothing if the token's subject no longer maps to a user (deleted user with valid token β†’ anonymous). JwtTokenFilter.java:28-45, 50-61

  3. ArticleFavoriteRepository.save β€” duplicate favorite silently skipped, no signal to caller. MyBatisArticleFavoriteRepository.java:20-24

MEDIUM β€” Unmapped exceptions / missing handlers:

  1. DateTimeCursor.parse β€” NumberFormatException from Long.parseLong is not handled by CustomizeExceptionHandler (which only handles InvalidRequestException, InvalidAuthenticationException, ConstraintViolationException, MethodArgumentNotValidException). A bad cursor likely surfaces as a 500. DateTimeCursor.java:21, CustomizeExceptionHandler.java:27-87

  2. ArticleFavoriteApi.favoriteArticle β€” articleQueryService.findBySlug(slug, user).get() calls .get() on an Optional without isPresent check (line 36). If the article was deleted between the findBySlug lookup and this call, this throws NoSuchElementException. ArticleFavoriteApi.java:36

  3. CommentsApi.createComment β€” commentQueryService.findById(comment.getId(), user).get() (line 50) β€” same unguarded .get() pattern. CommentsApi.java:50

LOW β€” Inconsistent status mapping:

  1. CustomizeExceptionHandler returns 422 for InvalidAuthenticationException (login failure) rather than 401 β€” intentional per tests but worth locking down. CustomizeExceptionHandler.java:50-60

Suggested Test Scenarios

Auth / JWT - Given header "Bearer" (no token), When GET /user, Then 401 (not 500). JwtTokenFilter.java:55 - Given a token signed with a different secret, When getSubFromToken, Then Optional.empty(). DefaultJwtService.java:44-48 - Given a valid token whose subject user was deleted, When GET /user, Then 401. JwtTokenFilter.java:33-43

Slug / Article - Given title "Hello, World?!", When toSlug, Then "hello-world-" (trailing hyphen from ?!). Article.java:68 - Given title "δ½ ε₯½" (CJK), When toSlug, Then "-". Article.java:68 - Given an article, When update(null, "new desc", null), Then slug unchanged, description updated, updatedAt advanced. Article.java:57-60 - Given an article, When update("New Title", null, null), Then slug recomputed from new title. Article.java:52-56

Pagination - Given cursor "abc", When DateTimeCursor.parse, Then a mapped 4xx (currently NumberFormatException). DateTimeCursor.java:21 - Given limit=5000, When setLimit, Then limit == 1000. CursorPageParameter.java:33-39 - Given limit=0, When setLimit, Then limit retains default. CursorPageParameter.java:33-39 - Given a PREV page with hasExtra=true, When CursorPager constructed, Then hasPrevious()==true, hasNext()==false. CursorPager.java:18-21 - Given an empty result set, When getStartCursor(), Then null. CursorPager.java:32-34

Favorites / Comments - Given a user already favorited an article, When favoriteArticle again, Then no duplicate row and 200. MyBatisArticleFavoriteRepository.java:20-24 - Given a user never favorited, When DELETE /articles/{slug}/favorite, Then 200 (idempotent). ArticleFavoriteApi.java:39-40 - Given a comment on an article, When a non-author/non-article-owner deletes it, Then 403. CommentsApi.java:78-80, AuthorizationService.java:12-14

User update - Given user A updates email to user B's email, When updateUser, Then 422 "email already exist". UserService.java:74-105 - Given user A updates email to their own current email, When updateUser, Then success (equality check passes). UserService.java:80-81


Complex Code Paths

  1. ArticleQueryService.findRecentArticlesWithCursor / findUserFeedWithCursor β€” branching on empty result, hasExtra trim, PREV reversal, then fillExtraInfo. Four interacting conditions; the reversal-after-trim ordering is easy to get wrong. ArticleQueryService.java:54-98

  2. ArticleQueryService.fillExtraInfo β€” null-user guard skips setIsFavorite/setIsFollowingAuthor but always runs setFavoriteCount; countMap.get(id) can yield null. ArticleQueryService.java:125-159

  3. CursorPager constructor β€” direction-dependent flag assignment (next vs previous). CursorPager.java:12-22

  4. GraphQLCustomizeExceptionHandler.getParam β€” split("\\.") with 1-segment vs β‰₯2-segment branches; Arrays.copyOfRange(splits, 2, ...) on a 2-segment path returns an empty array β†’ empty string. GraphQLCustomizeExceptionHandler.java:95-102

  5. UpdateUserValidator.isValid β€” two independent uniqueness checks combined with &&, each using Optional.map(...).orElse(true). UserService.java:74-105

  6. Article.update / User.update β€” three/five independent if (!Util.isEmpty(...)) branches each mutating updatedAt. Article.java:51-65, User.java:29-49

  7. MyBatisArticleRepository.createNew β€” iterates tags, find-or-insert each, then inserts relations and article (transaction-sensitive; covered by ArticleRepositoryTransactionTest). MyBatisArticleRepository.java:29-41


Coverage notes for the test lead

  • Existing tests are strong on happy-path REST endpoints and duplicate/validation errors (UsersApiTest, ArticlesApiTest, CommentsApiTest).
  • Weakest coverage: JWT filter header parsing, cursor parsing/limits, idempotent favorite/unfavorite, partial-update slug semantics, and unguarded Optional.get() in ArticleFavoriteApi:36 and CommentsApi:50.
  • RealworldApplicationTests.contextLoads is empty β€” it only proves the context boots, not behaviour. RealworldApplicationTests.java:9-10