Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete neo4j test harness dependency in favor of Testcontainers Neo4j #2434

Open
wants to merge 4 commits into
base: 5.0.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,30 @@
import io.micronaut.starter.build.dependencies.Dependency;
import io.micronaut.starter.build.dependencies.MicronautDependencyUtils;
import io.micronaut.starter.feature.Category;
import io.micronaut.starter.feature.Feature;
import io.micronaut.starter.feature.testcontainers.ContributingTestContainerArtifactId;
import io.micronaut.starter.feature.testresources.EaseTestingFeature;
import io.micronaut.starter.feature.testresources.TestResources;
import jakarta.inject.Singleton;

@Singleton
public class Neo4jBolt implements Feature {
private static final Dependency DEPENDENCY_NEO4J_HARNESS = Dependency.builder()
.groupId("org.neo4j.test")
.artifactId("neo4j-harness")
.testRuntime()
public class Neo4jBolt extends EaseTestingFeature implements ContributingTestContainerArtifactId {

public static final String NAME = "neo4j-bolt";
private static final String TEST_CONTAINERS_ARTIFACT_ID_NEO4J = "neo4j";

private static final Dependency DEPENDENCY_NEO4J = MicronautDependencyUtils.neo4j()
.artifactId("micronaut-neo4j-bolt")
.compile()
.build();

public Neo4jBolt(TestContainers testContainers, TestResources testResources) {
super(testContainers, testResources);
}

@Override
@NonNull
public String getName() {
return "neo4j-bolt";
return NAME;
}

@Override
Expand All @@ -52,10 +61,7 @@ public String getDescription() {
@Override
public void apply(GeneratorContext generatorContext) {
generatorContext.getConfiguration().put("neo4j.uri", "bolt://${NEO4J_HOST:localhost}");
generatorContext.addDependency(MicronautDependencyUtils.neo4j()
.artifactId("micronaut-neo4j-bolt")
.compile());
generatorContext.addDependency(DEPENDENCY_NEO4J_HARNESS);
generatorContext.addDependency(DEPENDENCY_NEO4J);
}

@Override
Expand All @@ -72,4 +78,14 @@ public String getCategory() {
public String getMicronautDocumentation() {
return "https://micronaut-projects.github.io/micronaut-neo4j/latest/guide/index.html";
}

@Override
public String getThirdPartyDocumentation() {
return "https://neo4j.com/docs/java-manual/current/";
}

@Override
public String testContainersArtifactId() {
return TEST_CONTAINERS_ARTIFACT_ID_NEO4J;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Neo4jBoltSpec extends ApplicationContextSpec implements CommandOutputFixt
then:
readme
readme.contains("https://micronaut-projects.github.io/micronaut-neo4j/latest/guide/index.html")
readme.contains("https://neo4j.com/docs/java-manual/current/")
}

void "test neo4j bolt features"() {
Expand All @@ -30,26 +31,69 @@ class Neo4jBoltSpec extends ApplicationContextSpec implements CommandOutputFixt
features.contains("neo4j-bolt")
}

void "test dependencies are present for #buildTool"(BuildTool buildTool) {
void "test config"() {
when:
GeneratorContext ctx = buildGeneratorContext(['neo4j-bolt'])

then:
ctx.getConfiguration().get("neo4j.uri") == "bolt://\${NEO4J_HOST:localhost}"
}

void "neo4j-bolt dependency is present for build tool #buildTool"(BuildTool buildTool) {
when:
String template = new BuildBuilder(beanContext, buildTool)
.features(["neo4j-bolt"])
.features(['neo4j-bolt'])
.render()
BuildTestVerifier verifier = BuildTestUtil.verifier(buildTool, template)

then:
verifier.hasDependency("io.micronaut.neo4j", "micronaut-neo4j-bolt", Scope.COMPILE)
verifier.hasDependency("org.neo4j.test", "neo4j-harness", Scope.TEST_RUNTIME)
verifier.hasDependency("io.micronaut.neo4j","micronaut-neo4j-bolt")
!verifier.hasDependency("org.testcontainers","neo4j", Scope.TEST)

where:
buildTool << BuildTool.values()
}

void "test config"() {
void "testcontainers neo4j-bolt dependency is present for build tool #buildTool"(BuildTool buildTool) {
when:
GeneratorContext ctx = buildGeneratorContext(['neo4j-bolt'])
String template = new BuildBuilder(beanContext, buildTool)
.features(['neo4j-bolt','testcontainers'])
.render()
BuildTestVerifier verifier = BuildTestUtil.verifier(buildTool, template)

then:
ctx.getConfiguration().get("neo4j.uri") == "bolt://\${NEO4J_HOST:localhost}"
verifier.hasDependency("org.testcontainers","neo4j", Scope.TEST)

where:
buildTool << BuildTool.values()
}

void "test neo4j-bolt test-resources for build tool #buildTool"(BuildTool buildTool) {
when:
String template = new BuildBuilder(beanContext, buildTool)
.features(['neo4j-bolt','test-resources'])
.render()
BuildTestVerifier verifier = BuildTestUtil.verifier(buildTool, template)

then:
!verifier.hasDependency("org.testcontainers","neo4j", Scope.TEST)
!verifier.hasDependency("org.testcontainers","testcontainers", Scope.TEST)
verifier.hasBuildPlugin("io.micronaut.test-resources")

where:
buildTool << BuildTool.valuesGradle()
}

void "test neo4j-bolt test-resources for build tool Maven"() {
when:
String template = new BuildBuilder(beanContext, BuildTool.MAVEN)
.features(['neo4j-bolt','test-resources'])
.render()
BuildTestVerifier verifier = BuildTestUtil.verifier(BuildTool.MAVEN, template)

then:
!verifier.hasDependency("org.testcontainers","neo4j", Scope.TEST)
!verifier.hasDependency("org.testcontainers","testcontainers", Scope.TEST)
verifier.hasDependency("io.micronaut.testresources","micronaut-test-resources-client")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ class TestContainersSpec extends ApplicationContextSpec {
template.contains('testImplementation("org.testcontainers:testcontainers")')
}

void "test neo4j dependency is present for gradle"() {
when:
String template = new BuildBuilder(beanContext, BuildTool.GRADLE)
.features([TestContainers.NAME, Neo4jBolt.NAME])
.render()

then:
template.contains('testImplementation("org.testcontainers:neo4j")')
template.contains('testImplementation("org.testcontainers:testcontainers")')
}

void "test testcontainers core is present when no testcontainer modules are present for gradle"() {
when:
String template = new BuildBuilder(beanContext, BuildTool.GRADLE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import io.micronaut.starter.feature.database.MariaDB
import io.micronaut.starter.feature.database.MongoReactive
import io.micronaut.starter.feature.database.MongoSync
import io.micronaut.starter.feature.database.MySQL
import io.micronaut.starter.feature.database.Neo4jBolt
import io.micronaut.starter.feature.database.Oracle
import io.micronaut.starter.feature.database.PostgreSQL
import io.micronaut.starter.feature.database.SQLServer
Expand All @@ -34,6 +35,7 @@ class OptionalTestContainerSpec extends ApplicationContextSpec {
Mqtt.NAME,
MongoSync.NAME,
MongoReactive.NAME,
Neo4jBolt.NAME,
HibernateReactiveJpa.NAME,
DataHibernateReactive.NAME,
]
Expand Down
Loading