feat(backend): add Sentry/GlitchTip error reporting via sentry-spring-boot-starter-jakarta #592

Merged
marcel merged 8 commits from feat/issue-580-sentry-backend into main 2026-05-15 11:08:48 +02:00
Showing only changes of commit fa191b5c05 - Show all commits

View File

@@ -0,0 +1,53 @@
package org.raddatz.familienarchiv.config;
import io.sentry.Sentry;
import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.springframework.test.util.ReflectionTestUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.times;
class SentryConfigTest {
@Test
void init_does_not_call_sentry_when_dsn_is_blank() {
SentryConfig config = new SentryConfig();
ReflectionTestUtils.setField(config, "dsn", "");
ReflectionTestUtils.setField(config, "environment", "test");
ReflectionTestUtils.setField(config, "tracesSampleRate", 1.0);
try (MockedStatic<Sentry> sentryMock = mockStatic(Sentry.class)) {
config.init();
sentryMock.verifyNoInteractions();
}
}
@Test
void init_calls_sentry_init_when_dsn_is_set() {
SentryConfig config = new SentryConfig();
ReflectionTestUtils.setField(config, "dsn", "https://key@glitchtip.example.com/1");
ReflectionTestUtils.setField(config, "environment", "test");
ReflectionTestUtils.setField(config, "tracesSampleRate", 0.5);
try (MockedStatic<Sentry> sentryMock = mockStatic(Sentry.class)) {
config.init();
sentryMock.verify(() -> Sentry.init(any(Sentry.OptionsConfiguration.class)), times(1));
}
}
@Test
void init_does_not_call_sentry_when_dsn_is_null() {
SentryConfig config = new SentryConfig();
ReflectionTestUtils.setField(config, "dsn", null);
ReflectionTestUtils.setField(config, "environment", "test");
ReflectionTestUtils.setField(config, "tracesSampleRate", 1.0);
try (MockedStatic<Sentry> sentryMock = mockStatic(Sentry.class)) {
config.init();
sentryMock.verifyNoInteractions();
}
}
}