Make fields final
Closes gh-33537
This commit is contained in:
@@ -146,7 +146,7 @@ public class FilteredClassLoader extends URLClassLoader implements SmartClassLoa
|
||||
*/
|
||||
public static final class ClassFilter implements Predicate<String> {
|
||||
|
||||
private Class<?>[] hiddenClasses;
|
||||
private final Class<?>[] hiddenClasses;
|
||||
|
||||
private ClassFilter(Class<?>[] hiddenClasses) {
|
||||
this.hiddenClasses = hiddenClasses;
|
||||
|
||||
@@ -95,11 +95,11 @@ public class MockitoPostProcessor implements InstantiationAwareBeanPostProcessor
|
||||
|
||||
private final MockitoBeans mockitoBeans = new MockitoBeans();
|
||||
|
||||
private Map<Definition, String> beanNameRegistry = new HashMap<>();
|
||||
private final Map<Definition, String> beanNameRegistry = new HashMap<>();
|
||||
|
||||
private Map<Field, String> fieldRegistry = new HashMap<>();
|
||||
private final Map<Field, String> fieldRegistry = new HashMap<>();
|
||||
|
||||
private Map<String, SpyDefinition> spies = new HashMap<>();
|
||||
private final Map<String, SpyDefinition> spies = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Create a new {@link MockitoPostProcessor} instance with the given initial
|
||||
|
||||
@@ -318,7 +318,7 @@ class OutputCapture implements CapturedOutput {
|
||||
*/
|
||||
private static class AnsiOutputState {
|
||||
|
||||
private Enabled saved;
|
||||
private final Enabled saved;
|
||||
|
||||
AnsiOutputState() {
|
||||
this.saved = AnsiOutput.getEnabled();
|
||||
|
||||
@@ -55,7 +55,7 @@ public class OutputCaptureRule implements TestRule, CapturedOutput {
|
||||
|
||||
private final OutputCapture delegate = new OutputCapture();
|
||||
|
||||
private List<Matcher<? super String>> matchers = new ArrayList<>();
|
||||
private final List<Matcher<? super String>> matchers = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public Statement apply(Statement base, Description description) {
|
||||
|
||||
@@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
*/
|
||||
class AnnotatedClassFinderTests {
|
||||
|
||||
private AnnotatedClassFinder finder = new AnnotatedClassFinder(SpringBootConfiguration.class);
|
||||
private final AnnotatedClassFinder finder = new AnnotatedClassFinder(SpringBootConfiguration.class);
|
||||
|
||||
@Test
|
||||
void findFromClassWhenSourceIsNullShouldThrowException() {
|
||||
|
||||
@@ -41,7 +41,7 @@ import static org.mockito.Mockito.mock;
|
||||
*/
|
||||
class ImportsContextCustomizerFactoryTests {
|
||||
|
||||
private ImportsContextCustomizerFactory factory = new ImportsContextCustomizerFactory();
|
||||
private final ImportsContextCustomizerFactory factory = new ImportsContextCustomizerFactory();
|
||||
|
||||
@Test
|
||||
void getContextCustomizerWhenHasNoImportAnnotationShouldReturnNull() {
|
||||
|
||||
@@ -44,7 +44,7 @@ class ApplicationContextAssertTests {
|
||||
|
||||
private StaticApplicationContext context;
|
||||
|
||||
private RuntimeException failure = new RuntimeException();
|
||||
private final RuntimeException failure = new RuntimeException();
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
|
||||
@@ -35,9 +35,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
class TestTypeExcludeFilterTests {
|
||||
|
||||
private TestTypeExcludeFilter filter = new TestTypeExcludeFilter();
|
||||
private final TestTypeExcludeFilter filter = new TestTypeExcludeFilter();
|
||||
|
||||
private MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
|
||||
private final MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
|
||||
|
||||
@Test
|
||||
void matchesJUnit4TestClass() throws Exception {
|
||||
|
||||
@@ -40,7 +40,7 @@ class BasicJsonTesterTests {
|
||||
|
||||
private static final String JSON = "{\"spring\":[\"boot\",\"framework\"]}";
|
||||
|
||||
private BasicJsonTester json = new BasicJsonTester(getClass());
|
||||
private final BasicJsonTester json = new BasicJsonTester(getClass());
|
||||
|
||||
@Test
|
||||
void createWhenResourceLoadClassIsNullShouldThrowException() {
|
||||
|
||||
@@ -60,7 +60,7 @@ class JsonContentAssertTests {
|
||||
|
||||
private static final String NULLS = loadJson("nulls.json");
|
||||
|
||||
private static JSONComparator COMPARATOR = new DefaultComparator(JSONCompareMode.LENIENT);
|
||||
private static final JSONComparator COMPARATOR = new DefaultComparator(JSONCompareMode.LENIENT);
|
||||
|
||||
@TempDir
|
||||
public Path tempDir;
|
||||
|
||||
@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
*/
|
||||
class DefinitionsParserTests {
|
||||
|
||||
private DefinitionsParser parser = new DefinitionsParser();
|
||||
private final DefinitionsParser parser = new DefinitionsParser();
|
||||
|
||||
@Test
|
||||
void parseSingleMockBean() {
|
||||
|
||||
@@ -45,7 +45,7 @@ import static org.mockito.Mockito.mock;
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class MockitoTestExecutionListenerTests {
|
||||
|
||||
private MockitoTestExecutionListener listener = new MockitoTestExecutionListener();
|
||||
private final MockitoTestExecutionListener listener = new MockitoTestExecutionListener();
|
||||
|
||||
@Mock
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@@ -43,7 +43,7 @@ class OutputCaptureTests {
|
||||
|
||||
private TestPrintStream systemErr;
|
||||
|
||||
private TestOutputCapture output = new TestOutputCapture();
|
||||
private final TestOutputCapture output = new TestOutputCapture();
|
||||
|
||||
@BeforeEach
|
||||
void replaceSystemStreams() {
|
||||
|
||||
@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
*/
|
||||
class SpringBootTestRandomPortEnvironmentPostProcessorTests {
|
||||
|
||||
private SpringBootTestRandomPortEnvironmentPostProcessor postProcessor = new SpringBootTestRandomPortEnvironmentPostProcessor();
|
||||
private final SpringBootTestRandomPortEnvironmentPostProcessor postProcessor = new SpringBootTestRandomPortEnvironmentPostProcessor();
|
||||
|
||||
private MockEnvironment environment;
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class RootUriRequestExpectationManagerTests {
|
||||
|
||||
private String uri = "https://example.com";
|
||||
private final String uri = "https://example.com";
|
||||
|
||||
@Mock
|
||||
private RequestExpectationManager delegate;
|
||||
|
||||
Reference in New Issue
Block a user