Migrate to assertThatExceptionOfType
Consistently use `assertThatExceptionOfType(...).isThrownBy(...)` rather than `assertThatCode` or `assertThatThrownBy`. This aligns with Spring Boot and Spring Cloud. It also allows the convenience `assertThatIllegalArgument` and `assertThatIllegalState` methods to be used. Issue gh-8945
This commit is contained in:
+4
-3
@@ -44,7 +44,7 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatCode;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
@@ -76,8 +76,9 @@ public class SecurityMockServerConfigurersOAuth2ClientTests extends AbstractMock
|
||||
@Test
|
||||
public void oauth2ClientWhenUsingDefaultsThenException() throws Exception {
|
||||
WebHttpHandlerBuilder builder = WebHttpHandlerBuilder.webHandler(new DispatcherHandler());
|
||||
assertThatCode(() -> SecurityMockServerConfigurers.mockOAuth2Client().beforeServerCreated(builder))
|
||||
.isInstanceOf(IllegalArgumentException.class).hasMessageContaining("ClientRegistration");
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> SecurityMockServerConfigurers.mockOAuth2Client().beforeServerCreated(builder))
|
||||
.withMessageContaining("ClientRegistration");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+4
-3
@@ -49,7 +49,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatCode;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
@@ -93,8 +93,9 @@ public class SecurityMockMvcRequestPostProcessorsOAuth2ClientTests {
|
||||
|
||||
@Test
|
||||
public void oauth2ClientWhenUsingDefaultsThenException() throws Exception {
|
||||
assertThatCode(() -> oauth2Client().postProcessRequest(new MockHttpServletRequest()))
|
||||
.isInstanceOf(IllegalArgumentException.class).hasMessageContaining("ClientRegistration");
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> oauth2Client().postProcessRequest(new MockHttpServletRequest()))
|
||||
.withMessageContaining("ClientRegistration");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user