Search in sources :

Example 1 with RoundEnvironmentTester

use of org.springframework.boot.configurationprocessor.test.RoundEnvironmentTester in project spring-boot by spring-projects.

the class PropertyDescriptorResolverTests method process.

private void process(Class<?> target, Collection<Class<?>> additionalClasses, BiConsumer<TypeElement, MetadataGenerationEnvironment> consumer) throws IOException {
    BiConsumer<RoundEnvironmentTester, MetadataGenerationEnvironment> internalConsumer = (roundEnv, metadataEnv) -> {
        TypeElement element = roundEnv.getRootElement(target);
        consumer.accept(element, metadataEnv);
    };
    TestableAnnotationProcessor<MetadataGenerationEnvironment> processor = new TestableAnnotationProcessor<>(internalConsumer, new MetadataGenerationEnvironmentFactory());
    TestCompiler compiler = new TestCompiler(this.tempDir);
    ArrayList<Class<?>> allClasses = new ArrayList<>();
    allClasses.add(target);
    allClasses.addAll(additionalClasses);
    compiler.getTask(allClasses.toArray(new Class<?>[0])).call(processor);
}
Also used : HierarchicalProperties(org.springframework.boot.configurationsample.simple.HierarchicalProperties) Arrays(java.util.Arrays) RoundEnvironmentTester(org.springframework.boot.configurationprocessor.test.RoundEnvironmentTester) HierarchicalPropertiesParent(org.springframework.boot.configurationsample.simple.HierarchicalPropertiesParent) ImmutableClassConstructorBindingProperties(org.springframework.boot.configurationsample.immutable.ImmutableClassConstructorBindingProperties) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) TestableAnnotationProcessor(org.springframework.boot.configurationprocessor.test.TestableAnnotationProcessor) SimpleProperties(org.springframework.boot.configurationsample.simple.SimpleProperties) TypeElement(javax.lang.model.element.TypeElement) ImmutableMultiConstructorProperties(org.springframework.boot.configurationsample.immutable.ImmutableMultiConstructorProperties) ArrayList(java.util.ArrayList) ItemMetadata(org.springframework.boot.configurationprocessor.metadata.ItemMetadata) AutowiredProperties(org.springframework.boot.configurationsample.simple.AutowiredProperties) BiConsumer(java.util.function.BiConsumer) TwoConstructorsExample(org.springframework.boot.configurationsample.specific.TwoConstructorsExample) TestCompiler(org.springframework.boot.testsupport.compiler.TestCompiler) ImmutableNameAnnotationProperties(org.springframework.boot.configurationsample.immutable.ImmutableNameAnnotationProperties) ImmutableDeducedConstructorBindingProperties(org.springframework.boot.configurationsample.immutable.ImmutableDeducedConstructorBindingProperties) LombokExplicitProperties(org.springframework.boot.configurationsample.lombok.LombokExplicitProperties) Collection(java.util.Collection) ImmutableSimpleProperties(org.springframework.boot.configurationsample.immutable.ImmutableSimpleProperties) IOException(java.io.IOException) LombokSimpleValueProperties(org.springframework.boot.configurationsample.lombok.LombokSimpleValueProperties) HierarchicalPropertiesGrandparent(org.springframework.boot.configurationsample.simple.HierarchicalPropertiesGrandparent) File(java.io.File) Consumer(java.util.function.Consumer) Test(org.junit.jupiter.api.Test) Stream(java.util.stream.Stream) TempDir(org.junit.jupiter.api.io.TempDir) LombokSimpleProperties(org.springframework.boot.configurationsample.lombok.LombokSimpleProperties) Collections(java.util.Collections) LombokSimpleDataProperties(org.springframework.boot.configurationsample.lombok.LombokSimpleDataProperties) TestableAnnotationProcessor(org.springframework.boot.configurationprocessor.test.TestableAnnotationProcessor) TestCompiler(org.springframework.boot.testsupport.compiler.TestCompiler) TypeElement(javax.lang.model.element.TypeElement) RoundEnvironmentTester(org.springframework.boot.configurationprocessor.test.RoundEnvironmentTester) ArrayList(java.util.ArrayList)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 BiConsumer (java.util.function.BiConsumer)1 Consumer (java.util.function.Consumer)1 Stream (java.util.stream.Stream)1 TypeElement (javax.lang.model.element.TypeElement)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Test (org.junit.jupiter.api.Test)1 TempDir (org.junit.jupiter.api.io.TempDir)1 ItemMetadata (org.springframework.boot.configurationprocessor.metadata.ItemMetadata)1 RoundEnvironmentTester (org.springframework.boot.configurationprocessor.test.RoundEnvironmentTester)1 TestableAnnotationProcessor (org.springframework.boot.configurationprocessor.test.TestableAnnotationProcessor)1 ImmutableClassConstructorBindingProperties (org.springframework.boot.configurationsample.immutable.ImmutableClassConstructorBindingProperties)1 ImmutableDeducedConstructorBindingProperties (org.springframework.boot.configurationsample.immutable.ImmutableDeducedConstructorBindingProperties)1 ImmutableMultiConstructorProperties (org.springframework.boot.configurationsample.immutable.ImmutableMultiConstructorProperties)1 ImmutableNameAnnotationProperties (org.springframework.boot.configurationsample.immutable.ImmutableNameAnnotationProperties)1