Cleanup and format code
This commit is contained in:
@@ -231,7 +231,7 @@ class ImportsContextCustomizer implements ContextCustomizer {
|
||||
private static final Set<AnnotationFilter> ANNOTATION_FILTERS;
|
||||
|
||||
static {
|
||||
Set<AnnotationFilter> filters = new HashSet<AnnotationFilter>();
|
||||
Set<AnnotationFilter> filters = new HashSet<>();
|
||||
filters.add(new JavaLangAnnotationFilter());
|
||||
filters.add(new KotlinAnnotationFilter());
|
||||
filters.add(new SpockAnnotationFilter());
|
||||
@@ -241,8 +241,8 @@ class ImportsContextCustomizer implements ContextCustomizer {
|
||||
private final Set<Object> key;
|
||||
|
||||
ContextCustomizerKey(Class<?> testClass) {
|
||||
Set<Annotation> annotations = new HashSet<Annotation>();
|
||||
Set<Class<?>> seen = new HashSet<Class<?>>();
|
||||
Set<Annotation> annotations = new HashSet<>();
|
||||
Set<Class<?>> seen = new HashSet<>();
|
||||
collectClassAnnotations(testClass, annotations, seen);
|
||||
Set<Object> determinedImports = determineImports(annotations, testClass);
|
||||
this.key = Collections.<Object>unmodifiableSet(
|
||||
@@ -284,7 +284,7 @@ class ImportsContextCustomizer implements ContextCustomizer {
|
||||
|
||||
private Set<Object> determineImports(Set<Annotation> annotations,
|
||||
Class<?> testClass) {
|
||||
Set<Object> determinedImports = new LinkedHashSet<Object>();
|
||||
Set<Object> determinedImports = new LinkedHashSet<>();
|
||||
AnnotationMetadata testClassMetadata = new StandardAnnotationMetadata(
|
||||
testClass);
|
||||
for (Annotation annotation : annotations) {
|
||||
|
||||
@@ -83,7 +83,7 @@ public class SpringBootContextLoader extends AbstractContextLoader {
|
||||
private static final Set<String> INTEGRATION_TEST_ANNOTATIONS;
|
||||
|
||||
static {
|
||||
Set<String> annotations = new LinkedHashSet<String>();
|
||||
Set<String> annotations = new LinkedHashSet<>();
|
||||
annotations.add("org.springframework.boot.test.IntegrationTest");
|
||||
annotations.add("org.springframework.boot.test.WebIntegrationTest");
|
||||
INTEGRATION_TEST_ANNOTATIONS = Collections.unmodifiableSet(annotations);
|
||||
@@ -139,7 +139,7 @@ public class SpringBootContextLoader extends AbstractContextLoader {
|
||||
}
|
||||
|
||||
private Set<Object> getSources(MergedContextConfiguration mergedConfig) {
|
||||
Set<Object> sources = new LinkedHashSet<Object>();
|
||||
Set<Object> sources = new LinkedHashSet<>();
|
||||
sources.addAll(Arrays.asList(mergedConfig.getClasses()));
|
||||
sources.addAll(Arrays.asList(mergedConfig.getLocations()));
|
||||
Assert.state(!sources.isEmpty(), "No configuration classes "
|
||||
@@ -156,7 +156,7 @@ public class SpringBootContextLoader extends AbstractContextLoader {
|
||||
}
|
||||
|
||||
protected String[] getInlinedProperties(MergedContextConfiguration config) {
|
||||
ArrayList<String> properties = new ArrayList<String>();
|
||||
ArrayList<String> properties = new ArrayList<>();
|
||||
// JMX bean names will clash if the same bean is used in multiple contexts
|
||||
disableJmx(properties);
|
||||
properties.addAll(Arrays.asList(config.getPropertySourceProperties()));
|
||||
@@ -188,7 +188,7 @@ public class SpringBootContextLoader extends AbstractContextLoader {
|
||||
|
||||
private List<ApplicationContextInitializer<?>> getInitializers(
|
||||
MergedContextConfiguration config, SpringApplication application) {
|
||||
List<ApplicationContextInitializer<?>> initializers = new ArrayList<ApplicationContextInitializer<?>>();
|
||||
List<ApplicationContextInitializer<?>> initializers = new ArrayList<>();
|
||||
for (ContextCustomizer contextCustomizer : config.getContextCustomizers()) {
|
||||
initializers.add(new ContextCustomizerAdapter(contextCustomizer, config));
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
|
||||
|
||||
private void addConfigAttributesClasses(
|
||||
ContextConfigurationAttributes configAttributes, Class<?>[] classes) {
|
||||
List<Class<?>> combined = new ArrayList<Class<?>>();
|
||||
List<Class<?>> combined = new ArrayList<>();
|
||||
combined.addAll(Arrays.asList(classes));
|
||||
if (configAttributes.getClasses() != null) {
|
||||
combined.addAll(Arrays.asList(configAttributes.getClasses()));
|
||||
@@ -253,7 +253,7 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
|
||||
|
||||
private List<String> getAndProcessPropertySourceProperties(
|
||||
MergedContextConfiguration mergedConfig) {
|
||||
List<String> propertySourceProperties = new ArrayList<String>(
|
||||
List<String> propertySourceProperties = new ArrayList<>(
|
||||
Arrays.asList(mergedConfig.getPropertySourceProperties()));
|
||||
String differentiator = getDifferentiatorPropertySourceProperty();
|
||||
if (differentiator != null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -123,7 +123,7 @@ public abstract class AbstractJsonMarshalTester<T> {
|
||||
verify();
|
||||
Assert.notNull(value, "Value must not be null");
|
||||
String json = writeObject(value, this.type);
|
||||
return new JsonContent<T>(this.resourceLoadClass, this.type, json);
|
||||
return new JsonContent<>(this.resourceLoadClass, this.type, json);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -266,7 +266,7 @@ public abstract class AbstractJsonMarshalTester<T> {
|
||||
InputStream inputStream = resource.getInputStream();
|
||||
T object = readObject(inputStream, this.type);
|
||||
closeQuietly(inputStream);
|
||||
return new ObjectContent<T>(this.type, object);
|
||||
return new ObjectContent<>(this.type, object);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -291,7 +291,7 @@ public abstract class AbstractJsonMarshalTester<T> {
|
||||
Assert.notNull(reader, "Reader must not be null");
|
||||
T object = readObject(reader, this.type);
|
||||
closeQuietly(reader);
|
||||
return new ObjectContent<T>(this.type, object);
|
||||
return new ObjectContent<>(this.type, object);
|
||||
}
|
||||
|
||||
private void closeQuietly(Closeable closeable) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -169,7 +169,7 @@ public class BasicJsonTester {
|
||||
}
|
||||
|
||||
private JsonContent<Object> getJsonContent(String json) {
|
||||
return new JsonContent<Object>(this.loader.getResourceLoadClass(), null, json);
|
||||
return new JsonContent<>(this.loader.getResourceLoadClass(), null, json);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -121,7 +121,7 @@ public class GsonTester<T> extends AbstractJsonMarshalTester<T> {
|
||||
@Override
|
||||
protected AbstractJsonMarshalTester<Object> createTester(
|
||||
Class<?> resourceLoadClass, ResolvableType type, Gson marshaller) {
|
||||
return new GsonTester<Object>(resourceLoadClass, type, marshaller);
|
||||
return new GsonTester<>(resourceLoadClass, type, marshaller);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -137,7 +137,7 @@ public class JacksonTester<T> extends AbstractJsonMarshalTester<T> {
|
||||
protected AbstractJsonMarshalTester<Object> createTester(
|
||||
Class<?> resourceLoadClass, ResolvableType type,
|
||||
ObjectMapper marshaller) {
|
||||
return new JacksonTester<Object>(resourceLoadClass, type, marshaller);
|
||||
return new JacksonTester<>(resourceLoadClass, type, marshaller);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -49,7 +49,7 @@ public final class ObjectContent<T> implements AssertProvider<ObjectContentAsser
|
||||
|
||||
@Override
|
||||
public ObjectContentAssert<T> assertThat() {
|
||||
return new ObjectContentAssert<T>(this.object);
|
||||
return new ObjectContentAssert<>(this.object);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -51,8 +51,8 @@ class DefinitionsParser {
|
||||
}
|
||||
|
||||
DefinitionsParser(Collection<? extends Definition> existing) {
|
||||
this.definitions = new LinkedHashSet<Definition>();
|
||||
this.definitionFields = new LinkedHashMap<Definition, Field>();
|
||||
this.definitions = new LinkedHashSet<>();
|
||||
this.definitionFields = new LinkedHashMap<>();
|
||||
if (existing != null) {
|
||||
this.definitions.addAll(existing);
|
||||
}
|
||||
@@ -127,7 +127,7 @@ class DefinitionsParser {
|
||||
|
||||
private Set<ResolvableType> getOrDeduceTypes(AnnotatedElement element,
|
||||
Class<?>[] value) {
|
||||
Set<ResolvableType> types = new LinkedHashSet<ResolvableType>();
|
||||
Set<ResolvableType> types = new LinkedHashSet<>();
|
||||
for (Class<?> clazz : value) {
|
||||
types.add(ResolvableType.forClass(clazz));
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class MockDefinition extends Definition {
|
||||
}
|
||||
|
||||
private Set<Class<?>> asClassSet(Class<?>[] classes) {
|
||||
Set<Class<?>> classSet = new LinkedHashSet<Class<?>>();
|
||||
Set<Class<?>> classSet = new LinkedHashSet<>();
|
||||
if (classes != null) {
|
||||
classSet.addAll(Arrays.asList(classes));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -27,7 +27,7 @@ import java.util.List;
|
||||
*/
|
||||
class MockitoBeans implements Iterable<Object> {
|
||||
|
||||
private final List<Object> beans = new ArrayList<Object>();
|
||||
private final List<Object> beans = new ArrayList<>();
|
||||
|
||||
void add(Object bean) {
|
||||
this.beans.add(bean);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -34,7 +34,7 @@ class MockitoContextCustomizer implements ContextCustomizer {
|
||||
private final Set<Definition> definitions;
|
||||
|
||||
MockitoContextCustomizer(Set<? extends Definition> definitions) {
|
||||
this.definitions = new LinkedHashSet<Definition>(definitions);
|
||||
this.definitions = new LinkedHashSet<>(definitions);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -98,11 +98,11 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda
|
||||
|
||||
private final MockitoBeans mockitoBeans = new MockitoBeans();
|
||||
|
||||
private Map<Definition, String> beanNameRegistry = new HashMap<Definition, String>();
|
||||
private Map<Definition, String> beanNameRegistry = new HashMap<>();
|
||||
|
||||
private Map<Field, RegisteredField> fieldRegistry = new HashMap<Field, RegisteredField>();
|
||||
private Map<Field, RegisteredField> fieldRegistry = new HashMap<>();
|
||||
|
||||
private Map<String, SpyDefinition> spies = new HashMap<String, SpyDefinition>();
|
||||
private Map<String, SpyDefinition> spies = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Create a new {@link MockitoPostProcessor} instance with the given initial
|
||||
@@ -150,7 +150,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda
|
||||
|
||||
private Set<Class<?>> getConfigurationClasses(
|
||||
ConfigurableListableBeanFactory beanFactory) {
|
||||
Set<Class<?>> configurationClasses = new LinkedHashSet<Class<?>>();
|
||||
Set<Class<?>> configurationClasses = new LinkedHashSet<>();
|
||||
for (BeanDefinition beanDefinition : getConfigurationBeanDefinitions(beanFactory)
|
||||
.values()) {
|
||||
configurationClasses.add(ClassUtils.resolveClassName(
|
||||
@@ -161,7 +161,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda
|
||||
|
||||
private Map<String, BeanDefinition> getConfigurationBeanDefinitions(
|
||||
ConfigurableListableBeanFactory beanFactory) {
|
||||
Map<String, BeanDefinition> definitions = new LinkedHashMap<String, BeanDefinition>();
|
||||
Map<String, BeanDefinition> definitions = new LinkedHashMap<>();
|
||||
for (String beanName : beanFactory.getBeanDefinitionNames()) {
|
||||
BeanDefinition definition = beanFactory.getBeanDefinition(beanName);
|
||||
if (definition.getAttribute(CONFIGURATION_CLASS_ATTRIBUTE) != null) {
|
||||
@@ -258,7 +258,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda
|
||||
private Set<String> findCandidateBeans(ConfigurableListableBeanFactory beanFactory,
|
||||
MockDefinition mockDefinition) {
|
||||
QualifierDefinition qualifier = mockDefinition.getQualifier();
|
||||
Set<String> candidates = new TreeSet<String>();
|
||||
Set<String> candidates = new TreeSet<>();
|
||||
for (String candidate : getExistingBeans(beanFactory,
|
||||
mockDefinition.getTypeToMock())) {
|
||||
if (qualifier == null || qualifier.matches(beanFactory, candidate)) {
|
||||
@@ -270,7 +270,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda
|
||||
|
||||
private String[] getExistingBeans(ConfigurableListableBeanFactory beanFactory,
|
||||
ResolvableType type) {
|
||||
Set<String> beans = new LinkedHashSet<String>(
|
||||
Set<String> beans = new LinkedHashSet<>(
|
||||
Arrays.asList(beanFactory.getBeanNamesForType(type)));
|
||||
String resolvedTypeName = type.resolve(Object.class).getName();
|
||||
for (String beanName : beanFactory.getBeanNamesForType(FactoryBean.class)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -80,7 +80,7 @@ public class MockitoTestExecutionListener extends AbstractTestExecutionListener
|
||||
*/
|
||||
private static class MockitoAnnotationCollection implements FieldCallback {
|
||||
|
||||
private final Set<Annotation> annotations = new LinkedHashSet<Annotation>();
|
||||
private final Set<Annotation> annotations = new LinkedHashSet<>();
|
||||
|
||||
@Override
|
||||
public void doWith(Field field)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -91,7 +91,7 @@ class QualifierDefinition {
|
||||
private static Set<Annotation> getQualifierAnnotations(Field field) {
|
||||
// Assume that any annotations other than @MockBean/@SpyBean are qualifiers
|
||||
Annotation[] candidates = field.getDeclaredAnnotations();
|
||||
Set<Annotation> annotations = new HashSet<Annotation>(candidates.length);
|
||||
Set<Annotation> annotations = new HashSet<>(candidates.length);
|
||||
for (Annotation candidate : candidates) {
|
||||
if (!isMockOrSpyAnnotation(candidate)) {
|
||||
annotations.add(candidate);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -60,7 +60,7 @@ public class ResetMocksTestExecutionListener extends AbstractTestExecutionListen
|
||||
MockReset reset) {
|
||||
ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();
|
||||
String[] names = beanFactory.getBeanDefinitionNames();
|
||||
Set<String> instantiatedSingletons = new HashSet<String>(
|
||||
Set<String> instantiatedSingletons = new HashSet<>(
|
||||
Arrays.asList(beanFactory.getSingletonNames()));
|
||||
for (String name : names) {
|
||||
BeanDefinition definition = beanFactory.getBeanDefinition(name);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -49,7 +49,7 @@ public class OutputCapture implements TestRule {
|
||||
|
||||
private ByteArrayOutputStream copy;
|
||||
|
||||
private List<Matcher<? super String>> matchers = new ArrayList<Matcher<? super String>>();
|
||||
private List<Matcher<? super String>> matchers = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public Statement apply(final Statement base, Description description) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -83,7 +83,7 @@ public abstract class EnvironmentTestUtils {
|
||||
if (sources.contains(name)) {
|
||||
return (Map<String, Object>) sources.get(name).getSource();
|
||||
}
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
sources.addFirst(new MapPropertySource(name, map));
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -53,9 +53,9 @@ import org.springframework.web.client.RestTemplate;
|
||||
*/
|
||||
public class MockServerRestTemplateCustomizer implements RestTemplateCustomizer {
|
||||
|
||||
private Map<RestTemplate, RequestExpectationManager> expectationManagers = new ConcurrentHashMap<RestTemplate, RequestExpectationManager>();
|
||||
private Map<RestTemplate, RequestExpectationManager> expectationManagers = new ConcurrentHashMap<>();
|
||||
|
||||
private Map<RestTemplate, MockRestServiceServer> servers = new ConcurrentHashMap<RestTemplate, MockRestServiceServer>();
|
||||
private Map<RestTemplate, MockRestServiceServer> servers = new ConcurrentHashMap<>();
|
||||
|
||||
private final Class<? extends RequestExpectationManager> expectationManager;
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ public class TestRestTemplate {
|
||||
if (interceptors == null) {
|
||||
interceptors = Collections.emptyList();
|
||||
}
|
||||
interceptors = new ArrayList<ClientHttpRequestInterceptor>(interceptors);
|
||||
interceptors = new ArrayList<>(interceptors);
|
||||
Iterator<ClientHttpRequestInterceptor> iterator = interceptors.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (iterator.next() instanceof BasicAuthorizationInterceptor) {
|
||||
@@ -1063,7 +1063,7 @@ public class TestRestTemplate {
|
||||
|
||||
public CustomHttpComponentsClientHttpRequestFactory(
|
||||
HttpClientOption[] httpClientOptions) {
|
||||
Set<HttpClientOption> options = new HashSet<TestRestTemplate.HttpClientOption>(
|
||||
Set<HttpClientOption> options = new HashSet<>(
|
||||
Arrays.asList(httpClientOptions));
|
||||
this.cookieSpec = (options.contains(HttpClientOption.ENABLE_COOKIES)
|
||||
? CookieSpecs.STANDARD : CookieSpecs.IGNORE_COOKIES);
|
||||
|
||||
@@ -26,8 +26,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.reactive.config.EnableWebFlux;
|
||||
|
||||
/**
|
||||
* Tests for {@link SpringBootTest} in a reactive environment configured
|
||||
* with {@link WebEnvironment#DEFINED_PORT}.
|
||||
* Tests for {@link SpringBootTest} in a reactive environment configured with
|
||||
* {@link WebEnvironment#DEFINED_PORT}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
|
||||
@@ -26,8 +26,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.reactive.config.EnableWebFlux;
|
||||
|
||||
/**
|
||||
* Tests for {@link SpringBootTest} in a reactive environment configured
|
||||
* with {@link WebEnvironment#RANDOM_PORT}.
|
||||
* Tests for {@link SpringBootTest} in a reactive environment configured with
|
||||
* {@link WebEnvironment#RANDOM_PORT}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -89,7 +89,7 @@ public abstract class AbstractJsonMarshalTesterTests {
|
||||
@Test
|
||||
public void writeMapShouldReturnJsonContent() throws Exception {
|
||||
ResolvableType type = ResolvableTypes.get("mapOfExampleObject");
|
||||
Map<String, Object> value = new LinkedHashMap<String, Object>();
|
||||
Map<String, Object> value = new LinkedHashMap<>();
|
||||
value.put("a", OBJECT);
|
||||
JsonContent<Object> content = createTester(type).write(value);
|
||||
assertThat(content).isEqualToJson(MAP_JSON);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -62,15 +62,14 @@ public class GsonTesterTests extends AbstractJsonMarshalTesterTests {
|
||||
@Override
|
||||
protected AbstractJsonMarshalTester<Object> createTester(Class<?> resourceLoadClass,
|
||||
ResolvableType type) {
|
||||
return new GsonTester<Object>(resourceLoadClass, type,
|
||||
new GsonBuilder().create());
|
||||
return new GsonTester<>(resourceLoadClass, type, new GsonBuilder().create());
|
||||
}
|
||||
|
||||
static abstract class InitFieldsBaseClass {
|
||||
|
||||
public GsonTester<ExampleObject> base;
|
||||
|
||||
public GsonTester<ExampleObject> baseSet = new GsonTester<ExampleObject>(
|
||||
public GsonTester<ExampleObject> baseSet = new GsonTester<>(
|
||||
InitFieldsBaseClass.class, ResolvableType.forClass(ExampleObject.class),
|
||||
new GsonBuilder().create());
|
||||
|
||||
@@ -80,7 +79,7 @@ public class GsonTesterTests extends AbstractJsonMarshalTesterTests {
|
||||
|
||||
public GsonTester<List<ExampleObject>> test;
|
||||
|
||||
public GsonTester<ExampleObject> testSet = new GsonTester<ExampleObject>(
|
||||
public GsonTester<ExampleObject> testSet = new GsonTester<>(
|
||||
InitFieldsBaseClass.class, ResolvableType.forClass(ExampleObject.class),
|
||||
new GsonBuilder().create());
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -52,7 +52,7 @@ public class JacksonTesterIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void typicalMapTest() throws Exception {
|
||||
Map<String, Integer> map = new LinkedHashMap<String, Integer>();
|
||||
Map<String, Integer> map = new LinkedHashMap<>();
|
||||
map.put("a", 1);
|
||||
map.put("b", 2);
|
||||
assertThat(this.mapJson.write(map)).extractingJsonPathNumberValue("@.a")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -61,14 +61,14 @@ public class JacksonTesterTests extends AbstractJsonMarshalTesterTests {
|
||||
@Override
|
||||
protected AbstractJsonMarshalTester<Object> createTester(Class<?> resourceLoadClass,
|
||||
ResolvableType type) {
|
||||
return new JacksonTester<Object>(resourceLoadClass, type, new ObjectMapper());
|
||||
return new JacksonTester<>(resourceLoadClass, type, new ObjectMapper());
|
||||
}
|
||||
|
||||
static abstract class InitFieldsBaseClass {
|
||||
|
||||
public JacksonTester<ExampleObject> base;
|
||||
|
||||
public JacksonTester<ExampleObject> baseSet = new JacksonTester<ExampleObject>(
|
||||
public JacksonTester<ExampleObject> baseSet = new JacksonTester<>(
|
||||
InitFieldsBaseClass.class, ResolvableType.forClass(ExampleObject.class),
|
||||
new ObjectMapper());
|
||||
|
||||
@@ -78,7 +78,7 @@ public class JacksonTesterTests extends AbstractJsonMarshalTesterTests {
|
||||
|
||||
public JacksonTester<List<ExampleObject>> test;
|
||||
|
||||
public JacksonTester<ExampleObject> testSet = new JacksonTester<ExampleObject>(
|
||||
public JacksonTester<ExampleObject> testSet = new JacksonTester<>(
|
||||
InitFieldsBaseClass.class, ResolvableType.forClass(ExampleObject.class),
|
||||
new ObjectMapper());
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -55,38 +55,33 @@ public class JsonContentTests {
|
||||
|
||||
@Test
|
||||
public void createWhenTypeIsNullShouldCreateContent() throws Exception {
|
||||
JsonContent<ExampleObject> content = new JsonContent<ExampleObject>(getClass(),
|
||||
null, JSON);
|
||||
JsonContent<ExampleObject> content = new JsonContent<>(getClass(), null, JSON);
|
||||
assertThat(content).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void assertThatShouldReturnJsonContentAssert() throws Exception {
|
||||
JsonContent<ExampleObject> content = new JsonContent<ExampleObject>(getClass(),
|
||||
TYPE, JSON);
|
||||
JsonContent<ExampleObject> content = new JsonContent<>(getClass(), TYPE, JSON);
|
||||
assertThat(content.assertThat()).isInstanceOf(JsonContentAssert.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getJsonShouldReturnJson() throws Exception {
|
||||
JsonContent<ExampleObject> content = new JsonContent<ExampleObject>(getClass(),
|
||||
TYPE, JSON);
|
||||
JsonContent<ExampleObject> content = new JsonContent<>(getClass(), TYPE, JSON);
|
||||
assertThat(content.getJson()).isEqualTo(JSON);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toStringWhenHasTypeShouldReturnString() throws Exception {
|
||||
JsonContent<ExampleObject> content = new JsonContent<ExampleObject>(getClass(),
|
||||
TYPE, JSON);
|
||||
JsonContent<ExampleObject> content = new JsonContent<>(getClass(), TYPE, JSON);
|
||||
assertThat(content.toString())
|
||||
.isEqualTo("JsonContent " + JSON + " created from " + TYPE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toStringWhenHasNoTypeShouldReturnString() throws Exception {
|
||||
JsonContent<ExampleObject> content = new JsonContent<ExampleObject>(getClass(),
|
||||
null, JSON);
|
||||
JsonContent<ExampleObject> content = new JsonContent<>(getClass(), null, JSON);
|
||||
assertThat(content.toString()).isEqualTo("JsonContent " + JSON);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -77,7 +77,7 @@ public class ObjectContentAssertTests {
|
||||
|
||||
@Override
|
||||
public ObjectContentAssert<Object> assertThat() {
|
||||
return new ObjectContentAssert<Object>(source);
|
||||
return new ObjectContentAssert<>(source);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -48,37 +48,32 @@ public class ObjectContentTests {
|
||||
|
||||
@Test
|
||||
public void createWhenTypeIsNullShouldCreateContent() throws Exception {
|
||||
ObjectContent<ExampleObject> content = new ObjectContent<ExampleObject>(null,
|
||||
OBJECT);
|
||||
ObjectContent<ExampleObject> content = new ObjectContent<>(null, OBJECT);
|
||||
assertThat(content).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void assertThatShouldReturnObjectContentAssert() throws Exception {
|
||||
ObjectContent<ExampleObject> content = new ObjectContent<ExampleObject>(TYPE,
|
||||
OBJECT);
|
||||
ObjectContent<ExampleObject> content = new ObjectContent<>(TYPE, OBJECT);
|
||||
assertThat(content.assertThat()).isInstanceOf(ObjectContentAssert.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getObjectShouldReturnObject() throws Exception {
|
||||
ObjectContent<ExampleObject> content = new ObjectContent<ExampleObject>(TYPE,
|
||||
OBJECT);
|
||||
ObjectContent<ExampleObject> content = new ObjectContent<>(TYPE, OBJECT);
|
||||
assertThat(content.getObject()).isEqualTo(OBJECT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toStringWhenHasTypeShouldReturnString() throws Exception {
|
||||
ObjectContent<ExampleObject> content = new ObjectContent<ExampleObject>(TYPE,
|
||||
OBJECT);
|
||||
ObjectContent<ExampleObject> content = new ObjectContent<>(TYPE, OBJECT);
|
||||
assertThat(content.toString())
|
||||
.isEqualTo("ObjectContent " + OBJECT + " created from " + TYPE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toStringWhenHasNoTypeShouldReturnString() throws Exception {
|
||||
ObjectContent<ExampleObject> content = new ObjectContent<ExampleObject>(null,
|
||||
OBJECT);
|
||||
ObjectContent<ExampleObject> content = new ObjectContent<>(null, OBJECT);
|
||||
assertThat(content.toString()).isEqualTo("ObjectContent " + OBJECT);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -215,7 +215,7 @@ public class DefinitionsParserTests {
|
||||
}
|
||||
|
||||
private List<Definition> getDefinitions() {
|
||||
return new ArrayList<Definition>(this.parser.getDefinitions());
|
||||
return new ArrayList<>(this.parser.getDefinitions());
|
||||
}
|
||||
|
||||
@MockBean(ExampleService.class)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -44,9 +44,9 @@ public class MockitoContextCustomizerTests {
|
||||
MockDefinition d2 = createTestMockDefinition(ExampleServiceCaller.class);
|
||||
MockitoContextCustomizer c1 = new MockitoContextCustomizer(NO_DEFINITIONS);
|
||||
MockitoContextCustomizer c2 = new MockitoContextCustomizer(
|
||||
new LinkedHashSet<MockDefinition>(Arrays.asList(d1, d2)));
|
||||
new LinkedHashSet<>(Arrays.asList(d1, d2)));
|
||||
MockitoContextCustomizer c3 = new MockitoContextCustomizer(
|
||||
new LinkedHashSet<MockDefinition>(Arrays.asList(d2, d1)));
|
||||
new LinkedHashSet<>(Arrays.asList(d2, d1)));
|
||||
assertThat(c2.hashCode()).isEqualTo(c3.hashCode());
|
||||
assertThat(c1).isEqualTo(c1).isNotEqualTo(c2);
|
||||
assertThat(c2).isEqualTo(c2).isEqualTo(c3).isNotEqualTo(c1);
|
||||
|
||||
@@ -48,7 +48,7 @@ public abstract class AbstractConfigurationClassTests {
|
||||
|
||||
@Test
|
||||
public void allBeanMethodsArePublic() throws IOException, ClassNotFoundException {
|
||||
Set<String> nonPublicBeanMethods = new HashSet<String>();
|
||||
Set<String> nonPublicBeanMethods = new HashSet<>();
|
||||
for (AnnotationMetadata configurationClass : findConfigurationClasses()) {
|
||||
Set<MethodMetadata> beanMethods = configurationClass
|
||||
.getAnnotatedMethods(Bean.class.getName());
|
||||
@@ -63,7 +63,7 @@ public abstract class AbstractConfigurationClassTests {
|
||||
}
|
||||
|
||||
private Set<AnnotationMetadata> findConfigurationClasses() throws IOException {
|
||||
Set<AnnotationMetadata> configurationClasses = new HashSet<AnnotationMetadata>();
|
||||
Set<AnnotationMetadata> configurationClasses = new HashSet<>();
|
||||
Resource[] resources = this.resolver.getResources("classpath*:"
|
||||
+ getClass().getPackage().getName().replace('.', '/') + "/**/*.class");
|
||||
for (Resource resource : resources) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -83,7 +83,7 @@ public class EnvironmentTestUtilsTests {
|
||||
|
||||
@Test
|
||||
public void testConfigHasHigherPrecedence() {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("my.foo", "bar");
|
||||
MapPropertySource source = new MapPropertySource("sample", map);
|
||||
this.environment.getPropertySources().addFirst(source);
|
||||
|
||||
@@ -269,7 +269,7 @@ public class TestRestTemplateTests {
|
||||
public void doWithTestRestTemplate(TestRestTemplate testRestTemplate,
|
||||
URI relativeUri) {
|
||||
testRestTemplate.exchange(relativeUri, HttpMethod.GET,
|
||||
new HttpEntity<byte[]>(new byte[0]), String.class);
|
||||
new HttpEntity<>(new byte[0]), String.class);
|
||||
}
|
||||
|
||||
});
|
||||
@@ -284,7 +284,7 @@ public class TestRestTemplateTests {
|
||||
public void doWithTestRestTemplate(TestRestTemplate testRestTemplate,
|
||||
URI relativeUri) {
|
||||
testRestTemplate.exchange(relativeUri, HttpMethod.GET,
|
||||
new HttpEntity<byte[]>(new byte[0]),
|
||||
new HttpEntity<>(new byte[0]),
|
||||
new ParameterizedTypeReference<String>() {
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user