Initialize propertyName
MethodArgumentTypeMismatchException and MethodArgumentConversionNotSupportedException are TypeMismatchException subclasses with MethodParameter information and should initialize propertyName in TypeMismatchInformation. Closes gh-29959
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -45,6 +45,7 @@ import org.springframework.web.testfixture.servlet.MockHttpServletResponse;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link RequestHeaderMethodArgumentResolver}.
|
||||
@@ -242,15 +243,16 @@ class RequestHeaderMethodArgumentResolverTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void uuidConversionWithInvalidValue() throws Exception {
|
||||
void uuidConversionWithInvalidValue() {
|
||||
servletRequest.addHeader("name", "bogus-uuid");
|
||||
|
||||
ConfigurableWebBindingInitializer bindingInitializer = new ConfigurableWebBindingInitializer();
|
||||
bindingInitializer.setConversionService(new DefaultFormattingConversionService());
|
||||
|
||||
assertThatExceptionOfType(MethodArgumentTypeMismatchException.class).isThrownBy(
|
||||
() -> resolver.resolveArgument(paramUuid, null, webRequest,
|
||||
new DefaultDataBinderFactory(bindingInitializer)));
|
||||
assertThatThrownBy(() ->
|
||||
resolver.resolveArgument(paramUuid, null, webRequest, new DefaultDataBinderFactory(bindingInitializer)))
|
||||
.isInstanceOf(MethodArgumentTypeMismatchException.class)
|
||||
.extracting("propertyName").isEqualTo("name");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user