Background
FlashSaleController is only covered today by the full-stack FlashSaleIntegrationTest. A @WebMvcTest slice test is much faster (< 1 s vs. > 30 s) and pinpoints controller-layer bugs — validation, HTTP status mapping, response body shape — without needing Redis, Kafka, or a database.
What to Test
@WebMvcTest(FlashSaleController.class)
class FlashSaleControllerTest {
@MockBean FlashSaleService flashSaleService;
@Test void buy_returns202_whenAccepted() { ... }
@Test void buy_returns410_whenSoldOut() { ... }
@Test void buy_returns429_whenRateLimited() { ... }
@Test void buy_returns409_whenConcurrentBlock() { ... }
@Test void buy_returns503_whenCircuitOpen() { ... }
@Test void buy_returns500_whenError() { ... }
@Test void buy_returns400_withBlankUserId() { ... }
@Test void buy_returns401_withoutApiKey() { ... }
@Test void responseBody_containsCorrelationId() { ... }
}
Notes
- Mock
FlashSaleService — no infrastructure needed.
ApiKeyAuthFilter must still be wired in (use the test API key from TestPropertySource).
- Assert response JSON shape using
jsonPath assertions.
- This is a good first contribution — the controller logic is straightforward and well-documented.
Acceptance Criteria
Background
FlashSaleControlleris only covered today by the full-stackFlashSaleIntegrationTest. A@WebMvcTestslice test is much faster (< 1 s vs. > 30 s) and pinpoints controller-layer bugs — validation, HTTP status mapping, response body shape — without needing Redis, Kafka, or a database.What to Test
Notes
FlashSaleService— no infrastructure needed.ApiKeyAuthFiltermust still be wired in (use the test API key fromTestPropertySource).jsonPathassertions.Acceptance Criteria