Skip to content

Commit 71cc729

Browse files
authored
Make Neo4jContainer generic and drop deprecated method (#10388)
1 parent cfe90d5 commit 71cc729

File tree

6 files changed

+37
-141
lines changed

6 files changed

+37
-141
lines changed

examples/neo4j-container/src/test/java/org/testcontainers/containers/Neo4jExampleTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
class Neo4jExampleTest {
2828

2929
@Container
30-
private static Neo4jContainer<?> neo4jContainer = new Neo4jContainer<>(DockerImageName.parse("neo4j:4.4"))
30+
private static Neo4jContainer neo4jContainer = new Neo4jContainer(DockerImageName.parse("neo4j:4.4"))
3131
.withoutAuthentication(); // Disable password
3232

3333
@Test

modules/neo4j/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ dependencies {
3939

4040
tasks.japicmp {
4141
classExcludes = [
42-
"org.testcontainers.containers.Neo4jContainer"
42+
"org.testcontainers.containers.Neo4jContainer",
43+
"org.testcontainers.containers.Neo4jLabsPlugin"
4344
]
4445
}

modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jContainer.java

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* <li>HTTPS: 7473</li>
3232
* </ul>
3333
*/
34-
public class Neo4jContainer<S extends Neo4jContainer<S>> extends GenericContainer<S> {
34+
public class Neo4jContainer extends GenericContainer<Neo4jContainer> {
3535

3636
/**
3737
* The image defaults to the official Neo4j image: <a href="https://hub.docker.com/_/neo4j/">Neo4j</a>.
@@ -205,7 +205,7 @@ public String getHttpsUrl() {
205205
*
206206
* @return This container.
207207
*/
208-
public S withEnterpriseEdition() {
208+
public Neo4jContainer withEnterpriseEdition() {
209209
if (!standardImage) {
210210
throw new IllegalStateException(
211211
String.format("Cannot use enterprise version with alternative image %s.", getDockerImageName())
@@ -227,7 +227,7 @@ public S withEnterpriseEdition() {
227227
* @param adminPassword The admin password for the default database account.
228228
* @return This container.
229229
*/
230-
public S withAdminPassword(final String adminPassword) {
230+
public Neo4jContainer withAdminPassword(final String adminPassword) {
231231
if (adminPassword != null && adminPassword.length() < 8) {
232232
logger().warn("Your provided admin password is too short and will not work with Neo4j 5.3+.");
233233
}
@@ -240,7 +240,7 @@ public S withAdminPassword(final String adminPassword) {
240240
*
241241
* @return This container.
242242
*/
243-
public S withoutAuthentication() {
243+
public Neo4jContainer withoutAuthentication() {
244244
return withAdminPassword(null);
245245
}
246246

@@ -264,7 +264,7 @@ public S withoutAuthentication() {
264264
* @throws IllegalArgumentException If the database version is not 3.5.
265265
* @return This container.
266266
*/
267-
public S withDatabase(MountableFile graphDb) {
267+
public Neo4jContainer withDatabase(MountableFile graphDb) {
268268
if (!isNeo4jDatabaseVersionSupportingDbCopy()) {
269269
throw new IllegalArgumentException(
270270
"Copying database folder is not supported for Neo4j instances with version 4.0 or higher."
@@ -283,7 +283,7 @@ public S withDatabase(MountableFile graphDb) {
283283
* @param plugins
284284
* @return This container.
285285
*/
286-
public S withPlugins(MountableFile plugins) {
286+
public Neo4jContainer withPlugins(MountableFile plugins) {
287287
return withCopyFileToContainer(plugins, "/var/lib/neo4j/plugins/");
288288
}
289289

@@ -295,7 +295,7 @@ public S withPlugins(MountableFile plugins) {
295295
* @param value The value to set
296296
* @return This container.
297297
*/
298-
public S withNeo4jConfig(String key, String value) {
298+
public Neo4jContainer withNeo4jConfig(String key, String value) {
299299
addEnv(formatConfigurationKey(key), value);
300300
return self();
301301
}
@@ -307,31 +307,6 @@ public String getAdminPassword() {
307307
return adminPassword;
308308
}
309309

310-
/**
311-
* Registers one or more {@link Neo4jLabsPlugin} for download and server startup.
312-
*
313-
* @param neo4jLabsPlugins The Neo4j plugins that should get started with the server.
314-
* @return This container.
315-
* @deprecated {@link Neo4jLabsPlugin} were deprecated due to naming changes that cannot be solved by this enumeration.
316-
* Please use the {@link Neo4jContainer#withPlugins(String...)} method.
317-
*/
318-
public S withLabsPlugins(Neo4jLabsPlugin... neo4jLabsPlugins) {
319-
List<String> pluginNames = Arrays
320-
.stream(neo4jLabsPlugins)
321-
.map(plugin -> plugin.pluginName)
322-
.collect(Collectors.toList());
323-
324-
this.labsPlugins.addAll(pluginNames);
325-
return self();
326-
}
327-
328-
/**
329-
* @deprecated Please use {@link Neo4jContainer#withPlugins(String...)} for named plugins.
330-
*/
331-
public S withLabsPlugins(String... neo4jLabsPlugins) {
332-
return this.withPlugins(neo4jLabsPlugins);
333-
}
334-
335310
/**
336311
* Registers one or more Neo4j plugins for server startup.
337312
* The plugins are listed here
@@ -343,7 +318,7 @@ public S withLabsPlugins(String... neo4jLabsPlugins) {
343318
* @param plugins The Neo4j plugins that should get started with the server.
344319
* @return This container.
345320
*/
346-
public S withPlugins(String... plugins) {
321+
public Neo4jContainer withPlugins(String... plugins) {
347322
this.labsPlugins.addAll(Arrays.asList(plugins));
348323
return self();
349324
}
@@ -376,7 +351,7 @@ private boolean isNeo4jDatabaseVersionSupportingDbCopy() {
376351
return false;
377352
}
378353

379-
public S withRandomPassword() {
354+
public Neo4jContainer withRandomPassword() {
380355
return withAdminPassword(UUID.randomUUID().toString());
381356
}
382357
}

modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jLabsPlugin.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerJUnitIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
public class Neo4jContainerJUnitIntegrationTest {
1919

2020
@ClassRule
21-
public static Neo4jContainer<?> neo4jContainer = new Neo4jContainer<>("neo4j:4.4");
21+
public static Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4");
2222

2323
@Test
2424
public void shouldStart() {

0 commit comments

Comments
 (0)