|
| 1 | +package org.sopt.makers.service; |
| 2 | + |
| 3 | +import static org.junit.jupiter.api.Assertions.*; |
| 4 | + |
| 5 | +import org.junit.jupiter.api.DisplayName; |
| 6 | +import org.junit.jupiter.api.Nested; |
| 7 | +import org.junit.jupiter.api.Test; |
| 8 | +import org.sopt.makers.dto.SentryEventDetail; |
| 9 | +import org.sopt.makers.global.config.ObjectMapperConfig; |
| 10 | +import org.sopt.makers.handler.FakeSentryPayload; |
| 11 | + |
| 12 | +import com.fasterxml.jackson.databind.ObjectMapper; |
| 13 | + |
| 14 | +@DisplayName("SentryEventExtractorService 단위 테스트") |
| 15 | +class SentryEventExtractorServiceTest { |
| 16 | + private final ObjectMapper objectMapper = ObjectMapperConfig.getInstance(); |
| 17 | + private final SentryEventExtractorService extractorService = new SentryEventExtractorService(objectMapper); |
| 18 | + |
| 19 | + @Test |
| 20 | + @DisplayName("실제 Sentry 웹훅 데이터에서 이벤트 정보를 정확히 추출하는지 테스트") |
| 21 | + void extractSentryEventFromRealPayload() { |
| 22 | + // Given |
| 23 | + String payload = FakeSentryPayload.REAL_SENTRY_WEBHOOK_PAYLOAD; |
| 24 | + |
| 25 | + // When |
| 26 | + SentryEventDetail result = extractorService.extractEvent(payload); |
| 27 | + |
| 28 | + // Then |
| 29 | + assertNotNull(result); |
| 30 | + assertEquals("0000000000", result.issueId()); |
| 31 | + assertEquals( |
| 32 | + "https://sentry.io/organizations/example-org/issues/0000000000/events/93153fe001674c70b39af22c49db350b/", |
| 33 | + result.webUrl()); |
| 34 | + assertEquals("Authentication failed, token expired!", result.message()); |
| 35 | + assertEquals("2025-05-21T08:52:45.182000Z", result.datetime()); |
| 36 | + assertEquals("error", result.level()); |
| 37 | + assertEquals("ApiException: Authentication failed, token expired!", result.title()); |
| 38 | + } |
| 39 | +} |
| 40 | + |
0 commit comments