Unify method visibility of private classes

Apply checkstyle rule to ensure that private and package private
classes do not have unnecessary public methods. Test classes have
also been unified as much as possible to use default scoped
inner-classes.

Closes gh-7316
This commit is contained in:
Phillip Webb
2019-07-01 12:29:51 -07:00
parent 0a02a3a19c
commit a66c4d3096
910 changed files with 3754 additions and 3945 deletions

View File

@@ -1034,14 +1034,14 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
this.jsonPath = JsonPath.compile(this.expression);
}
public void assertHasEmptyValue() {
void assertHasEmptyValue() {
if (ObjectUtils.isEmpty(getValue(false)) || isIndefiniteAndEmpty()) {
return;
}
failWithMessage(getExpectedValueMessage("an empty value"));
}
public void assertDoesNotHaveEmptyValue() {
void assertDoesNotHaveEmptyValue() {
if (!ObjectUtils.isEmpty(getValue(false))) {
return;
}
@@ -1049,7 +1049,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
}
public void assertHasValue(Class<?> type, String expectedDescription) {
void assertHasValue(Class<?> type, String expectedDescription) {
Object value = getValue(true);
if (value == null || isIndefiniteAndEmpty()) {
failWithMessage(getNoValueMessage());
@@ -1059,7 +1059,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
}
}
public void assertDoesNotHaveValue() {
void assertDoesNotHaveValue() {
if (getValue(false) == null || isIndefiniteAndEmpty()) {
return;
}
@@ -1078,7 +1078,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
return ObjectUtils.isEmpty(getValue(false));
}
public Object getValue(boolean required) {
Object getValue(boolean required) {
try {
CharSequence json = JsonContentAssert.this.actual;
return this.jsonPath.read((json != null) ? json.toString() : null,

View File

@@ -47,7 +47,7 @@ abstract class Definition {
* Return the name for bean.
* @return the name or {@code null}
*/
public String getName() {
String getName() {
return this.name;
}
@@ -55,7 +55,7 @@ abstract class Definition {
* Return the mock reset mode.
* @return the reset mode
*/
public MockReset getReset() {
MockReset getReset() {
return this.reset;
}
@@ -63,7 +63,7 @@ abstract class Definition {
* Return if AOP advised beans should be proxy target aware.
* @return if proxy target aware
*/
public boolean isProxyTargetAware() {
boolean isProxyTargetAware() {
return this.proxyTargetAware;
}
@@ -71,7 +71,7 @@ abstract class Definition {
* Return the qualifier or {@code null}.
* @return the qualifier
*/
public QualifierDefinition getQualifier() {
QualifierDefinition getQualifier() {
return this.qualifier;
}

View File

@@ -59,7 +59,7 @@ class DefinitionsParser {
}
}
public void parse(Class<?> source) {
void parse(Class<?> source) {
parseElement(source);
ReflectionUtils.doWithFields(source, this::parseElement);
}
@@ -119,11 +119,11 @@ class DefinitionsParser {
return types;
}
public Set<Definition> getDefinitions() {
Set<Definition> getDefinitions() {
return Collections.unmodifiableSet(this.definitions);
}
public Field getField(Definition definition) {
Field getField(Definition definition) {
return this.definitionFields.get(definition);
}

View File

@@ -71,7 +71,7 @@ class MockDefinition extends Definition {
* Return the type that should be mocked.
* @return the type to mock; never {@code null}
*/
public ResolvableType getTypeToMock() {
ResolvableType getTypeToMock() {
return this.typeToMock;
}
@@ -79,7 +79,7 @@ class MockDefinition extends Definition {
* Return the extra interfaces.
* @return the extra interfaces or an empty set
*/
public Set<Class<?>> getExtraInterfaces() {
Set<Class<?>> getExtraInterfaces() {
return this.extraInterfaces;
}
@@ -87,7 +87,7 @@ class MockDefinition extends Definition {
* Return the answers mode.
* @return the answers mode; never {@code null}
*/
public Answers getAnswer() {
Answers getAnswer() {
return this.answer;
}
@@ -95,7 +95,7 @@ class MockDefinition extends Definition {
* Return if the mock is serializable.
* @return if the mock is serializable
*/
public boolean isSerializable() {
boolean isSerializable() {
return this.serializable;
}
@@ -133,12 +133,12 @@ class MockDefinition extends Definition {
.append("serializable", this.serializable).append("reset", getReset()).toString();
}
public <T> T createMock() {
<T> T createMock() {
return createMock(getName());
}
@SuppressWarnings("unchecked")
public <T> T createMock(String name) {
<T> T createMock(String name) {
MockSettings settings = MockReset.withSettings(getReset());
if (StringUtils.hasLength(name)) {
settings.name(name);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2018 the original author or authors.
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -126,7 +126,7 @@ public enum MockReset {
this.reset = reset;
}
public MockReset getReset() {
MockReset getReset() {
return this.reset;
}

View File

@@ -455,7 +455,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda
return this.mockitoPostProcessor.createSpyIfNecessary(bean, beanName);
}
public static void register(BeanDefinitionRegistry registry) {
static void register(BeanDefinitionRegistry registry) {
if (!registry.containsBeanDefinition(BEAN_NAME)) {
RootBeanDefinition definition = new RootBeanDefinition(SpyPostProcessor.class);
definition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

View File

@@ -119,7 +119,7 @@ public class MockitoTestExecutionListener extends AbstractTestExecutionListener
}
}
public boolean hasAnnotations() {
boolean hasAnnotations() {
return !this.annotations.isEmpty();
}

View File

@@ -52,11 +52,11 @@ class QualifierDefinition {
this.annotations = annotations;
}
public boolean matches(ConfigurableListableBeanFactory beanFactory, String beanName) {
boolean matches(ConfigurableListableBeanFactory beanFactory, String beanName) {
return beanFactory.isAutowireCandidate(beanName, this.descriptor);
}
public void applyTo(RootBeanDefinition definition) {
void applyTo(RootBeanDefinition definition) {
definition.setQualifiedElement(this.field);
}
@@ -77,7 +77,7 @@ class QualifierDefinition {
return this.annotations.hashCode();
}
public static QualifierDefinition forElement(AnnotatedElement element) {
static QualifierDefinition forElement(AnnotatedElement element) {
if (element != null && element instanceof Field) {
Field field = (Field) element;
Set<Annotation> annotations = getQualifierAnnotations(field);

View File

@@ -47,7 +47,7 @@ class SpyDefinition extends Definition {
}
public ResolvableType getTypeToSpy() {
ResolvableType getTypeToSpy() {
return this.typeToSpy;
}
@@ -78,12 +78,12 @@ class SpyDefinition extends Definition {
.append("reset", getReset()).toString();
}
public <T> T createSpy(Object instance) {
<T> T createSpy(Object instance) {
return createSpy(getName(), instance);
}
@SuppressWarnings("unchecked")
public <T> T createSpy(String name, Object instance) {
<T> T createSpy(String name, Object instance) {
Assert.notNull(instance, "Instance must not be null");
Assert.isInstanceOf(this.typeToSpy.resolve(), instance);
if (Mockito.mockingDetails(instance).isSpy()) {

View File

@@ -154,7 +154,7 @@ class OutputCapture implements CapturedOutput {
System.setErr(this.err);
}
public void release() {
void release() {
System.setOut(this.out.getParent());
System.setErr(this.err.getParent());
}
@@ -171,7 +171,7 @@ class OutputCapture implements CapturedOutput {
}
}
public void append(StringBuilder builder, Predicate<Type> filter) {
void append(StringBuilder builder, Predicate<Type> filter) {
synchronized (this.monitor) {
for (CapturedString stringCapture : this.capturedStrings) {
if (filter.test(stringCapture.getType())) {
@@ -181,7 +181,7 @@ class OutputCapture implements CapturedOutput {
}
}
public void reset() {
void reset() {
synchronized (this.monitor) {
this.capturedStrings.clear();
}
@@ -201,7 +201,7 @@ class OutputCapture implements CapturedOutput {
this.parent = parent;
}
public PrintStream getParent() {
PrintStream getParent() {
return this.parent;
}
@@ -260,7 +260,7 @@ class OutputCapture implements CapturedOutput {
this.string = string;
}
public Type getType() {
Type getType() {
return this.type;
}
@@ -292,11 +292,11 @@ class OutputCapture implements CapturedOutput {
AnsiOutput.setEnabled(Enabled.NEVER);
}
public void restore() {
void restore() {
AnsiOutput.setEnabled(this.saved);
}
public static AnsiOutputState saveAndDisable() {
static AnsiOutputState saveAndDisable() {
if (!ClassUtils.isPresent("org.springframework.boot.ansi.AnsiOutput",
OutputCapture.class.getClassLoader())) {
return null;

View File

@@ -59,7 +59,7 @@ abstract class AbstractSpringBootTestEmbeddedReactiveWebEnvironmentTests {
@Autowired
private TestRestTemplate restTemplate;
public ReactiveWebApplicationContext getContext() {
ReactiveWebApplicationContext getContext() {
return this.context;
}
@@ -86,30 +86,30 @@ abstract class AbstractSpringBootTestEmbeddedReactiveWebEnvironmentTests {
assertThat(this.value).isEqualTo(123);
}
protected abstract static class AbstractConfig {
static class AbstractConfig {
@Value("${server.port:8080}")
private int port = 8080;
@Bean
public HttpHandler httpHandler(ApplicationContext applicationContext) {
HttpHandler httpHandler(ApplicationContext applicationContext) {
return WebHttpHandlerBuilder.applicationContext(applicationContext).build();
}
@Bean
public ReactiveWebServerFactory webServerFactory() {
ReactiveWebServerFactory webServerFactory() {
TomcatReactiveWebServerFactory factory = new TomcatReactiveWebServerFactory();
factory.setPort(this.port);
return factory;
}
@Bean
public static PropertySourcesPlaceholderConfigurer propertyPlaceholder() {
static PropertySourcesPlaceholderConfigurer propertyPlaceholder() {
return new PropertySourcesPlaceholderConfigurer();
}
@RequestMapping("/")
public Mono<String> home() {
Mono<String> home() {
return Mono.just("Hello World");
}

View File

@@ -60,11 +60,11 @@ abstract class AbstractSpringBootTestWebServerWebEnvironmentTests {
@Autowired
private TestRestTemplate restTemplate;
public WebApplicationContext getContext() {
WebApplicationContext getContext() {
return this.context;
}
public TestRestTemplate getRestTemplate() {
TestRestTemplate getRestTemplate() {
return this.restTemplate;
}
@@ -91,30 +91,30 @@ abstract class AbstractSpringBootTestWebServerWebEnvironmentTests {
assertThat(this.context).isSameAs(WebApplicationContextUtils.getWebApplicationContext(this.servletContext));
}
protected abstract static class AbstractConfig {
static class AbstractConfig {
@Value("${server.port:8080}")
private int port = 8080;
@Bean
public DispatcherServlet dispatcherServlet() {
DispatcherServlet dispatcherServlet() {
return new DispatcherServlet();
}
@Bean
public ServletWebServerFactory webServerFactory() {
ServletWebServerFactory webServerFactory() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
factory.setPort(this.port);
return factory;
}
@Bean
public static PropertySourcesPlaceholderConfigurer propertyPlaceholder() {
static PropertySourcesPlaceholderConfigurer propertyPlaceholder() {
return new PropertySourcesPlaceholderConfigurer();
}
@RequestMapping("/")
public String home() {
String home() {
return "Hello World";
}

View File

@@ -48,7 +48,7 @@ class ConfigFileApplicationContextInitializerTests {
}
@Configuration(proxyBeanMethods = false)
public static class Config {
static class Config {
}

View File

@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
*/
class FilteredClassLoaderTests {
private static ClassPathResource TEST_RESOURCE = new ClassPathResource(
static ClassPathResource TEST_RESOURCE = new ClassPathResource(
"org/springframework/boot/test/context/FilteredClassLoaderTestsResource.txt");
@Test

View File

@@ -127,7 +127,7 @@ class ImportsContextCustomizerFactoryTests {
static class TestWithImportAndBeanMethod {
@Bean
public String bean() {
String bean() {
return "bean";
}

View File

@@ -78,10 +78,10 @@ class SpringBootContextLoaderMockMvcTests {
@Configuration(proxyBeanMethods = false)
@EnableWebMvc
@RestController
protected static class Config {
static class Config {
@RequestMapping("/")
public String home() {
String home() {
return "Hello World";
}

View File

@@ -150,13 +150,13 @@ class SpringBootContextLoaderTests {
/**
* {@link TestContextManager} which exposes the {@link TestContext}.
*/
private static class ExposedTestContextManager extends TestContextManager {
static class ExposedTestContextManager extends TestContextManager {
ExposedTestContextManager(Class<?> testClass) {
super(testClass);
}
public final TestContext getExposedTestContext() {
final TestContext getExposedTestContext() {
return super.getTestContext();
}

View File

@@ -45,7 +45,7 @@ class SpringBootTestActiveProfileTests {
}
@Configuration(proxyBeanMethods = false)
protected static class Config {
static class Config {
}

View File

@@ -44,7 +44,7 @@ class SpringBootTestArgsTests {
}
@Configuration(proxyBeanMethods = false)
protected static class Config {
static class Config {
}

View File

@@ -43,7 +43,7 @@ class SpringBootTestCustomConfigNameTests {
@Configuration(proxyBeanMethods = false)
static class TestConfiguration {
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}

View File

@@ -43,7 +43,7 @@ class SpringBootTestCustomPortTests {
}
@Configuration(proxyBeanMethods = false)
protected static class Config {
static class Config {
}

View File

@@ -44,7 +44,7 @@ class SpringBootTestDefaultConfigurationTests {
}
@Configuration(proxyBeanMethods = false)
protected static class Config {
static class Config {
}

View File

@@ -44,10 +44,10 @@ class SpringBootTestJmxTests {
}
@Configuration(proxyBeanMethods = false)
protected static class Config {
static class Config {
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}

View File

@@ -49,7 +49,7 @@ class SpringBootTestMixedConfigurationTests {
}
@Configuration(proxyBeanMethods = false)
protected static class Config {
static class Config {
}

View File

@@ -37,7 +37,7 @@ public class SpringBootTestReactiveWebEnvironmentDefinedPortTests
@Configuration(proxyBeanMethods = false)
@EnableWebFlux
@RestController
protected static class Config extends AbstractConfig {
static class Config extends AbstractConfig {
}

View File

@@ -37,7 +37,7 @@ public class SpringBootTestReactiveWebEnvironmentRandomPortTests
@Configuration(proxyBeanMethods = false)
@EnableWebFlux
@RestController
protected static class Config extends AbstractConfig {
static class Config extends AbstractConfig {
}

View File

@@ -48,10 +48,10 @@ class SpringBootTestReactiveWebEnvironmentUserDefinedTestRestTemplateTests
@Configuration(proxyBeanMethods = false)
@EnableWebFlux
@RestController
protected static class Config extends AbstractConfig {
static class Config extends AbstractConfig {
@Bean
public RestTemplate testRestTemplate() {
RestTemplate testRestTemplate() {
return new RestTemplate();
}

View File

@@ -49,10 +49,10 @@ class SpringBootTestUserDefinedTestRestTemplateTests extends AbstractSpringBootT
@Configuration(proxyBeanMethods = false)
@EnableWebMvc
@RestController
protected static class Config extends AbstractConfig {
static class Config extends AbstractConfig {
@Bean
public RestTemplate testRestTemplate() {
RestTemplate testRestTemplate() {
return new RestTemplate();
}

View File

@@ -58,14 +58,14 @@ class SpringBootTestWebEnvironmentContextHierarchyTests {
}
@Configuration(proxyBeanMethods = false)
protected static class ParentConfiguration extends AbstractConfig {
static class ParentConfiguration extends AbstractConfig {
}
@Configuration(proxyBeanMethods = false)
@EnableWebMvc
@RestController
protected static class ChildConfiguration extends AbstractConfig {
static class ChildConfiguration extends AbstractConfig {
}

View File

@@ -36,7 +36,7 @@ public class SpringBootTestWebEnvironmentDefinedPortTests extends AbstractSpring
@Configuration(proxyBeanMethods = false)
@EnableWebMvc
@RestController
protected static class Config extends AbstractConfig {
static class Config extends AbstractConfig {
}

View File

@@ -80,10 +80,10 @@ class SpringBootTestWebEnvironmentMockTests {
@Configuration(proxyBeanMethods = false)
@EnableWebMvc
protected static class Config {
static class Config {
@Bean
public static PropertySourcesPlaceholderConfigurer propertyPlaceholder() {
static PropertySourcesPlaceholderConfigurer propertyPlaceholder() {
return new PropertySourcesPlaceholderConfigurer();
}

View File

@@ -53,10 +53,10 @@ class SpringBootTestWebEnvironmentMockWithWebAppConfigurationTests {
@Configuration(proxyBeanMethods = false)
@EnableWebMvc
protected static class Config {
static class Config {
@Bean
public static PropertySourcesPlaceholderConfigurer propertyPlaceholder() {
static PropertySourcesPlaceholderConfigurer propertyPlaceholder() {
return new PropertySourcesPlaceholderConfigurer();
}

View File

@@ -49,7 +49,7 @@ class SpringBootTestWebEnvironmentRandomPortCustomPortTests {
@Configuration(proxyBeanMethods = false)
@EnableWebMvc
protected static class Config extends AbstractConfig {
static class Config extends AbstractConfig {
}

View File

@@ -49,17 +49,17 @@ class SpringBootTestWebEnvironmentRandomPortTests extends AbstractSpringBootTest
@Configuration(proxyBeanMethods = false)
@EnableWebMvc
@RestController
protected static class Config extends AbstractConfig {
static class Config extends AbstractConfig {
@Bean
public RestTemplateBuilder restTemplateBuilder() {
RestTemplateBuilder restTemplateBuilder() {
return new RestTemplateBuilder().additionalMessageConverters(new MyConverter());
}
}
private static class MyConverter extends StringHttpMessageConverter {
static class MyConverter extends StringHttpMessageConverter {
}

View File

@@ -100,7 +100,7 @@ class SpringBootTestWithTestPropertySourceTests {
private String propertySourceInlinedOverridesBootTestInlined;
@Bean
public static PropertySourcesPlaceholderConfigurer propertyPlaceholder() {
static PropertySourcesPlaceholderConfigurer propertyPlaceholder() {
return new PropertySourcesPlaceholderConfigurer();
}

View File

@@ -193,13 +193,11 @@ class ApplicationContextAssertProviderTests {
ApplicationContext.class, contextSupplier);
}
private interface TestAssertProviderApplicationContext
extends ApplicationContextAssertProvider<ApplicationContext> {
interface TestAssertProviderApplicationContext extends ApplicationContextAssertProvider<ApplicationContext> {
}
private abstract static class TestAssertProviderApplicationContextClass
implements TestAssertProviderApplicationContext {
abstract static class TestAssertProviderApplicationContextClass implements TestAssertProviderApplicationContext {
}

View File

@@ -406,11 +406,11 @@ class ApplicationContextAssertTests {
});
}
private static class Foo {
static class Foo {
}
private static class Bar extends Foo {
static class Bar extends Foo {
}
@@ -418,13 +418,13 @@ class ApplicationContextAssertTests {
static class PrimaryFooConfig {
@Bean
public Foo foo() {
Foo foo() {
return new Foo();
}
@Bean
@Primary
public Bar bar() {
Bar bar() {
return new Bar();
}

View File

@@ -71,7 +71,7 @@ class SpringBootTestContextBootstrapperIntegrationTests {
static class TestConfig {
@Bean
public ExampleBean exampleBean() {
ExampleBean exampleBean() {
return new ExampleBean();
}

View File

@@ -63,13 +63,13 @@ class SpringBootTestContextBootstrapperTests {
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@WebAppConfiguration
private static class SpringBootTestNonMockWebEnvironmentAndWebAppConfiguration {
static class SpringBootTestNonMockWebEnvironmentAndWebAppConfiguration {
}
@SpringBootTest
@WebAppConfiguration
private static class SpringBootTestMockWebEnvironmentAndWebAppConfiguration {
static class SpringBootTestMockWebEnvironmentAndWebAppConfiguration {
}

View File

@@ -53,7 +53,7 @@ class SpringBootTestContextBootstrapperWithInitializersTests {
// gh-8483
public static class CustomInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
static class CustomInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {

View File

@@ -198,7 +198,7 @@ abstract class AbstractApplicationContextRunnerTests<T extends AbstractApplicati
static class FailingConfig {
@Bean
public String foo() {
String foo() {
throw new IllegalStateException("Failed");
}
@@ -208,7 +208,7 @@ abstract class AbstractApplicationContextRunnerTests<T extends AbstractApplicati
static class FooConfig {
@Bean
public String foo() {
String foo() {
return "foo";
}
@@ -218,7 +218,7 @@ abstract class AbstractApplicationContextRunnerTests<T extends AbstractApplicati
static class BarConfig {
@Bean
public String bar() {
String bar() {
return "bar";
}

View File

@@ -185,7 +185,7 @@ abstract class AbstractJsonMarshalTesterTests {
/**
* Access to field backed by {@link ResolvableType}.
*/
public static class ResolvableTypes {
static class ResolvableTypes {
public List<ExampleObject> listOfExampleObject;
@@ -193,7 +193,7 @@ abstract class AbstractJsonMarshalTesterTests {
public Map<String, ExampleObject> mapOfExampleObject;
public static ResolvableType get(String name) {
static ResolvableType get(String name) {
Field field = ReflectionUtils.findField(ResolvableTypes.class, name);
return ResolvableType.forField(field);
}

View File

@@ -61,7 +61,7 @@ class MockBeanForBeanFactoryIntegrationTests {
static class Config {
@Bean
public TestFactoryBean testFactoryBean() {
TestFactoryBean testFactoryBean() {
return new TestFactoryBean();
}

View File

@@ -77,7 +77,7 @@ class MockBeanOnContextHierarchyIntegrationTests {
this.context = applicationContext;
}
public ApplicationContext getContext() {
ApplicationContext getContext() {
return this.context;
}

View File

@@ -60,7 +60,7 @@ class MockBeanOnScopedProxyTests {
@Bean
@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS)
public ExampleService exampleService() {
ExampleService exampleService() {
return new FailingExampleService();
}

View File

@@ -70,17 +70,17 @@ class MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests {
static class TestConfig {
@Bean
public CustomQualifierExampleService service() {
CustomQualifierExampleService service() {
return new CustomQualifierExampleService();
}
@Bean
public ExampleService anotherService() {
ExampleService anotherService() {
return new RealExampleService("Another");
}
@Bean
public ExampleServiceCaller controller(@CustomQualifier ExampleService service) {
ExampleServiceCaller controller(@CustomQualifier ExampleService service) {
return new ExampleServiceCaller(service);
}

View File

@@ -71,14 +71,14 @@ class MockBeanWithAopProxyTests {
static class Config {
@Bean
public CacheResolver cacheResolver(CacheManager cacheManager) {
CacheResolver cacheResolver(CacheManager cacheManager) {
SimpleCacheResolver resolver = new SimpleCacheResolver();
resolver.setCacheManager(cacheManager);
return resolver;
}
@Bean
public ConcurrentMapCacheManager cacheManager() {
ConcurrentMapCacheManager cacheManager() {
ConcurrentMapCacheManager cacheManager = new ConcurrentMapCacheManager();
cacheManager.setCacheNames(Arrays.asList("test"));
return cacheManager;
@@ -90,7 +90,7 @@ class MockBeanWithAopProxyTests {
static class DateService {
@Cacheable(cacheNames = "test")
public Long getDate(boolean argument) {
Long getDate(boolean argument) {
return System.nanoTime();
}

View File

@@ -49,14 +49,14 @@ class MockBeanWithAsyncInterfaceMethodIntegrationTests {
assertThat(this.service.transform("foo")).isEqualTo("bar");
}
private interface Transformer {
interface Transformer {
@Async
String transform(String input);
}
private static class MyService {
static class MyService {
private final Transformer transformer;
@@ -64,7 +64,7 @@ class MockBeanWithAsyncInterfaceMethodIntegrationTests {
this.transformer = transformer;
}
public String transform(String input) {
String transform(String input) {
return this.transformer.transform(input);
}
@@ -75,7 +75,7 @@ class MockBeanWithAsyncInterfaceMethodIntegrationTests {
static class MyConfiguration {
@Bean
public MyService myService(Transformer transformer) {
MyService myService(Transformer transformer) {
return new MyService(transformer);
}

View File

@@ -44,18 +44,18 @@ class MockBeanWithInjectedFieldIntegrationTests {
assertThat(this.myService.getCount()).isEqualTo(5);
}
private static class MyService {
static class MyService {
@Autowired
private MyRepository repository;
public int getCount() {
int getCount() {
return this.repository.findAll().size();
}
}
private interface MyRepository {
interface MyRepository {
List<Object> findAll();

View File

@@ -128,7 +128,7 @@ class MockitoPostProcessorTests {
static class MockedFactoryBean {
@Bean
public TestFactoryBean testFactoryBean() {
TestFactoryBean testFactoryBean() {
return new TestFactoryBean();
}
@@ -139,12 +139,12 @@ class MockitoPostProcessorTests {
static class MultipleBeans {
@Bean
public ExampleService example1() {
ExampleService example1() {
return new FailingExampleService();
}
@Bean
public ExampleService example2() {
ExampleService example2() {
return new FailingExampleService();
}
@@ -159,18 +159,18 @@ class MockitoPostProcessorTests {
@Bean
@Qualifier("test")
public ExampleService example1() {
ExampleService example1() {
return new FailingExampleService();
}
@Bean
public ExampleService example2() {
ExampleService example2() {
return new FailingExampleService();
}
@Bean
@Qualifier("test")
public ExampleService example3() {
ExampleService example3() {
return new FailingExampleService();
}
@@ -184,13 +184,13 @@ class MockitoPostProcessorTests {
@Bean
@Qualifier("test")
public ExampleService exampleQualified() {
ExampleService exampleQualified() {
return new RealExampleService("qualified");
}
@Bean
@Primary
public ExampleService examplePrimary() {
ExampleService examplePrimary() {
return new RealExampleService("primary");
}
@@ -205,13 +205,13 @@ class MockitoPostProcessorTests {
@Bean
@Qualifier("test")
public ExampleService exampleQualified() {
ExampleService exampleQualified() {
return new RealExampleService("qualified");
}
@Bean
@Primary
public ExampleService examplePrimary() {
ExampleService examplePrimary() {
return new RealExampleService("primary");
}
@@ -225,13 +225,13 @@ class MockitoPostProcessorTests {
@Bean
@Qualifier("test")
public ExampleService exampleQualified() {
ExampleService exampleQualified() {
return new RealExampleService("qualified");
}
@Bean
@Primary
public ExampleService examplePrimary() {
ExampleService examplePrimary() {
return new RealExampleService("primary");
}
@@ -246,13 +246,13 @@ class MockitoPostProcessorTests {
@Bean
@Qualifier("test")
public ExampleService exampleQualified() {
ExampleService exampleQualified() {
return new RealExampleService("qualified");
}
@Bean
@Primary
public ExampleService examplePrimary() {
ExampleService examplePrimary() {
return new RealExampleService("primary");
}

View File

@@ -61,7 +61,7 @@ class ResetMocksTestExecutionListenerTests {
assertThat(getMock("after").greeting()).isNull();
}
public ExampleService getMock(String name) {
ExampleService getMock(String name) {
return this.context.getBean(name, ExampleService.class);
}
@@ -69,21 +69,21 @@ class ResetMocksTestExecutionListenerTests {
static class Config {
@Bean
public ExampleService before(MockitoBeans mockedBeans) {
ExampleService before(MockitoBeans mockedBeans) {
ExampleService mock = mock(ExampleService.class, MockReset.before());
mockedBeans.add(mock);
return mock;
}
@Bean
public ExampleService after(MockitoBeans mockedBeans) {
ExampleService after(MockitoBeans mockedBeans) {
ExampleService mock = mock(ExampleService.class, MockReset.after());
mockedBeans.add(mock);
return mock;
}
@Bean
public ExampleService none(MockitoBeans mockedBeans) {
ExampleService none(MockitoBeans mockedBeans) {
ExampleService mock = mock(ExampleService.class);
mockedBeans.add(mock);
return mock;
@@ -91,13 +91,13 @@ class ResetMocksTestExecutionListenerTests {
@Bean
@Lazy
public ExampleService fail() {
ExampleService fail() {
// gh-5870
throw new RuntimeException();
}
@Bean
public BrokenFactoryBean brokenFactoryBean() {
BrokenFactoryBean brokenFactoryBean() {
// gh-7270
return new BrokenFactoryBean();
}

View File

@@ -78,7 +78,7 @@ class SpyBeanOnContextHierarchyIntegrationTests {
this.context = applicationContext;
}
public ApplicationContext getContext() {
ApplicationContext getContext() {
return this.context;
}

View File

@@ -69,17 +69,17 @@ class SpyBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests {
static class TestConfig {
@Bean
public CustomQualifierExampleService service() {
CustomQualifierExampleService service() {
return new CustomQualifierExampleService();
}
@Bean
public ExampleService anotherService() {
ExampleService anotherService() {
return new RealExampleService("Another");
}
@Bean
public ExampleServiceCaller controller(@CustomQualifier ExampleService service) {
ExampleServiceCaller controller(@CustomQualifier ExampleService service) {
return new ExampleServiceCaller(service);
}

View File

@@ -61,7 +61,7 @@ class SpyBeanOnTestFieldForExistingGenericBeanIntegrationTests {
static class SpyBeanOnTestFieldForExistingBeanConfig {
@Bean
public ExampleGenericService<String> simpleExampleStringGenericService() {
ExampleGenericService<String> simpleExampleStringGenericService() {
// In order to trigger issue we need a method signature that returns the
// generic type not the actual implementation class
return new SimpleExampleStringGenericService();

View File

@@ -60,13 +60,13 @@ class SpyBeanOnTestFieldForMultipleExistingBeansWithOnePrimaryIntegrationTests {
static class Config {
@Bean
public SimpleExampleStringGenericService one() {
SimpleExampleStringGenericService one() {
return new SimpleExampleStringGenericService("one");
}
@Bean
@Primary
public SimpleExampleStringGenericService two() {
SimpleExampleStringGenericService two() {
return new SimpleExampleStringGenericService("two");
}

View File

@@ -64,14 +64,14 @@ class SpyBeanWithAopProxyAndNotProxyTargetAwareTests {
static class Config {
@Bean
public CacheResolver cacheResolver(CacheManager cacheManager) {
CacheResolver cacheResolver(CacheManager cacheManager) {
SimpleCacheResolver resolver = new SimpleCacheResolver();
resolver.setCacheManager(cacheManager);
return resolver;
}
@Bean
public ConcurrentMapCacheManager cacheManager() {
ConcurrentMapCacheManager cacheManager() {
ConcurrentMapCacheManager cacheManager = new ConcurrentMapCacheManager();
cacheManager.setCacheNames(Arrays.asList("test"));
return cacheManager;
@@ -80,7 +80,7 @@ class SpyBeanWithAopProxyAndNotProxyTargetAwareTests {
}
@Service
static class DateService {
public static class DateService {
@Cacheable(cacheNames = "test")
public Long getDate(boolean arg) {

View File

@@ -68,14 +68,14 @@ class SpyBeanWithAopProxyTests {
static class Config {
@Bean
public CacheResolver cacheResolver(CacheManager cacheManager) {
CacheResolver cacheResolver(CacheManager cacheManager) {
SimpleCacheResolver resolver = new SimpleCacheResolver();
resolver.setCacheManager(cacheManager);
return resolver;
}
@Bean
public ConcurrentMapCacheManager cacheManager() {
ConcurrentMapCacheManager cacheManager() {
ConcurrentMapCacheManager cacheManager = new ConcurrentMapCacheManager();
cacheManager.setCacheNames(Arrays.asList("test"));
return cacheManager;
@@ -84,7 +84,7 @@ class SpyBeanWithAopProxyTests {
}
@Service
static class DateService {
public static class DateService {
@Cacheable(cacheNames = "test")
public Long getDate(boolean arg) {

View File

@@ -52,12 +52,12 @@ class SpyBeanWithNameOnTestFieldForMultipleExistingBeansTests {
static class Config {
@Bean
public SimpleExampleStringGenericService one() {
SimpleExampleStringGenericService one() {
return new SimpleExampleStringGenericService("one");
}
@Bean
public SimpleExampleStringGenericService two() {
SimpleExampleStringGenericService two() {
return new SimpleExampleStringGenericService("two");
}

View File

@@ -163,7 +163,7 @@ class OutputCaptureTests {
assertThat(this.output.getOut()).isEqualTo("AC");
}
private static class TestPrintStream extends PrintStream {
static class TestPrintStream extends PrintStream {
TestPrintStream() {
super(new ByteArrayOutputStream());

View File

@@ -59,7 +59,7 @@ class TestRestTemplateContextCustomizerIntegrationTests {
static class TestConfig {
@Bean
public TomcatServletWebServerFactory webServerFactory() {
TomcatServletWebServerFactory webServerFactory() {
return new TomcatServletWebServerFactory(0);
}

View File

@@ -53,7 +53,7 @@ class TestRestTemplateContextCustomizerTests {
}
private static class TestApplicationContext extends AbstractApplicationContext {
static class TestApplicationContext extends AbstractApplicationContext {
private final ConfigurableListableBeanFactory beanFactory = new DefaultListableBeanFactory();

View File

@@ -53,7 +53,7 @@ class TestRestTemplateContextCustomizerWithFactoryBeanTests {
static class TestClassWithFactoryBean {
@Bean
public TomcatServletWebServerFactory webServerFactory() {
TomcatServletWebServerFactory webServerFactory() {
return new TomcatServletWebServerFactory(0);
}

View File

@@ -60,12 +60,12 @@ class TestRestTemplateContextCustomizerWithOverrideIntegrationTests {
static class TestConfig {
@Bean
public TomcatServletWebServerFactory webServerFactory() {
TomcatServletWebServerFactory webServerFactory() {
return new TomcatServletWebServerFactory(0);
}
@Bean
public TestRestTemplate template() {
TestRestTemplate template() {
return new CustomTestRestTemplate();
}

View File

@@ -355,7 +355,7 @@ class TestRestTemplateTests {
}
private interface TestRestTemplateCallback {
interface TestRestTemplateCallback {
void doWithTestRestTemplate(TestRestTemplate testRestTemplate, URI relativeUri);

View File

@@ -56,7 +56,7 @@ class WebTestClientContextCustomizerIntegrationTests {
static class TestConfig {
@Bean
public TomcatReactiveWebServerFactory webServerFactory() {
TomcatReactiveWebServerFactory webServerFactory() {
return new TomcatReactiveWebServerFactory(0);
}

View File

@@ -60,12 +60,12 @@ class WebTestClientContextCustomizerWithOverrideIntegrationTests {
static class TestConfig {
@Bean
public TomcatReactiveWebServerFactory webServerFactory() {
TomcatReactiveWebServerFactory webServerFactory() {
return new TomcatReactiveWebServerFactory(0);
}
@Bean
public WebTestClient webTestClient() {
WebTestClient webTestClient() {
return mock(CustomWebTestClient.class);
}