Skip to content

Task 4-2: Integration Test - Rollback (DECREASE) per Allocation Type

Phase: 4 - Testing Priority: Medium Depends on: task-1-1, task-1-2 Reference: docs/BountyHunter-Backend/details/feature-prize-allocation/SPEC.md

Background

Test DECREASE action (rollback) cho từng allocation type để đảm bảo inventory được restore đúng.

Test scenarios

DECREASE cho PRIZE allocation

  • [ ] Create room (PRIZE type) → ghi lại prize inventory trước khi create
  • [ ] Send DECREASE message với prizeRollback tương ứng
  • [ ] Verify: prize inventory restored về giá trị trước khi create room
  • [ ] Verify: không có duplicate rollback (idempotency — cùng correlationId)

DECREASE cho UNLIMITED allocation

  • [ ] Create room (UNLIMITED type) → ghi lại user free play count trước
  • [ ] Send DECREASE
  • [ ] Verify: user free play count restored về giá trị trước

DECREASE cho MISSION allocation

  • [ ] Complete mission (partial) → ghi lại mission progress
  • [ ] Send DECREASE
  • [ ] Verify: mission progress reverted đúng

DECREASE cho GACHA allocation

  • [ ] Gacha draw → ghi lại gacha ticket count trước
  • [ ] Send DECREASE
  • [ ] Verify: gacha ticket restored

Double DECREASE (idempotency)

  • [ ] Send cùng DECREASE message 2 lần (cùng correlationId)
  • [ ] Verify: rollback chỉ xảy ra 1 lần — inventory không bị restore 2 lần (over-restore)
  • [ ] Verify log: [IDEMPOTENCY] Duplicate message lần 2

Verification / Acceptance Criteria

  • [ ] Tất cả 4 allocation types: inventory correctly restored sau DECREASE
  • [ ] No over-restore: idempotent DECREASE không thay đổi state lần 2
  • [ ] Pre/post balance được verify (not just "no error")

Files to Modify

  • Test files trong batch/src/test/ hoặc integration test module