Migrate to BDD Mockito
Migrate Mockito imports to use the BDD variant. This aligns better with the "given" / "when" / "then" style used in most tests since the "given" block now uses Mockito `given(...)` calls. The commit also updates a few tests that were accidentally using Power Mockito when regular Mockito could be used. Issue gh-8945
This commit is contained in:
+23
-23
@@ -22,7 +22,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class WithMockUserSecurityContextFactoryTests {
|
||||
@@ -44,10 +44,10 @@ public class WithMockUserSecurityContextFactoryTests {
|
||||
|
||||
@Test
|
||||
public void valueDefaultsUsername() {
|
||||
when(this.withUser.value()).thenReturn("valueUser");
|
||||
when(this.withUser.password()).thenReturn("password");
|
||||
when(this.withUser.roles()).thenReturn(new String[] { "USER" });
|
||||
when(this.withUser.authorities()).thenReturn(new String[] {});
|
||||
given(this.withUser.value()).willReturn("valueUser");
|
||||
given(this.withUser.password()).willReturn("password");
|
||||
given(this.withUser.roles()).willReturn(new String[] { "USER" });
|
||||
given(this.withUser.authorities()).willReturn(new String[] {});
|
||||
|
||||
assertThat(this.factory.createSecurityContext(this.withUser).getAuthentication().getName())
|
||||
.isEqualTo(this.withUser.value());
|
||||
@@ -55,10 +55,10 @@ public class WithMockUserSecurityContextFactoryTests {
|
||||
|
||||
@Test
|
||||
public void usernamePrioritizedOverValue() {
|
||||
when(this.withUser.username()).thenReturn("customUser");
|
||||
when(this.withUser.password()).thenReturn("password");
|
||||
when(this.withUser.roles()).thenReturn(new String[] { "USER" });
|
||||
when(this.withUser.authorities()).thenReturn(new String[] {});
|
||||
given(this.withUser.username()).willReturn("customUser");
|
||||
given(this.withUser.password()).willReturn("password");
|
||||
given(this.withUser.roles()).willReturn(new String[] { "USER" });
|
||||
given(this.withUser.authorities()).willReturn(new String[] {});
|
||||
|
||||
assertThat(this.factory.createSecurityContext(this.withUser).getAuthentication().getName())
|
||||
.isEqualTo(this.withUser.username());
|
||||
@@ -66,10 +66,10 @@ public class WithMockUserSecurityContextFactoryTests {
|
||||
|
||||
@Test
|
||||
public void rolesWorks() {
|
||||
when(this.withUser.value()).thenReturn("valueUser");
|
||||
when(this.withUser.password()).thenReturn("password");
|
||||
when(this.withUser.roles()).thenReturn(new String[] { "USER", "CUSTOM" });
|
||||
when(this.withUser.authorities()).thenReturn(new String[] {});
|
||||
given(this.withUser.value()).willReturn("valueUser");
|
||||
given(this.withUser.password()).willReturn("password");
|
||||
given(this.withUser.roles()).willReturn(new String[] { "USER", "CUSTOM" });
|
||||
given(this.withUser.authorities()).willReturn(new String[] {});
|
||||
|
||||
assertThat(this.factory.createSecurityContext(this.withUser).getAuthentication().getAuthorities())
|
||||
.extracting("authority").containsOnly("ROLE_USER", "ROLE_CUSTOM");
|
||||
@@ -77,10 +77,10 @@ public class WithMockUserSecurityContextFactoryTests {
|
||||
|
||||
@Test
|
||||
public void authoritiesWorks() {
|
||||
when(this.withUser.value()).thenReturn("valueUser");
|
||||
when(this.withUser.password()).thenReturn("password");
|
||||
when(this.withUser.roles()).thenReturn(new String[] { "USER" });
|
||||
when(this.withUser.authorities()).thenReturn(new String[] { "USER", "CUSTOM" });
|
||||
given(this.withUser.value()).willReturn("valueUser");
|
||||
given(this.withUser.password()).willReturn("password");
|
||||
given(this.withUser.roles()).willReturn(new String[] { "USER" });
|
||||
given(this.withUser.authorities()).willReturn(new String[] { "USER", "CUSTOM" });
|
||||
|
||||
assertThat(this.factory.createSecurityContext(this.withUser).getAuthentication().getAuthorities())
|
||||
.extracting("authority").containsOnly("USER", "CUSTOM");
|
||||
@@ -88,18 +88,18 @@ public class WithMockUserSecurityContextFactoryTests {
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void authoritiesAndRolesInvalid() {
|
||||
when(this.withUser.value()).thenReturn("valueUser");
|
||||
when(this.withUser.roles()).thenReturn(new String[] { "CUSTOM" });
|
||||
when(this.withUser.authorities()).thenReturn(new String[] { "USER", "CUSTOM" });
|
||||
given(this.withUser.value()).willReturn("valueUser");
|
||||
given(this.withUser.roles()).willReturn(new String[] { "CUSTOM" });
|
||||
given(this.withUser.authorities()).willReturn(new String[] { "USER", "CUSTOM" });
|
||||
|
||||
this.factory.createSecurityContext(this.withUser);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void rolesWithRolePrefixFails() {
|
||||
when(this.withUser.value()).thenReturn("valueUser");
|
||||
when(this.withUser.roles()).thenReturn(new String[] { "ROLE_FAIL" });
|
||||
when(this.withUser.authorities()).thenReturn(new String[] {});
|
||||
given(this.withUser.value()).willReturn("valueUser");
|
||||
given(this.withUser.roles()).willReturn(new String[] { "ROLE_FAIL" });
|
||||
given(this.withUser.authorities()).willReturn(new String[] {});
|
||||
|
||||
this.factory.createSecurityContext(this.withUser);
|
||||
}
|
||||
|
||||
+7
-7
@@ -45,8 +45,8 @@ import org.springframework.test.context.support.AbstractTestExecutionListener;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class WithSecurityContextTestExcecutionListenerTests {
|
||||
@@ -76,8 +76,8 @@ public class WithSecurityContextTestExcecutionListenerTests {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void beforeTestMethodNullSecurityContextNoError() throws Exception {
|
||||
Class testClass = FakeTest.class;
|
||||
when(this.testContext.getTestClass()).thenReturn(testClass);
|
||||
when(this.testContext.getTestMethod()).thenReturn(ReflectionUtils.findMethod(testClass, "testNoAnnotation"));
|
||||
given(this.testContext.getTestClass()).willReturn(testClass);
|
||||
given(this.testContext.getTestMethod()).willReturn(ReflectionUtils.findMethod(testClass, "testNoAnnotation"));
|
||||
|
||||
this.listener.beforeTestMethod(this.testContext);
|
||||
}
|
||||
@@ -86,8 +86,8 @@ public class WithSecurityContextTestExcecutionListenerTests {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void beforeTestMethodNoApplicationContext() throws Exception {
|
||||
Class testClass = FakeTest.class;
|
||||
when(this.testContext.getApplicationContext()).thenThrow(new IllegalStateException());
|
||||
when(this.testContext.getTestMethod()).thenReturn(ReflectionUtils.findMethod(testClass, "testWithMockUser"));
|
||||
given(this.testContext.getApplicationContext()).willThrow(new IllegalStateException());
|
||||
given(this.testContext.getTestMethod()).willReturn(ReflectionUtils.findMethod(testClass, "testWithMockUser"));
|
||||
|
||||
this.listener.beforeTestMethod(this.testContext);
|
||||
|
||||
@@ -128,8 +128,8 @@ public class WithSecurityContextTestExcecutionListenerTests {
|
||||
Method method = ReflectionUtils.findMethod(WithSecurityContextTestExcecutionListenerTests.class,
|
||||
"handlesGenericAnnotationTestMethod");
|
||||
TestContext testContext = mock(TestContext.class);
|
||||
when(testContext.getTestMethod()).thenReturn(method);
|
||||
when(testContext.getApplicationContext()).thenThrow(new IllegalStateException(""));
|
||||
given(testContext.getTestMethod()).willReturn(method);
|
||||
given(testContext.getApplicationContext()).willThrow(new IllegalStateException(""));
|
||||
|
||||
this.listener.beforeTestMethod(testContext);
|
||||
|
||||
|
||||
+13
-13
@@ -44,9 +44,9 @@ import org.springframework.test.context.junit4.rules.SpringMethodRule;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @author Rob Winch
|
||||
@@ -78,8 +78,8 @@ public class WithSecurityContextTestExecutionListenerTests {
|
||||
@Test
|
||||
public void beforeTestMethodWhenWithMockUserTestExecutionDefaultThenSecurityContextSet() throws Exception {
|
||||
Method testMethod = TheTest.class.getMethod("withMockUserDefault");
|
||||
when(this.testContext.getApplicationContext()).thenReturn(this.applicationContext);
|
||||
when(this.testContext.getTestMethod()).thenReturn(testMethod);
|
||||
given(this.testContext.getApplicationContext()).willReturn(this.applicationContext);
|
||||
given(this.testContext.getTestMethod()).willReturn(testMethod);
|
||||
|
||||
this.listener.beforeTestMethod(this.testContext);
|
||||
|
||||
@@ -91,8 +91,8 @@ public class WithSecurityContextTestExecutionListenerTests {
|
||||
@Test
|
||||
public void beforeTestMethodWhenWithMockUserTestMethodThenSecurityContextSet() throws Exception {
|
||||
Method testMethod = TheTest.class.getMethod("withMockUserTestMethod");
|
||||
when(this.testContext.getApplicationContext()).thenReturn(this.applicationContext);
|
||||
when(this.testContext.getTestMethod()).thenReturn(testMethod);
|
||||
given(this.testContext.getApplicationContext()).willReturn(this.applicationContext);
|
||||
given(this.testContext.getTestMethod()).willReturn(testMethod);
|
||||
|
||||
this.listener.beforeTestMethod(this.testContext);
|
||||
|
||||
@@ -104,8 +104,8 @@ public class WithSecurityContextTestExecutionListenerTests {
|
||||
@Test
|
||||
public void beforeTestMethodWhenWithMockUserTestExecutionThenTestContextSet() throws Exception {
|
||||
Method testMethod = TheTest.class.getMethod("withMockUserTestExecution");
|
||||
when(this.testContext.getApplicationContext()).thenReturn(this.applicationContext);
|
||||
when(this.testContext.getTestMethod()).thenReturn(testMethod);
|
||||
given(this.testContext.getApplicationContext()).willReturn(this.applicationContext);
|
||||
given(this.testContext.getTestMethod()).willReturn(testMethod);
|
||||
|
||||
this.listener.beforeTestMethod(this.testContext);
|
||||
|
||||
@@ -118,8 +118,8 @@ public class WithSecurityContextTestExecutionListenerTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void beforeTestMethodWhenWithMockUserTestExecutionThenTestContextSupplierOk() throws Exception {
|
||||
Method testMethod = TheTest.class.getMethod("withMockUserTestExecution");
|
||||
when(this.testContext.getApplicationContext()).thenReturn(this.applicationContext);
|
||||
when(this.testContext.getTestMethod()).thenReturn(testMethod);
|
||||
given(this.testContext.getApplicationContext()).willReturn(this.applicationContext);
|
||||
given(this.testContext.getTestMethod()).willReturn(testMethod);
|
||||
|
||||
this.listener.beforeTestMethod(this.testContext);
|
||||
|
||||
@@ -133,9 +133,9 @@ public class WithSecurityContextTestExecutionListenerTests {
|
||||
// gh-6591
|
||||
public void beforeTestMethodWhenTestExecutionThenDelayFactoryCreate() throws Exception {
|
||||
Method testMethod = TheTest.class.getMethod("withUserDetails");
|
||||
when(this.testContext.getApplicationContext()).thenReturn(this.applicationContext);
|
||||
given(this.testContext.getApplicationContext()).willReturn(this.applicationContext);
|
||||
// do not set a UserDetailsService Bean so it would fail if looked up
|
||||
when(this.testContext.getTestMethod()).thenReturn(testMethod);
|
||||
given(this.testContext.getTestMethod()).willReturn(testMethod);
|
||||
|
||||
this.listener.beforeTestMethod(this.testContext);
|
||||
// bean lookup of UserDetailsService would fail if it has already been looked up
|
||||
@@ -153,8 +153,8 @@ public class WithSecurityContextTestExecutionListenerTests {
|
||||
SecurityContextImpl securityContext = new SecurityContextImpl();
|
||||
securityContext.setAuthentication(new TestingAuthenticationToken("user", "passsword", "ROLE_USER"));
|
||||
Supplier<SecurityContext> supplier = () -> securityContext;
|
||||
when(this.testContext.removeAttribute(WithSecurityContextTestExecutionListener.SECURITY_CONTEXT_ATTR_NAME))
|
||||
.thenReturn(supplier);
|
||||
given(this.testContext.removeAttribute(WithSecurityContextTestExecutionListener.SECURITY_CONTEXT_ATTR_NAME))
|
||||
.willReturn(supplier);
|
||||
|
||||
this.listener.beforeTestExecution(this.testContext);
|
||||
|
||||
|
||||
+19
-19
@@ -32,8 +32,8 @@ import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class WithUserDetailsSecurityContextFactoryTests {
|
||||
@@ -68,17 +68,17 @@ public class WithUserDetailsSecurityContextFactoryTests {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void createSecurityContextEmptyValue() {
|
||||
|
||||
when(this.withUserDetails.value()).thenReturn("");
|
||||
given(this.withUserDetails.value()).willReturn("");
|
||||
this.factory.createSecurityContext(this.withUserDetails);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createSecurityContextWithExistingUser() {
|
||||
String username = "user";
|
||||
when(this.beans.getBean(ReactiveUserDetailsService.class)).thenThrow(new NoSuchBeanDefinitionException(""));
|
||||
when(this.beans.getBean(UserDetailsService.class)).thenReturn(this.userDetailsService);
|
||||
when(this.withUserDetails.value()).thenReturn(username);
|
||||
when(this.userDetailsService.loadUserByUsername(username)).thenReturn(this.userDetails);
|
||||
given(this.beans.getBean(ReactiveUserDetailsService.class)).willThrow(new NoSuchBeanDefinitionException(""));
|
||||
given(this.beans.getBean(UserDetailsService.class)).willReturn(this.userDetailsService);
|
||||
given(this.withUserDetails.value()).willReturn(username);
|
||||
given(this.userDetailsService.loadUserByUsername(username)).willReturn(this.userDetails);
|
||||
|
||||
SecurityContext context = this.factory.createSecurityContext(this.withUserDetails);
|
||||
assertThat(context.getAuthentication()).isInstanceOf(UsernamePasswordAuthenticationToken.class);
|
||||
@@ -91,12 +91,12 @@ public class WithUserDetailsSecurityContextFactoryTests {
|
||||
public void createSecurityContextWithUserDetailsServiceName() {
|
||||
String beanName = "secondUserDetailsServiceBean";
|
||||
String username = "user";
|
||||
when(this.beans.getBean(beanName, ReactiveUserDetailsService.class)).thenThrow(
|
||||
given(this.beans.getBean(beanName, ReactiveUserDetailsService.class)).willThrow(
|
||||
new BeanNotOfRequiredTypeException("", ReactiveUserDetailsService.class, UserDetailsService.class));
|
||||
when(this.withUserDetails.value()).thenReturn(username);
|
||||
when(this.withUserDetails.userDetailsServiceBeanName()).thenReturn(beanName);
|
||||
when(this.userDetailsService.loadUserByUsername(username)).thenReturn(this.userDetails);
|
||||
when(this.beans.getBean(beanName, UserDetailsService.class)).thenReturn(this.userDetailsService);
|
||||
given(this.withUserDetails.value()).willReturn(username);
|
||||
given(this.withUserDetails.userDetailsServiceBeanName()).willReturn(beanName);
|
||||
given(this.userDetailsService.loadUserByUsername(username)).willReturn(this.userDetails);
|
||||
given(this.beans.getBean(beanName, UserDetailsService.class)).willReturn(this.userDetailsService);
|
||||
|
||||
SecurityContext context = this.factory.createSecurityContext(this.withUserDetails);
|
||||
assertThat(context.getAuthentication()).isInstanceOf(UsernamePasswordAuthenticationToken.class);
|
||||
@@ -107,9 +107,9 @@ public class WithUserDetailsSecurityContextFactoryTests {
|
||||
@Test
|
||||
public void createSecurityContextWithReactiveUserDetailsService() {
|
||||
String username = "user";
|
||||
when(this.withUserDetails.value()).thenReturn(username);
|
||||
when(this.beans.getBean(ReactiveUserDetailsService.class)).thenReturn(this.reactiveUserDetailsService);
|
||||
when(this.reactiveUserDetailsService.findByUsername(username)).thenReturn(Mono.just(this.userDetails));
|
||||
given(this.withUserDetails.value()).willReturn(username);
|
||||
given(this.beans.getBean(ReactiveUserDetailsService.class)).willReturn(this.reactiveUserDetailsService);
|
||||
given(this.reactiveUserDetailsService.findByUsername(username)).willReturn(Mono.just(this.userDetails));
|
||||
|
||||
SecurityContext context = this.factory.createSecurityContext(this.withUserDetails);
|
||||
assertThat(context.getAuthentication()).isInstanceOf(UsernamePasswordAuthenticationToken.class);
|
||||
@@ -121,11 +121,11 @@ public class WithUserDetailsSecurityContextFactoryTests {
|
||||
public void createSecurityContextWithReactiveUserDetailsServiceAndBeanName() {
|
||||
String beanName = "secondUserDetailsServiceBean";
|
||||
String username = "user";
|
||||
when(this.withUserDetails.value()).thenReturn(username);
|
||||
when(this.withUserDetails.userDetailsServiceBeanName()).thenReturn(beanName);
|
||||
when(this.beans.getBean(beanName, ReactiveUserDetailsService.class))
|
||||
.thenReturn(this.reactiveUserDetailsService);
|
||||
when(this.reactiveUserDetailsService.findByUsername(username)).thenReturn(Mono.just(this.userDetails));
|
||||
given(this.withUserDetails.value()).willReturn(username);
|
||||
given(this.withUserDetails.userDetailsServiceBeanName()).willReturn(beanName);
|
||||
given(this.beans.getBean(beanName, ReactiveUserDetailsService.class))
|
||||
.willReturn(this.reactiveUserDetailsService);
|
||||
given(this.reactiveUserDetailsService.findByUsername(username)).willReturn(Mono.just(this.userDetails));
|
||||
|
||||
SecurityContext context = this.factory.createSecurityContext(this.withUserDetails);
|
||||
assertThat(context.getAuthentication()).isInstanceOf(UsernamePasswordAuthenticationToken.class);
|
||||
|
||||
+3
-3
@@ -45,8 +45,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatCode;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.security.oauth2.client.registration.TestClientRegistrations.clientRegistration;
|
||||
import static org.springframework.security.oauth2.core.TestOAuth2AccessTokens.noScopes;
|
||||
import static org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.mockOAuth2Client;
|
||||
@@ -154,8 +154,8 @@ public class SecurityMockServerConfigurersOAuth2ClientTests extends AbstractMock
|
||||
assertThat(client.getClientRegistration().getClientId()).isEqualTo("test-client");
|
||||
|
||||
client = new OAuth2AuthorizedClient(clientRegistration().build(), "sub", noScopes());
|
||||
when(this.authorizedClientRepository.loadAuthorizedClient(eq("registration-id"), any(Authentication.class),
|
||||
any(ServerWebExchange.class))).thenReturn(Mono.just(client));
|
||||
given(this.authorizedClientRepository.loadAuthorizedClient(eq("registration-id"), any(Authentication.class),
|
||||
any(ServerWebExchange.class))).willReturn(Mono.just(client));
|
||||
this.client.get().uri("/client").exchange().expectStatus().isOk();
|
||||
client = this.controller.authorizedClient;
|
||||
assertThat(client).isNotNull();
|
||||
|
||||
+3
-3
@@ -49,9 +49,9 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import static org.assertj.core.api.Assertions.assertThatCode;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.security.oauth2.client.registration.TestClientRegistrations.clientRegistration;
|
||||
import static org.springframework.security.oauth2.core.TestOAuth2AccessTokens.noScopes;
|
||||
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.oauth2Client;
|
||||
@@ -143,8 +143,8 @@ public class SecurityMockMvcRequestPostProcessorsOAuth2ClientTests {
|
||||
|
||||
OAuth2AuthorizedClient client = new OAuth2AuthorizedClient(clientRegistration().build(), "sub", noScopes());
|
||||
OAuth2AuthorizedClientRepository repository = this.context.getBean(OAuth2AuthorizedClientRepository.class);
|
||||
when(repository.loadAuthorizedClient(eq("registration-id"), any(Authentication.class),
|
||||
any(HttpServletRequest.class))).thenReturn(client);
|
||||
given(repository.loadAuthorizedClient(eq("registration-id"), any(Authentication.class),
|
||||
any(HttpServletRequest.class))).willReturn(client);
|
||||
this.mvc.perform(get("/client-id")).andExpect(content().string("client-id"));
|
||||
verify(repository).loadAuthorizedClient(eq("registration-id"), any(Authentication.class),
|
||||
any(HttpServletRequest.class));
|
||||
|
||||
+4
-4
@@ -32,8 +32,8 @@ import org.springframework.web.context.WebApplicationContext;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class SecurityMockMvcConfigurerTests {
|
||||
@@ -55,7 +55,7 @@ public class SecurityMockMvcConfigurerTests {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
when(this.context.getServletContext()).thenReturn(this.servletContext);
|
||||
given(this.context.getServletContext()).willReturn(this.servletContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -107,8 +107,8 @@ public class SecurityMockMvcConfigurerTests {
|
||||
}
|
||||
|
||||
private void returnFilterBean() {
|
||||
when(this.context.containsBean(anyString())).thenReturn(true);
|
||||
when(this.context.getBean(anyString(), eq(Filter.class))).thenReturn(this.beanFilter);
|
||||
given(this.context.containsBean(anyString())).willReturn(true);
|
||||
given(this.context.getBean(anyString(), eq(Filter.class))).willReturn(this.beanFilter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user