|
19 | 19 | import static org.springframework.data.jpa.provider.PersistenceProvider.*; |
20 | 20 | import static org.springframework.data.jpa.provider.PersistenceProvider.Constants.*; |
21 | 21 |
|
22 | | -import java.util.ArrayList; |
23 | | -import java.util.List; |
24 | | - |
25 | 22 | import jakarta.persistence.EntityManager; |
26 | 23 |
|
| 24 | +import java.util.Arrays; |
| 25 | + |
27 | 26 | import org.assertj.core.api.Assumptions; |
28 | 27 | import org.hibernate.Version; |
29 | 28 | import org.junit.jupiter.api.BeforeEach; |
30 | 29 | import org.junit.jupiter.api.Test; |
31 | 30 | import org.mockito.Mockito; |
| 31 | + |
32 | 32 | import org.springframework.asm.ClassWriter; |
33 | 33 | import org.springframework.asm.Opcodes; |
34 | 34 | import org.springframework.instrument.classloading.ShadowingClassLoader; |
@@ -111,12 +111,12 @@ private EntityManager mockProviderSpecificEntityManagerInterface(String interfac |
111 | 111 |
|
112 | 112 | static class InterfaceGenerator implements Opcodes { |
113 | 113 |
|
114 | | - static Class<?> generate(final String interfaceName, ClassLoader parentClassLoader, |
115 | | - final Class<?>... interfaces) throws ClassNotFoundException { |
| 114 | + static Class<?> generate(final String interfaceName, ClassLoader parentClassLoader, final Class<?>... interfaces) |
| 115 | + throws ClassNotFoundException { |
116 | 116 |
|
117 | 117 | class CustomClassLoader extends ClassLoader { |
118 | 118 |
|
119 | | - CustomClassLoader(ClassLoader parent) { |
| 119 | + private CustomClassLoader(ClassLoader parent) { |
120 | 120 | super(parent); |
121 | 121 | } |
122 | 122 |
|
@@ -151,12 +151,10 @@ private static byte[] generateByteCodeForInterface(final String interfaceName, C |
151 | 151 |
|
152 | 152 | private static String[] toResourcePaths(Class<?>... interfacesToImplement) { |
153 | 153 |
|
154 | | - List<String> interfaceResourcePaths = new ArrayList<>(interfacesToImplement.length); |
155 | | - for (Class<?> targetInterface : interfacesToImplement) { |
156 | | - interfaceResourcePaths.add(ClassUtils.convertClassNameToResourcePath(targetInterface.getName())); |
157 | | - } |
158 | | - |
159 | | - return interfaceResourcePaths.toArray(new String[0]); |
| 154 | + return Arrays.stream(interfacesToImplement) // |
| 155 | + .map(Class::getName) // |
| 156 | + .map(ClassUtils::convertClassNameToResourcePath) // |
| 157 | + .toArray(String[]::new); |
160 | 158 | } |
161 | 159 | } |
162 | 160 | } |
0 commit comments