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

@@ -41,7 +41,7 @@ class SpringBootDependencyInjectionTestExecutionListenerPostConstructIntegration
private List<String> calls = new ArrayList<>();
@PostConstruct
public void postConstruct() {
void postConstruct() {
StringWriter writer = new StringWriter();
new RuntimeException().printStackTrace(new PrintWriter(writer));
this.calls.add(writer.toString());

View File

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

View File

@@ -50,10 +50,10 @@ class AutoConfigureCacheWithExistingCacheManagerIntegrationTests {
@Configuration(proxyBeanMethods = false)
@EnableCaching
public static class Config {
static class Config {
@Bean
public ConcurrentMapCacheManager existingCacheManager() {
ConcurrentMapCacheManager existingCacheManager() {
return new ConcurrentMapCacheManager();
}

View File

@@ -22,11 +22,7 @@ import org.springframework.data.repository.CrudRepository;
* Example repository used with {@link DataJdbcTest @DataJdbcTest} tests.
*
* @author Andy Wilkinson
* @author Dave Syer
* @since 1.2.1
* @deprecated since 2.0.6 since security prerequisites are not supported in Spring Boot 2
*/
@Deprecated
public interface ExampleRepository extends CrudRepository<ExampleEntity, Long> {
interface ExampleRepository extends CrudRepository<ExampleEntity, Long> {
}

View File

@@ -23,6 +23,6 @@ import org.springframework.data.ldap.repository.LdapRepository;
*
* @author Eddú Meléndez
*/
public interface ExampleRepository extends LdapRepository<ExampleEntry> {
interface ExampleRepository extends LdapRepository<ExampleEntry> {
}

View File

@@ -23,6 +23,6 @@ import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
*
* @author Stephane Nicoll
*/
public interface ExampleReactiveRepository extends ReactiveMongoRepository<ExampleDocument, String> {
interface ExampleReactiveRepository extends ReactiveMongoRepository<ExampleDocument, String> {
}

View File

@@ -23,6 +23,6 @@ import org.springframework.data.mongodb.repository.MongoRepository;
*
* @author Michael Simons
*/
public interface ExampleRepository extends MongoRepository<ExampleDocument, String> {
interface ExampleRepository extends MongoRepository<ExampleDocument, String> {
}

View File

@@ -23,6 +23,6 @@ import org.springframework.data.neo4j.repository.Neo4jRepository;
*
* @author Eddú Meléndez
*/
public interface ExampleRepository extends Neo4jRepository<ExampleGraph, Long> {
interface ExampleRepository extends Neo4jRepository<ExampleGraph, Long> {
}

View File

@@ -23,6 +23,6 @@ import org.springframework.data.repository.CrudRepository;
*
* @author Jayaram Pradhan
*/
public interface ExampleRepository extends CrudRepository<PersonHash, String> {
interface ExampleRepository extends CrudRepository<PersonHash, String> {
}

View File

@@ -56,12 +56,12 @@ class AutoConfigureTestDatabaseWithMultipleDatasourcesIntegrationTests {
@Bean
@Primary
public DataSource dataSource() {
DataSource dataSource() {
return new EmbeddedDatabaseBuilder().generateUniqueName(true).setType(EmbeddedDatabaseType.HSQL).build();
}
@Bean
public DataSource secondaryDataSource() {
DataSource secondaryDataSource() {
return new EmbeddedDatabaseBuilder().generateUniqueName(true).setType(EmbeddedDatabaseType.HSQL).build();
}

View File

@@ -56,7 +56,7 @@ public class ExampleRepository {
return this.jdbcTemplate.query("select id, name from example", ROW_MAPPER);
}
private static class ExampleEntityRowMapper implements RowMapper<ExampleEntity> {
static class ExampleEntityRowMapper implements RowMapper<ExampleEntity> {
@Override
public ExampleEntity mapRow(ResultSet rs, int rowNum) throws SQLException {

View File

@@ -55,7 +55,7 @@ class JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests {
static class Config {
@Bean
public DataSource dataSource() {
DataSource dataSource() {
return new EmbeddedDatabaseBuilder().generateUniqueName(true).setType(EmbeddedDatabaseType.H2).build();
}

View File

@@ -57,7 +57,7 @@ class JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests {
static class Config {
@Bean
public DataSource dataSource() {
DataSource dataSource() {
return new EmbeddedDatabaseBuilder().generateUniqueName(true).setType(EmbeddedDatabaseType.H2).build();
}

View File

@@ -64,7 +64,7 @@ class TestDatabaseAutoConfigurationTests {
static class ExistingDataSourceConfiguration {
@Bean
public DataSource dataSource() {
DataSource dataSource() {
return new EmbeddedDatabaseBuilder().generateUniqueName(true).setType(EmbeddedDatabaseType.HSQL).build();
}

View File

@@ -39,7 +39,7 @@ import org.springframework.boot.test.autoconfigure.json.JsonTest;
@JsonComponent
public class ExampleJsonComponent {
public static class Serializer extends JsonObjectSerializer<ExampleCustomObject> {
static class Serializer extends JsonObjectSerializer<ExampleCustomObject> {
@Override
protected void serializeObject(ExampleCustomObject value, JsonGenerator jgen, SerializerProvider provider)
@@ -49,7 +49,7 @@ public class ExampleJsonComponent {
}
public static class Deserializer extends JsonObjectDeserializer<ExampleCustomObject> {
static class Deserializer extends JsonObjectDeserializer<ExampleCustomObject> {
@Override
protected ExampleCustomObject deserializeObject(JsonParser jsonParser, DeserializationContext context,

View File

@@ -23,7 +23,7 @@ import org.springframework.data.repository.Repository;
*
* @author Phillip Webb
*/
public interface ExampleRepository extends Repository<ExampleEntity, Long> {
interface ExampleRepository extends Repository<ExampleEntity, Long> {
ExampleEntity findByReference(String reference);

View File

@@ -68,7 +68,7 @@ public class TestDatabaseAutoConfigurationNoEmbeddedTests {
static class ExistingDataSourceConfiguration {
@Bean
public DataSource myCustomDataSource() {
DataSource myCustomDataSource() {
return mock(DataSource.class);
}

View File

@@ -79,20 +79,20 @@ class MockMvcRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests {
}
@TestConfiguration
public static class CustomizationConfiguration {
static class CustomizationConfiguration {
@Bean
public RestDocumentationResultHandler restDocumentation() {
RestDocumentationResultHandler restDocumentation() {
return MockMvcRestDocumentation.document("{method-name}");
}
@Bean
public RestDocsMockMvcConfigurationCustomizer templateFormatCustomizer() {
RestDocsMockMvcConfigurationCustomizer templateFormatCustomizer() {
return (configurer) -> configurer.snippets().withTemplateFormat(TemplateFormats.markdown());
}
@Bean
public RestDocsMockMvcConfigurationCustomizer defaultSnippetsCustomizer() {
RestDocsMockMvcConfigurationCustomizer defaultSnippetsCustomizer() {
return (configurer) -> configurer.snippets()
.withAdditionalDefaults(responseFields(fieldWithPath("_links.self").description("Main URL")));
}

View File

@@ -83,20 +83,20 @@ class RestAssuredRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests
}
@TestConfiguration
public static class CustomizationConfiguration {
static class CustomizationConfiguration {
@Bean
public RestDocumentationResultHandler restDocumentation() {
RestDocumentationResultHandler restDocumentation() {
return MockMvcRestDocumentation.document("{method-name}");
}
@Bean
public RestDocsRestAssuredConfigurationCustomizer templateFormatCustomizer() {
RestDocsRestAssuredConfigurationCustomizer templateFormatCustomizer() {
return (configurer) -> configurer.snippets().withTemplateFormat(TemplateFormats.markdown());
}
@Bean
public RestDocsRestAssuredConfigurationCustomizer defaultSnippetsCustomizer() {
RestDocsRestAssuredConfigurationCustomizer defaultSnippetsCustomizer() {
return (configurer) -> configurer.snippets()
.withAdditionalDefaults(responseFields(fieldWithPath("_links.self").description("Main URL")));
}

View File

@@ -73,20 +73,20 @@ class WebTestClientRestDocsAutoConfigurationAdvancedConfigurationIntegrationTest
}
@TestConfiguration
public static class CustomizationConfiguration {
static class CustomizationConfiguration {
@Bean
public RestDocumentationResultHandler restDocumentation() {
RestDocumentationResultHandler restDocumentation() {
return MockMvcRestDocumentation.document("{method-name}");
}
@Bean
public RestDocsWebTestClientConfigurationCustomizer templateFormatCustomizer() {
RestDocsWebTestClientConfigurationCustomizer templateFormatCustomizer() {
return (configurer) -> configurer.snippets().withTemplateFormat(TemplateFormats.markdown());
}
@Bean
public RestDocsWebTestClientConfigurationCustomizer defaultSnippetsCustomizer() {
RestDocsWebTestClientConfigurationCustomizer defaultSnippetsCustomizer() {
return (configurer) -> configurer.snippets()
.withAdditionalDefaults(responseFields(fieldWithPath("_links.self").description("Main URL")));
}

View File

@@ -34,7 +34,7 @@ public class SecurityTestApplication {
@RequestMapping("/")
@Secured("ROLE_USER")
public String index() {
String index() {
return "Hello";
}

View File

@@ -116,7 +116,7 @@ class WebTestClientAutoConfigurationTests {
static class BaseConfiguration {
@Bean
public WebHandler webHandler() {
WebHandler webHandler() {
return mock(WebHandler.class);
}
@@ -127,7 +127,7 @@ class WebTestClientAutoConfigurationTests {
static class CodecConfiguration {
@Bean
public CodecCustomizer myCodecCustomizer() {
CodecCustomizer myCodecCustomizer() {
return mock(CodecCustomizer.class);
}

View File

@@ -67,7 +67,7 @@ class WebTestClientSpringBootTestIntegrationTests {
static class TestConfiguration {
@Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
return http.authorizeExchange().anyExchange().permitAll().and().build();
}

View File

@@ -69,7 +69,7 @@ class SpringBootMockMvcBuilderCustomizerTests {
static class ServletConfiguration {
@Bean
public TestServlet testServlet() {
TestServlet testServlet() {
return new TestServlet();
}
@@ -79,12 +79,12 @@ class SpringBootMockMvcBuilderCustomizerTests {
static class FilterConfiguration {
@Bean
public FilterRegistrationBean<OtherTestFilter> filterRegistrationBean() {
FilterRegistrationBean<OtherTestFilter> filterRegistrationBean() {
return new FilterRegistrationBean<>(new OtherTestFilter());
}
@Bean
public TestFilter testFilter() {
TestFilter testFilter() {
return new TestFilter();
}

View File

@@ -35,12 +35,12 @@ import org.springframework.web.bind.annotation.RestController;
class HateoasController {
@RequestMapping("/resource")
public EntityModel<Map<String, String>> resource() {
EntityModel<Map<String, String>> resource() {
return new EntityModel<>(new HashMap<>(), new Link("self", "https://api.example.com"));
}
@RequestMapping("/plain")
public Map<String, String> plain() {
Map<String, String> plain() {
return new HashMap<>();
}

View File

@@ -48,7 +48,7 @@ class WebMvcTestServletFilterRegistrationDisabledIntegrationTests {
static class DisabledRegistrationConfiguration {
@Bean
public FilterRegistrationBean<ExampleFilter> exampleFilterRegistration(ExampleFilter filter) {
FilterRegistrationBean<ExampleFilter> exampleFilterRegistration(ExampleFilter filter) {
FilterRegistrationBean<ExampleFilter> registration = new FilterRegistrationBean<>(filter);
registration.setEnabled(false);
return registration;

View File

@@ -64,7 +64,7 @@ class WebMvcTestWebDriverCustomScopeIntegrationTests {
@Bean
@Scope("singleton")
public WebDriverFactory webDriver(MockMvc mockMvc) {
WebDriverFactory webDriver(MockMvc mockMvc) {
return new WebDriverFactory(mockMvc);
}