Constently use assertThatExceptionOf... assertions
Closes gh-37964
This commit is contained in:
@@ -43,7 +43,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.actuate.metrics.AutoTimer;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -143,11 +143,9 @@ class GraphQlMetricsInstrumentationTests {
|
||||
DataFetcher<CompletionStage<String>> dataFetcher = mock(DataFetcher.class);
|
||||
given(dataFetcher.get(any())).willThrow(new IllegalStateException("test"));
|
||||
InstrumentationFieldFetchParameters fieldFetchParameters = mockFieldFetchParameters(false);
|
||||
|
||||
DataFetcher<?> instrumented = this.instrumentation.instrumentDataFetcher(dataFetcher, fieldFetchParameters);
|
||||
DataFetchingEnvironment environment = DataFetchingEnvironmentImpl.newDataFetchingEnvironment().build();
|
||||
assertThatThrownBy(() -> instrumented.get(environment)).isInstanceOf(IllegalStateException.class);
|
||||
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> instrumented.get(environment));
|
||||
Timer timer = this.registry.find("graphql.datafetcher").timer();
|
||||
assertThat(timer).isNotNull();
|
||||
assertThat(timer.count()).isEqualTo(1);
|
||||
|
||||
@@ -43,7 +43,7 @@ import org.springframework.web.reactive.function.client.ExchangeFunction;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
@@ -145,9 +145,10 @@ class MetricsWebClientFilterFunctionTests {
|
||||
.tags("method", "GET", "uri", "/projects/spring-boot", "status", "CLIENT_ERROR")
|
||||
.timer()
|
||||
.count()).isEqualTo(1);
|
||||
assertThatThrownBy(() -> this.registry.get("http.client.requests")
|
||||
.tags("method", "GET", "uri", "/projects/spring-boot", "status", "200")
|
||||
.timer()).isInstanceOf(MeterNotFoundException.class);
|
||||
assertThatExceptionOfType(MeterNotFoundException.class)
|
||||
.isThrownBy(() -> this.registry.get("http.client.requests")
|
||||
.tags("method", "GET", "uri", "/projects/spring-boot", "status", "200")
|
||||
.timer());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -162,9 +163,10 @@ class MetricsWebClientFilterFunctionTests {
|
||||
.tags("method", "GET", "uri", "/projects/spring-boot", "status", "200")
|
||||
.timer()
|
||||
.count()).isEqualTo(1);
|
||||
assertThatThrownBy(() -> this.registry.get("http.client.requests")
|
||||
.tags("method", "GET", "uri", "/projects/spring-boot", "status", "CLIENT_ERROR")
|
||||
.timer()).isInstanceOf(MeterNotFoundException.class);
|
||||
assertThatExceptionOfType(MeterNotFoundException.class)
|
||||
.isThrownBy(() -> this.registry.get("http.client.requests")
|
||||
.tags("method", "GET", "uri", "/projects/spring-boot", "status", "CLIENT_ERROR")
|
||||
.timer());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user