Skip to content

Replace TestObservationRegistryAssert.assertThat() with Assertions.assertThat() #33929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ private void runScheduledTaskAndAwait() throws InterruptedException {
}

private TestObservationRegistryAssert.TestObservationRegistryAssertReturningObservationContextAssert assertThatTaskObservation() {
return TestObservationRegistryAssert.assertThat(this.observationRegistry)
.hasObservationWithNameEqualTo("tasks.scheduled.execution").that();
return assertThat(this.observationRegistry).hasObservationWithNameEqualTo("tasks.scheduled.execution").that();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ void shouldUseCustomConvention() throws Exception {

restClient.get().uri("https://example.org").retrieve().toBodilessEntity();

TestObservationRegistryAssert.assertThat(this.observationRegistry)
.hasObservationWithNameEqualTo("custom.requests");
assertThat(this.observationRegistry).hasObservationWithNameEqualTo("custom.requests");
}

@Test
Expand Down Expand Up @@ -289,9 +288,8 @@ private void mockResponseBody(String expectedBody, MediaType mediaType) throws E


private TestObservationRegistryAssert.TestObservationRegistryAssertReturningObservationContextAssert assertThatHttpObservation() {
TestObservationRegistryAssert.assertThat(this.observationRegistry).hasNumberOfObservationsWithNameEqualTo("http.client.requests",1);
return TestObservationRegistryAssert.assertThat(this.observationRegistry)
.hasObservationWithNameEqualTo("http.client.requests").that();
assertThat(this.observationRegistry).hasNumberOfObservationsWithNameEqualTo("http.client.requests",1);
return assertThat(this.observationRegistry).hasObservationWithNameEqualTo("http.client.requests").that();
}

static class ContextAssertionObservationHandler implements ObservationHandler<ClientRequestObservationContext> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ private void mockResponseBody(String expectedBody, MediaType mediaType) throws E


private TestObservationRegistryAssert.TestObservationRegistryAssertReturningObservationContextAssert assertThatHttpObservation() {
return TestObservationRegistryAssert.assertThat(this.observationRegistry)
.hasObservationWithNameEqualTo("http.client.requests").that();
return assertThat(this.observationRegistry).hasObservationWithNameEqualTo("http.client.requests").that();
}

static class ContextAssertionObservationHandler implements ObservationHandler<ClientRequestObservationContext> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.stream.Stream;

import io.micrometer.observation.tck.TestObservationRegistry;
import io.micrometer.observation.tck.TestObservationRegistryAssert;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
Expand Down Expand Up @@ -131,9 +130,8 @@ void greeting(
assertThat(response).isEqualTo("Hello Spring!");
assertThat(request.getMethod()).isEqualTo("GET");
assertThat(request.getPath()).isEqualTo("/greeting");
TestObservationRegistryAssert.assertThat(observationRegistry)
.hasObservationWithNameEqualTo("http.client.requests")
.that().hasLowCardinalityKeyValue("uri", "/greeting");
assertThat(observationRegistry).hasObservationWithNameEqualTo("http.client.requests").that()
.hasLowCardinalityKeyValue("uri", "/greeting");
}

@ParameterizedAdapterTest
Expand All @@ -147,9 +145,8 @@ void greetingById(
assertThat(response.getBody()).isEqualTo("Hello Spring!");
assertThat(request.getMethod()).isEqualTo("GET");
assertThat(request.getPath()).isEqualTo("/greeting/456");
TestObservationRegistryAssert.assertThat(observationRegistry)
.hasObservationWithNameEqualTo("http.client.requests")
.that().hasLowCardinalityKeyValue("uri", "/greeting/{id}");
assertThat(observationRegistry).hasObservationWithNameEqualTo("http.client.requests").that()
.hasLowCardinalityKeyValue("uri", "/greeting/{id}");
}

@ParameterizedAdapterTest
Expand All @@ -163,9 +160,8 @@ void greetingWithDynamicUri(
assertThat(response.orElse("empty")).isEqualTo("Hello Spring!");
assertThat(request.getMethod()).isEqualTo("GET");
assertThat(request.getRequestUrl().uri()).isEqualTo(dynamicUri);
TestObservationRegistryAssert.assertThat(observationRegistry)
.hasObservationWithNameEqualTo("http.client.requests")
.that().hasLowCardinalityKeyValue("uri", "none");
assertThat(observationRegistry).hasObservationWithNameEqualTo("http.client.requests").that()
.hasLowCardinalityKeyValue("uri", "none");
}

@ParameterizedAdapterTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,14 @@ void shouldNotCloseObservationDuringAsyncDispatch() throws Exception {
this.mockFilterChain = new MockFilterChain(new ScopeCheckingServlet(this.observationRegistry));
this.request.setDispatcherType(DispatcherType.ASYNC);
this.filter.doFilter(this.request, this.response, this.mockFilterChain);
TestObservationRegistryAssert.assertThat(this.observationRegistry)
.hasObservationWithNameEqualTo("http.server.requests")
.that().isNotStopped();
assertThat(this.observationRegistry).hasObservationWithNameEqualTo("http.server.requests").that()
.isNotStopped();
}

private TestObservationRegistryAssert.TestObservationRegistryAssertReturningObservationContextAssert assertThatHttpObservation() {
TestObservationRegistryAssert.assertThat(this.observationRegistry)
.hasNumberOfObservationsWithNameEqualTo("http.server.requests", 1);
assertThat(this.observationRegistry).hasNumberOfObservationsWithNameEqualTo("http.server.requests", 1);

return TestObservationRegistryAssert.assertThat(this.observationRegistry)
.hasObservationWithNameEqualTo("http.server.requests")
.that()
return assertThat(this.observationRegistry).hasObservationWithNameEqualTo("http.server.requests").that()
.hasBeenStopped();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ private WebFilterChain createFilterChain(ThrowingConsumer<ServerWebExchange> exc
}

private TestObservationRegistryAssert.TestObservationRegistryAssertReturningObservationContextAssert assertThatHttpObservation() {
return TestObservationRegistryAssert.assertThat(this.observationRegistry)
.hasObservationWithNameEqualTo("http.server.requests").that();
return assertThat(this.observationRegistry).hasObservationWithNameEqualTo("http.server.requests").that();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ private HttpWebHandlerAdapter createWebHandler(WebHandler targetHandler) {
}

private TestObservationRegistryAssert.TestObservationRegistryAssertReturningObservationContextAssert assertThatHttpObservation() {
return TestObservationRegistryAssert.assertThat(this.observationRegistry)
.hasObservationWithNameEqualTo("http.server.requests").that();
return assertThat(this.observationRegistry).hasObservationWithNameEqualTo("http.server.requests").that();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.function.Function;

import io.micrometer.observation.tck.TestObservationRegistry;
import io.micrometer.observation.tck.TestObservationRegistryAssert;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
Expand Down Expand Up @@ -171,8 +170,8 @@ void observationRegistry() {
handler.handle(MockServerHttpRequest.get("/").build(), response).block();

TestObservationRegistry observationRegistry = applicationContext.getBean(TestObservationRegistry.class);
TestObservationRegistryAssert.assertThat(observationRegistry).hasObservationWithNameEqualTo("http.server.requests")
.that().hasLowCardinalityKeyValue("uri", "UNKNOWN");
assertThat(observationRegistry).hasObservationWithNameEqualTo("http.server.requests").that()
.hasLowCardinalityKeyValue("uri", "UNKNOWN");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ void recordsObservationWithResponseDetailsWhenFilterFunctionErrors() {
}

private TestObservationRegistryAssert.TestObservationRegistryAssertReturningObservationContextAssert assertThatHttpObservation() {
return TestObservationRegistryAssert.assertThat(this.observationRegistry)
.hasObservationWithNameEqualTo("http.client.requests").that();
return assertThat(this.observationRegistry).hasObservationWithNameEqualTo("http.client.requests").that();
}

private ClientRequest verifyAndGetRequest() {
Expand Down