Skip to content

[Fix] 결제 동시 승인 테스트 안정화#108

Merged
whc9999 merged 1 commit into
mainfrom
fix/payment-concurrency-test
Jun 28, 2026
Merged

[Fix] 결제 동시 승인 테스트 안정화#108
whc9999 merged 1 commit into
mainfrom
fix/payment-concurrency-test

Conversation

@whc9999

@whc9999 whc9999 commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

✨ 어떤 이유로 PR를 하셨나요?

  • feature 병합
  • 버그 수정(아래에 issue #를 남겨주세요)
  • 코드 개선
  • 코드 수정
  • 배포
  • 기타(아래에 자세한 내용 기입해주세요)

📋 세부 내용 - 왜 해당 PR이 필요한지 작업 내용을 자세하게 설명해주세요

  • 동일 결제 승인 동시 요청 테스트의 비결정적인 성공/실패 개수 검증 제거
  • 이미 완료된 동일 paymentKey 요청이 기존 결과를 반환할 수 있는 현재 정책을 반영
  • 실패 응답이 발생하는 경우 PAYMENT_ALREADY_PROCESSED 예외인지 검증
  • 크레딧 충전과 충전 거래 내역이 한 번만 생성되는 핵심 보장 조건 유지
  • 전체 테스트 통과 확인

📸 작업 화면 스크린샷

⚠️ PR하기 전에 확인해주세요

  • 로컬테스트를 진행하셨나요?
  • 머지할 브랜치를 확인하셨나요?
  • 관련 label을 선택하셨나요?

🚨 관련 이슈 번호 [ ]

Summary by CodeRabbit

  • Bug Fixes

    • Improved job posting creation flow so failed follow-up actions are cleaned up automatically, helping prevent incomplete postings from remaining in the system.
    • Strengthened payment confirmation handling so concurrent payment attempts consistently report that the payment was already processed.
  • Tests

    • Expanded automated coverage for job posting ingestion and payment confirmation edge cases.

- 동일 결제 승인 동시 요청 테스트의 비결정적인 성공/실패 개수 검증 제거
- 이미 완료된 동일 paymentKey 요청이 기존 결과를 반환할 수 있는 현재 정책을 반영
- 실패 응답이 발생하는 경우 PAYMENT_ALREADY_PROCESSED 예외인지 검증
- 크레딧 충전과 충전 거래 내역이 한 번만 생성되는 핵심 보장 조건 유지
- 전체 테스트 통과 확인
@whc9999 whc9999 self-assigned this Jun 28, 2026
@whc9999 whc9999 added ✨ feat New feature or request 🐛 fix labels Jun 28, 2026
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

JobPostingExtensionIngestService adds a JobPostingService dependency and wraps mock-apply creation in a try/catch that deletes the ingested job posting on RuntimeException. Two new tests cover the null-saved and exception-compensation cases. PaymentServiceTest relaxes concurrency assertions to allow any number of concurrent failures, requiring each to be PAYMENT_ALREADY_PROCESSED.

Changes

Ingest Compensation on Mock-Apply Failure

Layer / File(s) Summary
Compensation logic in ingest service
src/main/java/.../jobposting/service/JobPostingExtensionIngestService.java
Adds JobPostingService field and replaces unconditional mock-apply call with try/catch that calls deleteJobPosting on RuntimeException before rethrowing.
Tests for null-saved and exception-compensation cases
src/test/java/.../jobposting/service/JobPostingExtensionIngestServiceTest.java
Adds JobPostingService mock, assertThatThrownBy import, and two new tests: null saved posting skips mock-apply; RuntimeException triggers compensation delete.

Payment Concurrency Test Hardening

Layer / File(s) Summary
Broader concurrency failure assertions
src/test/java/.../payment/service/PaymentServiceTest.java
Replaces exact success/failure count checks with at-least-one-success and all-failures-must-be-GeneralException(PAYMENT_ALREADY_PROCESSED) assertions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • JobDri-Developer/BackEnd#107: Introduces the extension ingest flow that calls createMockApplyFromJobPosting, which is the exact code path this PR adds compensation for.

Poem

🐇 Hoppin' through the ingest lane,
If mock-apply breaks the chain,
We delete and clean up right,
No orphaned posts left in the night.
The rabbit tests what could go wrong ~

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title matches the core change: stabilizing concurrent payment approval tests.
Description check ✅ Passed Description follows the template and covers purpose, details, and checklist items.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/payment-concurrency-test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/main/java/com/jobdri/jobdri_api/domain/jobposting/service/JobPostingExtensionIngestService.java (1)

32-34: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Preserve the original failure if compensation also throws.

If deleteJobPosting(...) fails here, it replaces the original createMockApplyFromJobPosting(...) exception, so the caller loses the actual root cause.

Suggested change
             try {
                 mockApply = mockApplyService.createMockApplyFromJobPosting(user, jobPostingId);
             } catch (RuntimeException e) {
-                jobPostingService.deleteJobPosting(user, jobPostingId);
+                try {
+                    jobPostingService.deleteJobPosting(user, jobPostingId);
+                } catch (RuntimeException compensationFailure) {
+                    e.addSuppressed(compensationFailure);
+                }
                 throw e;
             }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/jobdri/jobdri_api/domain/jobposting/service/JobPostingExtensionIngestService.java`
around lines 32 - 34, The catch block in JobPostingExtensionIngestService
currently lets deleteJobPosting(...) overwrite the original
createMockApplyFromJobPosting(...) failure if compensation also throws. Update
the RuntimeException handler in that flow to preserve the original exception as
the primary cause, and treat any deleteJobPosting failure as secondary so the
caller still receives the root cause; use the JobPostingExtensionIngestService
method and jobPostingService.deleteJobPosting as the key points to adjust.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@src/main/java/com/jobdri/jobdri_api/domain/jobposting/service/JobPostingExtensionIngestService.java`:
- Around line 32-34: The catch block in JobPostingExtensionIngestService
currently lets deleteJobPosting(...) overwrite the original
createMockApplyFromJobPosting(...) failure if compensation also throws. Update
the RuntimeException handler in that flow to preserve the original exception as
the primary cause, and treat any deleteJobPosting failure as secondary so the
caller still receives the root cause; use the JobPostingExtensionIngestService
method and jobPostingService.deleteJobPosting as the key points to adjust.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 87358fbc-c75d-4af6-811b-b35021659ec9

📥 Commits

Reviewing files that changed from the base of the PR and between 154ada5 and 52c5add.

📒 Files selected for processing (3)
  • src/main/java/com/jobdri/jobdri_api/domain/jobposting/service/JobPostingExtensionIngestService.java
  • src/test/java/com/jobdri/jobdri_api/domain/jobposting/service/JobPostingExtensionIngestServiceTest.java
  • src/test/java/com/jobdri/jobdri_api/domain/payment/service/PaymentServiceTest.java

@whc9999 whc9999 merged commit 82510d1 into main Jun 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ feat New feature or request 🐛 fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant