Skip to content

Commit

Permalink
Remove obsolete neo4j test harness dependency in favor of Testcontain…
Browse files Browse the repository at this point in the history
…ers Neo4j. Support for the former was removed from micronaut-neo4j for Micronaut Framework 5. [skip ci]

closes #2390
  • Loading branch information
wetted committed Apr 10, 2024
1 parent 38aaef1 commit b13bbf6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@

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

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

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

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

@Override
Expand All @@ -52,10 +54,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 +71,9 @@ 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/";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ public void apply(GeneratorContext generatorContext) {
if (generatorContext.isFeaturePresent(MockServerClient.class)) {
generatorContext.addDependency(testContainerTestDependency("mockserver"));
}
if (generatorContext.isFeaturePresent(Neo4jBolt.class)) {
generatorContext.addDependency(testContainerTestDependency("neo4j"));
}
}

@NonNull
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
package io.micronaut.starter.feature.database

import io.micronaut.starter.ApplicationContextSpec
import io.micronaut.starter.BuildBuilder
import io.micronaut.starter.application.generator.GeneratorContext
import io.micronaut.starter.build.BuildTestUtil
import io.micronaut.starter.build.BuildTestVerifier
import io.micronaut.starter.build.dependencies.Scope
import io.micronaut.starter.feature.Features
import io.micronaut.starter.fixture.CommandOutputFixture
import io.micronaut.starter.options.BuildTool

class Neo4jBoltSpec extends ApplicationContextSpec implements CommandOutputFixture {

Expand All @@ -20,6 +15,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,21 +26,6 @@ class Neo4jBoltSpec extends ApplicationContextSpec implements CommandOutputFixt
features.contains("neo4j-bolt")
}

void "test dependencies are present for #buildTool"(BuildTool buildTool) {
when:
String template = new BuildBuilder(beanContext, buildTool)
.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)

where:
buildTool << BuildTool.values()
}

void "test config"() {
when:
GeneratorContext ctx = buildGeneratorContext(['neo4j-bolt'])
Expand Down
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

0 comments on commit b13bbf6

Please sign in to comment.