Task 4-2: Integration Test - PVE Single Play & Queue Routing
Phase: 4 - Testing Priority: Medium Depends on: task-1-1 Reference:
docs/BountyHunter-Backend/details/feature-game-room-management/SPEC.md
Background
PVE Single Play cần test routing đúng queue theo prize type/reservedType.
Setup Note: Cần mock hoặc seed prize data trong database test để có prizes với các
reservedTypevàprizeTypekhác nhau.task-1-1phải hoàn thành để dùngRoomReasonCode.*trong assertions.
Test scenarios
Queue routing theo prize type
- [ ] Prize với
reservedType=STREAMING→ route quaqueue-prize-allocation-PRIZE_FOR_STREAMER - Clarification: Seed prize với
reservedType=STREAMINGtrong test DB, tạo room với prizeId đó, verify message đến đúng queue - [ ] Prize thông thường (no reservedType) → route qua
queue-prize-allocation-PRIZE - Clarification: Prize không có
reservedTypefield (null hoặc không set) - [ ] Prize
prizeType=TREASURE_BOX(non-streaming) → route quaqueue-prize-allocation-UNLIMITED - Clarification: Verify routing logic trong
CreateRoomService—TREASURE_BOXcó ưu tiên routing riêng
Concurrency guard
- [ ] Verify
PRIZEqueue cóconcurrency=1-1(không process 2 messages parallel) - Clarification: Gửi 2 messages tới queue đồng thời, verify chúng được xử lý tuần tự (không overlap). Có thể verify qua log timestamps hoặc mock processing time.
- [ ]
UNLIMITEDqueue có thể process concurrent messages - Clarification: Verify
concurrencysetting trong JMS listener config cho queue này cho phép > 1
Validation
- [ ] Tạo room với prizeId không tồn tại →
VALIDATE_GAMEevent vớireason=INVALID_PRIZE_ID - Clarification: Dùng
RoomReasonCode.INVALID_PRIZE_IDtrong assertion (sau task-1-1) - [ ] Tạo room khi insufficient balance →
VALIDATE_GAMEevent vớireason=INSUFFICIENT_BALANCE - Clarification: Mock user balance service để return insufficient balance, hoặc seed user với balance < required amount
Verification / Acceptance Criteria
- [ ] Tất cả 3 queue routing scenarios pass: PRIZE_FOR_STREAMER, PRIZE, UNLIMITED routing đúng
- [ ] Validation tests verify đúng
reasoncode từRoomReasonCode.*constants - [ ] Concurrency test cho
PRIZEqueue: 2 messages được xử lý tuần tự (không concurrent) - [ ] Concurrency config cho
UNLIMITEDqueue cho phép > 1 concurrent consumer (verify config, không cần stress test) - [ ] Tests không phụ thuộc vào thứ tự chạy (isolated)
- [ ] Queue routing assertions verify đúng queue name string (không typo)
- [ ] Tests pass khi chạy với embedded JMS broker