From 749fafaea81e2bd180a9e93608192798a124ea01 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Wed, 21 Aug 2024 19:40:50 +0200 Subject: [PATCH] enforce static imports (#12009) --- buildscripts/checkstyle.xml | 12 ++++ docs/contributing/style-guideline.md | 5 ++ .../MessagingProducerMetricsTest.java | 7 +-- .../internal/OperationMetricsUtilTest.java | 9 +-- .../src/test/java/test/GrailsTest.java | 4 +- .../instrumentation/grpc/v1_6/GrpcTest.java | 5 +- .../grpc/v1_6/AbstractGrpcTest.java | 3 +- .../AbstractLettuceSyncClientAuthTest.java | 4 +- .../v5_1/AbstractLettuceSyncClientTest.java | 4 +- .../LogReplayOpenTelemetryAppenderTest.java | 9 ++- .../LogReplayOpenTelemetryAppenderTest.java | 5 +- .../JavaagentInstrumentationTest.java | 39 ++++++------ .../v1_31/metrics/MeterTest.java | 23 ++++---- .../v1_32/incubator/metrics/MeterTest.java | 23 ++++---- .../v1_32/metrics/MeterTest.java | 6 +- .../v1_37/incubator/metrics/MeterTest.java | 23 ++++---- .../v1_37/incubator/metrics/MeterTest.java | 23 ++++---- .../v1_37/metrics/MeterTest.java | 6 +- .../v1_38/incubator/metrics/MeterTest.java | 7 +-- .../v1_38/metrics/MeterTest.java | 6 +- .../oshi/ProcessMetricsTest.java | 5 +- .../oshi/SystemMetricsTest.java | 5 +- .../pulsar/v2_8/AbstractPulsarClientTest.java | 59 +++++++++---------- .../pulsar/v2_8/PulsarClientTest.java | 23 ++++---- .../runtimemetrics/java8/JarAnalyzerTest.java | 6 +- .../resources/SpringResourceProviderTest.java | 5 +- .../instrumentation/vaadin/Vaadin16Test.java | 15 +++-- .../vaadin/VaadinLatestTest.java | 15 +++-- .../vaadin/AbstractVaadin14Test.java | 9 ++- .../vaadin/AbstractVaadinTest.java | 11 ++-- .../muzzle/ReferenceCollectorTest.java | 4 +- .../test/base/HttpClientTest.groovy | 6 +- .../test/base/HttpServerTest.groovy | 19 +++--- .../testing/InstrumentationTestRunner.java | 7 +-- 34 files changed, 202 insertions(+), 210 deletions(-) diff --git a/buildscripts/checkstyle.xml b/buildscripts/checkstyle.xml index daa859a76e87..a3a4ff7d3512 100644 --- a/buildscripts/checkstyle.xml +++ b/buildscripts/checkstyle.xml @@ -50,6 +50,18 @@ --> + + + + + + + + diff --git a/docs/contributing/style-guideline.md b/docs/contributing/style-guideline.md index baa025d54c57..42930cc21d25 100644 --- a/docs/contributing/style-guideline.md +++ b/docs/contributing/style-guideline.md @@ -67,6 +67,11 @@ rough guideline of what are commonly accepted static imports: - Singleton instances (especially where clearly named and hopefully immutable) - `tracer()` methods that expose tracer singleton instances +Some of these are enforced by checkstyle rules: + +- look for `RegexpSinglelineJava` in `checkstyle.xml` +- use `@SuppressWarnings("checkstyle:RegexpSinglelineJava")` to suppress the checkstyle warning + ## Ordering of class contents The following order is preferred: diff --git a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/messaging/MessagingProducerMetricsTest.java b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/messaging/MessagingProducerMetricsTest.java index 06521a9801e4..7bf3c3670d4c 100644 --- a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/messaging/MessagingProducerMetricsTest.java +++ b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/messaging/MessagingProducerMetricsTest.java @@ -5,8 +5,8 @@ package io.opentelemetry.instrumentation.api.incubator.semconv.messaging; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; -import static org.assertj.core.api.Assertions.assertThat; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.trace.Span; @@ -16,7 +16,6 @@ import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.OperationListener; import io.opentelemetry.sdk.metrics.SdkMeterProvider; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader; import io.opentelemetry.semconv.ServerAttributes; import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes; @@ -76,7 +75,7 @@ void collectsMetrics() { assertThat(metricReader.collectAllMetrics()) .satisfiesExactlyInAnyOrder( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasName("messaging.publish.duration") .hasUnit("s") .hasDescription("Measures the duration of publish operation.") @@ -112,7 +111,7 @@ void collectsMetrics() { assertThat(metricReader.collectAllMetrics()) .satisfiesExactlyInAnyOrder( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasName("messaging.publish.duration") .hasHistogramSatisfying( histogram -> diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/internal/OperationMetricsUtilTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/internal/OperationMetricsUtilTest.java index 945ab3297a1e..c7a8d0d54a2b 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/internal/OperationMetricsUtilTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/internal/OperationMetricsUtilTest.java @@ -5,6 +5,8 @@ package io.opentelemetry.instrumentation.api.internal; +import static org.assertj.core.api.Assertions.assertThat; + import io.opentelemetry.api.metrics.DoubleHistogramBuilder; import io.opentelemetry.api.metrics.Meter; import io.opentelemetry.api.metrics.MeterProvider; @@ -13,7 +15,6 @@ import io.opentelemetry.instrumentation.testing.junit.LibraryInstrumentationExtension; import java.lang.reflect.Proxy; import java.util.concurrent.atomic.AtomicBoolean; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -29,7 +30,7 @@ void noWarning() { "test metrics", meter -> null, (s, doubleHistogramBuilder) -> warning.set(true)); operationMetrics.create(testing.getOpenTelemetry().getMeter("test")); - Assertions.assertThat(warning).isFalse(); + assertThat(warning).isFalse(); } @Test @@ -40,7 +41,7 @@ void noWarningWithNoopMetrics() { "test metrics", meter -> null, (s, doubleHistogramBuilder) -> warning.set(true)); operationMetrics.create(MeterProvider.noop().get("test")); - Assertions.assertThat(warning).isFalse(); + assertThat(warning).isFalse(); } @Test @@ -65,7 +66,7 @@ void warning() { }); operationMetrics.create(meter); - Assertions.assertThat(warning).isTrue(); + assertThat(warning).isTrue(); } private static DoubleHistogramBuilder proxyDoubleHistogramBuilder(Meter meter) { diff --git a/instrumentation/grails-3.0/javaagent/src/test/java/test/GrailsTest.java b/instrumentation/grails-3.0/javaagent/src/test/java/test/GrailsTest.java index 85d91c7501db..11abd923af40 100644 --- a/instrumentation/grails-3.0/javaagent/src/test/java/test/GrailsTest.java +++ b/instrumentation/grails-3.0/javaagent/src/test/java/test/GrailsTest.java @@ -35,7 +35,6 @@ import java.util.Locale; import java.util.Map; import java.util.function.Consumer; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.extension.RegisterExtension; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.web.ServerProperties; @@ -183,8 +182,7 @@ public List> errorPageSpanAssertions( if (endpoint == NOT_FOUND) { spanAssertions.add( span -> - span.satisfies( - spanData -> Assertions.assertThat(spanData.getName()).endsWith(".sendError")) + span.satisfies(spanData -> assertThat(spanData.getName()).endsWith(".sendError")) .hasKind(SpanKind.INTERNAL) .hasAttributesSatisfying(Attributes::isEmpty)); } diff --git a/instrumentation/grpc-1.6/library/src/test/java/io/opentelemetry/instrumentation/grpc/v1_6/GrpcTest.java b/instrumentation/grpc-1.6/library/src/test/java/io/opentelemetry/instrumentation/grpc/v1_6/GrpcTest.java index da2180df7b4f..5aa6f1aa9a41 100644 --- a/instrumentation/grpc-1.6/library/src/test/java/io/opentelemetry/instrumentation/grpc/v1_6/GrpcTest.java +++ b/instrumentation/grpc-1.6/library/src/test/java/io/opentelemetry/instrumentation/grpc/v1_6/GrpcTest.java @@ -5,6 +5,8 @@ package io.opentelemetry.instrumentation.grpc.v1_6; +import static org.assertj.core.api.Assertions.assertThat; + import example.GreeterGrpc; import example.Helloworld; import io.grpc.BindableService; @@ -23,7 +25,6 @@ import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.LibraryInstrumentationExtension; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import java.util.Collections; import java.util.concurrent.TimeUnit; import javax.annotation.Nullable; @@ -124,7 +125,7 @@ public void sayHello( "parent", () -> client.sayHello(Helloworld.Request.newBuilder().setName("test").build())); - OpenTelemetryAssertions.assertThat(response.getMessage()).isEqualTo("Hello test"); + assertThat(response.getMessage()).isEqualTo("Hello test"); testing() .waitAndAssertTraces( diff --git a/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java b/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java index 0e41014eb4c3..bc812d26babd 100644 --- a/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java +++ b/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java @@ -46,7 +46,6 @@ import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.util.ThrowingRunnable; import io.opentelemetry.sdk.testing.assertj.AttributeAssertion; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import io.opentelemetry.sdk.trace.data.StatusData; import io.opentelemetry.semconv.NetworkAttributes; import io.opentelemetry.semconv.ServerAttributes; @@ -1643,7 +1642,7 @@ public void sayHello( "parent", () -> client.sayHello(Helloworld.Request.newBuilder().setName("test").build())); - OpenTelemetryAssertions.assertThat(response.getMessage()).isEqualTo("Hello test"); + assertThat(response.getMessage()).isEqualTo("Hello test"); testing() .waitAndAssertTraces( diff --git a/instrumentation/lettuce/lettuce-5.1/testing/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceSyncClientAuthTest.java b/instrumentation/lettuce/lettuce-5.1/testing/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceSyncClientAuthTest.java index c74c918d355f..19e354bdf381 100644 --- a/instrumentation/lettuce/lettuce-5.1/testing/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceSyncClientAuthTest.java +++ b/instrumentation/lettuce/lettuce-5.1/testing/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceSyncClientAuthTest.java @@ -6,11 +6,11 @@ package io.opentelemetry.instrumentation.lettuce.v5_1; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies; import static org.assertj.core.api.Assertions.assertThat; import io.lettuce.core.api.sync.RedisCommands; import io.opentelemetry.api.trace.SpanKind; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import io.opentelemetry.semconv.NetworkAttributes; import io.opentelemetry.semconv.ServerAttributes; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; @@ -90,7 +90,7 @@ void testAuthCommand() throws Exception { equalTo(ServerAttributes.SERVER_ADDRESS, host), equalTo(ServerAttributes.SERVER_PORT, port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - OpenTelemetryAssertions.satisfies( + satisfies( DbIncubatingAttributes.DB_STATEMENT, stringAssert -> stringAssert.startsWith("CLIENT SETINFO lib-ver")))), diff --git a/instrumentation/lettuce/lettuce-5.1/testing/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceSyncClientTest.java b/instrumentation/lettuce/lettuce-5.1/testing/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceSyncClientTest.java index 2492fb4c27ec..156a8b49df7f 100644 --- a/instrumentation/lettuce/lettuce-5.1/testing/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceSyncClientTest.java +++ b/instrumentation/lettuce/lettuce-5.1/testing/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceSyncClientTest.java @@ -6,6 +6,7 @@ package io.opentelemetry.instrumentation.lettuce.v5_1; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.catchThrowable; @@ -20,7 +21,6 @@ import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.instrumentation.test.utils.PortUtils; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import io.opentelemetry.semconv.NetworkAttributes; import io.opentelemetry.semconv.ServerAttributes; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; @@ -396,7 +396,7 @@ void testDebugSegfaultCommandWithNoArgumentProducesNoSpan() { equalTo(ServerAttributes.SERVER_ADDRESS, host), equalTo(ServerAttributes.SERVER_PORT, containerConnection.port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - OpenTelemetryAssertions.satisfies( + satisfies( DbIncubatingAttributes.DB_STATEMENT, stringAssert -> stringAssert.startsWith("CLIENT SETINFO lib-ver")))), diff --git a/instrumentation/log4j/log4j-appender-2.17/library/src/test/java/io/opentelemetry/instrumentation/log4j/appender/v2_17/LogReplayOpenTelemetryAppenderTest.java b/instrumentation/log4j/log4j-appender-2.17/library/src/test/java/io/opentelemetry/instrumentation/log4j/appender/v2_17/LogReplayOpenTelemetryAppenderTest.java index af14fe95a4bf..5b854d1fdc8d 100644 --- a/instrumentation/log4j/log4j-appender-2.17/library/src/test/java/io/opentelemetry/instrumentation/log4j/appender/v2_17/LogReplayOpenTelemetryAppenderTest.java +++ b/instrumentation/log4j/log4j-appender-2.17/library/src/test/java/io/opentelemetry/instrumentation/log4j/appender/v2_17/LogReplayOpenTelemetryAppenderTest.java @@ -6,11 +6,10 @@ package io.opentelemetry.instrumentation.log4j.appender.v2_17; import static io.opentelemetry.api.common.AttributeKey.stringKey; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; -import static org.assertj.core.api.Assertions.assertThat; import io.opentelemetry.sdk.logs.data.LogRecordData; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import java.util.List; import org.apache.logging.log4j.message.StringMapMessage; import org.apache.logging.log4j.message.StructuredDataMessage; @@ -45,7 +44,7 @@ void twoLogs() { List logDataList = logRecordExporter.getFinishedLogRecordItems(); assertThat(logDataList).hasSize(1); - OpenTelemetryAssertions.assertThat(logDataList.get(0)) + assertThat(logDataList.get(0)) .hasResource(resource) .hasInstrumentationScope(instrumentationScopeInfo) .hasBody("log message 1"); @@ -69,7 +68,7 @@ void twoLogsStringMapMessage() { List logDataList = logRecordExporter.getFinishedLogRecordItems(); assertThat(logDataList).hasSize(1); - OpenTelemetryAssertions.assertThat(logDataList.get(0)) + assertThat(logDataList.get(0)) .hasResource(resource) .hasInstrumentationScope(instrumentationScopeInfo) .hasAttributesSatisfyingExactly( @@ -94,7 +93,7 @@ void twoLogsStructuredDataMessage() { List logDataList = logRecordExporter.getFinishedLogRecordItems(); assertThat(logDataList).hasSize(1); - OpenTelemetryAssertions.assertThat(logDataList.get(0)) + assertThat(logDataList.get(0)) .hasResource(resource) .hasInstrumentationScope(instrumentationScopeInfo) .hasBody("a message") diff --git a/instrumentation/logback/logback-appender-1.0/library/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/LogReplayOpenTelemetryAppenderTest.java b/instrumentation/logback/logback-appender-1.0/library/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/LogReplayOpenTelemetryAppenderTest.java index 50625dcd14ef..778fcef42839 100644 --- a/instrumentation/logback/logback-appender-1.0/library/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/LogReplayOpenTelemetryAppenderTest.java +++ b/instrumentation/logback/logback-appender-1.0/library/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/LogReplayOpenTelemetryAppenderTest.java @@ -5,13 +5,12 @@ package io.opentelemetry.instrumentation.logback.appender.v1_0; -import static org.assertj.core.api.Assertions.assertThat; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.util.ContextInitializer; import ch.qos.logback.core.spi.ContextAware; import io.opentelemetry.sdk.logs.data.LogRecordData; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import java.net.URL; import java.util.List; import org.junit.jupiter.api.BeforeEach; @@ -65,7 +64,7 @@ void twoLogs() { List logDataList = logRecordExporter.getFinishedLogRecordItems(); assertThat(logDataList).hasSize(1); LogRecordData logData = logDataList.get(0); - OpenTelemetryAssertions.assertThat(logData) + assertThat(logData) .hasResource(resource) .hasInstrumentationScope(instrumentationScopeInfo) .hasBody("log message 1") diff --git a/instrumentation/opencensus-shim/testing/src/test/java/io/opentelemetry/opencensusshim/JavaagentInstrumentationTest.java b/instrumentation/opencensus-shim/testing/src/test/java/io/opentelemetry/opencensusshim/JavaagentInstrumentationTest.java index 6731250b5685..02a11c5754d4 100644 --- a/instrumentation/opencensus-shim/testing/src/test/java/io/opentelemetry/opencensusshim/JavaagentInstrumentationTest.java +++ b/instrumentation/opencensus-shim/testing/src/test/java/io/opentelemetry/opencensusshim/JavaagentInstrumentationTest.java @@ -5,6 +5,8 @@ package io.opentelemetry.opencensusshim; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies; + import io.opencensus.trace.AttributeValue; import io.opencensus.trace.Tracing; import io.opencensus.trace.samplers.Samplers; @@ -15,7 +17,6 @@ import io.opentelemetry.context.Scope; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import org.assertj.core.api.AbstractBooleanAssert; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -84,9 +85,9 @@ void testInterleavedSpansOcFirst() { .hasNoParent() .hasAttribute(AttributeKey.booleanKey("outer"), true) .hasAttributesSatisfying( - OpenTelemetryAssertions.satisfies( + satisfies( AttributeKey.booleanKey("inner"), AbstractBooleanAssert::isNull), - OpenTelemetryAssertions.satisfies( + satisfies( AttributeKey.booleanKey("middle"), AbstractBooleanAssert::isNull)), // middle span sa -> @@ -94,9 +95,9 @@ void testInterleavedSpansOcFirst() { .hasParent(ta.getSpan(0)) .hasAttribute(AttributeKey.booleanKey("middle"), true) .hasAttributesSatisfying( - OpenTelemetryAssertions.satisfies( + satisfies( AttributeKey.booleanKey("inner"), AbstractBooleanAssert::isNull), - OpenTelemetryAssertions.satisfies( + satisfies( AttributeKey.booleanKey("outer"), AbstractBooleanAssert::isNull)), // inner span sa -> @@ -104,9 +105,9 @@ void testInterleavedSpansOcFirst() { .hasParent(ta.getSpan(1)) .hasAttribute(AttributeKey.booleanKey("inner"), true) .hasAttributesSatisfying( - OpenTelemetryAssertions.satisfies( + satisfies( AttributeKey.booleanKey("middle"), AbstractBooleanAssert::isNull), - OpenTelemetryAssertions.satisfies( + satisfies( AttributeKey.booleanKey("outer"), AbstractBooleanAssert::isNull)))); } @@ -159,9 +160,9 @@ void testInterleavedSpansOtelFirst() { .hasNoParent() .hasAttribute(AttributeKey.booleanKey("outer"), true) .hasAttributesSatisfying( - OpenTelemetryAssertions.satisfies( + satisfies( AttributeKey.booleanKey("inner"), AbstractBooleanAssert::isNull), - OpenTelemetryAssertions.satisfies( + satisfies( AttributeKey.booleanKey("middle"), AbstractBooleanAssert::isNull)), // middle span sa -> @@ -169,9 +170,9 @@ void testInterleavedSpansOtelFirst() { .hasParent(ta.getSpan(0)) .hasAttribute(AttributeKey.booleanKey("middle"), true) .hasAttributesSatisfying( - OpenTelemetryAssertions.satisfies( + satisfies( AttributeKey.booleanKey("inner"), AbstractBooleanAssert::isNull), - OpenTelemetryAssertions.satisfies( + satisfies( AttributeKey.booleanKey("outer"), AbstractBooleanAssert::isNull)), // inner span sa -> @@ -179,9 +180,9 @@ void testInterleavedSpansOtelFirst() { .hasParent(ta.getSpan(1)) .hasAttribute(AttributeKey.booleanKey("inner"), true) .hasAttributesSatisfying( - OpenTelemetryAssertions.satisfies( + satisfies( AttributeKey.booleanKey("middle"), AbstractBooleanAssert::isNull), - OpenTelemetryAssertions.satisfies( + satisfies( AttributeKey.booleanKey("outer"), AbstractBooleanAssert::isNull)))); } @@ -299,9 +300,9 @@ void testNestedOpenCensusSpans() { .hasNoParent() .hasAttribute(AttributeKey.booleanKey("outer"), true) .hasAttributesSatisfying( - OpenTelemetryAssertions.satisfies( + satisfies( AttributeKey.booleanKey("inner"), AbstractBooleanAssert::isNull), - OpenTelemetryAssertions.satisfies( + satisfies( AttributeKey.booleanKey("middle"), AbstractBooleanAssert::isNull)), // middle span sa -> @@ -309,9 +310,9 @@ void testNestedOpenCensusSpans() { .hasParent(ta.getSpan(0)) .hasAttribute(AttributeKey.booleanKey("middle"), true) .hasAttributesSatisfying( - OpenTelemetryAssertions.satisfies( + satisfies( AttributeKey.booleanKey("inner"), AbstractBooleanAssert::isNull), - OpenTelemetryAssertions.satisfies( + satisfies( AttributeKey.booleanKey("outer"), AbstractBooleanAssert::isNull)), // inner span sa -> @@ -319,9 +320,9 @@ void testNestedOpenCensusSpans() { .hasParent(ta.getSpan(1)) .hasAttribute(AttributeKey.booleanKey("inner"), true) .hasAttributesSatisfying( - OpenTelemetryAssertions.satisfies( + satisfies( AttributeKey.booleanKey("middle"), AbstractBooleanAssert::isNull), - OpenTelemetryAssertions.satisfies( + satisfies( AttributeKey.booleanKey("outer"), AbstractBooleanAssert::isNull)))); } } diff --git a/instrumentation/opentelemetry-api/opentelemetry-api-1.31/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_31/metrics/MeterTest.java b/instrumentation/opentelemetry-api/opentelemetry-api-1.31/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_31/metrics/MeterTest.java index be7da451a6a4..6c954a646d8f 100644 --- a/instrumentation/opentelemetry-api/opentelemetry-api-1.31/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_31/metrics/MeterTest.java +++ b/instrumentation/opentelemetry-api/opentelemetry-api-1.31/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_31/metrics/MeterTest.java @@ -6,9 +6,9 @@ package io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_31.metrics; import static io.opentelemetry.api.common.AttributeKey.stringKey; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.metrics.DoubleCounter; @@ -40,7 +40,6 @@ import io.opentelemetry.extension.incubator.metrics.LongGauge; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import org.assertj.core.api.AbstractIterableAssert; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -86,7 +85,7 @@ void longCounter() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -123,7 +122,7 @@ void doubleCounter() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -160,7 +159,7 @@ void longUpDownCounter() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -198,7 +197,7 @@ void doubleUpDownCounter() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -236,7 +235,7 @@ void longHistogram() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -274,7 +273,7 @@ void doubleHistogram() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -311,7 +310,7 @@ void longGauge() throws InterruptedException { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -355,7 +354,7 @@ void syncLongGauge() throws InterruptedException { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -398,7 +397,7 @@ void doubleGauge() throws InterruptedException { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -441,7 +440,7 @@ void syncDoubleGauge() throws InterruptedException { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( diff --git a/instrumentation/opentelemetry-api/opentelemetry-api-1.32/javaagent/src/incubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_32/incubator/metrics/MeterTest.java b/instrumentation/opentelemetry-api/opentelemetry-api-1.32/javaagent/src/incubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_32/incubator/metrics/MeterTest.java index 2c8446897eb2..4bd4470e2797 100644 --- a/instrumentation/opentelemetry-api/opentelemetry-api-1.32/javaagent/src/incubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_32/incubator/metrics/MeterTest.java +++ b/instrumentation/opentelemetry-api/opentelemetry-api-1.32/javaagent/src/incubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_32/incubator/metrics/MeterTest.java @@ -6,9 +6,9 @@ package io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_32.incubator.metrics; import static io.opentelemetry.api.common.AttributeKey.stringKey; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.metrics.DoubleCounter; @@ -40,7 +40,6 @@ import io.opentelemetry.extension.incubator.metrics.LongGauge; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import org.assertj.core.api.AbstractIterableAssert; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -86,7 +85,7 @@ void longCounter() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -123,7 +122,7 @@ void doubleCounter() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -160,7 +159,7 @@ void longUpDownCounter() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -198,7 +197,7 @@ void doubleUpDownCounter() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -236,7 +235,7 @@ void longHistogram() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -274,7 +273,7 @@ void doubleHistogram() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -311,7 +310,7 @@ void longGauge() throws InterruptedException { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -355,7 +354,7 @@ void syncLongGauge() throws InterruptedException { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -398,7 +397,7 @@ void doubleGauge() throws InterruptedException { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -441,7 +440,7 @@ void syncDoubleGauge() throws InterruptedException { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( diff --git a/instrumentation/opentelemetry-api/opentelemetry-api-1.32/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_32/metrics/MeterTest.java b/instrumentation/opentelemetry-api/opentelemetry-api-1.32/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_32/metrics/MeterTest.java index 982e47d4e651..aae3a68e7418 100644 --- a/instrumentation/opentelemetry-api/opentelemetry-api-1.32/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_32/metrics/MeterTest.java +++ b/instrumentation/opentelemetry-api/opentelemetry-api-1.32/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_32/metrics/MeterTest.java @@ -6,6 +6,7 @@ package io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_32.metrics; import static io.opentelemetry.api.common.AttributeKey.stringKey; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; import static java.util.Collections.singletonList; @@ -17,7 +18,6 @@ import io.opentelemetry.api.metrics.Meter; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; @@ -61,7 +61,7 @@ void longHistogram() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -96,7 +96,7 @@ void doubleHistogram() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( diff --git a/instrumentation/opentelemetry-api/opentelemetry-api-1.37/javaagent/src/incubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_37/incubator/metrics/MeterTest.java b/instrumentation/opentelemetry-api/opentelemetry-api-1.37/javaagent/src/incubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_37/incubator/metrics/MeterTest.java index 84cc8c400360..ca78917ba4a9 100644 --- a/instrumentation/opentelemetry-api/opentelemetry-api-1.37/javaagent/src/incubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_37/incubator/metrics/MeterTest.java +++ b/instrumentation/opentelemetry-api/opentelemetry-api-1.37/javaagent/src/incubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_37/incubator/metrics/MeterTest.java @@ -6,9 +6,9 @@ package io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_37.incubator.metrics; import static io.opentelemetry.api.common.AttributeKey.stringKey; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.incubator.metrics.DoubleGauge; @@ -40,7 +40,6 @@ import io.opentelemetry.api.metrics.ObservableLongGauge; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import org.assertj.core.api.AbstractIterableAssert; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -86,7 +85,7 @@ void longCounter() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -123,7 +122,7 @@ void doubleCounter() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -160,7 +159,7 @@ void longUpDownCounter() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -198,7 +197,7 @@ void doubleUpDownCounter() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -236,7 +235,7 @@ void longHistogram() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -274,7 +273,7 @@ void doubleHistogram() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -311,7 +310,7 @@ void longGauge() throws InterruptedException { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -355,7 +354,7 @@ void syncLongGauge() throws InterruptedException { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -398,7 +397,7 @@ void doubleGauge() throws InterruptedException { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -441,7 +440,7 @@ void syncDoubleGauge() throws InterruptedException { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( diff --git a/instrumentation/opentelemetry-api/opentelemetry-api-1.37/javaagent/src/oldAndNewIncubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_37/incubator/metrics/MeterTest.java b/instrumentation/opentelemetry-api/opentelemetry-api-1.37/javaagent/src/oldAndNewIncubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_37/incubator/metrics/MeterTest.java index 84cc8c400360..ca78917ba4a9 100644 --- a/instrumentation/opentelemetry-api/opentelemetry-api-1.37/javaagent/src/oldAndNewIncubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_37/incubator/metrics/MeterTest.java +++ b/instrumentation/opentelemetry-api/opentelemetry-api-1.37/javaagent/src/oldAndNewIncubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_37/incubator/metrics/MeterTest.java @@ -6,9 +6,9 @@ package io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_37.incubator.metrics; import static io.opentelemetry.api.common.AttributeKey.stringKey; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.incubator.metrics.DoubleGauge; @@ -40,7 +40,6 @@ import io.opentelemetry.api.metrics.ObservableLongGauge; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import org.assertj.core.api.AbstractIterableAssert; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -86,7 +85,7 @@ void longCounter() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -123,7 +122,7 @@ void doubleCounter() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -160,7 +159,7 @@ void longUpDownCounter() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -198,7 +197,7 @@ void doubleUpDownCounter() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -236,7 +235,7 @@ void longHistogram() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -274,7 +273,7 @@ void doubleHistogram() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -311,7 +310,7 @@ void longGauge() throws InterruptedException { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -355,7 +354,7 @@ void syncLongGauge() throws InterruptedException { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -398,7 +397,7 @@ void doubleGauge() throws InterruptedException { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -441,7 +440,7 @@ void syncDoubleGauge() throws InterruptedException { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( diff --git a/instrumentation/opentelemetry-api/opentelemetry-api-1.37/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_37/metrics/MeterTest.java b/instrumentation/opentelemetry-api/opentelemetry-api-1.37/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_37/metrics/MeterTest.java index 519656f2b27b..f5d2ecaf23fc 100644 --- a/instrumentation/opentelemetry-api/opentelemetry-api-1.37/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_37/metrics/MeterTest.java +++ b/instrumentation/opentelemetry-api/opentelemetry-api-1.37/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_37/metrics/MeterTest.java @@ -6,6 +6,7 @@ package io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_37.metrics; import static io.opentelemetry.api.common.AttributeKey.stringKey; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; import static java.util.Collections.singletonList; @@ -17,7 +18,6 @@ import io.opentelemetry.api.metrics.Meter; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; @@ -61,7 +61,7 @@ void longHistogram() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -96,7 +96,7 @@ void doubleHistogram() { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( diff --git a/instrumentation/opentelemetry-api/opentelemetry-api-1.38/javaagent/src/incubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_38/incubator/metrics/MeterTest.java b/instrumentation/opentelemetry-api/opentelemetry-api-1.38/javaagent/src/incubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_38/incubator/metrics/MeterTest.java index 986c17a04580..f8b9b1fbf94b 100644 --- a/instrumentation/opentelemetry-api/opentelemetry-api-1.38/javaagent/src/incubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_38/incubator/metrics/MeterTest.java +++ b/instrumentation/opentelemetry-api/opentelemetry-api-1.38/javaagent/src/incubatorTest/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_38/incubator/metrics/MeterTest.java @@ -6,9 +6,9 @@ package io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_38.incubator.metrics; import static io.opentelemetry.api.common.AttributeKey.stringKey; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.incubator.metrics.ExtendedDoubleGaugeBuilder; @@ -20,7 +20,6 @@ import io.opentelemetry.api.metrics.Meter; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import org.assertj.core.api.AbstractIterableAssert; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -66,7 +65,7 @@ void syncLongGauge() throws InterruptedException { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -108,7 +107,7 @@ void syncDoubleGauge() throws InterruptedException { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( diff --git a/instrumentation/opentelemetry-api/opentelemetry-api-1.38/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_38/metrics/MeterTest.java b/instrumentation/opentelemetry-api/opentelemetry-api-1.38/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_38/metrics/MeterTest.java index adb929d4c75f..b2719df723e6 100644 --- a/instrumentation/opentelemetry-api/opentelemetry-api-1.38/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_38/metrics/MeterTest.java +++ b/instrumentation/opentelemetry-api/opentelemetry-api-1.38/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_38/metrics/MeterTest.java @@ -6,6 +6,7 @@ package io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_38.metrics; import static io.opentelemetry.api.common.AttributeKey.stringKey; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; import io.opentelemetry.api.common.Attributes; @@ -16,7 +17,6 @@ import io.opentelemetry.api.metrics.Meter; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import org.assertj.core.api.AbstractIterableAssert; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -59,7 +59,7 @@ void syncLongGauge() throws InterruptedException { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( @@ -98,7 +98,7 @@ void syncDoubleGauge() throws InterruptedException { metrics -> metrics.anySatisfy( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasDescription("d") .hasUnit("u") .hasInstrumentationScope( diff --git a/instrumentation/oshi/library/src/test/java/io/opentelemetry/instrumentation/oshi/ProcessMetricsTest.java b/instrumentation/oshi/library/src/test/java/io/opentelemetry/instrumentation/oshi/ProcessMetricsTest.java index b1134922928a..f2b3dc14bdb0 100644 --- a/instrumentation/oshi/library/src/test/java/io/opentelemetry/instrumentation/oshi/ProcessMetricsTest.java +++ b/instrumentation/oshi/library/src/test/java/io/opentelemetry/instrumentation/oshi/ProcessMetricsTest.java @@ -5,11 +5,12 @@ package io.opentelemetry.instrumentation.oshi; +import static org.assertj.core.api.Assertions.assertThat; + import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.LibraryInstrumentationExtension; import java.util.List; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -48,6 +49,6 @@ protected InstrumentationExtension testing() { @Test void verifyObservablesAreNotEmpty() { - Assertions.assertThat(observables).as("List of observables").isNotEmpty(); + assertThat(observables).as("List of observables").isNotEmpty(); } } diff --git a/instrumentation/oshi/library/src/test/java/io/opentelemetry/instrumentation/oshi/SystemMetricsTest.java b/instrumentation/oshi/library/src/test/java/io/opentelemetry/instrumentation/oshi/SystemMetricsTest.java index 4f2fd97fa623..958378004852 100644 --- a/instrumentation/oshi/library/src/test/java/io/opentelemetry/instrumentation/oshi/SystemMetricsTest.java +++ b/instrumentation/oshi/library/src/test/java/io/opentelemetry/instrumentation/oshi/SystemMetricsTest.java @@ -5,11 +5,12 @@ package io.opentelemetry.instrumentation.oshi; +import static org.assertj.core.api.Assertions.assertThat; + import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.LibraryInstrumentationExtension; import java.util.List; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -48,6 +49,6 @@ protected InstrumentationExtension testing() { @Test void verifyObservablesAreNotEmpty() { - Assertions.assertThat(observables).as("List of observables").isNotEmpty(); + assertThat(observables).as("List of observables").isNotEmpty(); } } diff --git a/instrumentation/pulsar/pulsar-2.8/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/pulsar/v2_8/AbstractPulsarClientTest.java b/instrumentation/pulsar/pulsar-2.8/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/pulsar/v2_8/AbstractPulsarClientTest.java index 65ef82d94d9f..d87708e196bb 100644 --- a/instrumentation/pulsar/pulsar-2.8/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/pulsar/v2_8/AbstractPulsarClientTest.java +++ b/instrumentation/pulsar/pulsar-2.8/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/pulsar/v2_8/AbstractPulsarClientTest.java @@ -5,6 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.pulsar.v2_8; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies; import static io.opentelemetry.semconv.ServerAttributes.SERVER_ADDRESS; @@ -16,14 +17,12 @@ import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID; import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_OPERATION; import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_SYSTEM; -import static org.assertj.core.api.Assertions.assertThat; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.sdk.testing.assertj.AttributeAssertion; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import io.opentelemetry.sdk.trace.data.LinkData; import io.opentelemetry.sdk.trace.data.SpanData; import java.time.Duration; @@ -174,7 +173,7 @@ void testConsumeNonPartitionedTopicUsingBatchReceive() throws Exception { assertThat(testing.metrics()) .satisfiesExactlyInAnyOrder( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasName("messaging.receive.duration") .hasUnit("s") .hasDescription("Measures the duration of receive operation.") @@ -191,7 +190,7 @@ void testConsumeNonPartitionedTopicUsingBatchReceive() throws Exception { equalTo(SERVER_ADDRESS, brokerHost)) .hasBucketBoundaries(DURATION_BUCKETS))), metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasName("messaging.publish.duration") .hasUnit("s") .hasDescription("Measures the duration of publish operation.") @@ -208,23 +207,21 @@ void testConsumeNonPartitionedTopicUsingBatchReceive() throws Exception { equalTo(SERVER_ADDRESS, brokerHost)) .hasBucketBoundaries(DURATION_BUCKETS))), metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasName("messaging.receive.messages") .hasUnit("{message}") .hasDescription("Measures the number of received messages.") .hasLongSumSatisfying( - sum -> { - sum.hasPointsSatisfying( - point -> { - point - .hasValue(1) - .hasAttributesSatisfying( - equalTo(MESSAGING_SYSTEM, "pulsar"), - equalTo(MESSAGING_DESTINATION_NAME, topic), - equalTo(SERVER_PORT, brokerPort), - equalTo(SERVER_ADDRESS, brokerHost)); - }); - })); + sum -> + sum.hasPointsSatisfying( + point -> + point + .hasValue(1) + .hasAttributesSatisfying( + equalTo(MESSAGING_SYSTEM, "pulsar"), + equalTo(MESSAGING_DESTINATION_NAME, topic), + equalTo(SERVER_PORT, brokerPort), + equalTo(SERVER_ADDRESS, brokerHost))))); } @Test @@ -292,7 +289,7 @@ void testConsumeNonPartitionedTopicUsingBatchReceiveAsync() throws Exception { assertThat(testing.metrics()) .satisfiesExactlyInAnyOrder( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasName("messaging.receive.duration") .hasUnit("s") .hasDescription("Measures the duration of receive operation.") @@ -309,7 +306,7 @@ void testConsumeNonPartitionedTopicUsingBatchReceiveAsync() throws Exception { equalTo(SERVER_ADDRESS, brokerHost)) .hasBucketBoundaries(DURATION_BUCKETS))), metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasName("messaging.publish.duration") .hasUnit("s") .hasDescription("Measures the duration of publish operation.") @@ -326,23 +323,21 @@ void testConsumeNonPartitionedTopicUsingBatchReceiveAsync() throws Exception { equalTo(SERVER_ADDRESS, brokerHost)) .hasBucketBoundaries(DURATION_BUCKETS))), metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasName("messaging.receive.messages") .hasUnit("{message}") .hasDescription("Measures the number of received messages.") .hasLongSumSatisfying( - sum -> { - sum.hasPointsSatisfying( - point -> { - point - .hasValue(1) - .hasAttributesSatisfying( - equalTo(MESSAGING_SYSTEM, "pulsar"), - equalTo(MESSAGING_DESTINATION_NAME, topic), - equalTo(SERVER_PORT, brokerPort), - equalTo(SERVER_ADDRESS, brokerHost)); - }); - })); + sum -> + sum.hasPointsSatisfying( + point -> + point + .hasValue(1) + .hasAttributesSatisfying( + equalTo(MESSAGING_SYSTEM, "pulsar"), + equalTo(MESSAGING_DESTINATION_NAME, topic), + equalTo(SERVER_PORT, brokerPort), + equalTo(SERVER_ADDRESS, brokerHost))))); } static List sendAttributes( diff --git a/instrumentation/pulsar/pulsar-2.8/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/pulsar/v2_8/PulsarClientTest.java b/instrumentation/pulsar/pulsar-2.8/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/pulsar/v2_8/PulsarClientTest.java index 2166d552061f..93f13f9ee1d8 100644 --- a/instrumentation/pulsar/pulsar-2.8/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/pulsar/v2_8/PulsarClientTest.java +++ b/instrumentation/pulsar/pulsar-2.8/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/pulsar/v2_8/PulsarClientTest.java @@ -7,15 +7,14 @@ import static io.opentelemetry.instrumentation.testing.util.TelemetryDataUtil.orderByRootSpanKind; import static io.opentelemetry.instrumentation.testing.util.TelemetryDataUtil.orderByRootSpanName; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; import static io.opentelemetry.semconv.ServerAttributes.SERVER_ADDRESS; import static io.opentelemetry.semconv.ServerAttributes.SERVER_PORT; import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME; import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_SYSTEM; -import static org.assertj.core.api.Assertions.assertThat; import io.opentelemetry.api.trace.SpanKind; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import io.opentelemetry.sdk.trace.data.LinkData; import io.opentelemetry.sdk.trace.data.SpanData; import java.util.concurrent.CompletableFuture; @@ -138,7 +137,7 @@ void testConsumeNonPartitionedTopicUsingReceive() throws Exception { assertThat(testing.metrics()) .satisfiesExactlyInAnyOrder( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasName("messaging.receive.duration") .hasUnit("s") .hasDescription("Measures the duration of receive operation.") @@ -155,7 +154,7 @@ void testConsumeNonPartitionedTopicUsingReceive() throws Exception { equalTo(SERVER_ADDRESS, brokerHost)) .hasBucketBoundaries(DURATION_BUCKETS))), metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasName("messaging.receive.messages") .hasUnit("{message}") .hasDescription("Measures the number of received messages.") @@ -173,7 +172,7 @@ void testConsumeNonPartitionedTopicUsingReceive() throws Exception { }); }), metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasName("messaging.publish.duration") .hasUnit("s") .hasDescription("Measures the duration of publish operation.") @@ -252,7 +251,7 @@ void testConsumeNonPartitionedTopicUsingReceiveAsync() throws Exception { assertThat(testing.metrics()) .satisfiesExactlyInAnyOrder( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasName("messaging.receive.duration") .hasUnit("s") .hasDescription("Measures the duration of receive operation.") @@ -269,7 +268,7 @@ void testConsumeNonPartitionedTopicUsingReceiveAsync() throws Exception { equalTo(SERVER_ADDRESS, brokerHost)) .hasBucketBoundaries(DURATION_BUCKETS))), metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasName("messaging.receive.messages") .hasUnit("{message}") .hasDescription("Measures the number of received messages.") @@ -287,7 +286,7 @@ void testConsumeNonPartitionedTopicUsingReceiveAsync() throws Exception { }); }), metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasName("messaging.publish.duration") .hasUnit("s") .hasDescription("Measures the duration of publish operation.") @@ -353,7 +352,7 @@ void testConsumeNonPartitionedTopicUsingReceiveWithTimeout() throws Exception { assertThat(testing.metrics()) .satisfiesExactlyInAnyOrder( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasName("messaging.receive.duration") .hasUnit("s") .hasDescription("Measures the duration of receive operation.") @@ -370,7 +369,7 @@ void testConsumeNonPartitionedTopicUsingReceiveWithTimeout() throws Exception { equalTo(SERVER_ADDRESS, brokerHost)) .hasBucketBoundaries(DURATION_BUCKETS))), metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasName("messaging.receive.messages") .hasUnit("{message}") .hasDescription("Measures the number of received messages.") @@ -388,7 +387,7 @@ void testConsumeNonPartitionedTopicUsingReceiveWithTimeout() throws Exception { }); }), metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasName("messaging.publish.duration") .hasUnit("s") .hasDescription("Measures the duration of publish operation.") @@ -643,7 +642,7 @@ void testConsumePartitionedTopicUsingBatchReceive() throws Exception { assertThat(testing.metrics()) .satisfiesOnlyOnce( metric -> - OpenTelemetryAssertions.assertThat(metric) + assertThat(metric) .hasName("messaging.receive.messages") .hasUnit("{message}") .hasDescription("Measures the number of received messages.") diff --git a/instrumentation/runtime-telemetry/runtime-telemetry-java8/testing/src/test/java/io/opentelemetry/instrumentation/javaagent/runtimemetrics/java8/JarAnalyzerTest.java b/instrumentation/runtime-telemetry/runtime-telemetry-java8/testing/src/test/java/io/opentelemetry/instrumentation/javaagent/runtimemetrics/java8/JarAnalyzerTest.java index f49aba1cbe40..4ce7cbea0a69 100644 --- a/instrumentation/runtime-telemetry/runtime-telemetry-java8/testing/src/test/java/io/opentelemetry/instrumentation/javaagent/runtimemetrics/java8/JarAnalyzerTest.java +++ b/instrumentation/runtime-telemetry/runtime-telemetry-java8/testing/src/test/java/io/opentelemetry/instrumentation/javaagent/runtimemetrics/java8/JarAnalyzerTest.java @@ -12,7 +12,7 @@ import static io.opentelemetry.instrumentation.javaagent.runtimemetrics.java8.JarAnalyzer.PACKAGE_PATH; import static io.opentelemetry.instrumentation.javaagent.runtimemetrics.java8.JarAnalyzer.PACKAGE_TYPE; import static io.opentelemetry.instrumentation.javaagent.runtimemetrics.java8.JarAnalyzer.PACKAGE_VERSION; -import static org.assertj.core.api.Assertions.assertThat; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; @@ -25,7 +25,6 @@ import io.opentelemetry.api.incubator.events.EventLogger; import io.opentelemetry.api.trace.Tracer; import io.opentelemetry.sdk.testing.assertj.AttributesAssert; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import java.io.File; import java.net.MalformedURLException; import java.net.URL; @@ -52,8 +51,7 @@ void processUrl_EmitsEvents(URL archiveUrl, Consumer attribute ArgumentCaptor attributesArgumentCaptor = ArgumentCaptor.forClass(Attributes.class); verify(builder).setAttributes(attributesArgumentCaptor.capture()); - attributesConsumer.accept( - OpenTelemetryAssertions.assertThat(attributesArgumentCaptor.getValue())); + attributesConsumer.accept(assertThat(attributesArgumentCaptor.getValue())); } private static Stream processUrlArguments() { diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/resources/SpringResourceProviderTest.java b/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/resources/SpringResourceProviderTest.java index 614f33b37273..b2c4bc3b521c 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/resources/SpringResourceProviderTest.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/resources/SpringResourceProviderTest.java @@ -5,6 +5,8 @@ package io.opentelemetry.instrumentation.spring.autoconfigure.internal.resources; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; + import io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration; import io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties.OtelResourceProperties; import io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties.OtlpExporterProperties; @@ -13,7 +15,6 @@ import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties; import io.opentelemetry.sdk.testing.assertj.AttributesAssert; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import io.opentelemetry.semconv.ServiceAttributes; import java.util.Collections; import java.util.Properties; @@ -70,7 +71,7 @@ private static AttributesAssert assertResourceAttributes(AssertableApplicationCo new PropagationProperties(), DefaultConfigProperties.createFromMap(Collections.emptyMap())); - return OpenTelemetryAssertions.assertThat( + return assertThat( context .getBean(SpringResourceProvider.class) .createResource(configProperties) diff --git a/instrumentation/vaadin-14.2/javaagent/src/vaadin16Test/java/io/opentelemetry/javaagent/instrumentation/vaadin/Vaadin16Test.java b/instrumentation/vaadin-14.2/javaagent/src/vaadin16Test/java/io/opentelemetry/javaagent/instrumentation/vaadin/Vaadin16Test.java index 7c9ea5ac1e9a..f51f621c2c60 100644 --- a/instrumentation/vaadin-14.2/javaagent/src/vaadin16Test/java/io/opentelemetry/javaagent/instrumentation/vaadin/Vaadin16Test.java +++ b/instrumentation/vaadin-14.2/javaagent/src/vaadin16Test/java/io/opentelemetry/javaagent/instrumentation/vaadin/Vaadin16Test.java @@ -5,11 +5,10 @@ package io.opentelemetry.javaagent.instrumentation.vaadin; -import static org.assertj.core.api.Assertions.assertThat; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static org.awaitility.Awaitility.await; import io.opentelemetry.api.trace.SpanKind; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import io.opentelemetry.sdk.testing.assertj.TracesAssert; import io.opentelemetry.sdk.trace.data.SpanData; import java.io.File; @@ -40,32 +39,32 @@ void assertFirstRequest() { assertThat(trace.get(0)) .satisfies( spans -> - OpenTelemetryAssertions.assertThat(spans.get(0)) + assertThat(spans.get(0)) .hasName("GET IndexHtmlRequestHandler.handleRequest") .hasNoParent() .hasKind(SpanKind.SERVER)); assertThat(trace) .anySatisfy( spans -> { - OpenTelemetryAssertions.assertThat(spans.get(0)) + assertThat(spans.get(0)) .hasName("POST " + getContextPath() + "/main") .hasNoParent() .hasKind(SpanKind.SERVER); - OpenTelemetryAssertions.assertThat(spans.get(1)) + assertThat(spans.get(1)) .hasName("SpringVaadinServletService.handleRequest") .hasParent(spans.get(0)) .hasKind(SpanKind.INTERNAL); // we don't assert all the handler spans as these vary between // vaadin versions - OpenTelemetryAssertions.assertThat(spans.get(spans.size() - 3)) + assertThat(spans.get(spans.size() - 3)) .hasName("UidlRequestHandler.handleRequest") .hasParent(spans.get(1)) .hasKind(SpanKind.INTERNAL); - OpenTelemetryAssertions.assertThat(spans.get(spans.size() - 2)) + assertThat(spans.get(spans.size() - 2)) .hasName("PublishedServerEventHandlerRpcHandler.handle") .hasParent(spans.get(spans.size() - 3)) .hasKind(SpanKind.INTERNAL); - OpenTelemetryAssertions.assertThat(spans.get(spans.size() - 1)) + assertThat(spans.get(spans.size() - 1)) .hasName("JavaScriptBootstrapUI.connectClient") .hasParent(spans.get(spans.size() - 2)) .hasKind(SpanKind.INTERNAL); diff --git a/instrumentation/vaadin-14.2/javaagent/src/vaadinLatestTest/java/io/opentelemetry/javaagent/instrumentation/vaadin/VaadinLatestTest.java b/instrumentation/vaadin-14.2/javaagent/src/vaadinLatestTest/java/io/opentelemetry/javaagent/instrumentation/vaadin/VaadinLatestTest.java index e92817a3acba..ab3fcd05974c 100644 --- a/instrumentation/vaadin-14.2/javaagent/src/vaadinLatestTest/java/io/opentelemetry/javaagent/instrumentation/vaadin/VaadinLatestTest.java +++ b/instrumentation/vaadin-14.2/javaagent/src/vaadinLatestTest/java/io/opentelemetry/javaagent/instrumentation/vaadin/VaadinLatestTest.java @@ -5,11 +5,10 @@ package io.opentelemetry.javaagent.instrumentation.vaadin; -import static org.assertj.core.api.Assertions.assertThat; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static org.awaitility.Awaitility.await; import io.opentelemetry.api.trace.SpanKind; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import io.opentelemetry.sdk.testing.assertj.TracesAssert; import io.opentelemetry.sdk.trace.data.SpanData; import java.util.List; @@ -28,32 +27,32 @@ void assertFirstRequest() { assertThat(trace.get(0)) .satisfies( spans -> - OpenTelemetryAssertions.assertThat(spans.get(0)) + assertThat(spans.get(0)) .hasName("GET IndexHtmlRequestHandler.handleRequest") .hasNoParent() .hasKind(SpanKind.SERVER)); assertThat(trace) .anySatisfy( spans -> { - OpenTelemetryAssertions.assertThat(spans.get(0)) + assertThat(spans.get(0)) .hasName("POST " + getContextPath()) .hasNoParent() .hasKind(SpanKind.SERVER); - OpenTelemetryAssertions.assertThat(spans.get(1)) + assertThat(spans.get(1)) .hasName("SpringVaadinServletService.handleRequest") .hasParent(spans.get(0)) .hasKind(SpanKind.INTERNAL); // we don't assert all the handler spans as these vary between // vaadin versions - OpenTelemetryAssertions.assertThat(spans.get(spans.size() - 3)) + assertThat(spans.get(spans.size() - 3)) .hasName("UidlRequestHandler.handleRequest") .hasParent(spans.get(1)) .hasKind(SpanKind.INTERNAL); - OpenTelemetryAssertions.assertThat(spans.get(spans.size() - 2)) + assertThat(spans.get(spans.size() - 2)) .hasName("PublishedServerEventHandlerRpcHandler.handle") .hasParent(spans.get(spans.size() - 3)) .hasKind(SpanKind.INTERNAL); - OpenTelemetryAssertions.assertThat(spans.get(spans.size() - 1)) + assertThat(spans.get(spans.size() - 1)) .hasName("UI.connectClient") .hasParent(spans.get(spans.size() - 2)) .hasKind(SpanKind.INTERNAL); diff --git a/instrumentation/vaadin-14.2/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/AbstractVaadin14Test.java b/instrumentation/vaadin-14.2/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/AbstractVaadin14Test.java index fff1388fa74f..82eb7ee48dd8 100644 --- a/instrumentation/vaadin-14.2/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/AbstractVaadin14Test.java +++ b/instrumentation/vaadin-14.2/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/AbstractVaadin14Test.java @@ -5,11 +5,10 @@ package io.opentelemetry.javaagent.instrumentation.vaadin; -import static org.assertj.core.api.Assertions.assertThat; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static org.awaitility.Awaitility.await; import io.opentelemetry.api.trace.SpanKind; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import io.opentelemetry.sdk.trace.data.SpanData; import java.util.List; @@ -23,17 +22,17 @@ void assertFirstRequest() { assertThat(traces.get(0)) .satisfies( spans -> { - OpenTelemetryAssertions.assertThat(spans.get(0)) + assertThat(spans.get(0)) .hasName("GET " + getContextPath() + "/main") .hasNoParent() .hasKind(SpanKind.SERVER); - OpenTelemetryAssertions.assertThat(spans.get(1)) + assertThat(spans.get(1)) .hasName("SpringVaadinServletService.handleRequest") .hasParent(spans.get(0)) .hasKind(SpanKind.INTERNAL); // we don't assert all the handler spans as these vary between // vaadin versions - OpenTelemetryAssertions.assertThat(spans.get(spans.size() - 1)) + assertThat(spans.get(spans.size() - 1)) .hasName("BootstrapHandler.handleRequest") .hasParent(spans.get(1)) .hasKind(SpanKind.INTERNAL); diff --git a/instrumentation/vaadin-14.2/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/AbstractVaadinTest.java b/instrumentation/vaadin-14.2/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/AbstractVaadinTest.java index 161a574119ed..f80635f5cae2 100644 --- a/instrumentation/vaadin-14.2/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/AbstractVaadinTest.java +++ b/instrumentation/vaadin-14.2/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/AbstractVaadinTest.java @@ -5,7 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.vaadin; -import static org.assertj.core.api.Assertions.assertThat; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static org.awaitility.Awaitility.await; import com.vaadin.flow.server.Version; @@ -14,7 +14,6 @@ import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerUsingTest; import io.opentelemetry.instrumentation.testing.junit.http.HttpServerInstrumentationExtension; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import io.opentelemetry.sdk.trace.data.SpanData; import java.io.File; import java.io.IOException; @@ -154,21 +153,21 @@ private void assertButtonClick() { assertThat(traces.get(0)) .satisfies( spans -> { - OpenTelemetryAssertions.assertThat(spans.get(0)) + assertThat(spans.get(0)) .hasName("POST " + getContextPath() + "/main") .hasNoParent() .hasKind(SpanKind.SERVER); - OpenTelemetryAssertions.assertThat(spans.get(1)) + assertThat(spans.get(1)) .hasName("SpringVaadinServletService.handleRequest") .hasParent(spans.get(0)) .hasKind(SpanKind.INTERNAL); // we don't assert all the handler spans as these vary between // vaadin versions - OpenTelemetryAssertions.assertThat(spans.get(spans.size() - 2)) + assertThat(spans.get(spans.size() - 2)) .hasName("UidlRequestHandler.handleRequest") .hasParent(spans.get(1)) .hasKind(SpanKind.INTERNAL); - OpenTelemetryAssertions.assertThat(spans.get(spans.size() - 1)) + assertThat(spans.get(spans.size() - 1)) .hasName("EventRpcHandler.handle/click") .hasParent(spans.get(spans.size() - 2)) .hasKind(SpanKind.INTERNAL); diff --git a/muzzle/src/test/java/io/opentelemetry/javaagent/tooling/muzzle/ReferenceCollectorTest.java b/muzzle/src/test/java/io/opentelemetry/javaagent/tooling/muzzle/ReferenceCollectorTest.java index 04cd424be6f1..d9d49612c18a 100644 --- a/muzzle/src/test/java/io/opentelemetry/javaagent/tooling/muzzle/ReferenceCollectorTest.java +++ b/muzzle/src/test/java/io/opentelemetry/javaagent/tooling/muzzle/ReferenceCollectorTest.java @@ -8,6 +8,7 @@ import static io.opentelemetry.javaagent.tooling.muzzle.references.Flag.MinimumVisibilityFlag.PACKAGE_OR_HIGHER; import static io.opentelemetry.javaagent.tooling.muzzle.references.Flag.MinimumVisibilityFlag.PROTECTED_OR_HIGHER; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.entry; import external.instrumentation.ExternalHelper; @@ -31,7 +32,6 @@ import muzzle.TestClasses.MethodBodyAdvice; import muzzle.TestClasses.Nested; import muzzle.other.OtherTestClasses; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -369,7 +369,7 @@ public void shouldNotCollectVirtualFieldsForInvalidScenario( @SuppressWarnings("unused") String desc, String adviceClassName) { ReferenceCollector collector = new ReferenceCollector(s -> false); - Assertions.assertThatExceptionOfType(MuzzleCompilationException.class) + assertThatExceptionOfType(MuzzleCompilationException.class) .isThrownBy( () -> { collector.collectReferencesFromAdvice(adviceClassName); diff --git a/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpClientTest.groovy b/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpClientTest.groovy index 3dd760176144..38449f0ff596 100644 --- a/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpClientTest.groovy +++ b/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpClientTest.groovy @@ -15,12 +15,12 @@ import io.opentelemetry.instrumentation.testing.junit.http.HttpClientResult import io.opentelemetry.instrumentation.testing.junit.http.HttpClientTestOptions import io.opentelemetry.instrumentation.testing.junit.http.HttpClientTestServer import io.opentelemetry.instrumentation.testing.junit.http.SingleConnection -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions import io.opentelemetry.sdk.trace.data.SpanData import spock.lang.Requires import spock.lang.Shared import spock.lang.Unroll +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat import static org.junit.jupiter.api.Assumptions.assumeTrue @Unroll @@ -445,7 +445,7 @@ abstract class HttpClientTest extends InstrumentationSpecification { final void clientSpan(TraceAssert trace, int index, Object parentSpan, String method = "GET", URI uri = resolveAddress("/success"), Integer responseCode = 200) { trace.assertedIndexes.add(index) def spanData = trace.span(index) - def assertion = junitTest.assertClientSpan(OpenTelemetryAssertions.assertThat(spanData), uri, method, responseCode, null) + def assertion = junitTest.assertClientSpan(assertThat(spanData), uri, method, responseCode, null) if (parentSpan == null) { assertion.hasParentSpanId(SpanId.invalid) } else { @@ -456,7 +456,7 @@ abstract class HttpClientTest extends InstrumentationSpecification { final void serverSpan(TraceAssert trace, int index, Object parentSpan = null) { trace.assertedIndexes.add(index) def spanData = trace.span(index) - def assertion = junitTest.assertServerSpan(OpenTelemetryAssertions.assertThat(spanData)) + def assertion = junitTest.assertServerSpan(assertThat(spanData)) if (parentSpan == null) { assertion.hasParentSpanId(SpanId.invalid) } else { diff --git a/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy b/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy index 54bcba8bbc26..51ebea5841f1 100644 --- a/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy +++ b/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy @@ -9,7 +9,6 @@ import io.opentelemetry.api.common.AttributeKey import io.opentelemetry.api.trace.Span import io.opentelemetry.api.trace.SpanId import io.opentelemetry.api.trace.SpanKind -import io.opentelemetry.semconv.NetworkAttributes import io.opentelemetry.instrumentation.api.internal.HttpConstants import io.opentelemetry.instrumentation.test.InstrumentationSpecification import io.opentelemetry.instrumentation.test.asserts.TraceAssert @@ -17,9 +16,9 @@ import io.opentelemetry.instrumentation.testing.GlobalTraceUtil import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerTest import io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions import io.opentelemetry.sdk.trace.data.SpanData import io.opentelemetry.semconv.HttpAttributes +import io.opentelemetry.semconv.NetworkAttributes import io.opentelemetry.testing.internal.armeria.common.AggregatedHttpRequest import io.opentelemetry.testing.internal.armeria.common.HttpMethod import spock.lang.Shared @@ -28,12 +27,8 @@ import spock.lang.Unroll import javax.annotation.Nullable import java.util.concurrent.Callable -import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.EXCEPTION -import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.INDEXED_CHILD -import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.NOT_FOUND -import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.PATH_PARAM -import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.QUERY_PARAM -import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.SUCCESS +import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.* +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat import static org.junit.jupiter.api.Assumptions.assumeFalse import static org.junit.jupiter.api.Assumptions.assumeTrue @@ -455,7 +450,7 @@ abstract class HttpServerTest extends InstrumentationSpecification imple void controllerSpan(TraceAssert trace, int index, Object parent, Throwable expectedException = null) { trace.assertedIndexes.add(index) def spanData = trace.span(index) - def assertion = junitTest.assertControllerSpan(OpenTelemetryAssertions.assertThat(spanData), expectedException) + def assertion = junitTest.assertControllerSpan(assertThat(spanData), expectedException) if (parent == null) { assertion.hasParentSpanId(SpanId.invalid) } else { @@ -502,7 +497,7 @@ abstract class HttpServerTest extends InstrumentationSpecification imple void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", ServerEndpoint endpoint = SUCCESS, String spanID = null) { trace.assertedIndexes.add(index) def spanData = trace.span(index) - def assertion = junitTest.assertServerSpan(OpenTelemetryAssertions.assertThat(spanData), method, endpoint, endpoint.status) + def assertion = junitTest.assertServerSpan(assertThat(spanData), method, endpoint, endpoint.status) if (parentID == null) { assertion.hasParentSpanId(SpanId.invalid) } else { @@ -519,7 +514,7 @@ abstract class HttpServerTest extends InstrumentationSpecification imple void indexedServerSpan(TraceAssert trace, int index, Object parent, int requestId) { trace.assertedIndexes.add(index) def spanData = trace.span(index) - def assertion = junitTest.assertIndexedServerSpan(OpenTelemetryAssertions.assertThat(spanData), requestId) + def assertion = junitTest.assertIndexedServerSpan(assertThat(spanData), requestId) if (parent == null) { assertion.hasParentSpanId(SpanId.invalid) } else { @@ -530,7 +525,7 @@ abstract class HttpServerTest extends InstrumentationSpecification imple void indexedControllerSpan(TraceAssert trace, int index, Object parent, int requestId) { trace.assertedIndexes.add(index) def spanData = trace.span(index) - def assertion = junitTest.assertIndexedControllerSpan(OpenTelemetryAssertions.assertThat(spanData), requestId) + def assertion = junitTest.assertIndexedControllerSpan(assertThat(spanData), requestId) if (parent == null) { assertion.hasParentSpanId(SpanId.invalid) } else { diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/InstrumentationTestRunner.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/InstrumentationTestRunner.java index 6580189cf90c..8f68cce5c084 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/InstrumentationTestRunner.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/InstrumentationTestRunner.java @@ -5,7 +5,7 @@ package io.opentelemetry.instrumentation.testing; -import static org.assertj.core.api.Assertions.assertThat; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static org.awaitility.Awaitility.await; import io.opentelemetry.api.OpenTelemetry; @@ -15,7 +15,6 @@ import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.metrics.data.MetricData; import io.opentelemetry.sdk.testing.assertj.MetricAssert; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import io.opentelemetry.sdk.testing.assertj.TraceAssert; import io.opentelemetry.sdk.testing.assertj.TracesAssert; import io.opentelemetry.sdk.trace.data.SpanData; @@ -182,9 +181,7 @@ public final void waitAndAssertMetrics( Collection metrics = instrumentationMetrics(instrumentationName); assertThat(metrics).isNotEmpty(); for (Consumer assertion : assertions) { - assertThat(metrics) - .anySatisfy( - metric -> assertion.accept(OpenTelemetryAssertions.assertThat(metric))); + assertThat(metrics).anySatisfy(metric -> assertion.accept(assertThat(metric))); } }); }