Cleanup and format code
This commit is contained in:
@@ -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