Merge pull request #15401 from igor-suhorukov

* pr/15401:
  Polish "Replace this lambda with a method reference"
  Replace this lambda with a method reference
This commit is contained in:
Stephane Nicoll
2018-12-07 11:10:41 +01:00
13 changed files with 22 additions and 22 deletions

View File

@@ -80,7 +80,7 @@ public class CloudFoundryWebEndpointDiscovererTests {
private void load(Class<?> configuration,
Consumer<CloudFoundryWebEndpointDiscoverer> consumer) {
this.load((id) -> null, (id) -> id.toString(), configuration, consumer);
this.load((id) -> null, EndpointId::toString, configuration, consumer);
}
private void load(Function<EndpointId, Long> timeToLive,

View File

@@ -92,7 +92,7 @@ public class TokenTests {
String claims = "{\"exp\": 2147483647, \"iss\": \"http://localhost:8080/uaa/oauth/token\"}";
Token token = createToken(header, claims);
assertThatExceptionOfType(CloudFoundryAuthorizationException.class)
.isThrownBy(() -> token.getSignatureAlgorithm())
.isThrownBy(token::getSignatureAlgorithm)
.satisfies(reasonRequirement(Reason.INVALID_TOKEN));
}
@@ -102,7 +102,7 @@ public class TokenTests {
String claims = "{\"exp\": 2147483647}";
Token token = createToken(header, claims);
assertThatExceptionOfType(CloudFoundryAuthorizationException.class)
.isThrownBy(() -> token.getIssuer())
.isThrownBy(token::getIssuer)
.satisfies(reasonRequirement(Reason.INVALID_TOKEN));
}
@@ -112,7 +112,7 @@ public class TokenTests {
String claims = "{\"exp\": 2147483647}";
Token token = createToken(header, claims);
assertThatExceptionOfType(CloudFoundryAuthorizationException.class)
.isThrownBy(() -> token.getKeyId())
.isThrownBy(token::getKeyId)
.satisfies(reasonRequirement(Reason.INVALID_TOKEN));
}
@@ -122,7 +122,7 @@ public class TokenTests {
String claims = "{\"iss\": \"http://localhost:8080/uaa/oauth/token\"" + "}";
Token token = createToken(header, claims);
assertThatExceptionOfType(CloudFoundryAuthorizationException.class)
.isThrownBy(() -> token.getExpiry())
.isThrownBy(token::getExpiry)
.satisfies(reasonRequirement(Reason.INVALID_TOKEN));
}

View File

@@ -84,7 +84,7 @@ public class ServletEndpointManagementContextConfigurationTests {
@Bean
public ServletEndpointsSupplier servletEndpointsSupplier() {
return () -> Collections.emptyList();
return Collections::emptyList;
}
@Bean

View File

@@ -61,7 +61,7 @@ public class JerseyWebEndpointManagementContextConfigurationTests {
@Bean
public WebEndpointsSupplier webEndpointsSupplier() {
return () -> Collections.emptyList();
return Collections::emptyList;
}
}

View File

@@ -26,6 +26,7 @@ import org.glassfish.jersey.server.model.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.actuate.endpoint.EndpointId;
import org.springframework.boot.actuate.endpoint.http.ActuatorMediaType;
import org.springframework.boot.actuate.endpoint.invoke.convert.ConversionServiceParameterValueMapper;
import org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver;
@@ -142,7 +143,7 @@ public class JerseyEndpointRequestIntegrationTests
mediaTypes);
WebEndpointDiscoverer discoverer = new WebEndpointDiscoverer(
this.applicationContext, new ConversionServiceParameterValueMapper(),
endpointMediaTypes, Arrays.asList((id) -> id.toString()),
endpointMediaTypes, Arrays.asList(EndpointId::toString),
Collections.emptyList(), Collections.emptyList());
Collection<Resource> resources = new JerseyEndpointResourceFactory()
.createEndpointResources(new EndpointMapping("/actuator"),

View File

@@ -22,6 +22,7 @@ import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.actuate.endpoint.EndpointId;
import org.springframework.boot.actuate.endpoint.http.ActuatorMediaType;
import org.springframework.boot.actuate.endpoint.invoke.convert.ConversionServiceParameterValueMapper;
import org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver;
@@ -130,7 +131,7 @@ public class MvcEndpointRequestIntegrationTests
mediaTypes);
WebEndpointDiscoverer discoverer = new WebEndpointDiscoverer(
this.applicationContext, new ConversionServiceParameterValueMapper(),
endpointMediaTypes, Arrays.asList((id) -> id.toString()),
endpointMediaTypes, Arrays.asList(EndpointId::toString),
Collections.emptyList(), Collections.emptyList());
return new WebMvcEndpointHandlerMapping(new EndpointMapping("/actuator"),
discoverer.getEndpoints(), endpointMediaTypes,

View File

@@ -182,7 +182,7 @@ public class WebEndpointDiscovererTests {
@Test
public void getEndpointsWhenHasCacheWithTtlShouldCacheReadOperationWithTtlValue() {
load((id) -> 500L, (id) -> id.toString(), TestEndpointConfiguration.class,
load((id) -> 500L, EndpointId::toString, TestEndpointConfiguration.class,
(discoverer) -> {
Map<EndpointId, ExposableWebEndpoint> endpoints = mapEndpoints(
discoverer.getEndpoints());
@@ -246,7 +246,7 @@ public class WebEndpointDiscovererTests {
}
private void load(Class<?> configuration, Consumer<WebEndpointDiscoverer> consumer) {
this.load((id) -> null, (id) -> id.toString(), configuration, consumer);
this.load((id) -> null, EndpointId::toString, configuration, consumer);
}
private void load(Function<EndpointId, Long> timeToLive,

View File

@@ -260,7 +260,7 @@ public class HttpExchangeTracerTests {
public void principalIsNotIncludedByDefault() {
HttpTrace trace = new HttpTrace(createRequest());
new HttpExchangeTracer(EnumSet.noneOf(Include.class)).sendingResponse(trace,
createResponse(), () -> createPrincipal(), null);
createResponse(), this::createPrincipal, null);
assertThat(trace.getPrincipal()).isNull();
}
@@ -268,7 +268,7 @@ public class HttpExchangeTracerTests {
public void principalCanBeIncluded() {
HttpTrace trace = new HttpTrace(createRequest());
new HttpExchangeTracer(EnumSet.of(Include.PRINCIPAL)).sendingResponse(trace,
createResponse(), () -> createPrincipal(), null);
createResponse(), this::createPrincipal, null);
assertThat(trace.getPrincipal()).isNotNull();
assertThat(trace.getPrincipal().getName()).isEqualTo("alice");
}

View File

@@ -72,8 +72,7 @@ public final class OAuth2ClientPropertiesRegistrationAdapter {
map.from(properties::getAuthorizationGrantType).as(AuthorizationGrantType::new)
.to(builder::authorizationGrantType);
map.from(properties::getRedirectUri).to(builder::redirectUriTemplate);
map.from(properties::getScope).as((scope) -> StringUtils.toStringArray(scope))
.to(builder::scope);
map.from(properties::getScope).as(StringUtils::toStringArray).to(builder::scope);
map.from(properties::getClientName).to(builder::clientName);
return builder.build();
}

View File

@@ -794,7 +794,7 @@ public class WebMvcAutoConfigurationTests {
@Test
public void cachePeriod() {
this.contextRunner.withPropertyValues("spring.resources.cache.period:5")
.run((context) -> assertCachePeriod(context));
.run(this::assertCachePeriod);
}
private void assertCachePeriod(AssertableWebApplicationContext context) {
@@ -817,7 +817,7 @@ public class WebMvcAutoConfigurationTests {
this.contextRunner
.withPropertyValues("spring.resources.cache.cachecontrol.max-age:5",
"spring.resources.cache.cachecontrol.proxy-revalidate:true")
.run((context) -> assertCacheControl(context));
.run(this::assertCacheControl);
}
@Test

View File

@@ -44,7 +44,7 @@ public class RemoteUrlPropertyExtractorTests {
@Test
public void missingUrl() {
assertThatIllegalStateException().isThrownBy(() -> doTest())
assertThatIllegalStateException().isThrownBy(this::doTest)
.withMessageContaining("No remote URL specified");
}

View File

@@ -131,8 +131,7 @@ public class ApplicationContextAssertProviderTests {
public void getSourceContextWhenContextFailsShouldThrowException() {
ApplicationContextAssertProvider<ApplicationContext> context = get(
this.startupFailureSupplier);
assertThatIllegalStateException()
.isThrownBy(() -> context.getSourceApplicationContext())
assertThatIllegalStateException().isThrownBy(context::getSourceApplicationContext)
.withCause(this.startupFailure).withMessageContaining("failed to start");
}

View File

@@ -66,8 +66,8 @@ public class BindResultTests {
@Test
public void getWhenHasNoValueShouldThrowException() {
BindResult<String> result = BindResult.of(null);
assertThatExceptionOfType(NoSuchElementException.class)
.isThrownBy(() -> result.get()).withMessageContaining("No value bound");
assertThatExceptionOfType(NoSuchElementException.class).isThrownBy(result::get)
.withMessageContaining("No value bound");
}
@Test