From f98c3f9ea40de55b6e188b6c92f56466560d0ccd Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Mon, 26 Jan 2026 12:59:25 +0100 Subject: [PATCH 1/4] create issue for code quality Signed-off-by: Gregor Zeitlinger --- .github/super-linter.env | 2 +- CODE_QUALITY_IMPROVEMENTS.md | 86 ------------------------------------ 2 files changed, 1 insertion(+), 87 deletions(-) delete mode 100644 CODE_QUALITY_IMPROVEMENTS.md diff --git a/.github/super-linter.env b/.github/super-linter.env index 1ebf97898..566f1bfb3 100644 --- a/.github/super-linter.env +++ b/.github/super-linter.env @@ -1,4 +1,4 @@ -FILTER_REGEX_EXCLUDE=mvnw|src/main/generated/.*|docs/themes/.*|keystore.pkcs12|.*.java|prometheus-metrics-exporter-opentelemetry-shaded/pom.xml|CODE_OF_CONDUCT.md|CLAUDE.md|CODE_QUALITY_IMPROVEMENTS.md +FILTER_REGEX_EXCLUDE=mvnw|src/main/generated/.*|docs/themes/.*|keystore.pkcs12|.*.java|prometheus-metrics-exporter-opentelemetry-shaded/pom.xml|CODE_OF_CONDUCT.md|CLAUDE.md IGNORE_GITIGNORED_FILES=true JAVA_FILE_NAME=google_checks.xml LOG_LEVEL=ERROR diff --git a/CODE_QUALITY_IMPROVEMENTS.md b/CODE_QUALITY_IMPROVEMENTS.md deleted file mode 100644 index 28984b36b..000000000 --- a/CODE_QUALITY_IMPROVEMENTS.md +++ /dev/null @@ -1,86 +0,0 @@ -# Code Quality Improvement Plan - -This document tracks code quality improvements for the Prometheus Java Client library. Work through these items incrementally across sessions. - -## High Priority - -### 1. Add Missing Test Coverage for Exporter Modules -- [x] `prometheus-metrics-exporter-common` - base module, no tests -- [x] `prometheus-metrics-exporter-servlet-jakarta` - no tests -- [x] `prometheus-metrics-exporter-servlet-javax` - no tests -- [x] `prometheus-metrics-exporter-opentelemetry-otel-agent-resources` - no tests - -### 2. Eliminate Dropwizard Module Duplication -- [x] Create shared base class or use generics for `prometheus-metrics-instrumentation-dropwizard` and `prometheus-metrics-instrumentation-dropwizard5` (~297 lines each, nearly identical) - -### 3. Address Technical Debt (TODOs) -- [ ] `prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/metrics/Histogram.java:965` - "reset interval isn't tested yet" -- [ ] `prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/metrics/Summary.java:205` - "Exemplars (are hard-coded as empty)" -- [ ] `prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/metrics/SlidingWindow.java:18` - "synchronized implementation, room for optimization" -- [ ] `prometheus-metrics-config/src/main/java/io/prometheus/metrics/config/PrometheusPropertiesLoader.java:105` - "Add environment variables like EXEMPLARS_ENABLED" -- [ ] `prometheus-metrics-exporter-opentelemetry/src/main/java/io/prometheus/metrics/exporter/opentelemetry/PrometheusMetricProducer.java:44` - "filter configuration for OpenTelemetry exporter" -- [ ] `prometheus-metrics-config/src/main/java/io/prometheus/metrics/config/ExporterOpenTelemetryProperties.java:7` - "JavaDoc missing" - -### 4. Improve Exception Handling -Replace broad `catch (Exception e)` with specific exception types: -- [ ] `prometheus-metrics-instrumentation-dropwizard5/src/main/java/.../DropwizardExports.java:237` -- [ ] `prometheus-metrics-instrumentation-caffeine/src/main/java/.../CacheMetricsCollector.java:229` -- [ ] `prometheus-metrics-exporter-opentelemetry/src/main/java/.../PrometheusInstrumentationScope.java:47` -- [ ] `prometheus-metrics-exporter-opentelemetry/src/main/java/.../OtelAutoConfig.java:115` -- [ ] `prometheus-metrics-instrumentation-jvm/src/main/java/.../JvmNativeMemoryMetrics.java:166` -- [ ] `prometheus-metrics-exporter-httpserver/src/main/java/.../HttpExchangeAdapter.java:115` - -## Medium Priority - -### 5. Add Branch Coverage to JaCoCo -- [ ] Update `pom.xml` to add branch coverage requirement (~50% minimum) -```xml - - BRANCH - COVEREDRATIO - 0.50 - -``` - -### 6. Raise Minimum Coverage Thresholds -Current thresholds to review: -- [ ] `prometheus-metrics-exporter-httpserver` - 45% (raise to 60%) -- [ ] `prometheus-metrics-instrumentation-dropwizard5` - 50% (raise to 60%) -- [ ] `prometheus-metrics-exposition-textformats` - 50% (raise to 60%) -- [ ] `prometheus-metrics-instrumentation-jvm` - 55% (raise to 60%) - -### 7. Add SpotBugs -- [ ] Add `spotbugs-maven-plugin` to `pom.xml` -- [ ] Configure with appropriate rule set - -### 8. Narrow Checkstyle Suppressions -- [ ] Review `checkstyle-suppressions.xml` - currently suppresses ALL Javadoc checks globally -- [ ] Narrow to specific packages/classes that need exceptions - -## Lower Priority - -### 9. Refactor Large Classes -- [ ] `prometheus-metrics-core/src/main/java/.../Histogram.java` (978 lines) - consider extracting native histogram logic - -### 10. Document Configuration Classes -- [ ] `PrometheusPropertiesLoader` - add JavaDoc -- [ ] `ExporterProperties` and related classes - add JavaDoc -- [ ] `ExporterOpenTelemetryProperties` - add JavaDoc (noted in TODO) - -### 11. Consolidate Servlet Exporter Duplication -- [ ] Extract common logic from `servlet-jakarta` and `servlet-javax` into `exporter-common` - -### 12. Add Mutation Testing -- [ ] Add Pitest (`pitest-maven`) for critical modules -- [ ] Start with `prometheus-metrics-core` and `prometheus-metrics-model` - ---- - -## Progress Notes - -_Add notes here as items are completed:_ - -| Date | Item | Notes | -|------|------|-------| -| 2026-01-24 | Missing Test Coverage for Exporter Modules | Added 55 tests across 4 modules: exporter-common (22 tests), servlet-jakarta (14 tests), servlet-javax (14 tests), otel-agent-resources (5 tests). All tests passing. | -| 2026-01-24 | Eliminate Dropwizard Module Duplication | Created AbstractDropwizardExports base class (267 lines) with generic type parameters. Reduced dropwizard module from 297 to 209 lines (-88 lines, -30%), dropwizard5 module from 297 to 212 lines (-85 lines, -29%). All tests passing (32 tests dropwizard5, 13 tests dropwizard). | From 605788b4ebcedd03af482f1aa091be7097149423 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Mon, 26 Jan 2026 13:18:29 +0100 Subject: [PATCH 2/4] make tests package protected Signed-off-by: Gregor Zeitlinger --- CLAUDE.md | 1 + .../client/it/common/ExporterTest.java | 2 +- .../client/it/common/LogConsumer.java | 2 +- .../prometheus/client/it/common/Volume.java | 2 +- .../metrics/it/exporter/test/ExporterIT.java | 28 +++---- .../metrics/it/noprotobuf/NoProtobufIT.java | 2 +- .../metrics/it/pushgateway/PushGatewayIT.java | 16 ++-- .../it/springboot/ApplicationTest.java | 2 +- .../PrometheusPropertiesLoaderTest.java | 4 +- .../config/PrometheusPropertiesTest.java | 6 +- .../ExemplarSamplerConfigTestUtil.java | 2 +- .../core/exemplars/ExemplarSamplerTest.java | 18 ++--- .../exemplars/SpanContextSupplierTest.java | 8 +- .../core/metrics/CKMSQuantilesTest.java | 32 ++++---- .../metrics/core/metrics/CounterTest.java | 28 +++---- .../core/metrics/CounterWithCallbackTest.java | 4 +- .../metrics/core/metrics/GaugeTest.java | 20 ++--- .../core/metrics/GaugeWithCallbackTest.java | 4 +- .../metrics/core/metrics/HistogramTest.java | 58 +++++++-------- .../metrics/core/metrics/InfoTest.java | 10 +-- .../core/metrics/SlidingWindowTest.java | 6 +- .../metrics/core/metrics/StateSetTest.java | 6 +- .../core/metrics/StatefulMetricTest.java | 8 +- .../metrics/core/metrics/SummaryTest.java | 22 +++--- .../core/metrics/SummaryWithCallbackTest.java | 4 +- .../common/PrometheusHttpRequestTest.java | 22 +++--- .../common/PrometheusScrapeHandlerTest.java | 24 +++--- .../exporter/httpserver/HTTPServerTest.java | 2 +- .../ResourceAttributesFromOtelAgentTest.java | 10 +-- .../exporter/opentelemetry/ExemplarTest.java | 4 +- .../exporter/opentelemetry/ExportTest.java | 2 +- .../pushgateway/BasicAuthPushGatewayTest.java | 4 +- .../BearerTokenPushGatewayTest.java | 4 +- .../exporter/pushgateway/PushGatewayTest.java | 54 +++++++------- .../jakarta/HttpExchangeAdapterTest.java | 22 +++--- .../jakarta/PrometheusMetricsServletTest.java | 8 +- .../javax/HttpExchangeAdapterTest.java | 22 +++--- .../javax/PrometheusMetricsServletTest.java | 8 +- .../ExpositionFormatsTest.java | 74 +++++++++---------- .../caffeine/CacheMetricsCollectorTest.java | 4 +- .../dropwizard/DropwizardExportsTest.java | 22 +++--- .../dropwizard5/DropwizardExportsTest.java | 18 ++--- .../labels/CustomLabelMapperTest.java | 16 ++-- .../labels/GraphiteNamePatternTest.java | 16 ++-- .../dropwizard5/labels/MapperConfigTest.java | 12 +-- .../guava/CacheMetricsCollectorTest.java | 8 +- .../jvm/JvmBufferPoolMetricsTest.java | 6 +- .../jvm/JvmClassLoadingMetricsTest.java | 6 +- .../jvm/JvmCompilationMetricsTest.java | 6 +- .../jvm/JvmGarbageCollectorMetricsTest.java | 6 +- .../jvm/JvmMemoryMetricsTest.java | 6 +- .../JvmMemoryPoolAllocationMetricsTest.java | 2 +- .../instrumentation/jvm/JvmMetricsTest.java | 2 +- .../jvm/JvmNativeMemoryMetricsTest.java | 8 +- .../jvm/JvmRuntimeInfoMetricTest.java | 2 +- .../jvm/JvmThreadsMetricsTest.java | 8 +- .../jvm/ProcessMetricsTest.java | 8 +- .../model/registry/MetricNameFilterTest.java | 2 +- .../MultiCollectorNameFilterTest.java | 8 +- .../registry/PrometheusRegistryTest.java | 12 +-- .../ClassicHistogramBucketsTest.java | 22 +++--- .../model/snapshots/CounterSnapshotTest.java | 12 +-- .../metrics/model/snapshots/ExemplarTest.java | 14 ++-- .../model/snapshots/ExemplarsTest.java | 6 +- .../model/snapshots/GaugeSnapshotTest.java | 14 ++-- .../snapshots/HistogramSnapshotTest.java | 22 +++--- .../model/snapshots/InfoSnapshotTest.java | 10 +-- .../metrics/model/snapshots/LabelsTest.java | 24 +++--- .../model/snapshots/MetricMetadataTest.java | 20 ++--- .../model/snapshots/MetricSnapshotTest.java | 6 +- .../model/snapshots/MetricSnapshotsTest.java | 10 +-- .../snapshots/NativeHistogramBucketsTest.java | 10 +-- .../model/snapshots/PrometheusNamingTest.java | 18 ++--- .../model/snapshots/QuantilesTest.java | 8 +- .../model/snapshots/SnapshotEscaperTest.java | 10 +-- .../model/snapshots/StateSetSnapshotTest.java | 20 ++--- .../model/snapshots/SummarySnapshotTest.java | 8 +- .../metrics/model/snapshots/UnitTest.java | 10 +-- .../model/snapshots/UnknownSnapshotTest.java | 12 +-- .../bridge/SimpleclientCollectorTest.java | 26 +++---- 80 files changed, 508 insertions(+), 507 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index ba985e587..492b11dc0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -88,6 +88,7 @@ Pre-built instrumentations: `prometheus-metrics-instrumentation-jvm`, `-caffeine - JUnit 5 (Jupiter) with `@Test` annotations - AssertJ for fluent assertions - Mockito for mocking +- **Test visibility**: Test classes and test methods must be package-protected (no `public` modifier) - Integration tests are in `integration-tests/` and run during `verify` phase - Acceptance tests use OATs framework: `mise run acceptance-test` diff --git a/integration-tests/it-common/src/test/java/io/prometheus/client/it/common/ExporterTest.java b/integration-tests/it-common/src/test/java/io/prometheus/client/it/common/ExporterTest.java index 605e760f4..c397351ab 100644 --- a/integration-tests/it-common/src/test/java/io/prometheus/client/it/common/ExporterTest.java +++ b/integration-tests/it-common/src/test/java/io/prometheus/client/it/common/ExporterTest.java @@ -53,7 +53,7 @@ protected void start(String outcome) { } @AfterEach - public void tearDown() throws IOException { + void tearDown() throws IOException { sampleAppContainer.stop(); sampleAppVolume.remove(); } diff --git a/integration-tests/it-common/src/test/java/io/prometheus/client/it/common/LogConsumer.java b/integration-tests/it-common/src/test/java/io/prometheus/client/it/common/LogConsumer.java index a57c5a7f3..a7861bd24 100644 --- a/integration-tests/it-common/src/test/java/io/prometheus/client/it/common/LogConsumer.java +++ b/integration-tests/it-common/src/test/java/io/prometheus/client/it/common/LogConsumer.java @@ -4,7 +4,7 @@ import org.testcontainers.containers.output.OutputFrame; /** Print Docker logs from TestContainers to stdout or stderr. */ -public class LogConsumer implements Consumer { +class LogConsumer implements Consumer { private final String prefix; diff --git a/integration-tests/it-common/src/test/java/io/prometheus/client/it/common/Volume.java b/integration-tests/it-common/src/test/java/io/prometheus/client/it/common/Volume.java index af5b0918e..d9436940a 100644 --- a/integration-tests/it-common/src/test/java/io/prometheus/client/it/common/Volume.java +++ b/integration-tests/it-common/src/test/java/io/prometheus/client/it/common/Volume.java @@ -12,7 +12,7 @@ import java.util.function.Predicate; /** Temporary directory in ./target/ to be mounted as a volume in Docker containers. */ -public class Volume { +class Volume { private final Path tmpDir; // will be created in the ./target/ directory diff --git a/integration-tests/it-exporter/it-exporter-test/src/test/java/io/prometheus/metrics/it/exporter/test/ExporterIT.java b/integration-tests/it-exporter/it-exporter-test/src/test/java/io/prometheus/metrics/it/exporter/test/ExporterIT.java index cf876b3fd..a257ad98a 100644 --- a/integration-tests/it-exporter/it-exporter-test/src/test/java/io/prometheus/metrics/it/exporter/test/ExporterIT.java +++ b/integration-tests/it-exporter/it-exporter-test/src/test/java/io/prometheus/metrics/it/exporter/test/ExporterIT.java @@ -22,7 +22,7 @@ public ExporterIT(String sampleApp) throws IOException, URISyntaxException { } @Test - public void testOpenMetricsTextFormat() throws IOException { + void testOpenMetricsTextFormat() throws IOException { start(); Response response = scrape("GET", "", "Accept", "application/openmetrics-text; version=1.0.0; charset=utf-8"); @@ -44,7 +44,7 @@ public void testOpenMetricsTextFormat() throws IOException { } @Test - public void testPrometheusTextFormat() throws IOException { + void testPrometheusTextFormat() throws IOException { start(); Response response = scrape("GET", ""); assertThat(response.status).isEqualTo(200); @@ -64,7 +64,7 @@ public void testPrometheusTextFormat() throws IOException { } @Test - public void testPrometheusProtobufFormat() throws IOException { + void testPrometheusProtobufFormat() throws IOException { start(); Response response = scrape( @@ -121,7 +121,7 @@ public void testPrometheusProtobufDebugFormat(String format, String expected) th } @Test - public void testCompression() throws IOException { + void testCompression() throws IOException { start(); Response response = scrape( @@ -149,7 +149,7 @@ public void testCompression() throws IOException { } @Test - public void testErrorHandling() throws IOException { + void testErrorHandling() throws IOException { start("error"); Response response = scrape("GET", ""); assertThat(response.status).isEqualTo(500); @@ -157,7 +157,7 @@ public void testErrorHandling() throws IOException { } @Test - public void testHeadRequest() throws IOException { + void testHeadRequest() throws IOException { start(); Response fullResponse = scrape("GET", ""); int size = fullResponse.body.length; @@ -169,7 +169,7 @@ public void testHeadRequest() throws IOException { } @Test - public void testDebug() throws IOException { + void testDebug() throws IOException { start(); Response response = scrape("GET", "debug=openmetrics"); assertThat(response.status).isEqualTo(200); @@ -180,7 +180,7 @@ public void testDebug() throws IOException { } @Test - public void testNameFilter() throws IOException { + void testNameFilter() throws IOException { start(); Response response = scrape( @@ -199,7 +199,7 @@ public void testNameFilter() throws IOException { } @Test - public void testEmptyResponseOpenMetrics() throws IOException { + void testEmptyResponseOpenMetrics() throws IOException { start(); Response response = scrape( @@ -217,7 +217,7 @@ public void testEmptyResponseOpenMetrics() throws IOException { } @Test - public void testEmptyResponseText() throws IOException { + void testEmptyResponseText() throws IOException { start(); Response response = scrape("GET", nameParam("none_existing")); assertThat(response.status).isEqualTo(200); @@ -231,7 +231,7 @@ public void testEmptyResponseText() throws IOException { } @Test - public void testEmptyResponseProtobuf() throws IOException { + void testEmptyResponseProtobuf() throws IOException { start(); Response response = scrape( @@ -249,7 +249,7 @@ public void testEmptyResponseProtobuf() throws IOException { } @Test - public void testEmptyResponseGzipOpenMetrics() throws IOException { + void testEmptyResponseGzipOpenMetrics() throws IOException { start(); Response response = scrape( @@ -265,7 +265,7 @@ public void testEmptyResponseGzipOpenMetrics() throws IOException { } @Test - public void testEmptyResponseGzipText() throws IOException { + void testEmptyResponseGzipText() throws IOException { start(); Response response = scrape("GET", nameParam("none_existing"), "Accept-Encoding", "gzip"); assertThat(response.status).isEqualTo(200); @@ -278,7 +278,7 @@ private String nameParam(String name) { } @Test - public void testDebugUnknown() throws IOException { + void testDebugUnknown() throws IOException { start(); Response response = scrape("GET", "debug=unknown"); assertThat(response.status).isEqualTo(500); diff --git a/integration-tests/it-exporter/it-no-protobuf-test/src/test/java/io/prometheus/metrics/it/noprotobuf/NoProtobufIT.java b/integration-tests/it-exporter/it-no-protobuf-test/src/test/java/io/prometheus/metrics/it/noprotobuf/NoProtobufIT.java index cd534dcb9..9b041795e 100644 --- a/integration-tests/it-exporter/it-no-protobuf-test/src/test/java/io/prometheus/metrics/it/noprotobuf/NoProtobufIT.java +++ b/integration-tests/it-exporter/it-no-protobuf-test/src/test/java/io/prometheus/metrics/it/noprotobuf/NoProtobufIT.java @@ -14,7 +14,7 @@ public NoProtobufIT() throws IOException, URISyntaxException { } @Test - public void testPrometheusProtobufDebugFormat() throws IOException { + void testPrometheusProtobufDebugFormat() throws IOException { start(); assertThat(scrape("GET", "debug=text").status).isEqualTo(200); // protobuf is not supported diff --git a/integration-tests/it-pushgateway/src/test/java/io/prometheus/metrics/it/pushgateway/PushGatewayIT.java b/integration-tests/it-pushgateway/src/test/java/io/prometheus/metrics/it/pushgateway/PushGatewayIT.java index 29a8fad72..26c48a977 100644 --- a/integration-tests/it-pushgateway/src/test/java/io/prometheus/metrics/it/pushgateway/PushGatewayIT.java +++ b/integration-tests/it-pushgateway/src/test/java/io/prometheus/metrics/it/pushgateway/PushGatewayIT.java @@ -22,7 +22,7 @@ import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.utility.MountableFile; -public class PushGatewayIT { +class PushGatewayIT { private GenericContainer sampleAppContainer; private GenericContainer pushGatewayContainer; @@ -30,7 +30,7 @@ public class PushGatewayIT { private Volume sampleAppVolume; @BeforeEach - public void setUp() throws IOException, URISyntaxException { + void setUp() throws IOException, URISyntaxException { Network network = Network.newNetwork(); sampleAppVolume = Volume.create("it-pushgateway").copy("pushgateway-test-app.jar"); pushGatewayContainer = @@ -56,7 +56,7 @@ public void setUp() throws IOException, URISyntaxException { } @AfterEach - public void tearDown() throws IOException { + void tearDown() throws IOException { prometheusContainer.stop(); pushGatewayContainer.stop(); sampleAppContainer.stop(); @@ -66,7 +66,7 @@ public void tearDown() throws IOException { final OkHttpClient client = new OkHttpClient(); @Test - public void testSimple() throws IOException, InterruptedException { + void testSimple() throws IOException, InterruptedException { pushGatewayContainer.start(); sampleAppContainer .withCommand( @@ -86,7 +86,7 @@ public void testSimple() throws IOException, InterruptedException { } @Test - public void testTextFormat() throws IOException, InterruptedException { + void testTextFormat() throws IOException, InterruptedException { pushGatewayContainer.start(); sampleAppContainer .withCommand( @@ -106,7 +106,7 @@ public void testTextFormat() throws IOException, InterruptedException { } @Test - public void testBasicAuth() throws IOException, InterruptedException { + void testBasicAuth() throws IOException, InterruptedException { pushGatewayContainer .withCopyFileToContainer( MountableFile.forClasspathResource("/pushgateway-basicauth.yaml"), @@ -131,7 +131,7 @@ public void testBasicAuth() throws IOException, InterruptedException { } @Test - public void testSsl() throws InterruptedException, IOException { + void testSsl() throws InterruptedException, IOException { pushGatewayContainer .withCopyFileToContainer( MountableFile.forClasspathResource("/pushgateway-ssl.yaml"), @@ -156,7 +156,7 @@ public void testSsl() throws InterruptedException, IOException { } @Test - public void testProtobuf() throws IOException, InterruptedException { + void testProtobuf() throws IOException, InterruptedException { pushGatewayContainer.start(); sampleAppContainer .withCommand( diff --git a/integration-tests/it-spring-boot-smoke-test/src/test/java/io/prometheus/metrics/it/springboot/ApplicationTest.java b/integration-tests/it-spring-boot-smoke-test/src/test/java/io/prometheus/metrics/it/springboot/ApplicationTest.java index 94617dc25..69bc81608 100644 --- a/integration-tests/it-spring-boot-smoke-test/src/test/java/io/prometheus/metrics/it/springboot/ApplicationTest.java +++ b/integration-tests/it-spring-boot-smoke-test/src/test/java/io/prometheus/metrics/it/springboot/ApplicationTest.java @@ -14,7 +14,7 @@ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) class ApplicationTest { @Test - public void testPrometheusProtobufFormat() throws IOException { + void testPrometheusProtobufFormat() throws IOException { ExporterTest.Response response = ExporterTest.scrape( "GET", diff --git a/prometheus-metrics-config/src/test/java/io/prometheus/metrics/config/PrometheusPropertiesLoaderTest.java b/prometheus-metrics-config/src/test/java/io/prometheus/metrics/config/PrometheusPropertiesLoaderTest.java index cf4933acf..c4eebb551 100644 --- a/prometheus-metrics-config/src/test/java/io/prometheus/metrics/config/PrometheusPropertiesLoaderTest.java +++ b/prometheus-metrics-config/src/test/java/io/prometheus/metrics/config/PrometheusPropertiesLoaderTest.java @@ -11,7 +11,7 @@ class PrometheusPropertiesLoaderTest { @Test - public void propertiesShouldBeLoadedFromPropertiesFile() { + void propertiesShouldBeLoadedFromPropertiesFile() { PrometheusProperties prometheusProperties = PrometheusPropertiesLoader.load(); assertThat(prometheusProperties.getDefaultMetricProperties().getHistogramClassicUpperBounds()) .hasSize(11); @@ -38,7 +38,7 @@ void cantLoadPropertiesFile() { } @Test - public void externalPropertiesShouldOverridePropertiesFile() { + void externalPropertiesShouldOverridePropertiesFile() { Properties properties = new Properties(); properties.setProperty("io.prometheus.metrics.histogramClassicUpperBounds", ".005, .01"); properties.setProperty( diff --git a/prometheus-metrics-config/src/test/java/io/prometheus/metrics/config/PrometheusPropertiesTest.java b/prometheus-metrics-config/src/test/java/io/prometheus/metrics/config/PrometheusPropertiesTest.java index d0205b28e..42e21c7d9 100644 --- a/prometheus-metrics-config/src/test/java/io/prometheus/metrics/config/PrometheusPropertiesTest.java +++ b/prometheus-metrics-config/src/test/java/io/prometheus/metrics/config/PrometheusPropertiesTest.java @@ -12,7 +12,7 @@ class PrometheusPropertiesTest { @Test - public void testPrometheusConfig() { + void testPrometheusConfig() { PrometheusProperties result = PrometheusProperties.get(); assertThat(result.getDefaultMetricProperties().getHistogramClassicUpperBounds()).hasSize(11); assertThat(result.getMetricProperties("http_duration_seconds").getHistogramClassicUpperBounds()) @@ -20,7 +20,7 @@ public void testPrometheusConfig() { } @Test - public void testEmptyUpperBounds() throws IOException { + void testEmptyUpperBounds() throws IOException { Properties properties = new Properties(); try (InputStream stream = Thread.currentThread() @@ -34,7 +34,7 @@ public void testEmptyUpperBounds() throws IOException { } @Test - public void testBuilder() { + void testBuilder() { PrometheusProperties defaults = PrometheusPropertiesLoader.load(new HashMap<>()); PrometheusProperties.Builder builder = PrometheusProperties.builder(); builder.defaultMetricsProperties(defaults.getDefaultMetricProperties()); diff --git a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/exemplars/ExemplarSamplerConfigTestUtil.java b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/exemplars/ExemplarSamplerConfigTestUtil.java index e22e9d6c6..cbb8fb8de 100644 --- a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/exemplars/ExemplarSamplerConfigTestUtil.java +++ b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/exemplars/ExemplarSamplerConfigTestUtil.java @@ -2,7 +2,7 @@ import java.lang.reflect.Field; -public class ExemplarSamplerConfigTestUtil { +class ExemplarSamplerConfigTestUtil { private static ExemplarSamplerConfig getConfig(Object metric, String fieldName) throws NoSuchFieldException, IllegalAccessException { diff --git a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/exemplars/ExemplarSamplerTest.java b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/exemplars/ExemplarSamplerTest.java index 059929c22..8ba1370da 100644 --- a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/exemplars/ExemplarSamplerTest.java +++ b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/exemplars/ExemplarSamplerTest.java @@ -52,24 +52,24 @@ public void markCurrentSpanAsExemplar() {} } @Test - public void testCustomExemplarsBuckets() throws Exception { + void testCustomExemplarsBuckets() throws Exception { // TODO } private io.prometheus.metrics.tracer.common.SpanContext origContext; @BeforeEach - public void setUp() { + void setUp() { origContext = SpanContextSupplier.getSpanContext(); } @AfterEach - public void tearDown() { + void tearDown() { SpanContextSupplier.setSpanContext(origContext); } @Test - public void testIsSampled() throws Exception { + void testIsSampled() throws Exception { SpanContext context = new SpanContext(); context.isSampled = false; ExemplarSampler sampler = new ExemplarSampler(makeConfig(), context); @@ -79,7 +79,7 @@ public void testIsSampled() throws Exception { } @Test - public void testDefaultConfigHasFourExemplars() throws Exception { + void testDefaultConfigHasFourExemplars() throws Exception { ExemplarSampler sampler = new ExemplarSampler(makeConfig(), new SpanContext()); Thread.sleep(tick); // t = 1 tick sampler.observe(0.3); @@ -96,7 +96,7 @@ public void testDefaultConfigHasFourExemplars() throws Exception { } @Test - public void testEmptyBuckets() throws Exception { + void testEmptyBuckets() throws Exception { ExemplarSampler sampler = new ExemplarSampler(makeConfig(Double.POSITIVE_INFINITY), new SpanContext()); Thread.sleep(tick); // t = 1 tick @@ -108,7 +108,7 @@ public void testEmptyBuckets() throws Exception { } @Test - public void testDefaultExemplarsBuckets() throws Exception { + void testDefaultExemplarsBuckets() throws Exception { ExemplarSampler sampler = new ExemplarSampler( makeConfig(0.2, 0.4, 0.6, 0.8, 1.0, Double.POSITIVE_INFINITY), new SpanContext()); @@ -136,12 +136,12 @@ public void testDefaultExemplarsBuckets() throws Exception { } @Test - public void testCustomExemplarsNoBuckets() throws Exception { + void testCustomExemplarsNoBuckets() throws Exception { // TODO } @Test - public void testDefaultExemplarsNoBuckets() throws Exception { + void testDefaultExemplarsNoBuckets() throws Exception { ExemplarSampler sampler = new ExemplarSampler(makeConfig(), new SpanContext()); Scheduler.awaitInitialization(); Thread.sleep(tick); // t = 1 tick diff --git a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/exemplars/SpanContextSupplierTest.java b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/exemplars/SpanContextSupplierTest.java index 6c89b48a5..5ddfb2ad5 100644 --- a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/exemplars/SpanContextSupplierTest.java +++ b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/exemplars/SpanContextSupplierTest.java @@ -51,12 +51,12 @@ public void markCurrentSpanAsExemplar() {} ); @BeforeEach - public void setUp() { + void setUp() { origSpanContext = SpanContextSupplier.getSpanContext(); } @AfterEach - public void tearDown() { + void tearDown() { SpanContextSupplier.setSpanContext(origSpanContext); } @@ -66,7 +66,7 @@ public void tearDown() { * SpanContextSupplier}. */ @Test - public void testConstructorInjection() { + void testConstructorInjection() { ExemplarsProperties properties = ExemplarsProperties.builder().build(); ExemplarSamplerConfig config = new ExemplarSamplerConfig(properties, 1); ExemplarSampler exemplarSampler = new ExemplarSampler(config, spanContextA); @@ -86,7 +86,7 @@ public void testConstructorInjection() { * ExemplarSampler}). */ @Test - public void testUpdateSpanContext() throws InterruptedException { + void testUpdateSpanContext() throws InterruptedException { ExemplarSampler exemplarSampler = new ExemplarSampler(config); SpanContextSupplier.setSpanContext(spanContextB); diff --git a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/CKMSQuantilesTest.java b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/CKMSQuantilesTest.java index bd6b177a4..5a7fd7f48 100644 --- a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/CKMSQuantilesTest.java +++ b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/CKMSQuantilesTest.java @@ -20,13 +20,13 @@ class CKMSQuantilesTest { private final Quantile qMax = new Quantile(1.0, 0.00); @Test - public void testGetOnEmptyValues() { + void testGetOnEmptyValues() { CKMSQuantiles ckms = new CKMSQuantiles(q50, q95, q99); assertThat(Double.isNaN(ckms.get(q95.quantile))).isTrue(); } @Test - public void testGet() { + void testGet() { Random random = new Random(0); CKMSQuantiles ckms = new CKMSQuantiles(q50, q95, q99); List input = shuffledValues(100, random); @@ -37,7 +37,7 @@ public void testGet() { } @Test - public void testBatchInsert() { + void testBatchInsert() { Random random = new Random(1); testInsertBatch(1, 1, 100, random); testInsertBatch(1, 10, 100, random); @@ -87,7 +87,7 @@ private void testInsertBatch( } @Test - public void testGetWithAMillionElements() { + void testGetWithAMillionElements() { Random random = new Random(2); List input = shuffledValues(1000 * 1000, random); CKMSQuantiles ckms = new CKMSQuantiles(q50, q95, q99); @@ -99,7 +99,7 @@ public void testGetWithAMillionElements() { } @Test - public void testMin() { + void testMin() { Random random = new Random(3); List input = shuffledValues(1000, random); CKMSQuantiles ckms = new CKMSQuantiles(qMin); @@ -112,7 +112,7 @@ public void testMin() { } @Test - public void testMax() { + void testMax() { Random random = new Random(4); List input = shuffledValues(1000, random); CKMSQuantiles ckms = new CKMSQuantiles(qMax); @@ -125,7 +125,7 @@ public void testMax() { } @Test - public void testMinMax() { + void testMinMax() { Random random = new Random(5); List input = shuffledValues(1000, random); CKMSQuantiles ckms = new CKMSQuantiles(qMin, qMax); @@ -138,7 +138,7 @@ public void testMinMax() { } @Test - public void testMinAndOthers() { + void testMinAndOthers() { Random random = new Random(6); List input = shuffledValues(1000, random); CKMSQuantiles ckms = new CKMSQuantiles(q95, qMin); @@ -150,7 +150,7 @@ public void testMinAndOthers() { } @Test - public void testMaxAndOthers() { + void testMaxAndOthers() { Random random = new Random(7); List input = shuffledValues(10000, random); CKMSQuantiles ckms = new CKMSQuantiles(q50, q95, qMax); @@ -162,7 +162,7 @@ public void testMaxAndOthers() { } @Test - public void testMinMaxAndOthers() { + void testMinMaxAndOthers() { Random random = new Random(8); List input = shuffledValues(10000, random); CKMSQuantiles ckms = new CKMSQuantiles(qMin, q50, q95, q99, qMax); @@ -174,7 +174,7 @@ public void testMinMaxAndOthers() { } @Test - public void testExactQuantile() { + void testExactQuantile() { Random random = new Random(9); List input = shuffledValues(10000, random); CKMSQuantiles ckms = new CKMSQuantiles(new Quantile(0.95, 0)); @@ -187,7 +187,7 @@ public void testExactQuantile() { } @Test - public void testExactAndOthers() { + void testExactAndOthers() { Random random = new Random(10); List input = shuffledValues(10000, random); CKMSQuantiles ckms = new CKMSQuantiles(q50, new Quantile(0.95, 0), q99); @@ -200,7 +200,7 @@ public void testExactAndOthers() { } @Test - public void testExactAndMin() { + void testExactAndMin() { Random random = new Random(11); List input = shuffledValues(10000, random); CKMSQuantiles ckms = new CKMSQuantiles(qMin, q50, new Quantile(0.95, 0)); @@ -213,7 +213,7 @@ public void testExactAndMin() { } @Test - public void testMaxEpsilon() { + void testMaxEpsilon() { Random random = new Random(12); List input = shuffledValues(10000, random); // epsilon == 1 basically gives you random results, but it should still not throw an exception. @@ -225,7 +225,7 @@ public void testMaxEpsilon() { } @Test - public void testGetGaussian() { + void testGetGaussian() { RandomGenerator rand = new JDKRandomGenerator(); rand.setSeed(0); @@ -284,7 +284,7 @@ public void testGetGaussian() { } @Test - public void testIllegalArgumentException() { + void testIllegalArgumentException() { try { new Quantile(-1, 0); } catch (IllegalArgumentException e) { diff --git a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/CounterTest.java b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/CounterTest.java index c39bf1ad6..44f78b2a1 100644 --- a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/CounterTest.java +++ b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/CounterTest.java @@ -36,7 +36,7 @@ class CounterTest { private SpanContext origSpanContext; @BeforeEach - public void setUp() throws NoSuchFieldException, IllegalAccessException { + void setUp() throws NoSuchFieldException, IllegalAccessException { noLabels = Counter.builder().name("nolabels").build(); labels = Counter.builder().name("labels").help("help").unit(Unit.SECONDS).labelNames("l").build(); @@ -48,7 +48,7 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException { } @AfterEach - public void tearDown() { + void tearDown() { SpanContextSupplier.setSpanContext(origSpanContext); } @@ -71,7 +71,7 @@ private int getNumberOfLabels(Counter counter) { } @Test - public void testIncrement() { + void testIncrement() { noLabels.inc(); assertThat(getValue(noLabels)).isCloseTo(1.0, offset(.001)); noLabels.inc(2); @@ -83,20 +83,20 @@ public void testIncrement() { } @Test - public void testNegativeIncrementFails() { + void testNegativeIncrementFails() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> noLabels.inc(-1)) .withMessage("Negative increment -1 is illegal for Counter metrics."); } @Test - public void testEmptyCountersHaveNoLabels() { + void testEmptyCountersHaveNoLabels() { assertThat(getNumberOfLabels(noLabels)).isOne(); assertThat(getNumberOfLabels(labels)).isZero(); } @Test - public void testLabels() { + void testLabels() { assertThat(getNumberOfLabels(labels)).isZero(); labels.labelValues("a").inc(); assertThat(getNumberOfLabels(labels)).isOne(); @@ -125,7 +125,7 @@ public void testTotalStrippedFromName(String name) { } @Test - public void testSnapshotComplete() { + void testSnapshotComplete() { long before = System.currentTimeMillis(); Counter counter = Counter.builder() @@ -180,7 +180,7 @@ public void testSnapshotComplete() { } @Test - public void testIncWithExemplar() throws Exception { + void testIncWithExemplar() throws Exception { noLabels.incWithExemplar(Labels.of("key", "value")); assertExemplar(noLabels, 1.0, "key", "value"); @@ -202,7 +202,7 @@ private void assertExemplar(Counter counter, double value, String... labels) { } @Test - public void testExemplarSampler() throws Exception { + void testExemplarSampler() throws Exception { Exemplar exemplar1 = Exemplar.builder().value(2.0).traceId("abc").spanId("123").build(); Exemplar exemplar2 = Exemplar.builder().value(1.0).traceId("def").spanId("456").build(); Exemplar exemplar3 = Exemplar.builder().value(1.0).traceId("123").spanId("abc").build(); @@ -320,7 +320,7 @@ void incWithExemplar2() { } @Test - public void testExemplarSamplerDisabled() { + void testExemplarSamplerDisabled() { Counter counter = Counter.builder().name("count_total").withoutExemplars().build(); counter.incWithExemplar(3.0, Labels.of("a", "b")); assertThat(getData(counter).getExemplar()).isNull(); @@ -329,7 +329,7 @@ public void testExemplarSamplerDisabled() { } @Test - public void testExemplarSamplerDisabled_enabledByDefault() { + void testExemplarSamplerDisabled_enabledByDefault() { PrometheusProperties properties = PrometheusProperties.builder() .defaultMetricsProperties(MetricsProperties.builder().exemplarsEnabled(true).build()) @@ -342,7 +342,7 @@ public void testExemplarSamplerDisabled_enabledByDefault() { } @Test - public void testExemplarSamplerDisabledInBuilder_enabledByPropertiesOnMetric() { + void testExemplarSamplerDisabledInBuilder_enabledByPropertiesOnMetric() { PrometheusProperties properties = PrometheusProperties.builder() .putMetricProperty("count", MetricsProperties.builder().exemplarsEnabled(true).build()) @@ -355,7 +355,7 @@ public void testExemplarSamplerDisabledInBuilder_enabledByPropertiesOnMetric() { } @Test - public void testConstLabelsFirst() { + void testConstLabelsFirst() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( () -> @@ -367,7 +367,7 @@ public void testConstLabelsFirst() { } @Test - public void testConstLabelsSecond() { + void testConstLabelsSecond() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( () -> diff --git a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/CounterWithCallbackTest.java b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/CounterWithCallbackTest.java index 47c5f5c57..2907a8a02 100644 --- a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/CounterWithCallbackTest.java +++ b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/CounterWithCallbackTest.java @@ -13,7 +13,7 @@ class CounterWithCallbackTest { @Test - public void testCounter() { + void testCounter() { final AtomicInteger value = new AtomicInteger(1); List labelValues = Arrays.asList("v1", "v2"); CounterWithCallback counter = @@ -38,7 +38,7 @@ public void testCounter() { } @Test - public void testCounterNoCallback() { + void testCounterNoCallback() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( () -> CounterWithCallback.builder().name("counter").labelNames("l1", "l2").build()); diff --git a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/GaugeTest.java b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/GaugeTest.java index 108fc05ce..be25711c7 100644 --- a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/GaugeTest.java +++ b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/GaugeTest.java @@ -27,14 +27,14 @@ class GaugeTest { private SpanContext origSpanContext; @BeforeEach - public void setUp() { + void setUp() { noLabels = Gauge.builder().name("nolabels").build(); labels = Gauge.builder().name("labels").labelNames("l").build(); origSpanContext = SpanContextSupplier.getSpanContext(); } @AfterEach - public void tearDown() { + void tearDown() { SpanContextSupplier.setSpanContext(origSpanContext); } @@ -50,7 +50,7 @@ private double getValue(Gauge gauge, String... labels) { } @Test - public void testIncrement() { + void testIncrement() { noLabels.inc(); assertThat(getValue(noLabels)).isCloseTo(1.0, offset(.001)); noLabels.inc(2); @@ -62,7 +62,7 @@ public void testIncrement() { } @Test - public void testDecrement() { + void testDecrement() { noLabels.dec(); assertThat(getValue(noLabels)).isCloseTo(-1.0, offset(.001)); noLabels.dec(2); @@ -74,7 +74,7 @@ public void testDecrement() { } @Test - public void testSet() { + void testSet() { noLabels.set(42); assertThat(getValue(noLabels)).isCloseTo(42, offset(.001)); noLabels.set(7); @@ -92,12 +92,12 @@ public void testTimer() throws InterruptedException { } @Test - public void noLabelsDefaultZeroValue() { + void noLabelsDefaultZeroValue() { assertThat(getValue(noLabels)).isCloseTo(0.0, offset(.001)); } @Test - public void testLabels() { + void testLabels() { labels.labelValues("a").inc(); labels.labelValues("b").inc(3); assertThat(getValue(labels, "l", "a")).isCloseTo(1.0, offset(.001)); @@ -105,7 +105,7 @@ public void testLabels() { } @Test - public void testExemplarSampler() throws Exception { + void testExemplarSampler() throws Exception { Exemplar exemplar1 = Exemplar.builder().value(2.0).traceId("abc").spanId("123").build(); Exemplar exemplar2 = Exemplar.builder().value(6.5).traceId("def").spanId("456").build(); Exemplar exemplar3 = Exemplar.builder().value(7.0).traceId("123").spanId("abc").build(); @@ -222,7 +222,7 @@ void decWithExemplar() { } @Test - public void testExemplarSamplerDisabled() { + void testExemplarSamplerDisabled() { Gauge gauge = Gauge.builder().name("test").withoutExemplars().build(); gauge.setWithExemplar(3.0, Labels.of("a", "b")); assertThat(getData(gauge).getExemplar()).isNull(); @@ -231,7 +231,7 @@ public void testExemplarSamplerDisabled() { } @Test - public void testExemplarSamplerDisabledByBuilder_enabledByPropertiesOnMetric() { + void testExemplarSamplerDisabledByBuilder_enabledByPropertiesOnMetric() { PrometheusProperties properties = PrometheusProperties.builder() .putMetricProperty("test", MetricsProperties.builder().exemplarsEnabled(true).build()) diff --git a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/GaugeWithCallbackTest.java b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/GaugeWithCallbackTest.java index 92a2d605e..f89fd70d2 100644 --- a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/GaugeWithCallbackTest.java +++ b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/GaugeWithCallbackTest.java @@ -13,7 +13,7 @@ class GaugeWithCallbackTest { @Test - public void testGauge() { + void testGauge() { final AtomicInteger value = new AtomicInteger(1); List labelValues = Arrays.asList("v1", "v2"); GaugeWithCallback gauge = @@ -38,7 +38,7 @@ public void testGauge() { } @Test - public void testGaugeNoCallback() { + void testGaugeNoCallback() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> GaugeWithCallback.builder().name("gauge").labelNames("l1", "l2").build()); } diff --git a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/HistogramTest.java b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/HistogramTest.java index 0a17dccd3..cab6d8e61 100644 --- a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/HistogramTest.java +++ b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/HistogramTest.java @@ -51,12 +51,12 @@ class HistogramTest { private SpanContext origSpanContext; @BeforeEach - public void setUp() { + void setUp() { origSpanContext = SpanContextSupplier.getSpanContext(); } @AfterEach - public void tearDown() { + void tearDown() { SpanContextSupplier.setSpanContext(origSpanContext); } @@ -99,7 +99,7 @@ private void run() throws NoSuchFieldException, IllegalAccessException { /** Test cases copied from histogram_test.go in client_golang. */ @Test - public void testGolangTests() throws NoSuchFieldException, IllegalAccessException { + void testGolangTests() throws NoSuchFieldException, IllegalAccessException { GolangTestCase[] testCases = new GolangTestCase[] { new GolangTestCase( @@ -763,7 +763,7 @@ public void testGolangTests() throws NoSuchFieldException, IllegalAccessExceptio /** Additional tests that are not part of client_golang's test suite. */ @Test - public void testAdditional() throws NoSuchFieldException, IllegalAccessException { + void testAdditional() throws NoSuchFieldException, IllegalAccessException { GolangTestCase[] testCases = new GolangTestCase[] { new GolangTestCase( @@ -797,7 +797,7 @@ public void testAdditional() throws NoSuchFieldException, IllegalAccessException *

This test is ported from client_golang's TestGetLe(). */ @Test - public void testNativeBucketIndexToUpperBound() + void testNativeBucketIndexToUpperBound() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { int[] indexes = new int[] {-1, 0, 1, 512, 513, -1, 0, 1, 1024, 1025, -1, 0, 1, 4096, 4097}; int[] schemas = new int[] {-1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2}; @@ -839,7 +839,7 @@ public void testNativeBucketIndexToUpperBound() * findBucketIndex() */ @Test - public void testFindBucketIndex() + void testFindBucketIndex() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Random rand = new Random(); Method findBucketIndex = @@ -884,7 +884,7 @@ public void testFindBucketIndex() } @Test - public void testDefaults() throws IOException { + void testDefaults() throws IOException { Histogram histogram = Histogram.builder().name("test").build(); histogram.observe(0.5); HistogramSnapshot snapshot = histogram.collect(); @@ -955,7 +955,7 @@ public void testDefaults() throws IOException { } @Test - public void testExemplarsClassicHistogram() throws Exception { + void testExemplarsClassicHistogram() throws Exception { SpanContext spanContext = new SpanContext() { int callCount = 0; @@ -1099,7 +1099,7 @@ private Exemplar getExemplar(HistogramSnapshot snapshot, double le, String... la } @Test - public void testCustomExemplarsClassicHistogram() + void testCustomExemplarsClassicHistogram() throws InterruptedException, NoSuchFieldException, IllegalAccessException { // TODO: This was copied from the old simpleclient, can probably be refactored. @@ -1167,7 +1167,7 @@ private void assertExemplar(Histogram histogram, double value, String... labels) } @Test - public void testExemplarsNativeHistogram() throws NoSuchFieldException, IllegalAccessException { + void testExemplarsNativeHistogram() throws NoSuchFieldException, IllegalAccessException { SpanContext spanContext = new SpanContext() { @@ -1236,13 +1236,13 @@ public void markCurrentSpanAsExemplar() {} } @Test - public void testIllegalLabelName() { + void testIllegalLabelName() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Histogram.builder().name("test").labelNames("label", "le")); } @Test - public void testIllegalLabelNameConstLabels() { + void testIllegalLabelNameConstLabels() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( () -> @@ -1252,25 +1252,25 @@ public void testIllegalLabelNameConstLabels() { } @Test - public void testIllegalLabelNamePrefix() { + void testIllegalLabelNamePrefix() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Histogram.builder().name("test").labelNames("__hello")); } @Test - public void testNoName() { + void testNoName() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Histogram.builder().build()); } @Test - public void testNullName() { + void testNullName() { assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> Histogram.builder().name(null)); } @Test - public void testDuplicateClassicBuckets() { + void testDuplicateClassicBuckets() { Histogram histogram = Histogram.builder().name("test").classicUpperBounds(0, 3, 17, 3, 21).build(); List upperBounds = @@ -1282,7 +1282,7 @@ public void testDuplicateClassicBuckets() { } @Test - public void testUnsortedBuckets() { + void testUnsortedBuckets() { Histogram histogram = Histogram.builder().name("test").classicUpperBounds(0.2, 0.1).build(); List upperBounds = getData(histogram).getClassicBuckets().stream() @@ -1292,7 +1292,7 @@ public void testUnsortedBuckets() { } @Test - public void testEmptyBuckets() { + void testEmptyBuckets() { Histogram histogram = Histogram.builder().name("test").classicUpperBounds().build(); List upperBounds = getData(histogram).getClassicBuckets().stream() @@ -1302,7 +1302,7 @@ public void testEmptyBuckets() { } @Test - public void testBucketsIncludePositiveInfinity() { + void testBucketsIncludePositiveInfinity() { Histogram histogram = Histogram.builder() .name("test") @@ -1316,7 +1316,7 @@ public void testBucketsIncludePositiveInfinity() { } @Test - public void testLinearBuckets() { + void testLinearBuckets() { Histogram histogram = Histogram.builder().name("test").classicLinearUpperBounds(0.1, 0.1, 10).build(); List upperBounds = @@ -1330,7 +1330,7 @@ public void testLinearBuckets() { } @Test - public void testExponentialBuckets() { + void testExponentialBuckets() { Histogram histogram = Histogram.builder().classicExponentialUpperBounds(2, 2.5, 3).name("test").build(); List upperBounds = @@ -1341,14 +1341,14 @@ public void testExponentialBuckets() { } @Test - public void testBucketsIncludeNaN() { + void testBucketsIncludeNaN() { assertThatExceptionOfType(RuntimeException.class) .isThrownBy( () -> Histogram.builder().name("test").classicUpperBounds(0.01, 0.1, 1.0, Double.NaN)); } @Test - public void testNoLabelsDefaultZeroValue() { + void testNoLabelsDefaultZeroValue() { Histogram noLabels = Histogram.builder().name("test").build(); assertThat(getBucket(noLabels, 0.005).getCount()).isZero(); assertThat(getData(noLabels).getCount()).isZero(); @@ -1363,7 +1363,7 @@ private ClassicHistogramBucket getBucket(Histogram histogram, double le, String. } @Test - public void testObserve() { + void testObserve() { Histogram noLabels = Histogram.builder().name("test").build(); noLabels.observe(2); assertThat(noLabels.getCount()).isOne(); @@ -1410,7 +1410,7 @@ public void testNegativeAmount() { } @Test - public void testBoundaryConditions() { + void testBoundaryConditions() { Histogram histogram = Histogram.builder().name("test").build(); histogram.observe(2.5); assertThat(getBucket(histogram, 1).getCount()).isZero(); @@ -1425,14 +1425,14 @@ public void testBoundaryConditions() { } @Test - public void testExemplarsDisabledInBuilder() { + void testExemplarsDisabledInBuilder() { Histogram histogram = Histogram.builder().withoutExemplars().name("test").build(); histogram.observeWithExemplar(2.5, Labels.EMPTY); assertThat(getData(histogram).getExemplars().size()).isZero(); } @Test - public void testExemplarsDisabledInBuilder_enabledByPropertiesOnMetric() { + void testExemplarsDisabledInBuilder_enabledByPropertiesOnMetric() { PrometheusProperties properties = PrometheusProperties.builder() .putMetricProperty("test", MetricsProperties.builder().exemplarsEnabled(true).build()) @@ -1444,7 +1444,7 @@ public void testExemplarsDisabledInBuilder_enabledByPropertiesOnMetric() { } @Test - public void testObserveWithLabels() { + void testObserveWithLabels() { Histogram histogram = Histogram.builder() .name("test") @@ -1475,7 +1475,7 @@ public void testObserveWithLabels() { } @Test - public void testObserveMultithreaded() + void testObserveMultithreaded() throws InterruptedException, ExecutionException, TimeoutException { // Hard to test concurrency, but let's run a couple of observations in parallel and assert none // gets lost. diff --git a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/InfoTest.java b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/InfoTest.java index e47bb7d6c..13737ad16 100644 --- a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/InfoTest.java +++ b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/InfoTest.java @@ -34,7 +34,7 @@ public void testInfoStrippedFromName(String name) { } @Test - public void testAddAndRemove() { + void testAddAndRemove() { Info info = Info.builder().name("test_info").labelNames("a", "b").build(); assertThat(info.collect().getDataPoints()).isEmpty(); info.addLabelValues("val1", "val2"); @@ -58,7 +58,7 @@ public void testAddAndRemove() { } @Test - public void testSet() throws IOException { + void testSet() throws IOException { Info info = Info.builder() .name("target_info") @@ -88,7 +88,7 @@ public void testSet() throws IOException { } @Test - public void testConstLabelsOnly() throws IOException { + void testConstLabelsOnly() throws IOException { Info info = Info.builder() .name("target_info") @@ -106,14 +106,14 @@ void unit() { } @Test - public void testConstLabelsDuplicate1() { + void testConstLabelsDuplicate1() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( () -> Info.builder().constLabels(Labels.of("a_1", "val1")).labelNames("a.1").build()); } @Test - public void testConstLabelsDuplicate2() { + void testConstLabelsDuplicate2() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( () -> Info.builder().labelNames("a_1").constLabels(Labels.of("a.1", "val1")).build()); diff --git a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/SlidingWindowTest.java b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/SlidingWindowTest.java index d85e5637c..dea8fdfbd 100644 --- a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/SlidingWindowTest.java +++ b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/SlidingWindowTest.java @@ -43,7 +43,7 @@ void assertValues(double... expectedValues) { private final long timeBetweenRotateMillis = maxAgeSeconds * 1000 / ageBuckets + 2; @BeforeEach - public void setUp() { + void setUp() { startTime = System.currentTimeMillis(); currentTimeMillis.set(startTime); ringBuffer = @@ -57,7 +57,7 @@ public void setUp() { } @Test - public void testRotate() { + void testRotate() { for (int i = 0; i < ageBuckets; i++) { currentTimeMillis.addAndGet(timeBetweenRotateMillis); ringBuffer.observe(1.0); @@ -76,7 +76,7 @@ public void testRotate() { } @Test - public void testMultiRotate() { + void testMultiRotate() { ringBuffer.observe(1.0); currentTimeMillis.addAndGet(2 * timeBetweenRotateMillis); // 2/5 of max aqe ringBuffer.observe(2.0); diff --git a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/StateSetTest.java b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/StateSetTest.java index 7d466335b..318013edf 100644 --- a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/StateSetTest.java +++ b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/StateSetTest.java @@ -27,7 +27,7 @@ public String toString() { } @Test - public void testEnumStateSet() { + void testEnumStateSet() { StateSet stateSet = StateSet.builder() .name("feature_flags") @@ -51,7 +51,7 @@ public void testEnumStateSet() { } @Test - public void testDefaultFalse() { + void testDefaultFalse() { StateSet stateSet = StateSet.builder().name("test").states("state1", "state2", "state3").build(); assertThat(getData(stateSet).size()).isEqualTo(3); @@ -83,7 +83,7 @@ private StateSetSnapshot.StateSetDataPointSnapshot getData(StateSet stateSet, St } @Test - public void testStatesCannotBeEmpty() { + void testStatesCannotBeEmpty() { assertThatExceptionOfType(IllegalStateException.class) .isThrownBy(() -> StateSet.builder().name("invalid").build()); } diff --git a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/StatefulMetricTest.java b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/StatefulMetricTest.java index 00aa53bbd..f940d505d 100644 --- a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/StatefulMetricTest.java +++ b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/StatefulMetricTest.java @@ -12,7 +12,7 @@ class StatefulMetricTest { @Test - public void testLabelRemoveWhileCollecting() throws Exception { + void testLabelRemoveWhileCollecting() throws Exception { Counter counter = Counter.builder().name("test").labelNames("label1", "label2").build(); Field data = counter.getClass().getSuperclass().getDeclaredField("data"); data.setAccessible(true); @@ -61,7 +61,7 @@ public void testLabelRemoveIf() throws Exception { } @Test - public void testClear() { + void testClear() { Counter counter = Counter.builder().name("test").labelNames("label1", "label2").build(); counter.labelValues("a", "b").inc(3.0); counter.labelValues("c", "d").inc(3.0); @@ -76,7 +76,7 @@ public void testClear() { } @Test - public void testClearNoLabels() { + void testClearNoLabels() { Counter counter = Counter.builder().name("test").build(); counter.inc(); assertThat(counter.collect().getDataPoints()).hasSize(1); @@ -95,7 +95,7 @@ public void testClearNoLabels() { } @Test - public void testNullLabel() { + void testNullLabel() { Counter counter = Counter.builder().name("test").labelNames("l1", "l2").build(); assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> counter.labelValues("l1", null)) diff --git a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/SummaryTest.java b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/SummaryTest.java index cdfffe5f0..b6c045229 100644 --- a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/SummaryTest.java +++ b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/SummaryTest.java @@ -30,7 +30,7 @@ class SummaryTest { private Summary noLabelsAndQuantiles; @BeforeEach - public void setUp() { + void setUp() { registry = new PrometheusRegistry(); noLabels = Summary.builder().name("nolabels").unit(Unit.SECONDS).help("help").register(registry); @@ -63,7 +63,7 @@ public void setUp() { } @Test - public void testObserve() { + void testObserve() { noLabels.observe(2); assertThat(noLabels.getCount()).isOne(); assertThat(noLabels.getSum()).isCloseTo(2.0, offset(.0)); @@ -86,7 +86,7 @@ public void testObserve() { } @Test - public void testNegativeAmount() { + void testNegativeAmount() { noLabels.observe(-1); noLabels.observe(-3); assertThat(getCount(noLabels, Labels.EMPTY)).isEqualTo(2); @@ -94,7 +94,7 @@ public void testNegativeAmount() { } @Test - public void testQuantiles() { + void testQuantiles() { int nSamples = 1000000; // simulate one million samples for (int i = 1; i <= nSamples; i++) { @@ -119,7 +119,7 @@ public void testQuantiles() { } @Test - public void testMaxAge() throws InterruptedException { + void testMaxAge() throws InterruptedException { Summary summary = Summary.builder() .quantile(0.99, 0.001) @@ -138,7 +138,7 @@ public void testMaxAge() throws InterruptedException { } @Test - public void testTimer() { + void testTimer() { int result = noLabels.time(() -> 123); assertThat(result).isEqualTo(123); assertThat(getCount(noLabels, Labels.EMPTY)).isOne(); @@ -150,31 +150,31 @@ public void testTimer() { } @Test - public void noLabelsDefaultZeroValue() { + void noLabelsDefaultZeroValue() { assertThat(getCount(noLabels, Labels.EMPTY)).isZero(); assertThat(getSum(noLabels, Labels.EMPTY)).isCloseTo(0.0, offset(.001)); } @Test - public void testBuilderInvalidNumberOfAgeBuckets() { + void testBuilderInvalidNumberOfAgeBuckets() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Summary.builder().name("name").numberOfAgeBuckets(-1).build()); } @Test - public void testBuilderInvalidMaxAge() { + void testBuilderInvalidMaxAge() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Summary.builder().name("name").maxAgeSeconds(-1).build()); } @Test - public void testBuilderInvalidQuantile() { + void testBuilderInvalidQuantile() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Summary.builder().name("name").quantile(42).build()); } @Test - public void testBuilderInvalidQuantileError() { + void testBuilderInvalidQuantileError() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Summary.builder().name("name").quantile(0.5, 20).build()); } diff --git a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/SummaryWithCallbackTest.java b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/SummaryWithCallbackTest.java index 929efc597..aacb83193 100644 --- a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/SummaryWithCallbackTest.java +++ b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/SummaryWithCallbackTest.java @@ -15,7 +15,7 @@ class SummaryWithCallbackTest { @Test - public void testGauge() { + void testGauge() { final AtomicInteger count = new AtomicInteger(1); final AtomicInteger sum = new AtomicInteger(1); final Quantiles quantiles = Quantiles.of(new Quantile(0.5, 10)); @@ -49,7 +49,7 @@ public void testGauge() { } @Test - public void testSummaryNoCallback() { + void testSummaryNoCallback() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( () -> SummaryWithCallback.builder().name("summary").labelNames("l1", "l2").build()); diff --git a/prometheus-metrics-exporter-common/src/test/java/io/prometheus/metrics/exporter/common/PrometheusHttpRequestTest.java b/prometheus-metrics-exporter-common/src/test/java/io/prometheus/metrics/exporter/common/PrometheusHttpRequestTest.java index 65fcc8041..a2b630ecd 100644 --- a/prometheus-metrics-exporter-common/src/test/java/io/prometheus/metrics/exporter/common/PrometheusHttpRequestTest.java +++ b/prometheus-metrics-exporter-common/src/test/java/io/prometheus/metrics/exporter/common/PrometheusHttpRequestTest.java @@ -9,71 +9,71 @@ class PrometheusHttpRequestTest { @Test - public void testGetHeaderReturnsFirstValue() { + void testGetHeaderReturnsFirstValue() { PrometheusHttpRequest request = new TestPrometheusHttpRequest("name[]=metric1&name[]=metric2", "gzip"); assertThat(request.getHeader("Accept-Encoding")).isEqualTo("gzip"); } @Test - public void testGetHeaderReturnsNullWhenNoHeaders() { + void testGetHeaderReturnsNullWhenNoHeaders() { PrometheusHttpRequest request = new TestPrometheusHttpRequest("", null); assertThat(request.getHeader("Accept-Encoding")).isNull(); } @Test - public void testGetParameterReturnsFirstValue() { + void testGetParameterReturnsFirstValue() { PrometheusHttpRequest request = new TestPrometheusHttpRequest("name[]=metric1&name[]=metric2"); assertThat(request.getParameter("name[]")).isEqualTo("metric1"); } @Test - public void testGetParameterReturnsNullWhenNotPresent() { + void testGetParameterReturnsNullWhenNotPresent() { PrometheusHttpRequest request = new TestPrometheusHttpRequest("other=value"); assertThat(request.getParameter("name[]")).isNull(); } @Test - public void testGetParameterValuesReturnsMultipleValues() { + void testGetParameterValuesReturnsMultipleValues() { PrometheusHttpRequest request = new TestPrometheusHttpRequest("name[]=metric1&name[]=metric2"); String[] values = request.getParameterValues("name[]"); assertThat(values).containsExactly("metric1", "metric2"); } @Test - public void testGetParameterValuesReturnsNullWhenNotPresent() { + void testGetParameterValuesReturnsNullWhenNotPresent() { PrometheusHttpRequest request = new TestPrometheusHttpRequest("other=value"); assertThat(request.getParameterValues("name[]")).isNull(); } @Test - public void testGetParameterValuesWithEmptyQueryString() { + void testGetParameterValuesWithEmptyQueryString() { PrometheusHttpRequest request = new TestPrometheusHttpRequest(""); assertThat(request.getParameterValues("name[]")).isNull(); } @Test - public void testGetParameterValuesWithNullQueryString() { + void testGetParameterValuesWithNullQueryString() { PrometheusHttpRequest request = new TestPrometheusHttpRequest(null); assertThat(request.getParameterValues("name[]")).isNull(); } @Test - public void testGetParameterValuesWithUrlEncodedValues() { + void testGetParameterValuesWithUrlEncodedValues() { PrometheusHttpRequest request = new TestPrometheusHttpRequest("name=hello%20world"); String[] values = request.getParameterValues("name"); assertThat(values).containsExactly("hello world"); } @Test - public void testGetParameterValuesWithSpecialCharacters() { + void testGetParameterValuesWithSpecialCharacters() { PrometheusHttpRequest request = new TestPrometheusHttpRequest("name=%2Ffoo%2Fbar"); String[] values = request.getParameterValues("name"); assertThat(values).containsExactly("/foo/bar"); } @Test - public void testGetParameterValuesIgnoresParametersWithoutEquals() { + void testGetParameterValuesIgnoresParametersWithoutEquals() { PrometheusHttpRequest request = new TestPrometheusHttpRequest("name[]=value1&invalid&name[]=value2"); String[] values = request.getParameterValues("name[]"); diff --git a/prometheus-metrics-exporter-common/src/test/java/io/prometheus/metrics/exporter/common/PrometheusScrapeHandlerTest.java b/prometheus-metrics-exporter-common/src/test/java/io/prometheus/metrics/exporter/common/PrometheusScrapeHandlerTest.java index 4d38d75e8..07ea8ac52 100644 --- a/prometheus-metrics-exporter-common/src/test/java/io/prometheus/metrics/exporter/common/PrometheusScrapeHandlerTest.java +++ b/prometheus-metrics-exporter-common/src/test/java/io/prometheus/metrics/exporter/common/PrometheusScrapeHandlerTest.java @@ -23,7 +23,7 @@ class PrometheusScrapeHandlerTest { private Counter testCounter; @BeforeEach - public void setUp() { + void setUp() { registry = new PrometheusRegistry(); handler = new PrometheusScrapeHandler(registry); testCounter = Counter.builder().name("test_counter").help("Test counter").register(registry); @@ -31,7 +31,7 @@ public void setUp() { } @Test - public void testBasicScrape() throws IOException { + void testBasicScrape() throws IOException { TestHttpExchange exchange = new TestHttpExchange("GET", null); handler.handleRequest(exchange); @@ -41,7 +41,7 @@ public void testBasicScrape() throws IOException { } @Test - public void testOpenMetricsFormat() throws IOException { + void testOpenMetricsFormat() throws IOException { TestHttpExchange exchange = new TestHttpExchange("GET", null).withHeader("Accept", "application/openmetrics-text"); handler.handleRequest(exchange); @@ -53,7 +53,7 @@ public void testOpenMetricsFormat() throws IOException { } @Test - public void testPrometheusTextFormat() throws IOException { + void testPrometheusTextFormat() throws IOException { TestHttpExchange exchange = new TestHttpExchange("GET", null).withHeader("Accept", "text/plain"); handler.handleRequest(exchange); @@ -64,7 +64,7 @@ public void testPrometheusTextFormat() throws IOException { } @Test - public void testGzipCompression() throws IOException { + void testGzipCompression() throws IOException { TestHttpExchange exchange = new TestHttpExchange("GET", null).withHeader("Accept-Encoding", "gzip"); handler.handleRequest(exchange); @@ -79,7 +79,7 @@ public void testGzipCompression() throws IOException { } @Test - public void testMultipleAcceptEncodingHeaders() throws IOException { + void testMultipleAcceptEncodingHeaders() throws IOException { TestHttpExchange exchange = new TestHttpExchange("GET", null) .withHeader("Accept-Encoding", "deflate") @@ -91,7 +91,7 @@ public void testMultipleAcceptEncodingHeaders() throws IOException { } @Test - public void testHeadRequest() throws IOException { + void testHeadRequest() throws IOException { TestHttpExchange exchange = new TestHttpExchange("HEAD", null); handler.handleRequest(exchange); @@ -102,7 +102,7 @@ public void testHeadRequest() throws IOException { } @Test - public void testDebugOpenMetrics() throws IOException { + void testDebugOpenMetrics() throws IOException { TestHttpExchange exchange = new TestHttpExchange("GET", "debug=openmetrics"); handler.handleRequest(exchange); @@ -113,7 +113,7 @@ public void testDebugOpenMetrics() throws IOException { } @Test - public void testDebugText() throws IOException { + void testDebugText() throws IOException { TestHttpExchange exchange = new TestHttpExchange("GET", "debug=text"); handler.handleRequest(exchange); @@ -122,7 +122,7 @@ public void testDebugText() throws IOException { } @Test - public void testDebugInvalidParameter() throws IOException { + void testDebugInvalidParameter() throws IOException { TestHttpExchange exchange = new TestHttpExchange("GET", "debug=invalid"); handler.handleRequest(exchange); @@ -131,7 +131,7 @@ public void testDebugInvalidParameter() throws IOException { } @Test - public void testMetricNameFilter() throws IOException { + void testMetricNameFilter() throws IOException { Counter anotherCounter = Counter.builder().name("another_counter").help("Another counter").register(registry); anotherCounter.inc(10); @@ -145,7 +145,7 @@ public void testMetricNameFilter() throws IOException { } @Test - public void testMultipleMetricNameFilters() throws IOException { + void testMultipleMetricNameFilters() throws IOException { Counter counter1 = Counter.builder().name("metric_one").help("Metric one").register(registry); Counter counter2 = Counter.builder().name("metric_two").help("Metric two").register(registry); Counter counter3 = diff --git a/prometheus-metrics-exporter-httpserver/src/test/java/io/prometheus/metrics/exporter/httpserver/HTTPServerTest.java b/prometheus-metrics-exporter-httpserver/src/test/java/io/prometheus/metrics/exporter/httpserver/HTTPServerTest.java index 5959c5c91..58b5a9446 100644 --- a/prometheus-metrics-exporter-httpserver/src/test/java/io/prometheus/metrics/exporter/httpserver/HTTPServerTest.java +++ b/prometheus-metrics-exporter-httpserver/src/test/java/io/prometheus/metrics/exporter/httpserver/HTTPServerTest.java @@ -24,7 +24,7 @@ import javax.security.auth.Subject; import org.junit.jupiter.api.Test; -public class HTTPServerTest { +class HTTPServerTest { @Test @SuppressWarnings({"removal"}) diff --git a/prometheus-metrics-exporter-opentelemetry-otel-agent-resources/src/test/java/io/prometheus/otelagent/ResourceAttributesFromOtelAgentTest.java b/prometheus-metrics-exporter-opentelemetry-otel-agent-resources/src/test/java/io/prometheus/otelagent/ResourceAttributesFromOtelAgentTest.java index 1dd07e7c9..9f0165b45 100644 --- a/prometheus-metrics-exporter-opentelemetry-otel-agent-resources/src/test/java/io/prometheus/otelagent/ResourceAttributesFromOtelAgentTest.java +++ b/prometheus-metrics-exporter-opentelemetry-otel-agent-resources/src/test/java/io/prometheus/otelagent/ResourceAttributesFromOtelAgentTest.java @@ -8,7 +8,7 @@ class ResourceAttributesFromOtelAgentTest { @Test - public void testGetResourceAttributesWithoutOtelAgent() { + void testGetResourceAttributesWithoutOtelAgent() { // When OTel agent is not attached, should return empty map Map attributes = ResourceAttributesFromOtelAgent.getResourceAttributes("test-scope"); @@ -16,7 +16,7 @@ public void testGetResourceAttributesWithoutOtelAgent() { } @Test - public void testGetResourceAttributesWithDifferentInstrumentationScopes() { + void testGetResourceAttributesWithDifferentInstrumentationScopes() { // Test with different scope names to ensure temp directory creation works Map attributes1 = ResourceAttributesFromOtelAgent.getResourceAttributes("scope-one"); @@ -28,7 +28,7 @@ public void testGetResourceAttributesWithDifferentInstrumentationScopes() { } @Test - public void testGetResourceAttributesHandlesExceptions() { + void testGetResourceAttributesHandlesExceptions() { // Test with special characters that might cause issues in temp directory names Map attributes = ResourceAttributesFromOtelAgent.getResourceAttributes("test/scope"); @@ -37,7 +37,7 @@ public void testGetResourceAttributesHandlesExceptions() { } @Test - public void testGetResourceAttributesReturnsImmutableMap() { + void testGetResourceAttributesReturnsImmutableMap() { Map attributes = ResourceAttributesFromOtelAgent.getResourceAttributes("test-scope"); @@ -57,7 +57,7 @@ public void testGetResourceAttributesReturnsImmutableMap() { } @Test - public void testGetResourceAttributesWithNullKey() { + void testGetResourceAttributesWithNullKey() { // Test the null handling in the attribute map processing // Without OTel agent, this returns empty map, but tests the null check logic Map attributes = diff --git a/prometheus-metrics-exporter-opentelemetry/src/test/java/io/prometheus/metrics/exporter/opentelemetry/ExemplarTest.java b/prometheus-metrics-exporter-opentelemetry/src/test/java/io/prometheus/metrics/exporter/opentelemetry/ExemplarTest.java index 48054b192..c21f1ead4 100644 --- a/prometheus-metrics-exporter-opentelemetry/src/test/java/io/prometheus/metrics/exporter/opentelemetry/ExemplarTest.java +++ b/prometheus-metrics-exporter-opentelemetry/src/test/java/io/prometheus/metrics/exporter/opentelemetry/ExemplarTest.java @@ -45,7 +45,7 @@ class ExemplarTest { private OpenTelemetryExporter openTelemetryExporter; @BeforeEach - public void setUp() { + void setUp() { openTelemetryExporter = OpenTelemetryExporter.builder() .endpoint("http://localhost:4317") @@ -64,7 +64,7 @@ public void setUp() { } @AfterEach - public void tearDown() { + void tearDown() { PrometheusRegistry.defaultRegistry.unregister(testCounter); openTelemetryExporter.close(); } diff --git a/prometheus-metrics-exporter-opentelemetry/src/test/java/io/prometheus/metrics/exporter/opentelemetry/ExportTest.java b/prometheus-metrics-exporter-opentelemetry/src/test/java/io/prometheus/metrics/exporter/opentelemetry/ExportTest.java index 55589ce84..5ec213563 100644 --- a/prometheus-metrics-exporter-opentelemetry/src/test/java/io/prometheus/metrics/exporter/opentelemetry/ExportTest.java +++ b/prometheus-metrics-exporter-opentelemetry/src/test/java/io/prometheus/metrics/exporter/opentelemetry/ExportTest.java @@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -public class ExportTest { +class ExportTest { private static final Attributes ATTRIBUTES = Attributes.of(AttributeKey.stringKey("label"), "val", AttributeKey.stringKey("key"), "value"); diff --git a/prometheus-metrics-exporter-pushgateway/src/test/java/io/prometheus/metrics/exporter/pushgateway/BasicAuthPushGatewayTest.java b/prometheus-metrics-exporter-pushgateway/src/test/java/io/prometheus/metrics/exporter/pushgateway/BasicAuthPushGatewayTest.java index e2f052d6b..137686d32 100644 --- a/prometheus-metrics-exporter-pushgateway/src/test/java/io/prometheus/metrics/exporter/pushgateway/BasicAuthPushGatewayTest.java +++ b/prometheus-metrics-exporter-pushgateway/src/test/java/io/prometheus/metrics/exporter/pushgateway/BasicAuthPushGatewayTest.java @@ -21,7 +21,7 @@ class BasicAuthPushGatewayTest { PushGateway pushGateway; @BeforeEach - public void setUp() { + void setUp() { mockServerClient = ClientAndServer.startClientAndServer(0); registry = new PrometheusRegistry(); gauge = Gauge.builder().name("g").help("help").build(); @@ -42,7 +42,7 @@ void tearDown() { } @Test - public void testAuthorizedPush() throws IOException { + void testAuthorizedPush() throws IOException { mockServerClient .when( request() diff --git a/prometheus-metrics-exporter-pushgateway/src/test/java/io/prometheus/metrics/exporter/pushgateway/BearerTokenPushGatewayTest.java b/prometheus-metrics-exporter-pushgateway/src/test/java/io/prometheus/metrics/exporter/pushgateway/BearerTokenPushGatewayTest.java index 09e6ff5e9..996442e5a 100644 --- a/prometheus-metrics-exporter-pushgateway/src/test/java/io/prometheus/metrics/exporter/pushgateway/BearerTokenPushGatewayTest.java +++ b/prometheus-metrics-exporter-pushgateway/src/test/java/io/prometheus/metrics/exporter/pushgateway/BearerTokenPushGatewayTest.java @@ -21,7 +21,7 @@ class BearerTokenPushGatewayTest { PushGateway pushGateway; @BeforeEach - public void setUp() { + void setUp() { mockServerClient = ClientAndServer.startClientAndServer(0); registry = new PrometheusRegistry(); gauge = Gauge.builder().name("g").help("help").build(); @@ -40,7 +40,7 @@ void tearDown() { } @Test - public void testAuthorizedPush() throws IOException { + void testAuthorizedPush() throws IOException { mockServerClient .when( request() diff --git a/prometheus-metrics-exporter-pushgateway/src/test/java/io/prometheus/metrics/exporter/pushgateway/PushGatewayTest.java b/prometheus-metrics-exporter-pushgateway/src/test/java/io/prometheus/metrics/exporter/pushgateway/PushGatewayTest.java index 4eba4cb17..7e317fefe 100644 --- a/prometheus-metrics-exporter-pushgateway/src/test/java/io/prometheus/metrics/exporter/pushgateway/PushGatewayTest.java +++ b/prometheus-metrics-exporter-pushgateway/src/test/java/io/prometheus/metrics/exporter/pushgateway/PushGatewayTest.java @@ -26,7 +26,7 @@ class PushGatewayTest { Gauge gauge; @BeforeEach - public void setUp() { + void setUp() { mockServerClient = ClientAndServer.startClientAndServer(0); registry = new PrometheusRegistry(); gauge = Gauge.builder().name("g").help("help").build(); @@ -38,7 +38,7 @@ void tearDown() { } @Test - public void testInvalidURLThrowsRuntimeException() { + void testInvalidURLThrowsRuntimeException() { assertThatExceptionOfType(RuntimeException.class) .isThrownBy( () -> { @@ -49,7 +49,7 @@ public void testInvalidURLThrowsRuntimeException() { } @Test - public void testMultipleSlashesAreStrippedFromURL() + void testMultipleSlashesAreStrippedFromURL() throws NoSuchFieldException, IllegalAccessException { final PushGateway pushGateway = PushGateway.builder().address("example.com:1234/context///path//").job("test").build(); @@ -64,7 +64,7 @@ private URL getUrl(PushGateway pushGateway) throws IllegalAccessException, NoSuc } @Test - public void testPush() throws IOException { + void testPush() throws IOException { mockServerClient .when(request().withMethod("PUT").withPath("/metrics/job/j")) .respond(response().withStatusCode(202)); @@ -78,7 +78,7 @@ public void testPush() throws IOException { } @Test - public void testPush200Response() throws IOException { + void testPush200Response() throws IOException { mockServerClient .when(request().withMethod("PUT").withPath("/metrics/job/j")) .respond(response().withStatusCode(200)); @@ -92,7 +92,7 @@ public void testPush200Response() throws IOException { } @Test - public void testNon202ResponseThrows() { + void testNon202ResponseThrows() { mockServerClient .when(request().withMethod("PUT").withPath("/metrics/job/j")) .respond(response().withStatusCode(500)); @@ -114,7 +114,7 @@ public void testNon202ResponseThrows() { } @Test - public void testPushCollector() throws IOException { + void testPushCollector() throws IOException { mockServerClient .when(request().withMethod("PUT").withPath("/metrics/job/j")) .respond(response().withStatusCode(202)); @@ -128,7 +128,7 @@ public void testPushCollector() throws IOException { } @Test - public void testPushWithGroupingKey() throws IOException { + void testPushWithGroupingKey() throws IOException { mockServerClient .when(request().withMethod("PUT").withPath("/metrics/job/j/l/v")) .respond(response().withStatusCode(202)); @@ -143,7 +143,7 @@ public void testPushWithGroupingKey() throws IOException { } @Test - public void testPushWithEscapedGroupingKey() throws IOException { + void testPushWithEscapedGroupingKey() throws IOException { mockServerClient .when(request().withMethod("PUT").withPath("/metrics/job/j/U__l_2e_1/v1")) .respond(response().withStatusCode(202)); @@ -158,7 +158,7 @@ public void testPushWithEscapedGroupingKey() throws IOException { } @Test - public void testPushWithMultiGroupingKey() throws IOException { + void testPushWithMultiGroupingKey() throws IOException { mockServerClient .when(request().withMethod("PUT").withPath("/metrics/job/j/l/v/l2/v2")) .respond(response().withStatusCode(202)); @@ -174,7 +174,7 @@ public void testPushWithMultiGroupingKey() throws IOException { } @Test - public void testPushWithMultiEscapedGroupingKey() throws IOException { + void testPushWithMultiEscapedGroupingKey() throws IOException { mockServerClient .when(request().withMethod("PUT").withPath("/metrics/job/j/U__l_2e_1/v1/U__l_2e_2/v2")) @@ -191,7 +191,7 @@ public void testPushWithMultiEscapedGroupingKey() throws IOException { } @Test - public void testPushWithEmptyLabelGroupingKey() throws IOException { + void testPushWithEmptyLabelGroupingKey() throws IOException { mockServerClient .when(request().withMethod("PUT").withPath("/metrics/job/j/l/v/l2@base64/=")) .respond(response().withStatusCode(202)); @@ -207,7 +207,7 @@ public void testPushWithEmptyLabelGroupingKey() throws IOException { } @Test - public void testPushWithGroupingKeyWithSlashes() throws IOException { + void testPushWithGroupingKeyWithSlashes() throws IOException { mockServerClient .when( request().withMethod("PUT").withPath("/metrics/job@base64/YS9i/l/v/l2@base64/75-_Lw==")) @@ -224,7 +224,7 @@ public void testPushWithGroupingKeyWithSlashes() throws IOException { } @Test - public void testPushCollectorWithGroupingKey() throws IOException { + void testPushCollectorWithGroupingKey() throws IOException { mockServerClient .when(request().withMethod("PUT").withPath("/metrics/job/j/l/v")) .respond(response().withStatusCode(202)); @@ -239,7 +239,7 @@ public void testPushCollectorWithGroupingKey() throws IOException { } @Test - public void testPushCollectorWithEscapedGroupingKey() throws IOException { + void testPushCollectorWithEscapedGroupingKey() throws IOException { mockServerClient .when(request().withMethod("PUT").withPath("/metrics/job/j/U__l_2e_1/v1")) .respond(response().withStatusCode(202)); @@ -254,7 +254,7 @@ public void testPushCollectorWithEscapedGroupingKey() throws IOException { } @Test - public void testPushAdd() throws IOException { + void testPushAdd() throws IOException { mockServerClient .when(request().withMethod("POST").withPath("/metrics/job/j")) .respond(response().withStatusCode(202)); @@ -268,7 +268,7 @@ public void testPushAdd() throws IOException { } @Test - public void testPushAddCollector() throws IOException { + void testPushAddCollector() throws IOException { mockServerClient .when(request().withMethod("POST").withPath("/metrics/job/j")) .respond(response().withStatusCode(202)); @@ -278,7 +278,7 @@ public void testPushAddCollector() throws IOException { } @Test - public void testPushAddWithGroupingKey() throws IOException { + void testPushAddWithGroupingKey() throws IOException { mockServerClient .when(request().withMethod("POST").withPath("/metrics/job/j/l/v")) .respond(response().withStatusCode(202)); @@ -293,7 +293,7 @@ public void testPushAddWithGroupingKey() throws IOException { } @Test - public void testPushAddWithEscapedGroupingKey() throws IOException { + void testPushAddWithEscapedGroupingKey() throws IOException { mockServerClient .when(request().withMethod("POST").withPath("/metrics/job/j/U__l_2e_1/v1")) .respond(response().withStatusCode(202)); @@ -308,7 +308,7 @@ public void testPushAddWithEscapedGroupingKey() throws IOException { } @Test - public void testPushAddCollectorWithGroupingKey() throws IOException { + void testPushAddCollectorWithGroupingKey() throws IOException { mockServerClient .when(request().withMethod("POST").withPath("/metrics/job/j/l/v")) .respond(response().withStatusCode(202)); @@ -323,7 +323,7 @@ public void testPushAddCollectorWithGroupingKey() throws IOException { } @Test - public void testPushAddCollectorWithEscapedGroupingKey() throws IOException { + void testPushAddCollectorWithEscapedGroupingKey() throws IOException { mockServerClient .when(request().withMethod("POST").withPath("/metrics/job/j/U__l_2e_1/v1")) @@ -339,7 +339,7 @@ public void testPushAddCollectorWithEscapedGroupingKey() throws IOException { } @Test - public void testDelete() throws IOException { + void testDelete() throws IOException { mockServerClient .when(request().withMethod("DELETE").withPath("/metrics/job/j")) .respond(response().withStatusCode(202)); @@ -349,7 +349,7 @@ public void testDelete() throws IOException { } @Test - public void testDeleteWithGroupingKey() throws IOException { + void testDeleteWithGroupingKey() throws IOException { mockServerClient .when(request().withMethod("DELETE").withPath("/metrics/job/j/l/v")) .respond(response().withStatusCode(202)); @@ -363,7 +363,7 @@ public void testDeleteWithGroupingKey() throws IOException { } @Test - public void testDeleteWithEscapedGroupingKey() throws IOException { + void testDeleteWithEscapedGroupingKey() throws IOException { mockServerClient .when(request().withMethod("DELETE").withPath("/metrics/job/j/U__l_2e_1/v1")) @@ -378,7 +378,7 @@ public void testDeleteWithEscapedGroupingKey() throws IOException { } @Test - public void testInstanceIpGroupingKey() throws IOException { + void testInstanceIpGroupingKey() throws IOException { String ip = InetAddress.getLocalHost().getHostAddress(); assertThat(ip).isNotEmpty(); mockServerClient @@ -395,7 +395,7 @@ public void testInstanceIpGroupingKey() throws IOException { } @Test - public void testInstanceIpEscapedGroupingKey() throws IOException { + void testInstanceIpEscapedGroupingKey() throws IOException { String ip = InetAddress.getLocalHost().getHostAddress(); assertThat(ip).isNotEmpty(); @@ -416,7 +416,7 @@ public void testInstanceIpEscapedGroupingKey() throws IOException { } @Test - public void testEscapingSchemeDefaultValue() throws IllegalAccessException, NoSuchFieldException { + void testEscapingSchemeDefaultValue() throws IllegalAccessException, NoSuchFieldException { PushGateway pg = PushGateway.builder() .address("localhost:" + mockServerClient.getPort()) diff --git a/prometheus-metrics-exporter-servlet-jakarta/src/test/java/io/prometheus/metrics/exporter/servlet/jakarta/HttpExchangeAdapterTest.java b/prometheus-metrics-exporter-servlet-jakarta/src/test/java/io/prometheus/metrics/exporter/servlet/jakarta/HttpExchangeAdapterTest.java index 62fe74ae5..7a795cc04 100644 --- a/prometheus-metrics-exporter-servlet-jakarta/src/test/java/io/prometheus/metrics/exporter/servlet/jakarta/HttpExchangeAdapterTest.java +++ b/prometheus-metrics-exporter-servlet-jakarta/src/test/java/io/prometheus/metrics/exporter/servlet/jakarta/HttpExchangeAdapterTest.java @@ -18,7 +18,7 @@ class HttpExchangeAdapterTest { @Test - public void testRequestGetQueryString() { + void testRequestGetQueryString() { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); when(servletRequest.getQueryString()).thenReturn("name[]=test"); @@ -30,7 +30,7 @@ public void testRequestGetQueryString() { } @Test - public void testRequestGetHeaders() { + void testRequestGetHeaders() { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); when(servletRequest.getHeaders("Accept")) @@ -43,7 +43,7 @@ public void testRequestGetHeaders() { } @Test - public void testRequestGetMethod() { + void testRequestGetMethod() { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); when(servletRequest.getMethod()).thenReturn("GET"); @@ -55,7 +55,7 @@ public void testRequestGetMethod() { } @Test - public void testRequestGetRequestPath() { + void testRequestGetRequestPath() { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); when(servletRequest.getContextPath()).thenReturn("/app"); @@ -69,7 +69,7 @@ public void testRequestGetRequestPath() { } @Test - public void testRequestGetRequestPathWithPathInfo() { + void testRequestGetRequestPathWithPathInfo() { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); when(servletRequest.getContextPath()).thenReturn("/app"); @@ -83,7 +83,7 @@ public void testRequestGetRequestPathWithPathInfo() { } @Test - public void testResponseSetHeader() { + void testResponseSetHeader() { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); @@ -95,7 +95,7 @@ public void testResponseSetHeader() { } @Test - public void testResponseSendHeadersAndGetBody() throws IOException { + void testResponseSendHeadersAndGetBody() throws IOException { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); ServletOutputStream outputStream = mock(ServletOutputStream.class); @@ -112,7 +112,7 @@ public void testResponseSendHeadersAndGetBody() throws IOException { } @Test - public void testResponseSendHeadersWithContentLengthAlreadySet() throws IOException { + void testResponseSendHeadersWithContentLengthAlreadySet() throws IOException { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); ServletOutputStream outputStream = mock(ServletOutputStream.class); @@ -129,7 +129,7 @@ public void testResponseSendHeadersWithContentLengthAlreadySet() throws IOExcept } @Test - public void testHandleIOException() { + void testHandleIOException() { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); @@ -142,7 +142,7 @@ public void testHandleIOException() { } @Test - public void testHandleRuntimeException() { + void testHandleRuntimeException() { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); @@ -155,7 +155,7 @@ public void testHandleRuntimeException() { } @Test - public void testClose() { + void testClose() { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); diff --git a/prometheus-metrics-exporter-servlet-jakarta/src/test/java/io/prometheus/metrics/exporter/servlet/jakarta/PrometheusMetricsServletTest.java b/prometheus-metrics-exporter-servlet-jakarta/src/test/java/io/prometheus/metrics/exporter/servlet/jakarta/PrometheusMetricsServletTest.java index 6d5e03a71..5d0d66bfd 100644 --- a/prometheus-metrics-exporter-servlet-jakarta/src/test/java/io/prometheus/metrics/exporter/servlet/jakarta/PrometheusMetricsServletTest.java +++ b/prometheus-metrics-exporter-servlet-jakarta/src/test/java/io/prometheus/metrics/exporter/servlet/jakarta/PrometheusMetricsServletTest.java @@ -23,14 +23,14 @@ class PrometheusMetricsServletTest { private Counter testCounter; @BeforeEach - public void setUp() { + void setUp() { registry = new PrometheusRegistry(); testCounter = Counter.builder().name("test_counter").help("Test counter").register(registry); testCounter.inc(42); } @Test - public void testDoGetWritesMetrics() throws IOException { + void testDoGetWritesMetrics() throws IOException { HttpServletRequest request = mock(HttpServletRequest.class); HttpServletResponse response = mock(HttpServletResponse.class); @@ -69,13 +69,13 @@ public void setWriteListener(WriteListener writeListener) {} } @Test - public void testServletUsesDefaultRegistry() { + void testServletUsesDefaultRegistry() { PrometheusMetricsServlet servlet = new PrometheusMetricsServlet(); assertThat(servlet).isNotNull(); } @Test - public void testServletWithCustomRegistry() { + void testServletWithCustomRegistry() { PrometheusMetricsServlet servlet = new PrometheusMetricsServlet(registry); assertThat(servlet).isNotNull(); } diff --git a/prometheus-metrics-exporter-servlet-javax/src/test/java/io/prometheus/metrics/exporter/servlet/javax/HttpExchangeAdapterTest.java b/prometheus-metrics-exporter-servlet-javax/src/test/java/io/prometheus/metrics/exporter/servlet/javax/HttpExchangeAdapterTest.java index 144019f0d..f4f1f0f3f 100644 --- a/prometheus-metrics-exporter-servlet-javax/src/test/java/io/prometheus/metrics/exporter/servlet/javax/HttpExchangeAdapterTest.java +++ b/prometheus-metrics-exporter-servlet-javax/src/test/java/io/prometheus/metrics/exporter/servlet/javax/HttpExchangeAdapterTest.java @@ -19,7 +19,7 @@ class HttpExchangeAdapterTest { @Test - public void testRequestGetQueryString() { + void testRequestGetQueryString() { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); when(servletRequest.getQueryString()).thenReturn("name[]=test"); @@ -31,7 +31,7 @@ public void testRequestGetQueryString() { } @Test - public void testRequestGetHeaders() { + void testRequestGetHeaders() { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); when(servletRequest.getHeaders("Accept")) @@ -44,7 +44,7 @@ public void testRequestGetHeaders() { } @Test - public void testRequestGetMethod() { + void testRequestGetMethod() { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); when(servletRequest.getMethod()).thenReturn("GET"); @@ -56,7 +56,7 @@ public void testRequestGetMethod() { } @Test - public void testRequestGetRequestPath() { + void testRequestGetRequestPath() { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); when(servletRequest.getContextPath()).thenReturn("/app"); @@ -70,7 +70,7 @@ public void testRequestGetRequestPath() { } @Test - public void testRequestGetRequestPathWithPathInfo() { + void testRequestGetRequestPathWithPathInfo() { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); when(servletRequest.getContextPath()).thenReturn("/app"); @@ -84,7 +84,7 @@ public void testRequestGetRequestPathWithPathInfo() { } @Test - public void testResponseSetHeader() { + void testResponseSetHeader() { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); @@ -96,7 +96,7 @@ public void testResponseSetHeader() { } @Test - public void testResponseSendHeadersAndGetBody() throws IOException { + void testResponseSendHeadersAndGetBody() throws IOException { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); ServletOutputStream outputStream = @@ -125,7 +125,7 @@ public void setWriteListener(WriteListener writeListener) {} } @Test - public void testResponseSendHeadersWithContentLengthAlreadySet() throws IOException { + void testResponseSendHeadersWithContentLengthAlreadySet() throws IOException { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); ServletOutputStream outputStream = @@ -154,7 +154,7 @@ public void setWriteListener(WriteListener writeListener) {} } @Test - public void testHandleIOException() { + void testHandleIOException() { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); @@ -167,7 +167,7 @@ public void testHandleIOException() { } @Test - public void testHandleRuntimeException() { + void testHandleRuntimeException() { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); @@ -180,7 +180,7 @@ public void testHandleRuntimeException() { } @Test - public void testClose() { + void testClose() { HttpServletRequest servletRequest = mock(HttpServletRequest.class); HttpServletResponse servletResponse = mock(HttpServletResponse.class); diff --git a/prometheus-metrics-exporter-servlet-javax/src/test/java/io/prometheus/metrics/exporter/servlet/javax/PrometheusMetricsServletTest.java b/prometheus-metrics-exporter-servlet-javax/src/test/java/io/prometheus/metrics/exporter/servlet/javax/PrometheusMetricsServletTest.java index f847ca60c..0b3c5e5f6 100644 --- a/prometheus-metrics-exporter-servlet-javax/src/test/java/io/prometheus/metrics/exporter/servlet/javax/PrometheusMetricsServletTest.java +++ b/prometheus-metrics-exporter-servlet-javax/src/test/java/io/prometheus/metrics/exporter/servlet/javax/PrometheusMetricsServletTest.java @@ -23,14 +23,14 @@ class PrometheusMetricsServletTest { private Counter testCounter; @BeforeEach - public void setUp() { + void setUp() { registry = new PrometheusRegistry(); testCounter = Counter.builder().name("test_counter").help("Test counter").register(registry); testCounter.inc(42); } @Test - public void testDoGetWritesMetrics() throws IOException { + void testDoGetWritesMetrics() throws IOException { HttpServletRequest request = mock(HttpServletRequest.class); HttpServletResponse response = mock(HttpServletResponse.class); @@ -69,13 +69,13 @@ public void setWriteListener(WriteListener writeListener) {} } @Test - public void testServletUsesDefaultRegistry() { + void testServletUsesDefaultRegistry() { PrometheusMetricsServlet servlet = new PrometheusMetricsServlet(); assertThat(servlet).isNotNull(); } @Test - public void testServletWithCustomRegistry() { + void testServletWithCustomRegistry() { PrometheusMetricsServlet servlet = new PrometheusMetricsServlet(registry); assertThat(servlet).isNotNull(); } diff --git a/prometheus-metrics-exposition-textformats/src/test/java/io/prometheus/metrics/expositionformats/ExpositionFormatsTest.java b/prometheus-metrics-exposition-textformats/src/test/java/io/prometheus/metrics/expositionformats/ExpositionFormatsTest.java index 8a31e41b1..b43688bbb 100644 --- a/prometheus-metrics-exposition-textformats/src/test/java/io/prometheus/metrics/expositionformats/ExpositionFormatsTest.java +++ b/prometheus-metrics-exposition-textformats/src/test/java/io/prometheus/metrics/expositionformats/ExpositionFormatsTest.java @@ -109,7 +109,7 @@ void init() { } @Test - public void testCounterComplete() throws IOException { + void testCounterComplete() throws IOException { String openMetricsText = "# TYPE service:time_seconds counter\n" + "# UNIT service:time_seconds seconds\n" @@ -239,7 +239,7 @@ public void testCounterComplete() throws IOException { } @Test - public void testCounterMinimal() throws IOException { + void testCounterMinimal() throws IOException { String openMetricsText = """ # TYPE my_counter counter @@ -266,7 +266,7 @@ public void testCounterMinimal() throws IOException { } @Test - public void testCounterWithDots() throws IOException { + void testCounterWithDots() throws IOException { String openMetricsText = """ # TYPE U__my_2e_request_2e_count counter @@ -308,7 +308,7 @@ public void testCounterWithDots() throws IOException { } @Test - public void testGaugeComplete() throws IOException { + void testGaugeComplete() throws IOException { String openMetricsText = "# TYPE disk_usage_ratio gauge\n" + "# UNIT disk_usage_ratio ratio\n" @@ -389,7 +389,7 @@ public void testGaugeComplete() throws IOException { } @Test - public void testGaugeMinimal() throws IOException { + void testGaugeMinimal() throws IOException { String openMetricsText = """ # TYPE temperature_centigrade gauge @@ -416,7 +416,7 @@ public void testGaugeMinimal() throws IOException { } @Test - public void testGaugeWithDots() throws IOException { + void testGaugeWithDots() throws IOException { String openMetricsText = """ # TYPE U__my_2e_temperature_2e_celsius gauge @@ -472,7 +472,7 @@ public void testGaugeWithDots() throws IOException { } @Test - public void testGaugeUTF8() throws IOException { + void testGaugeUTF8() throws IOException { String prometheusText = """ # HELP "gauge.name" gauge\\ndoc\\nstr"ing @@ -506,7 +506,7 @@ public void testGaugeUTF8() throws IOException { } @Test - public void testSummaryComplete() throws IOException { + void testSummaryComplete() throws IOException { String openMetricsText = "# TYPE http_request_duration_seconds summary\n" + "# UNIT http_request_duration_seconds seconds\n" @@ -799,7 +799,7 @@ public void testSummaryComplete() throws IOException { } @Test - public void testSummaryWithoutQuantiles() throws IOException { + void testSummaryWithoutQuantiles() throws IOException { String openMetricsText = """ # TYPE latency_seconds summary @@ -843,7 +843,7 @@ public void testSummaryWithoutQuantiles() throws IOException { } @Test - public void testSummaryNoCountAndSum() throws IOException { + void testSummaryNoCountAndSum() throws IOException { String openMetricsText = """ # TYPE latency_seconds summary @@ -881,7 +881,7 @@ public void testSummaryNoCountAndSum() throws IOException { } @Test - public void testSummaryJustCount() throws IOException { + void testSummaryJustCount() throws IOException { String openMetricsText = """ # TYPE latency_seconds summary @@ -916,7 +916,7 @@ public void testSummaryJustCount() throws IOException { } @Test - public void testSummaryJustSum() throws IOException { + void testSummaryJustSum() throws IOException { String openMetricsText = """ # TYPE latency_seconds summary @@ -951,7 +951,7 @@ public void testSummaryJustSum() throws IOException { } @Test - public void testSummaryEmptyData() throws IOException { + void testSummaryEmptyData() throws IOException { // SummaryData can be present but empty (no count, no sum, no quantiles). // This should be treated like no data is present. SummarySnapshot summary = @@ -969,7 +969,7 @@ public void testSummaryEmptyData() throws IOException { } @Test - public void testSummaryEmptyAndNonEmpty() throws IOException { + void testSummaryEmptyAndNonEmpty() throws IOException { String openMetricsText = """ # TYPE latency_seconds summary @@ -1015,7 +1015,7 @@ public void testSummaryEmptyAndNonEmpty() throws IOException { } @Test - public void testSummaryWithDots() throws IOException { + void testSummaryWithDots() throws IOException { String openMetricsText = """ # TYPE U__my_2e_request_2e_duration_2e_seconds summary @@ -1073,7 +1073,7 @@ public void testSummaryWithDots() throws IOException { } @Test - public void testClassicHistogramComplete() throws Exception { + void testClassicHistogramComplete() throws Exception { String openMetricsText = "# TYPE response_size_bytes histogram\n" + "# UNIT response_size_bytes bytes\n" @@ -1379,7 +1379,7 @@ public void testClassicHistogramComplete() throws Exception { } @Test - public void testClassicHistogramMinimal() throws Exception { + void testClassicHistogramMinimal() throws Exception { // In OpenMetrics a histogram can have a _count if and only if it has a _sum. // In Prometheus format, a histogram can have a _count without a _sum. String openMetricsText = @@ -1427,7 +1427,7 @@ public void testClassicHistogramMinimal() throws Exception { } @Test - public void testClassicHistogramMinimalWithDots() throws Exception { + void testClassicHistogramMinimalWithDots() throws Exception { String openMetricsText = """ # TYPE "request.latency_seconds" histogram @@ -1458,7 +1458,7 @@ public void testClassicHistogramMinimalWithDots() throws Exception { } @Test - public void testClassicHistogramCountAndSum() throws Exception { + void testClassicHistogramCountAndSum() throws Exception { String openMetricsText = """ # TYPE request_latency_seconds histogram @@ -1509,7 +1509,7 @@ public void testClassicHistogramCountAndSum() throws Exception { } @Test - public void testClassicGaugeHistogramComplete() throws IOException { + void testClassicGaugeHistogramComplete() throws IOException { String openMetricsText = "# TYPE cache_size_bytes gaugehistogram\n" + "# UNIT cache_size_bytes bytes\n" @@ -1805,7 +1805,7 @@ public void testClassicGaugeHistogramComplete() throws IOException { } @Test - public void testClassicGaugeHistogramMinimal() throws IOException { + void testClassicGaugeHistogramMinimal() throws IOException { // In OpenMetrics a histogram can have a _count if and only if it has a _sum. // In Prometheus format, a histogram can have a _count without a _sum. String openMetricsText = @@ -1855,7 +1855,7 @@ public void testClassicGaugeHistogramMinimal() throws IOException { } @Test - public void testClassicGaugeHistogramCountAndSum() throws IOException { + void testClassicGaugeHistogramCountAndSum() throws IOException { String openMetricsText = """ # TYPE queue_size_bytes gaugehistogram @@ -1909,7 +1909,7 @@ public void testClassicGaugeHistogramCountAndSum() throws IOException { } @Test - public void testClassicHistogramWithDots() throws IOException { + void testClassicHistogramWithDots() throws IOException { String openMetricsText = """ # TYPE U__my_2e_request_2e_duration_2e_seconds histogram @@ -1981,7 +1981,7 @@ public void testClassicHistogramWithDots() throws IOException { } @Test - public void testNativeHistogramComplete() throws IOException { + void testNativeHistogramComplete() throws IOException { String openMetricsText = "# TYPE response_size_bytes histogram\n" + "# UNIT response_size_bytes bytes\n" @@ -2292,7 +2292,7 @@ public void testNativeHistogramComplete() throws IOException { } @Test - public void testNativeHistogramMinimal() throws IOException { + void testNativeHistogramMinimal() throws IOException { String openMetricsText = """ # TYPE latency_seconds histogram @@ -2330,7 +2330,7 @@ public void testNativeHistogramMinimal() throws IOException { } @Test - public void testNativeHistogramWithDots() throws IOException { + void testNativeHistogramWithDots() throws IOException { String openMetricsText = """ # TYPE U__my_2e_request_2e_duration_2e_seconds histogram @@ -2409,7 +2409,7 @@ public void testNativeHistogramWithDots() throws IOException { // TODO: Gauge Native Histogram @Test - public void testInfo() throws IOException { + void testInfo() throws IOException { String openMetrics = """ # TYPE version info @@ -2439,7 +2439,7 @@ public void testInfo() throws IOException { } @Test - public void testInfoWithDots() throws IOException { + void testInfoWithDots() throws IOException { String openMetricsText = """ # TYPE U__jvm_2e_status info @@ -2478,7 +2478,7 @@ public void testInfoWithDots() throws IOException { } @Test - public void testStateSetComplete() throws IOException { + void testStateSetComplete() throws IOException { String openMetrics = "# TYPE state stateset\n" + "# HELP state complete state set example\n" @@ -2536,7 +2536,7 @@ public void testStateSetComplete() throws IOException { } @Test - public void testStateSetMinimal() throws IOException { + void testStateSetMinimal() throws IOException { String openMetrics = """ # TYPE state stateset @@ -2566,7 +2566,7 @@ public void testStateSetMinimal() throws IOException { } @Test - public void testStateSetWithDots() throws IOException { + void testStateSetWithDots() throws IOException { String openMetricsText = """ # TYPE U__my_2e_application_2e_state stateset @@ -2614,7 +2614,7 @@ public void testStateSetWithDots() throws IOException { } @Test - public void testUnknownComplete() throws IOException { + void testUnknownComplete() throws IOException { String openMetrics = "# TYPE my_special_thing_bytes unknown\n" + "# UNIT my_special_thing_bytes bytes\n" @@ -2679,7 +2679,7 @@ public void testUnknownComplete() throws IOException { } @Test - public void testUnknownMinimal() throws IOException { + void testUnknownMinimal() throws IOException { String openMetrics = """ # TYPE other unknown @@ -2703,7 +2703,7 @@ public void testUnknownMinimal() throws IOException { } @Test - public void testUnknownWithDots() throws IOException { + void testUnknownWithDots() throws IOException { String openMetrics = """ # TYPE U__some_2e_unknown_2e_metric__bytes unknown @@ -2756,7 +2756,7 @@ public void testUnknownWithDots() throws IOException { } @Test - public void testHelpEscape() throws IOException { + void testHelpEscape() throws IOException { String openMetrics = """ # TYPE test counter @@ -2783,7 +2783,7 @@ public void testHelpEscape() throws IOException { } @Test - public void testLabelValueEscape() throws IOException { + void testLabelValueEscape() throws IOException { String openMetrics = """ # TYPE test counter @@ -2826,7 +2826,7 @@ public void testFindWriter(String acceptHeaderValue, String expectedFmt) { } @Test - public void testWrite() throws IOException { + void testWrite() throws IOException { ByteArrayOutputStream buff = new ByteArrayOutputStream(new AtomicInteger(2 << 9).get() + 1024); ExpositionFormats expositionFormats = ExpositionFormats.init(); UnknownSnapshot unknown = diff --git a/prometheus-metrics-instrumentation-caffeine/src/test/java/io/prometheus/metrics/instrumentation/caffeine/CacheMetricsCollectorTest.java b/prometheus-metrics-instrumentation-caffeine/src/test/java/io/prometheus/metrics/instrumentation/caffeine/CacheMetricsCollectorTest.java index 3a7b634a7..d2d12aa11 100644 --- a/prometheus-metrics-instrumentation-caffeine/src/test/java/io/prometheus/metrics/instrumentation/caffeine/CacheMetricsCollectorTest.java +++ b/prometheus-metrics-instrumentation-caffeine/src/test/java/io/prometheus/metrics/instrumentation/caffeine/CacheMetricsCollectorTest.java @@ -25,7 +25,7 @@ @SuppressWarnings("CheckReturnValue") class CacheMetricsCollectorTest { // This enum was added to simplify test parametrization on argument options. - public enum Options { + enum Options { LEGACY(false, false), COLLECT_EVICTION_WEIGHT_AS_COUNTER(true, false), COLLECT_WEIGHTED_SIZE(false, true), @@ -205,7 +205,7 @@ public void weightedCacheExposesMetricsForHitMissAndEvictionWeightedSize(Options @SuppressWarnings("unchecked") @Test - public void loadingCacheExposesMetricsForLoadsAndExceptions() throws Exception { + void loadingCacheExposesMetricsForLoadsAndExceptions() throws Exception { final CacheLoader loader = mock(CacheLoader.class); when(loader.load(anyString())) .thenReturn("First User") diff --git a/prometheus-metrics-instrumentation-dropwizard/src/test/java/io/prometheus/metrics/instrumentation/dropwizard/DropwizardExportsTest.java b/prometheus-metrics-instrumentation-dropwizard/src/test/java/io/prometheus/metrics/instrumentation/dropwizard/DropwizardExportsTest.java index ba5407942..c4c0b6241 100644 --- a/prometheus-metrics-instrumentation-dropwizard/src/test/java/io/prometheus/metrics/instrumentation/dropwizard/DropwizardExportsTest.java +++ b/prometheus-metrics-instrumentation-dropwizard/src/test/java/io/prometheus/metrics/instrumentation/dropwizard/DropwizardExportsTest.java @@ -23,7 +23,7 @@ class DropwizardExportsTest { private MetricRegistry metricRegistry; @BeforeEach - public void setUp() { + void setUp() { metricRegistry = new MetricRegistry(); DropwizardExports.builder() .dropwizardRegistry(metricRegistry) @@ -32,21 +32,21 @@ public void setUp() { } @Test - public void testBuilderThrowsErrorOnNullRegistry() { + void testBuilderThrowsErrorOnNullRegistry() { assertThatThrownBy( () -> DropwizardExports.builder().dropwizardRegistry(null).register(registry)) .isInstanceOf(IllegalArgumentException.class); } @Test - public void testBuilderCreatesOkay() { + void testBuilderCreatesOkay() { assertThatCode( () -> DropwizardExports.builder().dropwizardRegistry(metricRegistry).register(registry)) .doesNotThrowAnyException(); } @Test - public void testCounter() { + void testCounter() { metricRegistry.counter("foo.bar").inc(1); String expected = """ @@ -60,7 +60,7 @@ public void testCounter() { } @Test - public void testGauge() { + void testGauge() { // don't convert to lambda, as we need to test the type Gauge integerGauge = new Gauge() { @@ -128,7 +128,7 @@ public Boolean getValue() { } @Test - public void testInvalidGaugeType() { + void testInvalidGaugeType() { Gauge invalidGauge = () -> "foobar"; metricRegistry.register("invalid_gauge", invalidGauge); @@ -138,7 +138,7 @@ public void testInvalidGaugeType() { } @Test - public void testGaugeReturningNullValue() { + void testGaugeReturningNullValue() { Gauge invalidGauge = () -> null; metricRegistry.register("invalid_gauge", invalidGauge); String expected = "# EOF\n"; @@ -146,7 +146,7 @@ public void testGaugeReturningNullValue() { } @Test - public void testHistogram() { + void testHistogram() { // just test the standard mapper final MetricRegistry metricRegistry = new MetricRegistry(); PrometheusRegistry pmRegistry = new PrometheusRegistry(); @@ -199,7 +199,7 @@ public void testHistogram() { } @Test - public void testMeter() { + void testMeter() { Meter meter = metricRegistry.meter("meter"); meter.mark(); meter.mark(); @@ -215,7 +215,7 @@ public void testMeter() { } @Test - public void testTimer() throws InterruptedException { + void testTimer() throws InterruptedException { final MetricRegistry metricRegistry = new MetricRegistry(); DropwizardExports exports = new DropwizardExports(metricRegistry); Timer t = metricRegistry.timer("timer"); @@ -239,7 +239,7 @@ public void testTimer() throws InterruptedException { } @Test - public void testThatMetricHelpUsesOriginalDropwizardName() { + void testThatMetricHelpUsesOriginalDropwizardName() { metricRegistry.timer("my.application.namedTimer1"); metricRegistry.counter("my.application.namedCounter1"); metricRegistry.meter("my.application.namedMeter1"); diff --git a/prometheus-metrics-instrumentation-dropwizard5/src/test/java/io/prometheus/metrics/instrumentation/dropwizard5/DropwizardExportsTest.java b/prometheus-metrics-instrumentation-dropwizard5/src/test/java/io/prometheus/metrics/instrumentation/dropwizard5/DropwizardExportsTest.java index ff76438d1..7a7dcdf31 100644 --- a/prometheus-metrics-instrumentation-dropwizard5/src/test/java/io/prometheus/metrics/instrumentation/dropwizard5/DropwizardExportsTest.java +++ b/prometheus-metrics-instrumentation-dropwizard5/src/test/java/io/prometheus/metrics/instrumentation/dropwizard5/DropwizardExportsTest.java @@ -24,13 +24,13 @@ class DropwizardExportsTest { private MetricRegistry metricRegistry; @BeforeEach - public void setUp() { + void setUp() { metricRegistry = new MetricRegistry(); DropwizardExports.builder().dropwizardRegistry(metricRegistry).register(registry); } @Test - public void testCounter() { + void testCounter() { metricRegistry.counter("foo.bar").inc(1); String expected = """ @@ -44,7 +44,7 @@ public void testCounter() { } @Test - public void testGauge() { + void testGauge() { // don't convert to lambda, as we need to test the type Gauge integerGauge = new Gauge() { @@ -112,7 +112,7 @@ public Boolean getValue() { } @Test - public void testInvalidGaugeType() { + void testInvalidGaugeType() { Gauge invalidGauge = () -> "foobar"; metricRegistry.register(MetricName.parse("invalid_gauge"), invalidGauge); @@ -122,7 +122,7 @@ public void testInvalidGaugeType() { } @Test - public void testGaugeReturningNullValue() { + void testGaugeReturningNullValue() { Gauge invalidGauge = () -> null; metricRegistry.register(MetricName.parse("invalid_gauge"), invalidGauge); String expected = "# EOF\n"; @@ -130,7 +130,7 @@ public void testGaugeReturningNullValue() { } @Test - public void testHistogram() { + void testHistogram() { // just test the standard mapper final MetricRegistry metricRegistry = new MetricRegistry(); PrometheusRegistry pmRegistry = new PrometheusRegistry(); @@ -204,7 +204,7 @@ public void testHistogram() { } @Test - public void testMeter() { + void testMeter() { Meter meter = metricRegistry.meter("meter"); meter.mark(); meter.mark(); @@ -220,7 +220,7 @@ public void testMeter() { } @Test - public void testTimer() throws InterruptedException { + void testTimer() throws InterruptedException { final MetricRegistry metricRegistry = new MetricRegistry(); DropwizardExports exports = new DropwizardExports(metricRegistry); Timer t = metricRegistry.timer("timer"); @@ -246,7 +246,7 @@ public void testTimer() throws InterruptedException { } @Test - public void testThatMetricHelpUsesOriginalDropwizardName() { + void testThatMetricHelpUsesOriginalDropwizardName() { metricRegistry.timer("my.application.namedTimer1"); metricRegistry.counter("my.application.namedCounter1"); diff --git a/prometheus-metrics-instrumentation-dropwizard5/src/test/java/io/prometheus/metrics/instrumentation/dropwizard5/labels/CustomLabelMapperTest.java b/prometheus-metrics-instrumentation-dropwizard5/src/test/java/io/prometheus/metrics/instrumentation/dropwizard5/labels/CustomLabelMapperTest.java index 44c365898..8c61e1a01 100644 --- a/prometheus-metrics-instrumentation-dropwizard5/src/test/java/io/prometheus/metrics/instrumentation/dropwizard5/labels/CustomLabelMapperTest.java +++ b/prometheus-metrics-instrumentation-dropwizard5/src/test/java/io/prometheus/metrics/instrumentation/dropwizard5/labels/CustomLabelMapperTest.java @@ -20,18 +20,18 @@ class CustomLabelMapperTest { private MetricRegistry metricRegistry; @BeforeEach - public void setUp() { + void setUp() { metricRegistry = new MetricRegistry(); } @Test - public void test_WHEN_EmptyConfig_THEN_Fail() { + void test_WHEN_EmptyConfig_THEN_Fail() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new CustomLabelMapper(Collections.emptyList())); } @Test - public void test_WHEN_NoMatches_THEN_ShouldReturnDefaultSample() { + void test_WHEN_NoMatches_THEN_ShouldReturnDefaultSample() { final List mapperConfigs = Arrays.asList( new MapperConfig("client-nope.*.*.*"), @@ -56,7 +56,7 @@ public void test_WHEN_NoMatches_THEN_ShouldReturnDefaultSample() { } @Test - public void test_WHEN_OneMatch_THEN_ShouldReturnConverted() { + void test_WHEN_OneMatch_THEN_ShouldReturnConverted() { final Map labels = new HashMap(); labels.put("service", "${0}"); final MapperConfig mapperConfig = @@ -86,7 +86,7 @@ public void test_WHEN_OneMatch_THEN_ShouldReturnConverted() { } @Test - public void test_WHEN_MoreMatches_THEN_ShouldReturnFirstOne() { + void test_WHEN_MoreMatches_THEN_ShouldReturnFirstOne() { final Map labels = new HashMap<>(); labels.put("service", "${0}"); final MapperConfig mapperConfig = @@ -117,7 +117,7 @@ public void test_WHEN_MoreMatches_THEN_ShouldReturnFirstOne() { } @Test - public void test_WHEN_MoreMatchesReverseOrder_THEN_ShouldReturnFirstOne() { + void test_WHEN_MoreMatchesReverseOrder_THEN_ShouldReturnFirstOne() { final Map labels = new LinkedHashMap<>(); labels.put("service", "${0}"); labels.put("status", "${1}"); @@ -154,7 +154,7 @@ public void test_WHEN_MoreMatchesReverseOrder_THEN_ShouldReturnFirstOne() { } @Test - public void test_WHEN_MoreToFormatInLabelsAndName_THEN_ShouldReturnCorrectSample() { + void test_WHEN_MoreToFormatInLabelsAndName_THEN_ShouldReturnCorrectSample() { final Map labels = new LinkedHashMap<>(); labels.put("service", "${0}_${1}"); labels.put("status", "s_${1}"); @@ -187,7 +187,7 @@ public void test_WHEN_MoreToFormatInLabelsAndName_THEN_ShouldReturnCorrectSample } @Test - public void test_WHEN_AdditionalLabels_THEN_ShouldReturnCorrectSample() { + void test_WHEN_AdditionalLabels_THEN_ShouldReturnCorrectSample() { final Map labels = new LinkedHashMap<>(); labels.put("service", "${0}"); labels.put("status", "s_${1}"); diff --git a/prometheus-metrics-instrumentation-dropwizard5/src/test/java/io/prometheus/metrics/instrumentation/dropwizard5/labels/GraphiteNamePatternTest.java b/prometheus-metrics-instrumentation-dropwizard5/src/test/java/io/prometheus/metrics/instrumentation/dropwizard5/labels/GraphiteNamePatternTest.java index ed27d7f22..100703d94 100644 --- a/prometheus-metrics-instrumentation-dropwizard5/src/test/java/io/prometheus/metrics/instrumentation/dropwizard5/labels/GraphiteNamePatternTest.java +++ b/prometheus-metrics-instrumentation-dropwizard5/src/test/java/io/prometheus/metrics/instrumentation/dropwizard5/labels/GraphiteNamePatternTest.java @@ -13,7 +13,7 @@ class GraphiteNamePatternTest { @Test - public void createNew_WHEN_InvalidPattern_THEN_ShouldThrowException() { + void createNew_WHEN_InvalidPattern_THEN_ShouldThrowException() { List invalidPatterns = Arrays.asList( "", @@ -39,7 +39,7 @@ public void createNew_WHEN_InvalidPattern_THEN_ShouldThrowException() { } @Test - public void createNew_WHEN_ValidPattern_THEN_ShouldCreateThePatternSuccessfully() { + void createNew_WHEN_ValidPattern_THEN_ShouldCreateThePatternSuccessfully() { final List validPatterns = Arrays.asList( "org.test.controller.gather.status.400", @@ -54,7 +54,7 @@ public void createNew_WHEN_ValidPattern_THEN_ShouldCreateThePatternSuccessfully( } @Test - public void createNew_WHEN_ValidPattern_THEN_ShouldInitInternalPatternSuccessfully() { + void createNew_WHEN_ValidPattern_THEN_ShouldInitInternalPatternSuccessfully() { final Map validPatterns = new HashMap(); validPatterns.put( "org.test.controller.gather.status.400", "^\\Qorg.test.controller.gather.status.400\\E$"); @@ -74,7 +74,7 @@ public void createNew_WHEN_ValidPattern_THEN_ShouldInitInternalPatternSuccessful } @Test - public void match_WHEN_NotMatchingMetricNameProvided_THEN_ShouldNotMatch() { + void match_WHEN_NotMatchingMetricNameProvided_THEN_ShouldNotMatch() { final GraphiteNamePattern pattern = new GraphiteNamePattern("org.test.controller.*.status.*"); final List notMatchingMetricNamed = Arrays.asList("org.test.controller.status.400", "", null); @@ -87,7 +87,7 @@ public void match_WHEN_NotMatchingMetricNameProvided_THEN_ShouldNotMatch() { } @Test - public void match_WHEN_MatchingMetricNameProvided_THEN_ShouldMatch() { + void match_WHEN_MatchingMetricNameProvided_THEN_ShouldMatch() { final GraphiteNamePattern pattern = new GraphiteNamePattern("org.test.controller.*.status.*"); final List matchingMetricNamed = Arrays.asList( @@ -105,7 +105,7 @@ public void match_WHEN_MatchingMetricNameProvided_THEN_ShouldMatch() { } @Test - public void extractParameters() { + void extractParameters() { GraphiteNamePattern pattern; Map expected = new HashMap(); expected.put("${0}", "gather"); @@ -124,7 +124,7 @@ public void extractParameters() { } @Test - public void extractParameters_WHEN_emptyStringInDottedMetricsName_THEN_ShouldReturnEmptyString() { + void extractParameters_WHEN_emptyStringInDottedMetricsName_THEN_ShouldReturnEmptyString() { GraphiteNamePattern pattern; Map expected = new HashMap(); expected.put("${0}", ""); @@ -135,7 +135,7 @@ public void extractParameters_WHEN_emptyStringInDottedMetricsName_THEN_ShouldRet } @Test - public void extractParameters_WHEN_moreDots_THEN_ShouldReturnNoMatches() { + void extractParameters_WHEN_moreDots_THEN_ShouldReturnNoMatches() { GraphiteNamePattern pattern; pattern = new GraphiteNamePattern("org.test.controller.*.status.*"); Assertions.assertThat(pattern.extractParameters("org.test.controller...status.400")) diff --git a/prometheus-metrics-instrumentation-dropwizard5/src/test/java/io/prometheus/metrics/instrumentation/dropwizard5/labels/MapperConfigTest.java b/prometheus-metrics-instrumentation-dropwizard5/src/test/java/io/prometheus/metrics/instrumentation/dropwizard5/labels/MapperConfigTest.java index a17963e0d..982e8f24e 100644 --- a/prometheus-metrics-instrumentation-dropwizard5/src/test/java/io/prometheus/metrics/instrumentation/dropwizard5/labels/MapperConfigTest.java +++ b/prometheus-metrics-instrumentation-dropwizard5/src/test/java/io/prometheus/metrics/instrumentation/dropwizard5/labels/MapperConfigTest.java @@ -10,20 +10,20 @@ class MapperConfigTest { @Test - public void setMatch_WHEN_ExpressionMatchesPattern_AllGood() { + void setMatch_WHEN_ExpressionMatchesPattern_AllGood() { final MapperConfig mapperConfig = new MapperConfig(); mapperConfig.setMatch("com.company.meter.*"); assertThat(mapperConfig.getMatch()).isEqualTo("com.company.meter.*"); } @Test - public void setMatch_WHEN_ExpressionDoesnNotMatchPattern_ThrowException() { + void setMatch_WHEN_ExpressionDoesnNotMatchPattern_ThrowException() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new MapperConfig().setMatch("com.company.meter.**.yay")); } @Test - public void setLabels_WHEN_ExpressionMatchesPattern_AllGood() { + void setLabels_WHEN_ExpressionMatchesPattern_AllGood() { final MapperConfig mapperConfig = new MapperConfig(); final Map labels = new HashMap<>(); labels.put("valid", "${0}"); @@ -32,7 +32,7 @@ public void setLabels_WHEN_ExpressionMatchesPattern_AllGood() { } @Test - public void setLabels_WHEN_ExpressionDoesnNotMatchPattern_ThrowException() { + void setLabels_WHEN_ExpressionDoesnNotMatchPattern_ThrowException() { final MapperConfig mapperConfig = new MapperConfig(); final Map labels = new HashMap<>(); labels.put("valid", "${0}"); @@ -42,13 +42,13 @@ public void setLabels_WHEN_ExpressionDoesnNotMatchPattern_ThrowException() { } @Test - public void toString_WHEN_EmptyConfig_AllGood() { + void toString_WHEN_EmptyConfig_AllGood() { final MapperConfig mapperConfig = new MapperConfig(); assertThat(mapperConfig).hasToString("MapperConfig{match=null, name=null, labels={}}"); } @Test - public void toString_WHEN_FullyConfigured_AllGood() { + void toString_WHEN_FullyConfigured_AllGood() { final MapperConfig mapperConfig = new MapperConfig(); mapperConfig.setMatch("com.company.meter.*.foo"); mapperConfig.setName("foo"); diff --git a/prometheus-metrics-instrumentation-guava/src/test/java/io/prometheus/metrics/instrumentation/guava/CacheMetricsCollectorTest.java b/prometheus-metrics-instrumentation-guava/src/test/java/io/prometheus/metrics/instrumentation/guava/CacheMetricsCollectorTest.java index 31da91f20..3373afaed 100644 --- a/prometheus-metrics-instrumentation-guava/src/test/java/io/prometheus/metrics/instrumentation/guava/CacheMetricsCollectorTest.java +++ b/prometheus-metrics-instrumentation-guava/src/test/java/io/prometheus/metrics/instrumentation/guava/CacheMetricsCollectorTest.java @@ -23,7 +23,7 @@ class CacheMetricsCollectorTest { @Test - public void cacheExposesMetricsForHitMissAndEviction() { + void cacheExposesMetricsForHitMissAndEviction() { final Cache cache = CacheBuilder.newBuilder().maximumSize(2).recordStats().build(); @@ -73,7 +73,7 @@ public void cacheExposesMetricsForHitMissAndEviction() { @SuppressWarnings("unchecked") @Test - public void loadingCacheExposesMetricsForLoadsAndExceptions() throws Exception { + void loadingCacheExposesMetricsForLoadsAndExceptions() throws Exception { final CacheLoader loader = mock(CacheLoader.class); when(loader.load(anyString())) .thenReturn("First User") @@ -112,7 +112,7 @@ public void loadingCacheExposesMetricsForLoadsAndExceptions() throws Exception { } @Test - public void getPrometheusNamesHasSameSizeAsMetricSizeWhenScraping() { + void getPrometheusNamesHasSameSizeAsMetricSizeWhenScraping() { final CacheMetricsCollector collector = new CacheMetricsCollector(); final PrometheusRegistry registry = new PrometheusRegistry(); @@ -125,7 +125,7 @@ public void getPrometheusNamesHasSameSizeAsMetricSizeWhenScraping() { } @Test - public void collectedMetricNamesAreKnownPrometheusNames() { + void collectedMetricNamesAreKnownPrometheusNames() { final CacheMetricsCollector collector = new CacheMetricsCollector(); final PrometheusRegistry registry = new PrometheusRegistry(); diff --git a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmBufferPoolMetricsTest.java b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmBufferPoolMetricsTest.java index e3bf55fb4..5b320c678 100644 --- a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmBufferPoolMetricsTest.java +++ b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmBufferPoolMetricsTest.java @@ -22,7 +22,7 @@ class JvmBufferPoolMetricsTest { private final BufferPoolMXBean mappedBuffer = Mockito.mock(BufferPoolMXBean.class); @BeforeEach - public void setUp() { + void setUp() { when(directBuffer.getName()).thenReturn("direct"); when(directBuffer.getCount()).thenReturn(2L); when(directBuffer.getMemoryUsed()).thenReturn(1234L); @@ -34,7 +34,7 @@ public void setUp() { } @Test - public void testGoodCase() throws IOException { + void testGoodCase() throws IOException { PrometheusRegistry registry = new PrometheusRegistry(); JvmBufferPoolMetrics.builder() .bufferPoolBeans(Arrays.asList(mappedBuffer, directBuffer)) @@ -64,7 +64,7 @@ public void testGoodCase() throws IOException { } @Test - public void testIgnoredMetricNotScraped() { + void testIgnoredMetricNotScraped() { MetricNameFilter filter = MetricNameFilter.builder().nameMustNotBeEqualTo("jvm_buffer_pool_used_bytes").build(); diff --git a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmClassLoadingMetricsTest.java b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmClassLoadingMetricsTest.java index ac13ab382..7fe86c753 100644 --- a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmClassLoadingMetricsTest.java +++ b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmClassLoadingMetricsTest.java @@ -20,14 +20,14 @@ class JvmClassLoadingMetricsTest { private final ClassLoadingMXBean mockClassLoadingBean = Mockito.mock(ClassLoadingMXBean.class); @BeforeEach - public void setUp() { + void setUp() { when(mockClassLoadingBean.getLoadedClassCount()).thenReturn(1000); when(mockClassLoadingBean.getTotalLoadedClassCount()).thenReturn(2000L); when(mockClassLoadingBean.getUnloadedClassCount()).thenReturn(500L); } @Test - public void testGoodCase() throws IOException { + void testGoodCase() throws IOException { PrometheusRegistry registry = new PrometheusRegistry(); JvmClassLoadingMetrics.builder().classLoadingBean(mockClassLoadingBean).register(registry); MetricSnapshots snapshots = registry.scrape(); @@ -50,7 +50,7 @@ public void testGoodCase() throws IOException { } @Test - public void testIgnoredMetricNotScraped() { + void testIgnoredMetricNotScraped() { MetricNameFilter filter = MetricNameFilter.builder().nameMustNotBeEqualTo("jvm_classes_currently_loaded").build(); diff --git a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmCompilationMetricsTest.java b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmCompilationMetricsTest.java index 73d1a39df..e961d9394 100644 --- a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmCompilationMetricsTest.java +++ b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmCompilationMetricsTest.java @@ -20,13 +20,13 @@ class JvmCompilationMetricsTest { private final CompilationMXBean mockCompilationBean = Mockito.mock(CompilationMXBean.class); @BeforeEach - public void setUp() { + void setUp() { when(mockCompilationBean.getTotalCompilationTime()).thenReturn(10000L); when(mockCompilationBean.isCompilationTimeMonitoringSupported()).thenReturn(true); } @Test - public void testGoodCase() throws IOException { + void testGoodCase() throws IOException { PrometheusRegistry registry = new PrometheusRegistry(); JvmCompilationMetrics.builder().compilationBean(mockCompilationBean).register(registry); MetricSnapshots snapshots = registry.scrape(); @@ -44,7 +44,7 @@ public void testGoodCase() throws IOException { } @Test - public void testIgnoredMetricNotScraped() { + void testIgnoredMetricNotScraped() { MetricNameFilter filter = MetricNameFilter.builder() .nameMustNotBeEqualTo("jvm_compilation_time_seconds_total") diff --git a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmGarbageCollectorMetricsTest.java b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmGarbageCollectorMetricsTest.java index 177f29d2e..0f928ef34 100644 --- a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmGarbageCollectorMetricsTest.java +++ b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmGarbageCollectorMetricsTest.java @@ -23,7 +23,7 @@ class JvmGarbageCollectorMetricsTest { private final GarbageCollectorMXBean mockGcBean2 = Mockito.mock(GarbageCollectorMXBean.class); @BeforeEach - public void setUp() { + void setUp() { when(mockGcBean1.getName()).thenReturn("MyGC1"); when(mockGcBean1.getCollectionCount()).thenReturn(100L); when(mockGcBean1.getCollectionTime()).thenReturn(TimeUnit.SECONDS.toMillis(10)); @@ -33,7 +33,7 @@ public void setUp() { } @Test - public void testGoodCase() throws IOException { + void testGoodCase() throws IOException { PrometheusRegistry registry = new PrometheusRegistry(); JvmGarbageCollectorMetrics.builder() .garbageCollectorBeans(Arrays.asList(mockGcBean1, mockGcBean2)) @@ -56,7 +56,7 @@ public void testGoodCase() throws IOException { } @Test - public void testIgnoredMetricNotScraped() { + void testIgnoredMetricNotScraped() { MetricNameFilter filter = MetricNameFilter.builder().nameMustNotBeEqualTo("jvm_gc_collection_seconds").build(); diff --git a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmMemoryMetricsTest.java b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmMemoryMetricsTest.java index a79ec3b3b..b1916c064 100644 --- a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmMemoryMetricsTest.java +++ b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmMemoryMetricsTest.java @@ -32,7 +32,7 @@ class JvmMemoryMetricsTest { @SuppressWarnings("deprecation") @BeforeEach - public void setUp() { + void setUp() { when(mockMemoryBean.getHeapMemoryUsage()).thenReturn(memoryUsageHeap); when(mockMemoryBean.getNonHeapMemoryUsage()).thenReturn(memoryUsageNonHeap); @@ -80,7 +80,7 @@ public void setUp() { } @Test - public void testGoodCase() throws IOException { + void testGoodCase() throws IOException { PrometheusRegistry registry = new PrometheusRegistry(); JvmMemoryMetrics.builder() .withMemoryBean(mockMemoryBean) @@ -160,7 +160,7 @@ public void testGoodCase() throws IOException { } @Test - public void testIgnoredMetricNotScraped() { + void testIgnoredMetricNotScraped() { MetricNameFilter filter = MetricNameFilter.builder().nameMustNotBeEqualTo("jvm_memory_pool_used_bytes").build(); diff --git a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmMemoryPoolAllocationMetricsTest.java b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmMemoryPoolAllocationMetricsTest.java index 67dd6f2e6..3a8138baf 100644 --- a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmMemoryPoolAllocationMetricsTest.java +++ b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmMemoryPoolAllocationMetricsTest.java @@ -14,7 +14,7 @@ class JvmMemoryPoolAllocationMetricsTest { @Test - public void testListenerLogic() { + void testListenerLogic() { PrometheusRegistry registry = new PrometheusRegistry(); Counter counter = Counter.builder().name("test").labelNames("pool").register(registry); AllocationCountingNotificationListener listener = diff --git a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmMetricsTest.java b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmMetricsTest.java index 551ed35c7..c0553703d 100644 --- a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmMetricsTest.java +++ b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmMetricsTest.java @@ -20,7 +20,7 @@ void setUp() { } @Test - public void testRegisterIdempotent() { + void testRegisterIdempotent() { PrometheusRegistry registry = new PrometheusRegistry(); assertThat(registry.scrape().size()).isZero(); JvmMetrics.builder().register(registry); diff --git a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmNativeMemoryMetricsTest.java b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmNativeMemoryMetricsTest.java index bbf42ecc7..e2f2dcdca 100644 --- a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmNativeMemoryMetricsTest.java +++ b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmNativeMemoryMetricsTest.java @@ -14,7 +14,7 @@ class JvmNativeMemoryMetricsTest { @Test - public void testNativeMemoryTrackingFail() throws IOException { + void testNativeMemoryTrackingFail() throws IOException { JvmNativeMemoryMetrics.isEnabled.set(true); JvmNativeMemoryMetrics.PlatformMBeanServerAdapter adapter = @@ -39,7 +39,7 @@ void nativeMemoryTrackingNotEnabled() { } @Test - public void testNativeMemoryTrackingEmpty() throws IOException { + void testNativeMemoryTrackingEmpty() throws IOException { JvmNativeMemoryMetrics.isEnabled.set(true); JvmNativeMemoryMetrics.PlatformMBeanServerAdapter adapter = @@ -56,7 +56,7 @@ public void testNativeMemoryTrackingEmpty() throws IOException { } @Test - public void testNativeMemoryTrackingDisabled() throws IOException { + void testNativeMemoryTrackingDisabled() throws IOException { JvmNativeMemoryMetrics.isEnabled.set(true); JvmNativeMemoryMetrics.PlatformMBeanServerAdapter adapter = @@ -74,7 +74,7 @@ public void testNativeMemoryTrackingDisabled() throws IOException { } @Test - public void testNativeMemoryTrackingEnabled() throws IOException { + void testNativeMemoryTrackingEnabled() throws IOException { JvmNativeMemoryMetrics.isEnabled.set(true); JvmNativeMemoryMetrics.PlatformMBeanServerAdapter adapter = diff --git a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmRuntimeInfoMetricTest.java b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmRuntimeInfoMetricTest.java index a477065c9..2c6a2773f 100644 --- a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmRuntimeInfoMetricTest.java +++ b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmRuntimeInfoMetricTest.java @@ -11,7 +11,7 @@ class JvmRuntimeInfoMetricTest { @Test - public void testGoodCase() throws IOException { + void testGoodCase() throws IOException { PrometheusRegistry registry = new PrometheusRegistry(); JvmRuntimeInfoMetric.builder() .version("1.8.0_382-b05") diff --git a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmThreadsMetricsTest.java b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmThreadsMetricsTest.java index cd651cc7f..f001fad37 100644 --- a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmThreadsMetricsTest.java +++ b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmThreadsMetricsTest.java @@ -30,7 +30,7 @@ class JvmThreadsMetricsTest { private final ThreadInfo mockThreadInfoRunnable2 = Mockito.mock(ThreadInfo.class); @BeforeEach - public void setUp() { + void setUp() { when(mockThreadsBean.getThreadCount()).thenReturn(300); when(mockThreadsBean.getDaemonThreadCount()).thenReturn(200); when(mockThreadsBean.getPeakThreadCount()).thenReturn(301); @@ -49,7 +49,7 @@ public void setUp() { } @Test - public void testGoodCase() throws IOException { + void testGoodCase() throws IOException { PrometheusRegistry registry = new PrometheusRegistry(); JvmThreadsMetrics.builder().threadBean(mockThreadsBean).isNativeImage(false).register(registry); MetricSnapshots snapshots = registry.scrape(); @@ -90,7 +90,7 @@ public void testGoodCase() throws IOException { } @Test - public void testIgnoredMetricNotScraped() { + void testIgnoredMetricNotScraped() { MetricNameFilter filter = MetricNameFilter.builder().nameMustNotBeEqualTo("jvm_threads_deadlocked").build(); @@ -103,7 +103,7 @@ public void testIgnoredMetricNotScraped() { } @Test - public void testInvalidThreadIds() { + void testInvalidThreadIds() { try { String javaVersion = System.getProperty("java.version"); // Example: "21.0.2" String majorJavaVersion = javaVersion.replaceAll("\\..*", ""); // Example: "21" diff --git a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/ProcessMetricsTest.java b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/ProcessMetricsTest.java index f5804ad7f..9c2efd301 100644 --- a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/ProcessMetricsTest.java +++ b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/ProcessMetricsTest.java @@ -30,7 +30,7 @@ class ProcessMetricsTest { private final RuntimeMXBean runtimeBean = Mockito.mock(RuntimeMXBean.class); @BeforeEach - public void setUp() throws IOException { + void setUp() throws IOException { when(sunOsBean.getProcessCpuTime()).thenReturn(TimeUnit.MILLISECONDS.toNanos(72)); when(sunOsBean.getOpenFileDescriptorCount()).thenReturn(127L); when(sunOsBean.getMaxFileDescriptorCount()).thenReturn(244L); @@ -42,7 +42,7 @@ public void setUp() throws IOException { } @Test - public void testGoodCase() throws IOException { + void testGoodCase() throws IOException { PrometheusRegistry registry = new PrometheusRegistry(); ProcessMetrics.builder() .osBean(sunOsBean) @@ -97,7 +97,7 @@ public void testGoodCase() throws IOException { } @Test - public void testMinimal() throws IOException { + void testMinimal() throws IOException { PrometheusRegistry registry = new PrometheusRegistry(); ProcessMetrics.builder() .osBean(javaOsBean) @@ -119,7 +119,7 @@ public void testMinimal() throws IOException { } @Test - public void testIgnoredMetricNotScraped() { + void testIgnoredMetricNotScraped() { MetricNameFilter filter = MetricNameFilter.builder().nameMustNotBeEqualTo("process_max_fds").build(); diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/registry/MetricNameFilterTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/registry/MetricNameFilterTest.java index 0dc9cdee1..8f554bdc5 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/registry/MetricNameFilterTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/registry/MetricNameFilterTest.java @@ -13,7 +13,7 @@ class MetricNameFilterTest { private final PrometheusRegistry registry = new PrometheusRegistry(); @Test - public void testCounter() { + void testCounter() { registry.register( () -> CounterSnapshot.builder() diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/registry/MultiCollectorNameFilterTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/registry/MultiCollectorNameFilterTest.java index d2a38c3cf..48be456a6 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/registry/MultiCollectorNameFilterTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/registry/MultiCollectorNameFilterTest.java @@ -51,7 +51,7 @@ private boolean collectCalled() { } @Test - public void testPartialFilter() { + void testPartialFilter() { Registry registry = new Registry(Collections.emptyList()); MetricSnapshots snapshots = registry.scrape(name -> name.equals("counter_1")); assertThat(registry.collectCalled()).isTrue(); @@ -60,7 +60,7 @@ public void testPartialFilter() { } @Test - public void testPartialFilterWithPrometheusNames() { + void testPartialFilterWithPrometheusNames() { Registry registry = new Registry(Arrays.asList("counter_1", "gauge_2")); MetricSnapshots snapshots = registry.scrape(name -> name.equals("counter_1")); @@ -70,7 +70,7 @@ public void testPartialFilterWithPrometheusNames() { } @Test - public void testCompleteFilter_CollectCalled() { + void testCompleteFilter_CollectCalled() { Registry registry = new Registry(Collections.emptyList()); MetricSnapshots snapshots = registry.scrape(name -> !name.equals("counter_1") && !name.equals("gauge_2")); @@ -79,7 +79,7 @@ public void testCompleteFilter_CollectCalled() { } @Test - public void testCompleteFilter_CollectNotCalled() { + void testCompleteFilter_CollectNotCalled() { Registry registry = new Registry(Arrays.asList("counter_1", "gauge_2")); MetricSnapshots snapshots = registry.scrape(name -> !name.equals("counter_1") && !name.equals("gauge_2")); diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/registry/PrometheusRegistryTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/registry/PrometheusRegistryTest.java index 9e87f1fc9..3197dabb0 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/registry/PrometheusRegistryTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/registry/PrometheusRegistryTest.java @@ -82,7 +82,7 @@ public List getPrometheusNames() { }; @Test - public void registerNoName() { + void registerNoName() { PrometheusRegistry registry = new PrometheusRegistry(); // If the collector does not have a name at registration time, there is no conflict during // registration. @@ -96,7 +96,7 @@ public void registerNoName() { } @Test - public void registerDuplicateName() { + void registerDuplicateName() { PrometheusRegistry registry = new PrometheusRegistry(); registry.register(counterA1); assertThatExceptionOfType(IllegalStateException.class) @@ -104,7 +104,7 @@ public void registerDuplicateName() { } @Test - public void registerOk() { + void registerOk() { PrometheusRegistry registry = new PrometheusRegistry(); registry.register(counterA1); registry.register(counterB); @@ -122,7 +122,7 @@ public void registerOk() { } @Test - public void registerDuplicateMultiCollector() { + void registerDuplicateMultiCollector() { PrometheusRegistry registry = new PrometheusRegistry(); registry.register(multiCollector); assertThatExceptionOfType(IllegalStateException.class) @@ -130,7 +130,7 @@ public void registerDuplicateMultiCollector() { } @Test - public void registerOkMultiCollector() { + void registerOkMultiCollector() { PrometheusRegistry registry = new PrometheusRegistry(); registry.register(multiCollector); MetricSnapshots snapshots = registry.scrape(); @@ -142,7 +142,7 @@ public void registerOkMultiCollector() { } @Test - public void clearOk() { + void clearOk() { PrometheusRegistry registry = new PrometheusRegistry(); registry.register(counterA1); registry.register(counterB); diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/ClassicHistogramBucketsTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/ClassicHistogramBucketsTest.java index d39b32436..d06c2ac70 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/ClassicHistogramBucketsTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/ClassicHistogramBucketsTest.java @@ -11,7 +11,7 @@ class ClassicHistogramBucketsTest { @Test - public void testGoodCase() { + void testGoodCase() { ClassicHistogramBuckets buckets = ClassicHistogramBuckets.builder() .bucket(Double.NEGATIVE_INFINITY, 0) @@ -23,7 +23,7 @@ public void testGoodCase() { } @Test - public void testSort() { + void testSort() { ClassicHistogramBuckets buckets = ClassicHistogramBuckets.builder() .bucket(7, 2) @@ -40,21 +40,21 @@ public void testSort() { } @Test - public void testMinimalBuckets() { + void testMinimalBuckets() { ClassicHistogramBuckets buckets = ClassicHistogramBuckets.builder().bucket(Double.POSITIVE_INFINITY, 0).build(); assertThat(buckets.size()).isOne(); } @Test - public void testInfBucketMissing() { + void testInfBucketMissing() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( () -> ClassicHistogramBuckets.builder().bucket(Double.NEGATIVE_INFINITY, 0).build()); } @Test - public void testNegativeCount() { + void testNegativeCount() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( () -> @@ -65,7 +65,7 @@ public void testNegativeCount() { } @Test - public void testNaNBoundary() { + void testNaNBoundary() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( () -> @@ -77,7 +77,7 @@ public void testNaNBoundary() { } @Test - public void testDuplicateBoundary() { + void testDuplicateBoundary() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( () -> @@ -90,13 +90,13 @@ public void testDuplicateBoundary() { } @Test - public void testEmptyBuckets() { + void testEmptyBuckets() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ClassicHistogramBuckets.builder().build()); } @Test - public void testDifferentLength() { + void testDifferentLength() { double[] upperBounds = new double[] {0.7, 1.3, Double.POSITIVE_INFINITY}; long[] counts = new long[] {13, 178, 1024, 3000}; assertThatExceptionOfType(IllegalArgumentException.class) @@ -104,7 +104,7 @@ public void testDifferentLength() { } @Test - public void testImmutable() { + void testImmutable() { ClassicHistogramBuckets buckets = ClassicHistogramBuckets.builder() .bucket(1.0, 7) @@ -117,7 +117,7 @@ public void testImmutable() { } @Test - public void compare() { + void compare() { ClassicHistogramBuckets buckets = ClassicHistogramBuckets.builder() .bucket(1.0, 7) diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/CounterSnapshotTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/CounterSnapshotTest.java index a69ccfbab..ca4346cdb 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/CounterSnapshotTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/CounterSnapshotTest.java @@ -11,7 +11,7 @@ class CounterSnapshotTest { @Test - public void testCompleteGoodCase() { + void testCompleteGoodCase() { long createdTimestamp1 = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1); long createdTimestamp2 = System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(2); long exemplarTimestamp = System.currentTimeMillis(); @@ -68,7 +68,7 @@ public void testCompleteGoodCase() { } @Test - public void testMinimalGoodCase() { + void testMinimalGoodCase() { CounterSnapshot snapshot = CounterSnapshot.builder() .name("events") @@ -85,25 +85,25 @@ public void testMinimalGoodCase() { } @Test - public void testEmptyCounter() { + void testEmptyCounter() { CounterSnapshot snapshot = CounterSnapshot.builder().name("events").build(); assertThat(snapshot.getDataPoints()).isEmpty(); } @Test - public void testTotalSuffixPresent() { + void testTotalSuffixPresent() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> CounterSnapshot.builder().name("test_total").build()); } @Test - public void testValueMissing() { + void testValueMissing() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> CounterDataPointSnapshot.builder().build()); } @Test - public void testDataImmutable() { + void testDataImmutable() { CounterSnapshot snapshot = CounterSnapshot.builder() .name("events") diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/ExemplarTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/ExemplarTest.java index 4a40b47ef..db7ad2426 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/ExemplarTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/ExemplarTest.java @@ -9,7 +9,7 @@ class ExemplarTest { @Test - public void testGoodCaseComplete() { + void testGoodCaseComplete() { long timestamp = System.currentTimeMillis(); Exemplar exemplar = Exemplar.builder() @@ -36,13 +36,13 @@ public void testGoodCaseComplete() { } @Test - public void testValueMissing() { + void testValueMissing() { assertThatExceptionOfType(IllegalStateException.class) .isThrownBy(() -> Exemplar.builder().build()); } @Test - public void testMinimal() { + void testMinimal() { Exemplar exemplar = Exemplar.builder().value(0.0).build(); assertThat(exemplar.getValue()).isEqualTo(0.0); assertLabels(exemplar.getLabels()).isEqualTo(Labels.EMPTY); @@ -50,7 +50,7 @@ public void testMinimal() { } @Test - public void testLabelsMergeTraceId() { + void testLabelsMergeTraceId() { Exemplar exemplar = Exemplar.builder().value(0.0).labels(Labels.of("a", "b")).traceId("abc").build(); assertLabels(exemplar.getLabels()).isEqualTo(Labels.of("a", "b", "trace_id", "abc")); @@ -61,14 +61,14 @@ private static IterableAssert assertLabels(Labels labels) { } @Test - public void testLabelsMergeSpanId() { + void testLabelsMergeSpanId() { Exemplar exemplar = Exemplar.builder().value(0.0).labels(Labels.of("a", "b")).spanId("abc").build(); assertLabels(exemplar.getLabels()).isEqualTo(Labels.of("a", "b", "span_id", "abc")); } @Test - public void testLabelsMergeTraceIdAndSpanId() { + void testLabelsMergeTraceIdAndSpanId() { Exemplar exemplar = Exemplar.builder() .value(0.0) @@ -81,7 +81,7 @@ public void testLabelsMergeTraceIdAndSpanId() { } @Test - public void testLabelsMergeNone() { + void testLabelsMergeNone() { Exemplar exemplar = Exemplar.builder().value(0.0).labels(Labels.of("a", "b")).build(); assertLabels(exemplar.getLabels()).isEqualTo(Labels.of("a", "b")); } diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/ExemplarsTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/ExemplarsTest.java index cd38342cd..be69e7f16 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/ExemplarsTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/ExemplarsTest.java @@ -9,7 +9,7 @@ class ExemplarsTest { @Test - public void testUpperBound() { + void testUpperBound() { Exemplars exemplars = Exemplars.of( Exemplar.builder().value(1.0).build(), @@ -26,7 +26,7 @@ public void testUpperBound() { } @Test - public void testImmutable() { + void testImmutable() { Exemplars exemplars = Exemplars.of( Exemplar.builder().value(1.0).build(), @@ -38,7 +38,7 @@ public void testImmutable() { } @Test - public void testGet() { + void testGet() { Exemplar oldest = Exemplar.builder().timestampMillis(System.currentTimeMillis() - 100).value(1.8).build(); Exemplar middle = diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/GaugeSnapshotTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/GaugeSnapshotTest.java index c469647e0..5154e1eb1 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/GaugeSnapshotTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/GaugeSnapshotTest.java @@ -11,7 +11,7 @@ class GaugeSnapshotTest { @Test - public void testCompleteGoodCase() { + void testCompleteGoodCase() { long exemplarTimestamp = System.currentTimeMillis(); GaugeSnapshot snapshot = GaugeSnapshot.builder() @@ -63,7 +63,7 @@ public void testCompleteGoodCase() { } @Test - public void testMinimalGoodCase() { + void testMinimalGoodCase() { GaugeSnapshot snapshot = GaugeSnapshot.builder() .name("temperature") @@ -80,31 +80,31 @@ public void testMinimalGoodCase() { } @Test - public void testEmptyGauge() { + void testEmptyGauge() { GaugeSnapshot snapshot = GaugeSnapshot.builder().name("temperature").build(); assertThat(snapshot.getDataPoints().size()).isZero(); } @Test - public void testTotalSuffixPresent() { + void testTotalSuffixPresent() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> CounterSnapshot.builder().name("test_total").build()); } @Test - public void testTotalSuffixPresentDot() { + void testTotalSuffixPresentDot() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> CounterSnapshot.builder().name("test.total").build()); } @Test - public void testValueMissing() { + void testValueMissing() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> CounterDataPointSnapshot.builder().build()); } @Test - public void testDataImmutable() { + void testDataImmutable() { GaugeSnapshot snapshot = GaugeSnapshot.builder() .name("gauge") diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/HistogramSnapshotTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/HistogramSnapshotTest.java index 54eefbe66..6233481df 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/HistogramSnapshotTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/HistogramSnapshotTest.java @@ -13,7 +13,7 @@ class HistogramSnapshotTest { @Test - public void testGoodCaseComplete() { + void testGoodCaseComplete() { long createdTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1); long scrapeTimestamp = System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(2); long exemplarTimestamp = System.currentTimeMillis(); @@ -170,7 +170,7 @@ public void testGoodCaseComplete() { } @Test - public void testEmptyHistogram() { + void testEmptyHistogram() { assertThat(HistogramSnapshot.builder().name("empty_histogram").build().getDataPoints()) .isEmpty(); HistogramSnapshot snapshot = @@ -181,7 +181,7 @@ public void testEmptyHistogram() { } @Test - public void testMinimalClassicHistogram() { + void testMinimalClassicHistogram() { HistogramSnapshot snapshot = HistogramSnapshot.builder() .name("minimal_histogram") @@ -198,7 +198,7 @@ public void testMinimalClassicHistogram() { } @Test - public void testMinimalNativeHistogram() { + void testMinimalNativeHistogram() { HistogramSnapshot snapshot = HistogramSnapshot.builder() .name("hist") @@ -218,7 +218,7 @@ public void testMinimalNativeHistogram() { } @Test - public void testClassicCount() { + void testClassicCount() { HistogramSnapshot snapshot = HistogramSnapshot.builder() .name("test_histogram") @@ -239,21 +239,21 @@ public void testClassicCount() { } @Test - public void testEmptyData() { + void testEmptyData() { // This will fail because one of nativeSchema and classicHistogramBuckets is required assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> HistogramDataPointSnapshot.builder().build()); } @Test - public void testEmptyNativeData() { + void testEmptyNativeData() { HistogramDataPointSnapshot data = HistogramDataPointSnapshot.builder().nativeSchema(5).build(); assertThat(data.getNativeBucketsForNegativeValues().size()).isZero(); assertThat(data.getNativeBucketsForPositiveValues().size()).isZero(); } @Test - public void testDataImmutable() { + void testDataImmutable() { HistogramSnapshot snapshot = HistogramSnapshot.builder() .name("test_histogram") @@ -278,7 +278,7 @@ public void testDataImmutable() { } @Test - public void testEmptyClassicBuckets() { + void testEmptyClassicBuckets() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( () -> @@ -287,7 +287,7 @@ public void testEmptyClassicBuckets() { } @Test - public void testMinimalNativeData() { + void testMinimalNativeData() { new HistogramDataPointSnapshot( ClassicHistogramBuckets.EMPTY, 0, @@ -302,7 +302,7 @@ public void testMinimalNativeData() { } @Test - public void testMinimalClassicData() { + void testMinimalClassicData() { ClassicHistogramBuckets buckets = ClassicHistogramBuckets.builder().bucket(Double.POSITIVE_INFINITY, 0).build(); new HistogramDataPointSnapshot( diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/InfoSnapshotTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/InfoSnapshotTest.java index 983450181..3cf7d69af 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/InfoSnapshotTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/InfoSnapshotTest.java @@ -9,7 +9,7 @@ class InfoSnapshotTest { @Test - public void testCompleteGoodCase() { + void testCompleteGoodCase() { InfoSnapshot snapshot = InfoSnapshot.builder() .name("target") @@ -33,13 +33,13 @@ void create() { } @Test - public void testEmptyInfo() { + void testEmptyInfo() { InfoSnapshot snapshot = InfoSnapshot.builder().name("target").build(); assertThat(snapshot.getDataPoints()).isEmpty(); } @Test - public void testDataImmutable() { + void testDataImmutable() { InfoSnapshot snapshot = InfoSnapshot.builder() .name("target") @@ -60,13 +60,13 @@ public void testDataImmutable() { } @Test - public void testNameMustNotIncludeSuffix() { + void testNameMustNotIncludeSuffix() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> InfoSnapshot.builder().name("jvm_info").build()); } @Test - public void testNameMustNotIncludeSuffixDot() { + void testNameMustNotIncludeSuffixDot() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> InfoSnapshot.builder().name("jvm.info").build()); } diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/LabelsTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/LabelsTest.java index 5bdd285e3..3dc8f639f 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/LabelsTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/LabelsTest.java @@ -17,7 +17,7 @@ private > void assertGreaterThan(T a, T b) { } @Test - public void testCompareDifferentLabelNames() { + void testCompareDifferentLabelNames() { Labels labels1 = Labels.of("env", "prod", "status2", "200"); Labels labels2 = Labels.of("env", "prod", "status1", "200"); assertGreaterThan(labels1, labels2); @@ -31,7 +31,7 @@ private static IterableAssert assertLabels(Labels labels) { } @Test - public void testCompareSameLabelNames() { + void testCompareSameLabelNames() { // If all label names are the same, labels should be sorted by label value. Labels labels1 = Labels.of("env", "prod", "status", "200"); Labels labels2 = Labels.of("env", "prod", "status", "500"); @@ -42,7 +42,7 @@ public void testCompareSameLabelNames() { } @Test - public void testCompareDifferentNumberOfLabels() { + void testCompareDifferentNumberOfLabels() { Labels labels1 = Labels.of("env", "prod", "status", "200"); Labels labels2 = Labels.of("env", "prod", "status", "200", "x_code", "none"); assertLessThan(labels1, labels2); @@ -52,14 +52,14 @@ public void testCompareDifferentNumberOfLabels() { } @Test - public void testComparePrometheusNames() { + void testComparePrometheusNames() { Labels labels1 = Labels.of("my_a", "val"); Labels labels2 = Labels.of("my.b", "val"); assertLessThan(labels1, labels2); // this is true because it compares "my_a" to "my_b". } @Test - public void testEqualsHashcodeDots() { + void testEqualsHashcodeDots() { Labels labels1 = Labels.of("my_a", "val"); Labels labels2 = Labels.of("my.a", "val"); assertLabels(labels2).isEqualTo(labels1).hasSameHashCodeAs(labels1); @@ -67,7 +67,7 @@ public void testEqualsHashcodeDots() { @SuppressWarnings({"unchecked", "rawtypes"}) @Test - public void testCompareEquals() { + void testCompareEquals() { Labels labels1 = Labels.of("env", "prod", "status", "200"); Labels labels2 = Labels.of("env", "prod", "status", "200"); assertThat((Comparable) labels1).isEqualByComparingTo(labels2); @@ -77,19 +77,19 @@ public void testCompareEquals() { } @Test - public void testReservedLabelName() { + void testReservedLabelName() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Labels.of("__name__", "requests_total")); } @Test - public void testDuplicateLabelName() { + void testDuplicateLabelName() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Labels.of("name1", "value1", "name2", "value2", "name1", "value3")); } @Test - public void testMakePrometheusNames() { + void testMakePrometheusNames() { String[] names = new String[] {}; String[] prometheusNames = Labels.makePrometheusNames(names); assertThat(prometheusNames).isSameAs(names); @@ -107,7 +107,7 @@ public void testMakePrometheusNames() { } @Test - public void testMerge() { + void testMerge() { Labels labels1 = Labels.of("key.1", "value 1", "key.3", "value 3"); Labels labels2 = Labels.of("key_2", "value 2"); Labels merged = labels2.merge(labels1); @@ -117,7 +117,7 @@ public void testMerge() { } @Test - public void testMergeDuplicateName() { + void testMergeDuplicateName() { Labels labels1 = Labels.of("key_one", "v1"); Labels labels2 = Labels.of("key.one", "v2"); assertThatExceptionOfType(IllegalArgumentException.class) @@ -125,7 +125,7 @@ public void testMergeDuplicateName() { } @Test - public void testDuplicateName() { + void testDuplicateName() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Labels.of("key_one", "v1", "key.one", "v2")); } diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/MetricMetadataTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/MetricMetadataTest.java index f2d6a6ba4..41efe043b 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/MetricMetadataTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/MetricMetadataTest.java @@ -9,19 +9,19 @@ class MetricMetadataTest { @Test - public void testEmptyName() { + void testEmptyName() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new MetricMetadata("")); } @Test - public void testNullName() { + void testNullName() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new MetricMetadata(null)); } @Test - public void testSanitizationIllegalCharacters() { + void testSanitizationIllegalCharacters() { MetricMetadata metadata = new MetricMetadata( sanitizeMetricName("my_namespace/http.server.duration", Unit.SECONDS), @@ -34,42 +34,42 @@ public void testSanitizationIllegalCharacters() { } @Test - public void testSanitizationCounter() { + void testSanitizationCounter() { MetricMetadata metadata = new MetricMetadata(sanitizeMetricName("my_events_total")); assertThat(metadata.getName()).isEqualTo("my_events"); } @Test - public void testSanitizationInfo() { + void testSanitizationInfo() { MetricMetadata metadata = new MetricMetadata(sanitizeMetricName("target_info")); assertThat(metadata.getName()).isEqualTo("target"); } @Test - public void testSanitizationWeirdCornerCase() { + void testSanitizationWeirdCornerCase() { MetricMetadata metadata = new MetricMetadata(sanitizeMetricName("_total_created")); assertThat(metadata.getName()).isEqualTo("total"); } @Test - public void testSanitizeEmptyString() { + void testSanitizeEmptyString() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> sanitizeMetricName("")); } @Test - public void testUnitSuffixRequired() { + void testUnitSuffixRequired() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> new MetricMetadata("my_counter", "help", Unit.SECONDS)); } @Test - public void testUnitSuffixAdded() { + void testUnitSuffixAdded() { new MetricMetadata(sanitizeMetricName("my_counter", Unit.SECONDS), "help", Unit.SECONDS); } @Test - public void testUnitNotDuplicated() { + void testUnitNotDuplicated() { assertThat(sanitizeMetricName("my_counter_bytes", Unit.BYTES)).isEqualTo("my_counter_bytes"); } } diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/MetricSnapshotTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/MetricSnapshotTest.java index 2c1c04bb6..199cb8f4c 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/MetricSnapshotTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/MetricSnapshotTest.java @@ -8,7 +8,7 @@ class MetricSnapshotTest { @Test - public void testDuplicateLabels() { + void testDuplicateLabels() { assertThatExceptionOfType(DuplicateLabelsException.class) .isThrownBy( () -> @@ -39,13 +39,13 @@ public void testDuplicateLabels() { } @Test - public void testNoData() { + void testNoData() { MetricSnapshot snapshot = CounterSnapshot.builder().name("test").build(); assertThat(snapshot.getDataPoints().size()).isEqualTo(0); } @Test - public void testNullData() { + void testNullData() { assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> new CounterSnapshot(new MetricMetadata("test"), null)); } diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/MetricSnapshotsTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/MetricSnapshotsTest.java index 04a824f02..5d82a06a0 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/MetricSnapshotsTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/MetricSnapshotsTest.java @@ -9,13 +9,13 @@ class MetricSnapshotsTest { @Test - public void testEmpty() { + void testEmpty() { MetricSnapshots snapshots = MetricSnapshots.builder().build(); assertThat(snapshots.stream().findAny()).isNotPresent(); } @Test - public void testSort() { + void testSort() { CounterSnapshot c1 = CounterSnapshot.builder() .name("counter1") @@ -39,7 +39,7 @@ public void testSort() { } @Test - public void testDuplicateName() { + void testDuplicateName() { // Q: What if you have a counter named "foo" and a gauge named "foo"? // A: Great question. You might think this is a valid scenario, because the counter will produce // the values "foo_total" and "foo_created" while the gauge will produce the value "foo". @@ -62,7 +62,7 @@ public void testDuplicateName() { } @Test - public void testBuilder() { + void testBuilder() { CounterSnapshot counter = CounterSnapshot.builder() .name("my_metric") @@ -75,7 +75,7 @@ public void testBuilder() { } @Test - public void testImmutable() { + void testImmutable() { CounterSnapshot c1 = CounterSnapshot.builder() .name("counter1") diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/NativeHistogramBucketsTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/NativeHistogramBucketsTest.java index 32c7f3eb3..ed52a7d1a 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/NativeHistogramBucketsTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/NativeHistogramBucketsTest.java @@ -9,7 +9,7 @@ class NativeHistogramBucketsTest { @Test - public void testGoodCase() { + void testGoodCase() { NativeHistogramBuckets buckets = NativeHistogramBuckets.builder().bucket(-10, 12).bucket(120, 17).build(); assertThat(buckets.size()).isEqualTo(2); @@ -20,13 +20,13 @@ public void testGoodCase() { } @Test - public void testEmpty() { + void testEmpty() { NativeHistogramBuckets buckets = NativeHistogramBuckets.builder().build(); assertThat(buckets.size()).isZero(); } @Test - public void testSort() { + void testSort() { NativeHistogramBuckets buckets = NativeHistogramBuckets.builder().bucket(7, 4).bucket(2, 0).bucket(5, 3).build(); assertThat(buckets.size()).isEqualTo(3); @@ -39,7 +39,7 @@ public void testSort() { } @Test - public void testDifferentLength() { + void testDifferentLength() { int[] bucketIndexes = new int[] {0, 1, 2}; long[] cumulativeCounts = new long[] {13, 178, 1024, 3000}; assertThatExceptionOfType(IllegalArgumentException.class) @@ -47,7 +47,7 @@ public void testDifferentLength() { } @Test - public void testImmutable() { + void testImmutable() { NativeHistogramBuckets buckets = NativeHistogramBuckets.builder().bucket(1, 1).bucket(2, 1).build(); Iterator iterator = buckets.iterator(); diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/PrometheusNamingTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/PrometheusNamingTest.java index 40c1f1bde..847bb0f38 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/PrometheusNamingTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/PrometheusNamingTest.java @@ -21,7 +21,7 @@ class PrometheusNamingTest { @Test - public void testSanitizeMetricName() { + void testSanitizeMetricName() { assertThat(sanitizeMetricName("my_counter_total")).isEqualTo("my_counter"); assertThat(sanitizeMetricName("jvm.info")).isEqualTo("jvm"); assertThat(sanitizeMetricName("jvm_info")).isEqualTo("jvm"); @@ -32,7 +32,7 @@ public void testSanitizeMetricName() { } @Test - public void testSanitizeMetricNameWithUnit() { + void testSanitizeMetricNameWithUnit() { assertThat(prometheusName(sanitizeMetricName("def", Unit.RATIO))) .isEqualTo("def_" + Unit.RATIO); assertThat(prometheusName(sanitizeMetricName("my_counter_total", Unit.RATIO))) @@ -43,7 +43,7 @@ public void testSanitizeMetricNameWithUnit() { } @Test - public void testSanitizeLabelName() { + void testSanitizeLabelName() { assertThat(prometheusName(sanitizeLabelName("0abc.def"))).isEqualTo("_abc_def"); assertThat(prometheusName(sanitizeLabelName("_abc"))).isEqualTo("_abc"); assertThat(prometheusName(sanitizeLabelName("__abc"))).isEqualTo("_abc"); @@ -54,7 +54,7 @@ public void testSanitizeLabelName() { } @Test - public void testValidateUnitName() { + void testValidateUnitName() { assertThat(validateUnitName("secondstotal")).isNotNull(); assertThat(validateUnitName("total")).isNotNull(); assertThat(validateUnitName("seconds_total")).isNotNull(); @@ -66,7 +66,7 @@ public void testValidateUnitName() { } @Test - public void testSanitizeUnitName() { + void testSanitizeUnitName() { assertThat(sanitizeUnitName("seconds")).isEqualTo("seconds"); assertThat(sanitizeUnitName("seconds_total")).isEqualTo("seconds"); assertThat(sanitizeUnitName("seconds_total_total")).isEqualTo("seconds"); @@ -76,25 +76,25 @@ public void testSanitizeUnitName() { } @Test - public void testInvalidUnitName1() { + void testInvalidUnitName1() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> sanitizeUnitName("total")); } @Test - public void testInvalidUnitName2() { + void testInvalidUnitName2() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> sanitizeUnitName("_total")); } @Test - public void testInvalidUnitName3() { + void testInvalidUnitName3() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> sanitizeUnitName("%")); } @Test - public void testEmptyUnitName() { + void testEmptyUnitName() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> sanitizeUnitName("")); } diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/QuantilesTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/QuantilesTest.java index 8703657ca..4ccadddc8 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/QuantilesTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/QuantilesTest.java @@ -9,7 +9,7 @@ class QuantilesTest { @Test - public void testSort() { + void testSort() { Quantiles quantiles = Quantiles.builder().quantile(0.99, 0.23).quantile(0.5, 0.2).quantile(0.95, 0.22).build(); assertThat(quantiles.size()).isEqualTo(3); @@ -22,7 +22,7 @@ public void testSort() { } @Test - public void testImmutable() { + void testImmutable() { Quantiles quantiles = Quantiles.builder().quantile(0.99, 0.23).quantile(0.5, 0.2).quantile(0.95, 0.22).build(); Iterator iterator = quantiles.iterator(); @@ -31,12 +31,12 @@ public void testImmutable() { } @Test - public void testEmpty() { + void testEmpty() { assertThat(Quantiles.EMPTY.size()).isZero(); } @Test - public void testDuplicate() { + void testDuplicate() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( () -> diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/SnapshotEscaperTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/SnapshotEscaperTest.java index f84024e95..5c04719c0 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/SnapshotEscaperTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/SnapshotEscaperTest.java @@ -15,7 +15,7 @@ class SnapshotEscaperTest { @Test - public void testEscapeMetricSnapshotEmpty() { + void testEscapeMetricSnapshotEmpty() { MetricSnapshot original = CounterSnapshot.builder().name("empty").build(); MetricSnapshot got = escapeMetricSnapshot(original, EscapingScheme.VALUE_ENCODING_ESCAPING); assertThat(Objects.requireNonNull(got).getMetadata().getName()).isEqualTo("empty"); @@ -23,7 +23,7 @@ public void testEscapeMetricSnapshotEmpty() { } @Test - public void testEscapeMetricSnapshotSimpleNoEscapingNeeded() { + void testEscapeMetricSnapshotSimpleNoEscapingNeeded() { testEscapeMetricSnapshot( "my_metric", "some_label", @@ -36,7 +36,7 @@ public void testEscapeMetricSnapshotSimpleNoEscapingNeeded() { } @Test - public void testEscapeMetricSnapshotLabelNameEscapingNeeded() { + void testEscapeMetricSnapshotLabelNameEscapingNeeded() { testEscapeMetricSnapshot( "my_metric", "some.label", @@ -49,7 +49,7 @@ public void testEscapeMetricSnapshotLabelNameEscapingNeeded() { } @Test - public void testEscapeMetricSnapshotCounterEscapingNeeded() { + void testEscapeMetricSnapshotCounterEscapingNeeded() { testEscapeMetricSnapshot( "my.metric", "some?label", @@ -62,7 +62,7 @@ public void testEscapeMetricSnapshotCounterEscapingNeeded() { } @Test - public void testEscapeMetricSnapshotGaugeEscapingNeeded() { + void testEscapeMetricSnapshotGaugeEscapingNeeded() { testEscapeMetricSnapshot( "unicode.and.dots.花火", "some_label", diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/StateSetSnapshotTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/StateSetSnapshotTest.java index 05e102b9d..02d16e64f 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/StateSetSnapshotTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/StateSetSnapshotTest.java @@ -10,7 +10,7 @@ class StateSetSnapshotTest { @Test - public void testCompleteGoodCase() { + void testCompleteGoodCase() { long scrapeTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1); StateSetSnapshot snapshot = StateSetSnapshot.builder() @@ -49,7 +49,7 @@ public void testCompleteGoodCase() { } @Test - public void testStateSetDataSorted() { + void testStateSetDataSorted() { StateSetSnapshot.StateSetDataPointSnapshot data = StateSetSnapshot.StateSetDataPointSnapshot.builder() .state("b", true) @@ -69,14 +69,14 @@ public void testStateSetDataSorted() { } @Test - public void testMustHaveState() { + void testMustHaveState() { // Must have at least one state. assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> StateSetSnapshot.StateSetDataPointSnapshot.builder().build()); } @Test - public void testMinimal() { + void testMinimal() { StateSetSnapshot snapshot = StateSetSnapshot.builder() .name("my_flag") @@ -87,13 +87,13 @@ public void testMinimal() { } @Test - public void testEmpty() { + void testEmpty() { StateSetSnapshot snapshot = StateSetSnapshot.builder().name("my_flag").build(); assertThat(snapshot.dataPoints).isEmpty(); } @Test - public void testDataImmutable() { + void testDataImmutable() { StateSetSnapshot.StateSetDataPointSnapshot data = StateSetSnapshot.StateSetDataPointSnapshot.builder() .state("a", true) @@ -111,7 +111,7 @@ public void testDataImmutable() { } @Test - public void testDuplicateState() { + void testDuplicateState() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( () -> @@ -123,13 +123,13 @@ public void testDuplicateState() { } @Test - public void noUnit() { + void noUnit() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> StateSetSnapshot.builder().name("flags").unit(Unit.BYTES).build()); } @Test - public void testStateSetImmutable() { + void testStateSetImmutable() { StateSetSnapshot snapshot = StateSetSnapshot.builder() .name("flags") @@ -151,7 +151,7 @@ public void testStateSetImmutable() { } @Test - public void testLabelsUnique() { + void testLabelsUnique() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( () -> diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/SummarySnapshotTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/SummarySnapshotTest.java index df423ba97..8cd9571f5 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/SummarySnapshotTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/SummarySnapshotTest.java @@ -9,7 +9,7 @@ class SummarySnapshotTest { @Test - public void testCompleteGoodCase() { + void testCompleteGoodCase() { long createdTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1); long scrapeTimestamp = System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(2); long exemplarTimestamp = System.currentTimeMillis(); @@ -82,7 +82,7 @@ public void testCompleteGoodCase() { } @Test - public void testMinimal() { + void testMinimal() { SummarySnapshot snapshot = SummarySnapshot.builder() .name("size_bytes") @@ -95,13 +95,13 @@ public void testMinimal() { } @Test - public void testEmptySnapshot() { + void testEmptySnapshot() { SummarySnapshot snapshot = SummarySnapshot.builder().name("empty_summary").build(); assertThat(snapshot.getDataPoints()).isEmpty(); } @Test - public void testEmptyData() { + void testEmptyData() { SummarySnapshot.SummaryDataPointSnapshot data = SummarySnapshot.SummaryDataPointSnapshot.builder().build(); assertThat(data.getQuantiles().size()).isZero(); diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/UnitTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/UnitTest.java index 4585e7281..e288a2375 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/UnitTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/UnitTest.java @@ -8,12 +8,12 @@ class UnitTest { @Test - public void testEmpty() { + void testEmpty() { assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> new Unit(" ")); } @Test - public void testEquals1() { + void testEquals1() { Unit unit1 = Unit.BYTES; Unit unit2 = new Unit("bytes"); @@ -21,7 +21,7 @@ public void testEquals1() { } @Test - public void testEquals2() { + void testEquals2() { Unit unit1 = new Unit("bytes "); Unit unit2 = new Unit("bytes"); @@ -29,7 +29,7 @@ public void testEquals2() { } @Test - public void testEquals3() { + void testEquals3() { Unit unit1 = new Unit(" bytes"); Unit unit2 = new Unit("bytes"); @@ -37,7 +37,7 @@ public void testEquals3() { } @Test - public void testEquals4() { + void testEquals4() { Unit unit1 = new Unit(" bytes "); Unit unit2 = new Unit("bytes"); diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/UnknownSnapshotTest.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/UnknownSnapshotTest.java index 53df0a95d..33b4ac2b4 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/UnknownSnapshotTest.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/UnknownSnapshotTest.java @@ -9,7 +9,7 @@ class UnknownSnapshotTest { @Test - public void testCompleteGoodCase() { + void testCompleteGoodCase() { long exemplarTimestamp = System.currentTimeMillis(); UnknownSnapshot snapshot = UnknownSnapshot.builder() @@ -46,7 +46,7 @@ public void testCompleteGoodCase() { } @Test - public void testMinimal() { + void testMinimal() { UnknownSnapshot snapshot = UnknownSnapshot.builder() .name("test") @@ -56,25 +56,25 @@ public void testMinimal() { } @Test - public void testEmpty() { + void testEmpty() { UnknownSnapshot snapshot = UnknownSnapshot.builder().name("test").build(); assertThat(snapshot.getDataPoints()).isEmpty(); } @Test - public void testNameMissing() { + void testNameMissing() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> UnknownSnapshot.builder().build()); } @Test - public void testValueMissing() { + void testValueMissing() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> UnknownSnapshot.UnknownDataPointSnapshot.builder().build()); } @Test - public void testUnknownDataPointSnapshot() { + void testUnknownDataPointSnapshot() { Labels labels = Labels.of("k1", "v1"); Exemplar exemplar = Exemplar.builder().value(2.0).build(); diff --git a/prometheus-metrics-simpleclient-bridge/src/test/java/io/prometheus/metrics/simpleclient/bridge/SimpleclientCollectorTest.java b/prometheus-metrics-simpleclient-bridge/src/test/java/io/prometheus/metrics/simpleclient/bridge/SimpleclientCollectorTest.java index a17ed8bc4..3905f8f42 100644 --- a/prometheus-metrics-simpleclient-bridge/src/test/java/io/prometheus/metrics/simpleclient/bridge/SimpleclientCollectorTest.java +++ b/prometheus-metrics-simpleclient-bridge/src/test/java/io/prometheus/metrics/simpleclient/bridge/SimpleclientCollectorTest.java @@ -30,14 +30,14 @@ class SimpleclientCollectorTest { private PrometheusRegistry newRegistry; @BeforeEach - public void setUp() { + void setUp() { origRegistry = new CollectorRegistry(); newRegistry = new PrometheusRegistry(); SimpleclientCollector.builder().collectorRegistry(origRegistry).register(newRegistry); } @Test - public void testCounterComplete() throws IOException, InterruptedException { + void testCounterComplete() throws IOException, InterruptedException { Counter counter = Counter.build() .name("service_time_seconds_total") @@ -52,14 +52,14 @@ public void testCounterComplete() throws IOException, InterruptedException { } @Test - public void testCounterMinimal() throws IOException { + void testCounterMinimal() throws IOException { Counter.build().name("events").help("total number of events").register(origRegistry); assertThat(sort(newOpenMetrics())).isEqualTo(fixTimestamps(sort(origOpenMetrics()))); } @Test - public void testGaugeComplete() throws IOException, InterruptedException { + void testGaugeComplete() throws IOException, InterruptedException { Gauge gauge = Gauge.build() .name("disk_usage_ratio") @@ -75,7 +75,7 @@ public void testGaugeComplete() throws IOException, InterruptedException { } @Test - public void testGaugeMinimal() throws IOException { + void testGaugeMinimal() throws IOException { Gauge gauge = Gauge.build() .name("temperature_centigrade") @@ -88,7 +88,7 @@ public void testGaugeMinimal() throws IOException { } @Test - public void testHistogramComplete() throws IOException, InterruptedException { + void testHistogramComplete() throws IOException, InterruptedException { Histogram histogram = Histogram.build() .name("response_size_bytes") @@ -108,14 +108,14 @@ public void testHistogramComplete() throws IOException, InterruptedException { } @Test - public void testHistogramMinimal() throws IOException { + void testHistogramMinimal() throws IOException { Histogram.build().name("request_latency").help("request latency").register(origRegistry); assertThat(sort(newOpenMetrics())).isEqualTo(fixCounts(fixTimestamps(sort(origOpenMetrics())))); } @Test - public void testSummaryComplete() throws IOException, InterruptedException { + void testSummaryComplete() throws IOException, InterruptedException { Summary summary = Summary.build() .name("http_request_duration_seconds") @@ -139,14 +139,14 @@ public void testSummaryComplete() throws IOException, InterruptedException { } @Test - public void testSummaryMinimal() throws IOException { + void testSummaryMinimal() throws IOException { Summary.build().name("request_size").help("request size").register(origRegistry); assertThat(sort(newOpenMetrics())).isEqualTo(fixCounts(fixTimestamps(sort(origOpenMetrics())))); } @Test - public void testInfoComplete() throws IOException, InterruptedException { + void testInfoComplete() throws IOException, InterruptedException { Info info = Info.build() .name("version") @@ -161,7 +161,7 @@ public void testInfoComplete() throws IOException, InterruptedException { } @Test - public void testInfoMinimal() throws IOException { + void testInfoMinimal() throws IOException { Info info = Info.build().name("jvm").help("JVM info").register(origRegistry); info.info("version", "17"); @@ -169,7 +169,7 @@ public void testInfoMinimal() throws IOException { } @Test - public void testStateSetComplete() throws IOException { + void testStateSetComplete() throws IOException { Collector stateSet = new Collector() { @Override @@ -192,7 +192,7 @@ public List collect() { } @Test - public void testUnknownComplete() throws IOException { + void testUnknownComplete() throws IOException { Collector unknown = new Collector() { @Override From 38e1dca7cd1beaf83bb111b43779ebdc628af0d6 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Mon, 26 Jan 2026 13:24:27 +0100 Subject: [PATCH 3/4] make tests package protected Signed-off-by: Gregor Zeitlinger --- .../test/java/io/prometheus/client/it/common/LogConsumer.java | 2 +- .../src/test/java/io/prometheus/client/it/common/Volume.java | 2 +- .../metrics/core/exemplars/ExemplarSamplerConfigTestUtil.java | 2 +- .../test/java/io/prometheus/metrics/core/metrics/TestUtil.java | 2 +- .../io/prometheus/metrics/instrumentation/jvm/TestUtil.java | 2 +- .../io/prometheus/metrics/model/snapshots/SnapshotTestUtil.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/integration-tests/it-common/src/test/java/io/prometheus/client/it/common/LogConsumer.java b/integration-tests/it-common/src/test/java/io/prometheus/client/it/common/LogConsumer.java index a7861bd24..a57c5a7f3 100644 --- a/integration-tests/it-common/src/test/java/io/prometheus/client/it/common/LogConsumer.java +++ b/integration-tests/it-common/src/test/java/io/prometheus/client/it/common/LogConsumer.java @@ -4,7 +4,7 @@ import org.testcontainers.containers.output.OutputFrame; /** Print Docker logs from TestContainers to stdout or stderr. */ -class LogConsumer implements Consumer { +public class LogConsumer implements Consumer { private final String prefix; diff --git a/integration-tests/it-common/src/test/java/io/prometheus/client/it/common/Volume.java b/integration-tests/it-common/src/test/java/io/prometheus/client/it/common/Volume.java index d9436940a..af5b0918e 100644 --- a/integration-tests/it-common/src/test/java/io/prometheus/client/it/common/Volume.java +++ b/integration-tests/it-common/src/test/java/io/prometheus/client/it/common/Volume.java @@ -12,7 +12,7 @@ import java.util.function.Predicate; /** Temporary directory in ./target/ to be mounted as a volume in Docker containers. */ -class Volume { +public class Volume { private final Path tmpDir; // will be created in the ./target/ directory diff --git a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/exemplars/ExemplarSamplerConfigTestUtil.java b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/exemplars/ExemplarSamplerConfigTestUtil.java index cbb8fb8de..e22e9d6c6 100644 --- a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/exemplars/ExemplarSamplerConfigTestUtil.java +++ b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/exemplars/ExemplarSamplerConfigTestUtil.java @@ -2,7 +2,7 @@ import java.lang.reflect.Field; -class ExemplarSamplerConfigTestUtil { +public class ExemplarSamplerConfigTestUtil { private static ExemplarSamplerConfig getConfig(Object metric, String fieldName) throws NoSuchFieldException, IllegalAccessException { diff --git a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/TestUtil.java b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/TestUtil.java index 8d9a5bd0f..10ce1db94 100644 --- a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/TestUtil.java +++ b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/TestUtil.java @@ -6,7 +6,7 @@ import io.prometheus.metrics.model.snapshots.Exemplar; import io.prometheus.metrics.model.snapshots.Label; -class TestUtil { +public class TestUtil { public static void assertExemplarEquals(Exemplar expected, Exemplar actual) { // ignore timestamp diff --git a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/TestUtil.java b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/TestUtil.java index 64e15590c..8cdd6b1ae 100644 --- a/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/TestUtil.java +++ b/prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/TestUtil.java @@ -7,7 +7,7 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; -class TestUtil { +public class TestUtil { static String convertToOpenMetricsFormat(MetricSnapshots snapshots) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); diff --git a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/SnapshotTestUtil.java b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/SnapshotTestUtil.java index d8e8d33e4..8a8a7f93b 100644 --- a/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/SnapshotTestUtil.java +++ b/prometheus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/SnapshotTestUtil.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; -class SnapshotTestUtil { +public class SnapshotTestUtil { public static void assertMetadata( MetricSnapshot snapshot, String name, String help, String unit) { From 7636a1c330566bdd3b29616e296874a6b508e258 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Mon, 26 Jan 2026 13:31:11 +0100 Subject: [PATCH 4/4] make tests package protected Signed-off-by: Gregor Zeitlinger --- .../metrics/exporter/pushgateway/PushGatewayTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/prometheus-metrics-exporter-pushgateway/src/test/java/io/prometheus/metrics/exporter/pushgateway/PushGatewayTest.java b/prometheus-metrics-exporter-pushgateway/src/test/java/io/prometheus/metrics/exporter/pushgateway/PushGatewayTest.java index 7e317fefe..bae8fdd91 100644 --- a/prometheus-metrics-exporter-pushgateway/src/test/java/io/prometheus/metrics/exporter/pushgateway/PushGatewayTest.java +++ b/prometheus-metrics-exporter-pushgateway/src/test/java/io/prometheus/metrics/exporter/pushgateway/PushGatewayTest.java @@ -49,8 +49,7 @@ void testInvalidURLThrowsRuntimeException() { } @Test - void testMultipleSlashesAreStrippedFromURL() - throws NoSuchFieldException, IllegalAccessException { + void testMultipleSlashesAreStrippedFromURL() throws NoSuchFieldException, IllegalAccessException { final PushGateway pushGateway = PushGateway.builder().address("example.com:1234/context///path//").job("test").build(); assertThat(getUrl(pushGateway))