Task 4-1: Integration Test - PRIZE Queue Processing
Phase: 4 - Testing Priority: Medium Depends on: task-1-1 Reference: docs/BountyHunter-Backend/details/feature-prize-allocation/SPEC.md
Background
Test toàn bộ hành vi của PRIZE queue listener qua các action types.
Test scenarios
CREATE_PVE_SINGLE_PLAY
- [ ] Gửi message
action=CREATE_PVE_SINGLE_PLAY, allocationType=PRIZEtớiqueue-prize-allocation-PRIZE - [ ] Verify: room được tạo trong Redis (
status=WAITING) - [ ] Verify:
ROOM_CREATEDbroadcast qua WebSocket tới đúng userId
JOIN_AUTO_MATCH_MATCHING
- [ ] Gửi message
action=JOIN_AUTO_MATCH_MATCHING - [ ] Verify:
UserMatchingService.addUserToMatchingQueue()được gọi đúng tham số (userId,settingId,prizeId)
DECREASE (rollback)
- [ ] Gửi message
action=DECREASE, prizeRollback={...}sau khi allocation đã xảy ra - [ ] Verify: inventory/allocation được restore về trạng thái trước
- [ ] Verify: không có side effects (second DECREASE với cùng correlationId không rollback 2 lần)
MINT_ALLOCATION
- [ ] Gửi
mintAllocation={nftType=HUNTER, count=5}→ 5NftHunterAllocationrecords tạo mới - [ ] Tương tự với
GAUNTLET(2 records) vàBOUNTY_BALL(5 records)
Wrong allocationType guard
- [ ] Gửi message với
allocationType=UNLIMITEDtớiqueue-prize-allocation-PRIZE→ message không được xử lý - [ ] Verify log:
[PRIZE_ALLOC] Wrong allocationType, skipping(hoặc tương đương) - [ ] Verify: không có room hoặc allocation record được tạo
Idempotency (sau task-1-1)
- [ ] Gửi cùng
correlationId2 lần → chỉ xử lý lần đầu - [ ] Lần 2 log
[IDEMPOTENCY] Duplicate message ...và return
Verification / Acceptance Criteria
- [ ]
CREATE_PVE_SINGLE_PLAY: room created, WS event sent - [ ]
JOIN_AUTO_MATCH_MATCHING: matching queue updated correctly - [ ]
DECREASE: inventory restored, idempotent - [ ]
MINT_ALLOCATION: correct record count per NFT type - [ ] Wrong allocationType: no processing, appropriate log
- [ ] Duplicate correlationId: skip with WARN log
Files to Modify
- Test files trong
batch/src/test/hoặc integration test module