Merge pull request #18438 from 785172550

* pr/18438:
  Polish 'Simplify some code'
  Simplify some code

Closes gh-18438
This commit is contained in:
Phillip Webb
2019-10-01 22:10:47 -07:00
11 changed files with 13 additions and 28 deletions

View File

@@ -56,7 +56,7 @@ class OverrideAutoConfigurationContextCustomizerFactory implements ContextCustom
@Override
public boolean equals(Object obj) {
return (obj != null && obj.getClass() == getClass());
return (obj != null) && (obj.getClass() == getClass());
}
@Override

View File

@@ -71,8 +71,8 @@ class TypeExcludeFiltersContextCustomizer implements ContextCustomizer {
@Override
public boolean equals(Object obj) {
return (obj != null && getClass() == obj.getClass()
&& this.filters.equals(((TypeExcludeFiltersContextCustomizer) obj).filters));
return (obj != null) && (getClass() == obj.getClass())
&& this.filters.equals(((TypeExcludeFiltersContextCustomizer) obj).filters);
}
@Override

View File

@@ -57,8 +57,8 @@ class PropertyMappingContextCustomizer implements ContextCustomizer {
@Override
public boolean equals(Object obj) {
return (obj != null && getClass() == obj.getClass()
&& this.propertySource.equals(((PropertyMappingContextCustomizer) obj).propertySource));
return (obj != null) && (getClass() == obj.getClass())
&& this.propertySource.equals(((PropertyMappingContextCustomizer) obj).propertySource);
}
@Override

View File

@@ -132,8 +132,7 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
}
private void addConfigAttributesClasses(ContextConfigurationAttributes configAttributes, Class<?>[] classes) {
List<Class<?>> combined = new ArrayList<>();
combined.addAll(Arrays.asList(classes));
List<Class<?>> combined = new ArrayList<>(Arrays.asList(classes));
if (configAttributes.getClasses() != null) {
combined.addAll(Arrays.asList(configAttributes.getClasses()));
}

View File

@@ -37,13 +37,7 @@ class ExcludeFilterContextCustomizer implements ContextCustomizer {
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
return true;
return (obj != null) && (getClass() == obj.getClass());
}
@Override

View File

@@ -80,10 +80,7 @@ class DuplicateJsonObjectContextCustomizerFactory implements ContextCustomizerFa
@Override
public boolean equals(Object obj) {
if (obj == null || obj.getClass() != getClass()) {
return false;
}
return true;
return (obj != null) && (getClass() == obj.getClass());
}
@Override

View File

@@ -209,7 +209,7 @@ class OutputCapture implements CapturedOutput {
private static PrintStream getSystemStream(PrintStream printStream) {
while (printStream instanceof PrintStreamCapture) {
return ((PrintStreamCapture) printStream).getParent();
printStream = ((PrintStreamCapture) printStream).getParent();
}
return printStream;
}

View File

@@ -78,10 +78,7 @@ class TestRestTemplateContextCustomizer implements ContextCustomizer {
@Override
public boolean equals(Object obj) {
if (obj == null || obj.getClass() != getClass()) {
return false;
}
return true;
return (obj != null) && (obj.getClass() == getClass());
}
@Override

View File

@@ -17,7 +17,6 @@
package org.springframework.boot.test.web.htmlunit;
import java.io.IOException;
import java.net.MalformedURLException;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.Page;
@@ -43,8 +42,7 @@ public class LocalHostWebClient extends WebClient {
}
@Override
public <P extends Page> P getPage(String url)
throws IOException, FailingHttpStatusCodeException, MalformedURLException {
public <P extends Page> P getPage(String url) throws IOException, FailingHttpStatusCodeException {
if (url.startsWith("/")) {
String port = this.environment.getProperty("local.server.port", "8080");
url = "http://localhost:" + port + url;

View File

@@ -79,7 +79,7 @@ class WebTestClientContextCustomizer implements ContextCustomizer {
@Override
public boolean equals(Object obj) {
return (obj != null && obj.getClass() == getClass());
return (obj != null) && (obj.getClass() == getClass());
}
@Override

View File

@@ -92,7 +92,7 @@ class MockitoTestExecutionListenerTests {
given(mockTestContext.getAttribute(DependencyInjectionTestExecutionListener.REINJECT_DEPENDENCIES_ATTRIBUTE))
.willReturn(Boolean.TRUE);
this.listener.beforeTestMethod(mockTestContext);
verify(this.postProcessor).inject(this.fieldCaptor.capture(), eq(instance), (MockDefinition) any());
verify(this.postProcessor).inject(this.fieldCaptor.capture(), eq(instance), any(MockDefinition.class));
assertThat(this.fieldCaptor.getValue().getName()).isEqualTo("mockBean");
}