From 918a439797e4fec13d98c620177fcd635fc42ca5 Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Tue, 6 Sep 2022 09:08:07 +0200 Subject: [PATCH] Follow changes in core framework See spring-projects/spring-framework#29082 See spring-projects/spring-framework#28877 --- .../aot/AotTestCodeContributionBuilder.java | 24 +++++++++---------- .../BeanRegistrationContributionAssert.java | 3 +-- ...BeanRegistrationAotProcessorUnitTests.java | 2 +- ...toryRegistrationAotContributionAssert.java | 3 +-- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/test/java/org/springframework/data/aot/AotTestCodeContributionBuilder.java b/src/test/java/org/springframework/data/aot/AotTestCodeContributionBuilder.java index 6b97152e64..b924209cf0 100644 --- a/src/test/java/org/springframework/data/aot/AotTestCodeContributionBuilder.java +++ b/src/test/java/org/springframework/data/aot/AotTestCodeContributionBuilder.java @@ -15,23 +15,20 @@ */ package org.springframework.data.aot; -import javax.lang.model.element.Modifier; import java.util.function.Consumer; -import java.util.function.Supplier; + +import javax.lang.model.element.Modifier; import org.mockito.Mockito; -import org.springframework.aot.test.generator.compile.Compiled; -import org.springframework.aot.test.generator.compile.TestCompiler; -import org.springframework.beans.factory.aot.BeanInstanceSupplier; +import org.springframework.aot.test.generate.TestGenerationContext; +import org.springframework.aot.test.generate.compile.Compiled; +import org.springframework.aot.test.generate.compile.TestCompiler; import org.springframework.beans.factory.aot.BeanRegistrationAotContribution; import org.springframework.beans.factory.aot.BeanRegistrationCodeFragments; import org.springframework.beans.factory.support.InstanceSupplier; -import org.springframework.beans.factory.support.RegisteredBean; -import org.springframework.data.domain.ManagedTypes; import org.springframework.javapoet.CodeBlock; import org.springframework.javapoet.MethodSpec; import org.springframework.javapoet.ParameterizedTypeName; -import org.springframework.test.aot.generate.TestGenerationContext; /** * @author Christoph Strobl @@ -69,22 +66,23 @@ AotTestCodeContributionBuilder writeContentFor(BeanRegistrationAotContribution c Class beanType = Object.class; try { - beanType = contribution instanceof RegisteredBeanAotContribution ? ((RegisteredBeanAotContribution) contribution).getSource().getBeanClass() : Object.class; + beanType = contribution instanceof RegisteredBeanAotContribution + ? ((RegisteredBeanAotContribution) contribution).getSource().getBeanClass() + : Object.class; } catch (Exception e) {} ParameterizedTypeName parameterizedReturnTypeName = ParameterizedTypeName.get(InstanceSupplier.class, beanType); beanRegistrationCode.getTypeBuilder().set(type -> { type.addModifiers(Modifier.PUBLIC); - type.addMethod(MethodSpec.methodBuilder("get").addModifiers(Modifier.PUBLIC) - .returns(parameterizedReturnTypeName).addStatement("return $L", codeBlock).build()); + type.addMethod(MethodSpec.methodBuilder("get").addModifiers(Modifier.PUBLIC).returns(parameterizedReturnTypeName) + .addStatement("return $L", codeBlock).build()); }); return this; } public void compile() { - compile(it -> { - }); + compile(it -> {}); } public void compile(Consumer compiled) { diff --git a/src/test/java/org/springframework/data/aot/BeanRegistrationContributionAssert.java b/src/test/java/org/springframework/data/aot/BeanRegistrationContributionAssert.java index 7cab5f132d..8564c35887 100644 --- a/src/test/java/org/springframework/data/aot/BeanRegistrationContributionAssert.java +++ b/src/test/java/org/springframework/data/aot/BeanRegistrationContributionAssert.java @@ -20,11 +20,10 @@ import java.util.function.Consumer; import org.assertj.core.api.AbstractAssert; - import org.springframework.aot.generate.GenerationContext; +import org.springframework.aot.test.generate.TestGenerationContext; import org.springframework.beans.factory.aot.BeanRegistrationAotContribution; import org.springframework.beans.factory.aot.BeanRegistrationCode; -import org.springframework.test.aot.generate.TestGenerationContext; /** * @author Christoph Strobl diff --git a/src/test/java/org/springframework/data/aot/ManagedTypesBeanRegistrationAotProcessorUnitTests.java b/src/test/java/org/springframework/data/aot/ManagedTypesBeanRegistrationAotProcessorUnitTests.java index 292de936e4..4fa54d8700 100644 --- a/src/test/java/org/springframework/data/aot/ManagedTypesBeanRegistrationAotProcessorUnitTests.java +++ b/src/test/java/org/springframework/data/aot/ManagedTypesBeanRegistrationAotProcessorUnitTests.java @@ -29,6 +29,7 @@ import org.mockito.Mockito; import org.springframework.aot.generate.GenerationContext; import org.springframework.aot.hint.predicate.RuntimeHintsPredicates; +import org.springframework.aot.test.generate.TestGenerationContext; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.aot.BeanRegistrationAotContribution; import org.springframework.beans.factory.aot.BeanRegistrationCodeFragments; @@ -43,7 +44,6 @@ import org.springframework.data.domain.ManagedTypes; import org.springframework.javapoet.MethodSpec; import org.springframework.javapoet.MethodSpec.Builder; -import org.springframework.test.aot.generate.TestGenerationContext; import org.springframework.test.util.ReflectionTestUtils; /** diff --git a/src/test/java/org/springframework/data/aot/RepositoryRegistrationAotContributionAssert.java b/src/test/java/org/springframework/data/aot/RepositoryRegistrationAotContributionAssert.java index dd9f252078..24e5e0b6c2 100644 --- a/src/test/java/org/springframework/data/aot/RepositoryRegistrationAotContributionAssert.java +++ b/src/test/java/org/springframework/data/aot/RepositoryRegistrationAotContributionAssert.java @@ -23,12 +23,11 @@ import java.util.function.Consumer; import org.assertj.core.api.AbstractAssert; - import org.springframework.aot.generate.GenerationContext; +import org.springframework.aot.test.generate.TestGenerationContext; import org.springframework.beans.factory.aot.BeanRegistrationCode; import org.springframework.data.repository.core.RepositoryInformation; import org.springframework.data.repository.core.support.RepositoryFragment; -import org.springframework.test.aot.generate.TestGenerationContext; /** * AssertJ {@link AbstractAssert Assertion} for {@link RepositoryRegistrationAotContribution}.