Skip to content

Commit

Permalink
Follow changes in core framework
Browse files Browse the repository at this point in the history
  • Loading branch information
christophstrobl committed Sep 6, 2022
1 parent 3550f23 commit 918a439
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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> compiled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down

0 comments on commit 918a439

Please sign in to comment.