Relocate TestGenerationContext to spring-core-test
This commit moves the test implementation for GenerationContext in spring-core-test. This also removes the copy we had in testfixtures See gh-28877
This commit is contained in:
@@ -16,14 +16,12 @@
|
||||
|
||||
package org.springframework.aot.generate;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.aot.generate.GeneratedFiles.Kind;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.core.testfixture.aot.generate.TestTarget;
|
||||
import org.springframework.javapoet.TypeSpec;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -40,7 +38,7 @@ class DefaultGenerationContextTests {
|
||||
private static final Consumer<TypeSpec.Builder> typeSpecCustomizer = type -> {};
|
||||
|
||||
private final GeneratedClasses generatedClasses = new GeneratedClasses(
|
||||
new ClassNameGenerator(TestTarget.class));
|
||||
new ClassNameGenerator(SampleTarget.class));
|
||||
|
||||
private final InMemoryGeneratedFiles generatedFiles = new InMemoryGeneratedFiles();
|
||||
|
||||
@@ -50,7 +48,7 @@ class DefaultGenerationContextTests {
|
||||
@Test
|
||||
void createWithOnlyGeneratedFilesCreatesContext() {
|
||||
DefaultGenerationContext context = new DefaultGenerationContext(
|
||||
new ClassNameGenerator(TestTarget.class), this.generatedFiles);
|
||||
new ClassNameGenerator(SampleTarget.class), this.generatedFiles);
|
||||
assertThat(context.getGeneratedFiles()).isSameAs(this.generatedFiles);
|
||||
assertThat(context.getRuntimeHints()).isInstanceOf(RuntimeHints.class);
|
||||
}
|
||||
@@ -111,7 +109,7 @@ class DefaultGenerationContextTests {
|
||||
@Test
|
||||
void withNameUpdateNamingConvention() {
|
||||
DefaultGenerationContext context = new DefaultGenerationContext(
|
||||
new ClassNameGenerator(TestTarget.class), this.generatedFiles);
|
||||
new ClassNameGenerator(SampleTarget.class), this.generatedFiles);
|
||||
GenerationContext anotherContext = context.withName("Another");
|
||||
GeneratedClass generatedClass = anotherContext.getGeneratedClasses()
|
||||
.addForFeature("Test", typeSpecCustomizer);
|
||||
@@ -119,9 +117,9 @@ class DefaultGenerationContextTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void withNameKeepsTrackOfAllGeneratedFiles() throws IOException {
|
||||
void withNameKeepsTrackOfAllGeneratedFiles() {
|
||||
DefaultGenerationContext context = new DefaultGenerationContext(
|
||||
new ClassNameGenerator(TestTarget.class), this.generatedFiles);
|
||||
new ClassNameGenerator(SampleTarget.class), this.generatedFiles);
|
||||
context.getGeneratedClasses().addForFeature("Test", typeSpecCustomizer);
|
||||
GenerationContext anotherContext = context.withName("Another");
|
||||
assertThat(anotherContext.getGeneratedClasses()).isNotSameAs(context.getGeneratedClasses());
|
||||
@@ -133,7 +131,7 @@ class DefaultGenerationContextTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void withNameGeneratesUniqueName() throws IOException {
|
||||
void withNameGeneratesUniqueName() {
|
||||
DefaultGenerationContext context = new DefaultGenerationContext(
|
||||
new ClassNameGenerator(Object.class), this.generatedFiles);
|
||||
context.withName("Test").getGeneratedClasses()
|
||||
@@ -149,4 +147,6 @@ class DefaultGenerationContextTests {
|
||||
"java/lang/Object__Test2Feature.java");
|
||||
}
|
||||
|
||||
static class SampleTarget {}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user