Skip to content

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 reservedTypeprizeType khác nhau. task-1-1 phải hoàn thành để dùng RoomReasonCode.* trong assertions.

Test scenarios

Queue routing theo prize type

  • [ ] Prize với reservedType=STREAMING → route qua queue-prize-allocation-PRIZE_FOR_STREAMER
  • Clarification: Seed prize với reservedType=STREAMING trong 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ó reservedType field (null hoặc không set)
  • [ ] Prize prizeType=TREASURE_BOX (non-streaming) → route qua queue-prize-allocation-UNLIMITED
  • Clarification: Verify routing logic trong CreateRoomServiceTREASURE_BOX có ưu tiên routing riêng

Concurrency guard

  • [ ] Verify PRIZE queue 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.
  • [ ] UNLIMITED queue có thể process concurrent messages
  • Clarification: Verify concurrency setting 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_GAME event với reason=INVALID_PRIZE_ID
  • Clarification: Dùng RoomReasonCode.INVALID_PRIZE_ID trong assertion (sau task-1-1)
  • [ ] Tạo room khi insufficient balance → VALIDATE_GAME event với reason=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 reason code từ RoomReasonCode.* constants
  • [ ] Concurrency test cho PRIZE queue: 2 messages được xử lý tuần tự (không concurrent)
  • [ ] Concurrency config cho UNLIMITED queue 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