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:
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class ConfigFileApplicationContextInitializerTests {
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public static class Config {
|
||||
static class Config {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -127,7 +127,7 @@ class ImportsContextCustomizerFactoryTests {
|
||||
static class TestWithImportAndBeanMethod {
|
||||
|
||||
@Bean
|
||||
public String bean() {
|
||||
String bean() {
|
||||
return "bean";
|
||||
}
|
||||
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class SpringBootTestActiveProfileTests {
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
protected static class Config {
|
||||
static class Config {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class SpringBootTestArgsTests {
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
protected static class Config {
|
||||
static class Config {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class SpringBootTestCustomConfigNameTests {
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class TestConfiguration {
|
||||
|
||||
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
|
||||
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
|
||||
return new PropertySourcesPlaceholderConfigurer();
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class SpringBootTestCustomPortTests {
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
protected static class Config {
|
||||
static class Config {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class SpringBootTestDefaultConfigurationTests {
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
protected static class Config {
|
||||
static class Config {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class SpringBootTestMixedConfigurationTests {
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
protected static class Config {
|
||||
static class Config {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public class SpringBootTestReactiveWebEnvironmentDefinedPortTests
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableWebFlux
|
||||
@RestController
|
||||
protected static class Config extends AbstractConfig {
|
||||
static class Config extends AbstractConfig {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public class SpringBootTestReactiveWebEnvironmentRandomPortTests
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableWebFlux
|
||||
@RestController
|
||||
protected static class Config extends AbstractConfig {
|
||||
static class Config extends AbstractConfig {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class SpringBootTestWebEnvironmentRandomPortCustomPortTests {
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableWebMvc
|
||||
protected static class Config extends AbstractConfig {
|
||||
static class Config extends AbstractConfig {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ class SpringBootTestWithTestPropertySourceTests {
|
||||
private String propertySourceInlinedOverridesBootTestInlined;
|
||||
|
||||
@Bean
|
||||
public static PropertySourcesPlaceholderConfigurer propertyPlaceholder() {
|
||||
static PropertySourcesPlaceholderConfigurer propertyPlaceholder() {
|
||||
return new PropertySourcesPlaceholderConfigurer();
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ class SpringBootTestContextBootstrapperIntegrationTests {
|
||||
static class TestConfig {
|
||||
|
||||
@Bean
|
||||
public ExampleBean exampleBean() {
|
||||
ExampleBean exampleBean() {
|
||||
return new ExampleBean();
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class MockBeanForBeanFactoryIntegrationTests {
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public TestFactoryBean testFactoryBean() {
|
||||
TestFactoryBean testFactoryBean() {
|
||||
return new TestFactoryBean();
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ class MockBeanOnContextHierarchyIntegrationTests {
|
||||
this.context = applicationContext;
|
||||
}
|
||||
|
||||
public ApplicationContext getContext() {
|
||||
ApplicationContext getContext() {
|
||||
return this.context;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class MockBeanOnScopedProxyTests {
|
||||
|
||||
@Bean
|
||||
@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
public ExampleService exampleService() {
|
||||
ExampleService exampleService() {
|
||||
return new FailingExampleService();
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ class SpyBeanOnContextHierarchyIntegrationTests {
|
||||
this.context = applicationContext;
|
||||
}
|
||||
|
||||
public ApplicationContext getContext() {
|
||||
ApplicationContext getContext() {
|
||||
return this.context;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -59,7 +59,7 @@ class TestRestTemplateContextCustomizerIntegrationTests {
|
||||
static class TestConfig {
|
||||
|
||||
@Bean
|
||||
public TomcatServletWebServerFactory webServerFactory() {
|
||||
TomcatServletWebServerFactory webServerFactory() {
|
||||
return new TomcatServletWebServerFactory(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class TestRestTemplateContextCustomizerTests {
|
||||
|
||||
}
|
||||
|
||||
private static class TestApplicationContext extends AbstractApplicationContext {
|
||||
static class TestApplicationContext extends AbstractApplicationContext {
|
||||
|
||||
private final ConfigurableListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class TestRestTemplateContextCustomizerWithFactoryBeanTests {
|
||||
static class TestClassWithFactoryBean {
|
||||
|
||||
@Bean
|
||||
public TomcatServletWebServerFactory webServerFactory() {
|
||||
TomcatServletWebServerFactory webServerFactory() {
|
||||
return new TomcatServletWebServerFactory(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -355,7 +355,7 @@ class TestRestTemplateTests {
|
||||
|
||||
}
|
||||
|
||||
private interface TestRestTemplateCallback {
|
||||
interface TestRestTemplateCallback {
|
||||
|
||||
void doWithTestRestTemplate(TestRestTemplate testRestTemplate, URI relativeUri);
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class WebTestClientContextCustomizerIntegrationTests {
|
||||
static class TestConfig {
|
||||
|
||||
@Bean
|
||||
public TomcatReactiveWebServerFactory webServerFactory() {
|
||||
TomcatReactiveWebServerFactory webServerFactory() {
|
||||
return new TomcatReactiveWebServerFactory(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user