Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
20 changes: 19 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,25 @@
<version>3.19.4</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.21.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>1.21.3</version>
<scope>test</scope>
</dependency>
Comment on lines +104 to +114
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Manage Testcontainers versions via a property/BOM for consistency

Define a single testcontainers.version and import the Testcontainers BOM so all modules stay aligned. This avoids accidental version drift across artifacts.

Apply these diffs:

Add a property (Lines 69-72):

   <properties>
     <maven.compiler.source>8</maven.compiler.source>
     <maven.compiler.target>8</maven.compiler.target>
+    <testcontainers.version>1.21.3</testcontainers.version>
   </properties>

Import the BOM (add after properties; new block):

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>testcontainers-bom</artifactId>
      <version>${testcontainers.version}</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

Drop explicit versions for Testcontainers artifacts (Lines 104-114):

         <dependency>
           <groupId>org.testcontainers</groupId>
           <artifactId>testcontainers</artifactId>
-          <version>1.21.3</version>
           <scope>test</scope>
         </dependency>
         <dependency>
           <groupId>org.testcontainers</groupId>
           <artifactId>junit-jupiter</artifactId>
-          <version>1.21.3</version>
           <scope>test</scope>
         </dependency>

Note: keep the version for com.redis:testcontainers-redis; it’s not governed by the Testcontainers BOM.

🤖 Prompt for AI Agents
In pom.xml around lines 69-72 and 104-114, you should centralize Testcontainers
versioning: add a new property testcontainers.version (around lines 69-72) and
import the Testcontainers BOM via a dependencyManagement block immediately after
properties, then remove the explicit <version> tags from Testcontainers
dependencies at lines 104-114 so they inherit the BOM-managed version; keep
explicit versions for artifacts not covered by the BOM (e.g.,
com.redis:testcontainers-redis).

<dependency>
<groupId>com.redis</groupId>
<artifactId>testcontainers-redis</artifactId>
<version>2.2.4</version>
<scope>test</scope>
</dependency>
Comment on lines +116 to +120
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Confirm whether com.redis:testcontainers-redis is actually used

I don’t see usages in the provided diff; if unused, drop it to keep the test classpath lean.

Run this to check for usage:


🏁 Script executed:

#!/bin/bash
# Look for classes from com.redis.testcontainers or typical container names
rg -n -A2 -i $'package com\\.redis\\.testcontainers|Redis(Container|StackContainer)|com\\.redis\\.testcontainers' src/test || true

Length of output: 126


We'll broaden the search for any Redis-related usage in tests and code:


🏁 Script executed:

#!/bin/bash
# Search for any mention of 'redis' in test sources
rg -n -i 'redis' -A2 src/test || true

# Search for RedisContainer instantiations anywhere in the repo
rg -n -i 'RedisContainer' -A2 src || true

Length of output: 6297


Unused testcontainers-redis dependency
I couldn’t find any references to com.redis.testcontainers.RedisContainer or other classes from com.redis:testcontainers-redis in the test code. It appears this dependency isn’t used and can be removed to slim down the test classpath.

• In pom.xml, remove lines 116–120 (the <dependency> block for com.redis:testcontainers-redis:2.2.4).

🤖 Prompt for AI Agents
In pom.xml around lines 116 to 120, the com.redis:testcontainers-redis
dependency block is unused; remove the entire <dependency>...</dependency> block
(lines 116–120) from the test dependencies section, then run mvn -q
dependency:tree or mvn -q test to validate build and ensure no tests reference
Redis testcontainers; if build fails, restore the block and search tests for
com.redis.* usages to resolve references.

</dependencies>

<build>
<plugins>
Expand Down
15 changes: 8 additions & 7 deletions src/test/java/com/falkordb/InstantiationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,38 @@

import java.net.URI;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import com.falkordb.test.BaseTestIT;
import org.junit.jupiter.api.*;

public class InstantiationTest {
public class InstantiationTest extends BaseTestIT {
private GraphContextGenerator client;

@Test
public void createDefaultClient() {

client = FalkorDB.driver().graph("g");
ResultSet resultSet = client.query("CREATE ({name:'bsb'})");
Assertions.assertEquals(1, resultSet.getStatistics().nodesCreated());
}

@Test
public void createClientWithHostAndPort() {
client = FalkorDB.driver("localhost", 6379).graph("g");
client = FalkorDB.driver(getFalkordbHost(), getFalkordbPort()).graph("g");
ResultSet resultSet = client.query("CREATE ({name:'bsb'})");
Assertions.assertEquals(1, resultSet.getStatistics().nodesCreated());
}

@Test
public void createClientWithHostAndPortNoUser() {
client = FalkorDB.driver("localhost", 6379, null, null).graph("g");
client = FalkorDB.driver(getFalkordbHost(), getFalkordbPort(), null, null).graph("g");
ResultSet resultSet = client.query("CREATE ({name:'bsb'})");
Assertions.assertEquals(1, resultSet.getStatistics().nodesCreated());
}

@Test
public void createClientWithURL() {
client = FalkorDB.driver(URI.create("redis://localhost:6379")).graph("g");
client = FalkorDB.driver(URI.create(String.format("redis://%s:%d",
getFalkordbHost(), getFalkordbPort()))).graph("g");
ResultSet resultSet = client.query("CREATE ({name:'bsb'})");
Assertions.assertEquals(1, resultSet.getStatistics().nodesCreated());
}
Expand Down
42 changes: 42 additions & 0 deletions src/test/java/com/falkordb/test/BaseTestIT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.falkordb.test;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.utility.DockerImageName;

public class BaseTestIT {
private static final Logger log = LoggerFactory.getLogger(BaseTestIT.class);
public static final DockerImageName FALOKRDB_IMAGE = DockerImageName.parse("falkordb/falkordb:latest");

@Container
protected static GenericContainer<?> continerFalkordb;
private static final int falkordbPort = 6379; // Default port for Falkordb, adjust if necessary

@BeforeAll
public static void setUpContainer() {
continerFalkordb = new GenericContainer<>(FALOKRDB_IMAGE)
.withExposedPorts(falkordbPort)
.withLogConsumer(new Slf4jLogConsumer(log)); // Replace 6379 with Falkordb's default port if different
continerFalkordb.start();
}

@AfterAll
public static void tearDownContainer() {
if (continerFalkordb != null) {
continerFalkordb.stop();
}
}

protected int getFalkordbPort() {
return continerFalkordb.getFirstMappedPort();
}

protected String getFalkordbHost() {
return continerFalkordb.getHost();
}
}