Skip to content

Commit

Permalink
Fix visibility of Test Application class
Browse files Browse the repository at this point in the history
Closes gh-1217
  • Loading branch information
snicoll committed Jun 14, 2023
1 parent f66c418 commit eb4173c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ class GroovyTestContainersApplicationCodeProjectContributor extends

@Override
protected void contributeCode(GroovySourceCode sourceCode) {
customizeApplicationTypeDeclaration(sourceCode,
(type) -> type.addMethodDeclaration(GroovyMethodDeclaration.method("main")
.modifiers(Modifier.PUBLIC | Modifier.STATIC)
.returning("void")
.parameters(Parameter.of("args", String[].class))
.body(CodeBlock.ofStatement("$T.from($L::main).with($L).run(args)", SpringApplication.class,
getDescription().getApplicationName(), getTestApplicationName()))));
customizeApplicationTypeDeclaration(sourceCode, (type) -> {
type.modifiers(Modifier.PUBLIC);
type.addMethodDeclaration(GroovyMethodDeclaration.method("main")
.modifiers(Modifier.PUBLIC | Modifier.STATIC)
.returning("void")
.parameters(Parameter.of("args", String[].class))
.body(CodeBlock.ofStatement("$T.from($L::main).with($L).run(args)", SpringApplication.class,
getDescription().getApplicationName(), getTestApplicationName())));
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ class JavaTestContainersApplicationCodeProjectContributor extends

@Override
protected void contributeCode(JavaSourceCode sourceCode) {
customizeApplicationTypeDeclaration(sourceCode,
(type) -> type.addMethodDeclaration(JavaMethodDeclaration.method("main")
.modifiers(Modifier.PUBLIC | Modifier.STATIC)
.returning("void")
.parameters(Parameter.of("args", String[].class))
.body(CodeBlock.ofStatement("$T.from($L::main).with($L.class).run(args)", SpringApplication.class,
getDescription().getApplicationName(), getTestApplicationName()))));
customizeApplicationTypeDeclaration(sourceCode, (type) -> {
type.modifiers(Modifier.PUBLIC);
type.addMethodDeclaration(JavaMethodDeclaration.method("main")
.modifiers(Modifier.PUBLIC | Modifier.STATIC)
.returning("void")
.parameters(Parameter.of("args", String[].class))
.body(CodeBlock.ofStatement("$T.from($L::main).with($L.class).run(args)", SpringApplication.class,
getDescription().getApplicationName(), getTestApplicationName())));
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.spring.initializr.generator.language.Parameter;
import io.spring.initializr.generator.language.kotlin.KotlinCompilationUnit;
import io.spring.initializr.generator.language.kotlin.KotlinFunctionDeclaration;
import io.spring.initializr.generator.language.kotlin.KotlinModifier;
import io.spring.initializr.generator.language.kotlin.KotlinSourceCode;
import io.spring.initializr.generator.language.kotlin.KotlinSourceCodeWriter;
import io.spring.initializr.generator.language.kotlin.KotlinTypeDeclaration;
Expand Down Expand Up @@ -53,6 +54,7 @@ class KotlinTestContainersApplicationCodeProjectContributor extends
@Override
protected void contributeCode(KotlinSourceCode sourceCode) {
customizeApplicationTypeDeclaration(sourceCode, (type) -> {
type.modifiers(KotlinModifier.PUBLIC);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ void testApplicationWithJavaAndGenericContainerIsContributed() {
import org.testcontainers.containers.GenericContainer;
@TestConfiguration(proxyBeanMethods = false)
class TestDemoApplication {
public class TestDemoApplication {
@Bean
@ServiceConnection(name = "redis")
Expand Down Expand Up @@ -223,7 +223,7 @@ void testApplicationWithKotlinAndGenericContainerIsContributed() {
import org.testcontainers.containers.GenericContainer
@TestConfiguration(proxyBeanMethods = false)
class TestDemoApplication {
public class TestDemoApplication {
@Bean
@ServiceConnection(name = "redis")
Expand Down Expand Up @@ -287,7 +287,7 @@ void testApplicationWithJavaAndSpecificContainerIsContributed() {
import org.testcontainers.containers.CassandraContainer;
@TestConfiguration(proxyBeanMethods = false)
class TestDemoApplication {
public class TestDemoApplication {
@Bean
@ServiceConnection
Expand Down Expand Up @@ -321,7 +321,7 @@ void testApplicationWithKotlinAndSpecificContainerIsContributed() {
import org.testcontainers.containers.CassandraContainer
@TestConfiguration(proxyBeanMethods = false)
class TestDemoApplication {
public class TestDemoApplication {
@Bean
@ServiceConnection
Expand Down

0 comments on commit eb4173c

Please sign in to comment.