Hide builder implementations in RuntimeHints API
This commit is contained in:
@@ -21,13 +21,10 @@ import java.util.Arrays;
|
||||
import java.util.Properties;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.aot.hint.JdkProxyHint.Builder;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
@@ -78,6 +75,16 @@ class ProxyHintsTests {
|
||||
assertThat(this.proxyHints.jdkProxies()).singleElement().satisfies(proxiedInterfaces(Function.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerClassProxyWithTargetClassName() {
|
||||
this.proxyHints.registerClassProxy(TypeReference.of(Properties.class.getName()), classProxyHint ->
|
||||
classProxyHint.proxiedInterfaces(Serializable.class));
|
||||
assertThat(this.proxyHints.classProxies()).singleElement().satisfies(classProxyHint -> {
|
||||
assertThat(classProxyHint.getTargetClass()).isEqualTo(TypeReference.of(Properties.class));
|
||||
assertThat(classProxyHint.getProxiedInterfaces()).containsOnly(TypeReference.of(Serializable.class));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerClassProxyWithTargetClass() {
|
||||
this.proxyHints.registerClassProxy(Properties.class, classProxyHint ->
|
||||
@@ -94,11 +101,11 @@ class ProxyHintsTests {
|
||||
})).withMessageContaining(Serializable.class.getName());
|
||||
}
|
||||
|
||||
private static Supplier<JdkProxyHint> springProxy(TypeReference proxiedInterface) {
|
||||
return () -> new Builder().proxiedInterfaces(Stream.of("org.springframework.aop.SpringProxy",
|
||||
private static Consumer<JdkProxyHint.Builder> springProxy(TypeReference proxiedInterface) {
|
||||
return builder -> builder.proxiedInterfaces(Stream.of("org.springframework.aop.SpringProxy",
|
||||
"org.springframework.aop.framework.Advised", "org.springframework.core.DecoratingProxy")
|
||||
.map(TypeReference::of).toArray(TypeReference[]::new))
|
||||
.proxiedInterfaces(proxiedInterface).build();
|
||||
.proxiedInterfaces(proxiedInterface);
|
||||
}
|
||||
|
||||
private Consumer<JdkProxyHint> proxiedInterfaces(String... proxiedInterfaces) {
|
||||
|
||||
Reference in New Issue
Block a user