Support formatting annotations on HTTP service interface

Closes gh-29095
This commit is contained in:
rstoyanchev
2022-09-21 16:18:39 +01:00
parent 157c28bcec
commit 5192d99fa4
2 changed files with 28 additions and 7 deletions

View File

@@ -21,6 +21,7 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -31,6 +32,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.core.MethodParameter;
import org.springframework.core.annotation.AliasFor;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.support.DefaultFormattingConversionService;
import org.springframework.lang.Nullable;
import org.springframework.util.LinkedMultiValueMap;
@@ -73,6 +75,12 @@ class NamedValueArgumentResolverTests {
assertTestValue("value", "test");
}
@Test // gh-29095
void dateTestValue() {
this.service.executeDate(LocalDate.of(2022, 9, 16));
assertTestValue("value", "2022-09-16");
}
@Test
void objectTestValue() {
this.service.execute(Boolean.TRUE);
@@ -174,6 +182,9 @@ class NamedValueArgumentResolverTests {
@GetExchange
void executeString(@TestValue String value);
@GetExchange
void executeDate(@TestValue @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate value);
@GetExchange
void execute(@TestValue Object value);