Polish formatting

This commit is contained in:
Phillip Webb
2017-03-06 15:02:56 -08:00
parent 91a7bf92e6
commit 2a592103f0
102 changed files with 449 additions and 435 deletions

View File

@@ -59,7 +59,7 @@ public class SpringBootDependencyInjectionTestExecutionListener
@Override
public Set<Class<? extends TestExecutionListener>> postProcessDefaultTestExecutionListeners(
Set<Class<? extends TestExecutionListener>> listeners) {
Set<Class<? extends TestExecutionListener>> updated = new LinkedHashSet<Class<? extends TestExecutionListener>>(
Set<Class<? extends TestExecutionListener>> updated = new LinkedHashSet<>(
listeners.size());
for (Class<? extends TestExecutionListener> listener : listeners) {
updated.add(

View File

@@ -55,7 +55,7 @@ public class FilterAnnotations implements Iterable<TypeFilter> {
}
private List<TypeFilter> createTypeFilters(Filter[] filters) {
List<TypeFilter> typeFilters = new ArrayList<TypeFilter>();
List<TypeFilter> typeFilters = new ArrayList<>();
for (Filter filter : filters) {
for (Class<?> filterClass : filter.classes()) {
typeFilters.add(createTypeFilter(filter.type(), filterClass));

View File

@@ -50,7 +50,7 @@ class TypeExcludeFiltersContextCustomizer implements ContextCustomizer {
private Set<TypeExcludeFilter> instantiateTypeExcludeFilters(Class<?> testClass,
Set<Class<? extends TypeExcludeFilter>> filterClasses) {
Set<TypeExcludeFilter> filters = new LinkedHashSet<TypeExcludeFilter>();
Set<TypeExcludeFilter> filters = new LinkedHashSet<>();
for (Class<? extends TypeExcludeFilter> filterClass : filterClasses) {
filters.add(instantiateTypeExcludeFilter(testClass, filterClass));
}

View File

@@ -42,7 +42,7 @@ class TypeExcludeFiltersContextCustomizerFactory implements ContextCustomizerFac
TypeExcludeFilters annotation = AnnotatedElementUtils
.findMergedAnnotation(testClass, TypeExcludeFilters.class);
if (annotation != null) {
Set<Class<? extends TypeExcludeFilter>> filterClasses = new LinkedHashSet<Class<? extends TypeExcludeFilter>>(
Set<Class<? extends TypeExcludeFilter>> filterClasses = new LinkedHashSet<>(
Arrays.asList(annotation.value()));
return new TypeExcludeFiltersContextCustomizer(testClass, filterClasses);
}

View File

@@ -38,7 +38,7 @@ class JsonExcludeFilter extends AnnotationCustomizableTypeExcludeFilter {
private static final Set<Class<?>> DEFAULT_INCLUDES;
static {
Set<Class<?>> includes = new LinkedHashSet<Class<?>>();
Set<Class<?>> includes = new LinkedHashSet<>();
includes.add(Module.class);
includes.add(JsonComponent.class);
DEFAULT_INCLUDES = Collections.unmodifiableSet(includes);

View File

@@ -74,7 +74,7 @@ public class JsonTestersAutoConfiguration {
@ConditionalOnBean(ObjectMapper.class)
public FactoryBean<JacksonTester<?>> jacksonTesterFactoryBean(
ObjectMapper mapper) {
return new JsonTesterFactoryBean<JacksonTester<?>, ObjectMapper>(
return new JsonTesterFactoryBean<>(
JacksonTester.class, mapper);
}
@@ -87,7 +87,7 @@ public class JsonTestersAutoConfiguration {
@Scope("prototype")
@ConditionalOnBean(Gson.class)
public FactoryBean<GsonTester<?>> gsonTesterFactoryBean(Gson gson) {
return new JsonTesterFactoryBean<GsonTester<?>, Gson>(GsonTester.class, gson);
return new JsonTesterFactoryBean<>(GsonTester.class, gson);
}
}

View File

@@ -59,7 +59,7 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?>
}
private Map<String, Object> getProperties(Class<?> source) {
Map<String, Object> properties = new LinkedHashMap<String, Object>();
Map<String, Object> properties = new LinkedHashMap<>();
collectProperties(source, source, properties, new HashSet<Class<?>>());
return Collections.unmodifiableMap(properties);
}
@@ -84,7 +84,7 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?>
}
private List<Annotation> getMergedAnnotations(Class<?> root, Class<?> source) {
List<Annotation> mergedAnnotations = new ArrayList<Annotation>();
List<Annotation> mergedAnnotations = new ArrayList<>();
for (Annotation annotation : AnnotationUtils.getAnnotations(source)) {
if (!AnnotationUtils.isInJavaLangAnnotationPackage(annotation)) {
mergedAnnotations

View File

@@ -76,8 +76,8 @@ class PropertyMappingContextCustomizer implements ContextCustomizer {
public Object postProcessBeforeInitialization(Object bean, String beanName)
throws BeansException {
Class<?> beanClass = bean.getClass();
Set<Class<?>> components = new LinkedHashSet<Class<?>>();
Set<Class<?>> propertyMappings = new LinkedHashSet<Class<?>>();
Set<Class<?>> components = new LinkedHashSet<>();
Set<Class<?>> propertyMappings = new LinkedHashSet<>();
while (beanClass != null) {
for (Annotation annotation : AnnotationUtils.getAnnotations(beanClass)) {
if (isAnnotated(annotation, Component.class)) {

View File

@@ -40,7 +40,7 @@ class RestClientExcludeFilter extends AnnotationCustomizableTypeExcludeFilter {
private static final Set<Class<?>> DEFAULT_INCLUDES;
static {
Set<Class<?>> includes = new LinkedHashSet<Class<?>>();
Set<Class<?>> includes = new LinkedHashSet<>();
if (ClassUtils.isPresent("com.fasterxml.jackson.databind.Module",
RestClientExcludeFilter.class.getClassLoader())) {
try {
@@ -91,7 +91,7 @@ class RestClientExcludeFilter extends AnnotationCustomizableTypeExcludeFilter {
@Override
protected Set<Class<?>> getComponentIncludes() {
return new LinkedHashSet<Class<?>>(Arrays.asList(this.annotation.components()));
return new LinkedHashSet<>(Arrays.asList(this.annotation.components()));
}
}

View File

@@ -50,9 +50,9 @@ import org.springframework.test.web.reactive.server.WebTestClient;
* {@link WebTestClient}. For more fine-grained control of WebTestClient the
* {@link AutoConfigureWebTestClient @AutoConfigureWebTestClient} annotation can be used.
* <p>
* Typically {@code @WebFluxTest} is used in combination with {@link MockBean @MockBean} or
* {@link Import @Import} to create any collaborators required by your {@code @Controller}
* beans.
* Typically {@code @WebFluxTest} is used in combination with {@link MockBean @MockBean}
* or {@link Import @Import} to create any collaborators required by your
* {@code @Controller} beans.
* <p>
* If you are looking to load your full application configuration and use WebTestClient,
* you should consider {@link SpringBootTest @SpringBootTest} combined with

View File

@@ -41,7 +41,7 @@ class WebFluxTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter {
private static final Set<Class<?>> DEFAULT_INCLUDES;
static {
Set<Class<?>> includes = new LinkedHashSet<Class<?>>();
Set<Class<?>> includes = new LinkedHashSet<>();
includes.add(ControllerAdvice.class);
includes.add(JsonComponent.class);
includes.add(WebFluxConfigurer.class);
@@ -51,7 +51,7 @@ class WebFluxTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter {
private static final Set<Class<?>> DEFAULT_INCLUDES_AND_CONTROLLER;
static {
Set<Class<?>> includes = new LinkedHashSet<Class<?>>(DEFAULT_INCLUDES);
Set<Class<?>> includes = new LinkedHashSet<>(DEFAULT_INCLUDES);
includes.add(Controller.class);
DEFAULT_INCLUDES_AND_CONTROLLER = Collections.unmodifiableSet(includes);
}
@@ -71,10 +71,10 @@ class WebFluxTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter {
@Override
protected ComponentScan.Filter[] getFilters(FilterType type) {
switch (type) {
case INCLUDE:
return this.annotation.includeFilters();
case EXCLUDE:
return this.annotation.excludeFilters();
case INCLUDE:
return this.annotation.includeFilters();
case EXCLUDE:
return this.annotation.excludeFilters();
}
throw new IllegalStateException("Unsupported type " + type);
}

View File

@@ -28,6 +28,7 @@ import org.springframework.web.reactive.function.client.WebClient;
* Auto-configuration for {@link WebTestClient}.
*
* @author Stephane Nicoll
* @since 2.0.0
*/
@Configuration
@ConditionalOnClass({ WebClient.class, WebTestClient.class })

View File

@@ -192,7 +192,7 @@ public class SpringBootMockMvcBuilderCustomizer implements MockMvcBuilderCustomi
private static class Printer implements ResultValuePrinter {
private final List<String> lines = new ArrayList<String>();
private final List<String> lines = new ArrayList<>();
@Override
public void printHeading(String heading) {
@@ -238,7 +238,7 @@ public class SpringBootMockMvcBuilderCustomizer implements MockMvcBuilderCustomi
private final LinesWriter delegate;
private final List<String> lines = new ArrayList<String>();
private final List<String> lines = new ArrayList<>();
DeferredLinesWriter(WebApplicationContext context, LinesWriter delegate) {
Assert.state(context instanceof ConfigurableApplicationContext,

View File

@@ -50,7 +50,7 @@ class WebDriverScope implements Scope {
private static final String[] BEAN_CLASSES = { WEB_DRIVER_CLASS,
"org.springframework.test.web.servlet.htmlunit.webdriver.MockMvcHtmlUnitDriverBuilder" };
private final Map<String, Object> instances = new HashMap<String, Object>();
private final Map<String, Object> instances = new HashMap<>();
@Override
public Object get(String name, ObjectFactory<?> objectFactory) {

View File

@@ -45,7 +45,7 @@ class WebMvcTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter {
private static final Set<Class<?>> DEFAULT_INCLUDES;
static {
Set<Class<?>> includes = new LinkedHashSet<Class<?>>();
Set<Class<?>> includes = new LinkedHashSet<>();
includes.add(ControllerAdvice.class);
includes.add(JsonComponent.class);
includes.add(WebMvcConfigurer.class);
@@ -60,7 +60,7 @@ class WebMvcTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter {
private static final Set<Class<?>> DEFAULT_INCLUDES_AND_CONTROLLER;
static {
Set<Class<?>> includes = new LinkedHashSet<Class<?>>(DEFAULT_INCLUDES);
Set<Class<?>> includes = new LinkedHashSet<>(DEFAULT_INCLUDES);
includes.add(Controller.class);
DEFAULT_INCLUDES_AND_CONTROLLER = Collections.unmodifiableSet(includes);
}
@@ -103,7 +103,7 @@ class WebMvcTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter {
@Override
protected Set<Class<?>> getComponentIncludes() {
return new LinkedHashSet<Class<?>>(Arrays.asList(this.annotation.controllers()));
return new LinkedHashSet<>(Arrays.asList(this.annotation.controllers()));
}
}

View File

@@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest
public class SpringBootDependencyInjectionTestExecutionListenerPostConstructIntegrationTests {
private List<String> calls = new ArrayList<String>();
private List<String> calls = new ArrayList<>();
@PostConstruct
public void postConstruct() {

View File

@@ -76,7 +76,8 @@ public class TestDatabaseAutoConfigurationTests {
this.context = doLoad(config, environment);
}
private ConfigurableApplicationContext doLoad(Class<?> config, String... environment) {
private ConfigurableApplicationContext doLoad(Class<?> config,
String... environment) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
if (config != null) {
ctx.register(config);

View File

@@ -31,8 +31,8 @@ public class RestDocsTestController {
@ResponseBody
@RequestMapping(path = "/", produces = MediaTypes.HAL_JSON_VALUE)
public Map<String, Object> index() {
Map<String, Object> response = new HashMap<String, Object>();
Map<String, String> links = new HashMap<String, String>();
Map<String, Object> response = new HashMap<>();
Map<String, String> links = new HashMap<>();
links.put("self", ControllerLinkBuilder.linkTo(getClass()).toUri().toString());
response.put("_links", links);
return response;

View File

@@ -25,4 +25,5 @@ import org.springframework.stereotype.Service;
*/
@Service
public class ExampleRealService {
}

View File

@@ -25,4 +25,5 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
*/
@SpringBootApplication
public class ExampleWebFluxApplication {
}

View File

@@ -37,19 +37,13 @@ public class WebFluxTestAllControllersIntegrationTests {
@Test
public void shouldFindController1() {
this.webClient
.get().uri("/one")
.exchange()
.expectStatus().isOk()
this.webClient.get().uri("/one").exchange().expectStatus().isOk()
.expectBody(String.class).value().isEqualTo("one");
}
@Test
public void shouldFindController2() {
this.webClient
.get().uri("/two")
.exchange()
.expectStatus().isOk()
this.webClient.get().uri("/two").exchange().expectStatus().isOk()
.expectBody(String.class).value().isEqualTo("two");
}

View File

@@ -51,4 +51,5 @@ public class WebFluxTestAutoConfigurationIntegrationTests {
assertThat(this.applicationContext)
.has(importedAutoConfiguration(ValidationAutoConfiguration.class));
}
}

View File

@@ -37,19 +37,13 @@ public class WebFluxTestOneControllerIntegrationTests {
@Test
public void shouldFindController() {
this.webClient
.get().uri("/one")
.exchange()
.expectStatus().isOk()
this.webClient.get().uri("/one").exchange().expectStatus().isOk()
.expectBody(String.class).value().isEqualTo("one");
}
@Test
public void shouldNotScanOtherController() {
this.webClient
.get().uri("/two")
.exchange()
.expectStatus().isNotFound();
this.webClient.get().uri("/two").exchange().expectStatus().isNotFound();
}
}

View File

@@ -46,19 +46,13 @@ public class WebTestClientSpringBootTestIntegrationTests {
@Test
public void shouldFindController1() {
this.webClient
.get().uri("/one")
.exchange()
.expectStatus().isOk()
this.webClient.get().uri("/one").exchange().expectStatus().isOk()
.expectBody(String.class).value().isEqualTo("one");
}
@Test
public void shouldFindController2() {
this.webClient
.get().uri("/two")
.exchange()
.expectStatus().isOk()
this.webClient.get().uri("/two").exchange().expectStatus().isOk()
.expectBody(String.class).value().isEqualTo("two");
}

View File

@@ -35,13 +35,13 @@ class HateoasController {
@RequestMapping("/resource")
public Resource<Map<String, String>> resource() {
return new Resource<Map<String, String>>(new HashMap<String, String>(),
return new Resource<>(new HashMap<String, String>(),
new Link("self", "http://api.example.com"));
}
@RequestMapping("/plain")
public Map<String, String> plain() {
return new HashMap<String, String>();
return new HashMap<>();
}
}