Simplify some code

See gh-18438
This commit is contained in:
kenneth 2019-09-30 14:54:18 +08:00 committed by Phillip Webb
parent e41c5a4327
commit e6b45de41e
7 changed files with 7 additions and 19 deletions

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

@ -40,10 +40,7 @@ class ExcludeFilterContextCustomizer implements ContextCustomizer {
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 && obj.getClass() == getClass();
}
@Override

View File

@ -208,7 +208,7 @@ class OutputCapture implements CapturedOutput {
}
private static PrintStream getSystemStream(PrintStream printStream) {
while (printStream instanceof PrintStreamCapture) {
if (printStream instanceof PrintStreamCapture) {
return ((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

@ -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");
}