-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/#124-i18n
- Loading branch information
Showing
18 changed files
with
209 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...src/main/java/io/github/belgif/rest/problem/spring/AnnotationParameterNameDiscoverer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.github.belgif.rest.problem.spring; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import org.springframework.core.ParameterNameDiscoverer; | ||
|
||
import io.github.belgif.rest.problem.internal.CachedAnnotationParameterNameSupport; | ||
|
||
/** | ||
* ParameterNameDiscoverer that retrieves the parameter name from Spring MVC annotations (if present). | ||
*/ | ||
public class AnnotationParameterNameDiscoverer extends CachedAnnotationParameterNameSupport<String[]> | ||
implements ParameterNameDiscoverer { | ||
|
||
@Override | ||
protected String[] toResult(Stream<String> parameterNames) { | ||
return parameterNames.toArray(String[]::new); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...test/java/io/github/belgif/rest/problem/spring/AnnotationParameterNameDiscovererTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.github.belgif.rest.problem.spring; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class AnnotationParameterNameDiscovererTest { | ||
|
||
private final AnnotationParameterNameDiscoverer discoverer = new AnnotationParameterNameDiscoverer(); | ||
|
||
@Test | ||
void toResult() { | ||
assertThat(discoverer.toResult(Stream.of("A", "B"))).containsExactly("A", "B"); | ||
} | ||
|
||
} |
File renamed without changes.
22 changes: 22 additions & 0 deletions
22
...3/src/main/java/io/github/belgif/rest/problem/spring/AnnotationParameterNameProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.github.belgif.rest.problem.spring; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
import jakarta.validation.ParameterNameProvider; | ||
|
||
import io.github.belgif.rest.problem.internal.CachedAnnotationParameterNameSupport; | ||
|
||
/** | ||
* ParameterNameProvider that retrieves the parameter name from Spring MVC annotations (if present). | ||
*/ | ||
public class AnnotationParameterNameProvider extends CachedAnnotationParameterNameSupport<List<String>> | ||
implements ParameterNameProvider { | ||
|
||
@Override | ||
protected List<String> toResult(Stream<String> parameterNames) { | ||
return parameterNames.collect(Collectors.toList()); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
...n/java/io/github/belgif/rest/problem/spring/ProblemValidationConfigurationCustomizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.github.belgif.rest.problem.spring; | ||
|
||
import jakarta.validation.Configuration; | ||
|
||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.validation.ValidationConfigurationCustomizer; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* ValidationConfigurationCustomizer that registers the AnnotationParameterNameProvider. | ||
*/ | ||
@Component | ||
@ConditionalOnClass(Configuration.class) | ||
public class ProblemValidationConfigurationCustomizer implements ValidationConfigurationCustomizer { | ||
|
||
@Override | ||
public void customize(Configuration<?> configuration) { | ||
configuration.parameterNameProvider(new AnnotationParameterNameProvider()); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...c/test/java/io/github/belgif/rest/problem/spring/AnnotationParameterNameProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.github.belgif.rest.problem.spring; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class AnnotationParameterNameProviderTest { | ||
|
||
private final AnnotationParameterNameProvider provider = new AnnotationParameterNameProvider(); | ||
|
||
@Test | ||
void toResult() { | ||
assertThat(provider.toResult(Stream.of("A", "B"))).containsExactly("A", "B"); | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
...va/io/github/belgif/rest/problem/spring/ProblemValidationConfigurationCustomizerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.github.belgif.rest.problem.spring; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
import static org.mockito.Mockito.*; | ||
|
||
import jakarta.validation.Configuration; | ||
import jakarta.validation.ParameterNameProvider; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.ArgumentCaptor; | ||
import org.mockito.Captor; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class ProblemValidationConfigurationCustomizerTest { | ||
|
||
private final ProblemValidationConfigurationCustomizer customizer = new ProblemValidationConfigurationCustomizer(); | ||
|
||
@Mock | ||
private Configuration configuration; | ||
|
||
@Captor | ||
private ArgumentCaptor<ParameterNameProvider> parameterNameProviderCaptor; | ||
|
||
@Test | ||
void customize() { | ||
when(configuration.parameterNameProvider(parameterNameProviderCaptor.capture())).thenReturn(configuration); | ||
customizer.customize(configuration); | ||
assertThat(parameterNameProviderCaptor.getValue()).isInstanceOf(AnnotationParameterNameProvider.class); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.