This commit is contained in:
2026-08-25 16:40:48 +08:00
parent 1f6f1a0677
commit 87c5e18ca6
93 changed files with 1154 additions and 527 deletions
@@ -8,12 +8,32 @@ import org.junit.jupiter.api.Test;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.mockito.Mockito.mock;
class EventBridgeMetricsTest {
@Test
void productionConstructorIsExplicitForSpringWhenTestClockConstructorAlsoExists() throws Exception {
assertThat(EventBridgeMetrics.class.getConstructor(MeterRegistry.class)
.isAnnotationPresent(Autowired.class)).isTrue();
}
@Test
void springContextCreatesMetricsBeanWithTheAnnotatedProductionConstructor() {
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) {
context.registerBean(MeterRegistry.class, SimpleMeterRegistry::new);
context.register(EventBridgeMetrics.class);
context.refresh();
assertThat(context.getBean(EventBridgeMetrics.class)).isNotNull();
}
}
@Test
void collapsesUnboundedRegionAndEventTypeLabelsToOther() {
SimpleMeterRegistry registry = new SimpleMeterRegistry();