Browse Source

Polish contribution

See gh-28422
pull/27953/head
Sam Brannen 4 years ago
parent
commit
64c96c579d
  1. 5
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ErrorsMethodArgumentResolver.java
  2. 15
      spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ErrorsMethodArgumentResolverTests.java

5
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ErrorsMethodArgumentResolver.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 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.
@ -33,7 +33,8 @@ import org.springframework.web.server.ServerWebExchange; @@ -33,7 +33,8 @@ import org.springframework.web.server.ServerWebExchange;
/**
* Resolve {@link Errors} or {@link BindingResult} method arguments.
* An {@code Errors} argument is expected to appear immediately after the
*
* <p>An {@code Errors} argument is expected to appear immediately after the
* model attribute in the method signature.
*
* @author Rossen Stoyanchev

15
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ErrorsMethodArgumentResolverTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 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.
@ -82,12 +82,11 @@ class ErrorsMethodArgumentResolverTests { @@ -82,12 +82,11 @@ class ErrorsMethodArgumentResolverTests {
}
@Test
void resolveOnBindingResultAndModelAttributeWithCustomValue() {
void resolveOnBindingResultAndModelAttributeWithCustomName() {
BindingResult bindingResult = createBindingResult(new Foo(), "custom");
this.bindingContext.getModel().asMap().put(BindingResult.MODEL_KEY_PREFIX + "custom", bindingResult);
ResolvableMethod testMethod = ResolvableMethod.on(getClass())
.named("handleWithModelAttributeValue").build();
ResolvableMethod testMethod = ResolvableMethod.on(getClass()).named("handleWithCustomModelAttributeName").build();
MethodParameter parameter = testMethod.arg(Errors.class);
Object actual = this.resolver.resolveArgument(parameter, this.bindingContext, this.exchange)
@ -114,12 +113,11 @@ class ErrorsMethodArgumentResolverTests { @@ -114,12 +113,11 @@ class ErrorsMethodArgumentResolverTests {
}
@Test
void resolveWithMonoOnBindingResultAndModelAttributeWithCustomValue() {
void resolveWithMonoOnBindingResultAndModelAttributeWithCustomName() {
BindingResult bindingResult = createBindingResult(new Foo(), "custom");
this.bindingContext.getModel().asMap().put(BindingResult.MODEL_KEY_PREFIX + "custom", Mono.just(bindingResult));
ResolvableMethod testMethod = ResolvableMethod.on(getClass())
.named("handleWithModelAttributeValue").build();
ResolvableMethod testMethod = ResolvableMethod.on(getClass()).named("handleWithCustomModelAttributeName").build();
MethodParameter parameter = testMethod.arg(Errors.class);
Object actual = this.resolver.resolveArgument(parameter, this.bindingContext, this.exchange)
@ -181,7 +179,7 @@ class ErrorsMethodArgumentResolverTests { @@ -181,7 +179,7 @@ class ErrorsMethodArgumentResolverTests {
}
@SuppressWarnings("unused")
void handleWithModelAttributeValue(
void handleWithCustomModelAttributeName(
@ModelAttribute("custom") Foo foo,
Errors errors,
@ModelAttribute Mono<Foo> fooMono,
@ -189,4 +187,5 @@ class ErrorsMethodArgumentResolverTests { @@ -189,4 +187,5 @@ class ErrorsMethodArgumentResolverTests {
Mono<Errors> errorsMono,
String string) {
}
}

Loading…
Cancel
Save