1
0
mirror of synced 2026-08-04 09:17:02 +00:00

Fix mockito UnnecessaryStubbingException

This commit is contained in:
Rob Winch
2021-07-08 14:52:45 -05:00
parent 2a62c4d976
commit b6ff4d3674
22 changed files with 252 additions and 42 deletions
@@ -19,7 +19,6 @@ package org.springframework.security.test.web.servlet.setup;
import javax.servlet.Filter;
import javax.servlet.ServletContext;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
@@ -55,14 +54,9 @@ public class SecurityMockMvcConfigurerTests {
@Mock
private ServletContext servletContext;
@BeforeEach
public void setup() {
given(this.context.getServletContext()).willReturn(this.servletContext);
}
@Test
public void beforeMockMvcCreatedOverrideBean() throws Exception {
returnFilterBean();
given(this.context.getServletContext()).willReturn(this.servletContext);
SecurityMockMvcConfigurer configurer = new SecurityMockMvcConfigurer(this.filter);
configurer.afterConfigurerAdded(this.builder);
configurer.beforeMockMvcCreated(this.builder, this.context);
@@ -72,6 +66,7 @@ public class SecurityMockMvcConfigurerTests {
@Test
public void beforeMockMvcCreatedBean() throws Exception {
given(this.context.getServletContext()).willReturn(this.servletContext);
returnFilterBean();
SecurityMockMvcConfigurer configurer = new SecurityMockMvcConfigurer();
configurer.afterConfigurerAdded(this.builder);
@@ -81,6 +76,7 @@ public class SecurityMockMvcConfigurerTests {
@Test
public void beforeMockMvcCreatedNoBean() throws Exception {
given(this.context.getServletContext()).willReturn(this.servletContext);
SecurityMockMvcConfigurer configurer = new SecurityMockMvcConfigurer(this.filter);
configurer.afterConfigurerAdded(this.builder);
configurer.beforeMockMvcCreated(this.builder, this.context);