Skip to content
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 @@ -62,13 +62,13 @@
<!-- test dependencies -->
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<artifactId>testcontainers-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>neo4j</artifactId>
<artifactId>testcontainers-neo4j</artifactId>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<!-- test dependencies -->
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<artifactId>testcontainers-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

Expand Down
4 changes: 2 additions & 2 deletions embedding-stores/langchain4j-community-alloydb-pg/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@

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

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<artifactId>testcontainers-postgresql</artifactId>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.langchain4j.community.store.embedding.alloydb;

import static org.testcontainers.shaded.org.apache.commons.lang3.RandomUtils.nextInt;
import static org.apache.commons.lang3.RandomUtils.nextInt;

import dev.langchain4j.community.store.embedding.alloydb.index.DistanceStrategy;
import dev.langchain4j.data.segment.TextSegment;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.langchain4j.community.store.embedding.alloydb;

import static org.testcontainers.shaded.org.apache.commons.lang3.RandomUtils.nextInt;
import static org.apache.commons.lang3.RandomUtils.nextInt;

import dev.langchain4j.community.store.embedding.alloydb.index.DistanceStrategy;
import dev.langchain4j.data.segment.TextSegment;
Expand Down
2 changes: 1 addition & 1 deletion embedding-stores/langchain4j-community-clickhouse/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>clickhouse</artifactId>
<artifactId>testcontainers-clickhouse</artifactId>
<scope>test</scope>
</dependency>

Expand Down
4 changes: 2 additions & 2 deletions embedding-stores/langchain4j-community-cloud-sql-pg/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,13 @@

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

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<artifactId>testcontainers-postgresql</artifactId>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.langchain4j.community.store.embedding.cloudsql;

import static org.testcontainers.shaded.org.apache.commons.lang3.RandomUtils.nextInt;
import static org.apache.commons.lang3.RandomUtils.nextInt;

import dev.langchain4j.community.store.embedding.cloudsql.index.DistanceStrategy;
import dev.langchain4j.data.segment.TextSegment;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.langchain4j.community.store.embedding.cloudsql;

Check failure on line 1 in embedding-stores/langchain4j-community-cloud-sql-pg/src/test/java/dev/langchain4j/community/store/embedding/cloudsql/PostgresEmbeddingStoreRemovalIT.java

View workflow job for this annotation

GitHub Actions / java_build (21)

PostgresEmbeddingStoreRemovalIT.should_fail_to_remove_by_id(String)[1]

Expecting actual throwable to be exactly an instance of: java.lang.IllegalArgumentException but was: java.lang.NullPointerException: Cannot invoke "dev.langchain4j.store.embedding.EmbeddingStore.remove(String)" because the return value of "dev.langchain4j.store.embedding.EmbeddingStoreWithRemovalIT.embeddingStore()" is null at dev.langchain4j.store.embedding.EmbeddingStoreWithRemovalIT.lambda$should_fail_to_remove_by_id$0(EmbeddingStoreWithRemovalIT.java:56) at org.assertj.core.api.ThrowableAssert.catchThrowable(ThrowableAssert.java:63) at org.assertj.core.api.AssertionsForClassTypes.catchThrowable(AssertionsForClassTypes.java:904) ...(114 remaining lines not displayed - this can be changed with Assertions.setMaxStackTraceElementsDisplayed)

import static org.testcontainers.shaded.org.apache.commons.lang3.RandomUtils.nextInt;
import static org.apache.commons.lang3.RandomUtils.nextInt;

import dev.langchain4j.community.store.embedding.cloudsql.index.DistanceStrategy;
import dev.langchain4j.data.segment.TextSegment;
Expand Down
7 changes: 3 additions & 4 deletions embedding-stores/langchain4j-community-neo4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,15 @@
</dependency>

<!-- test dependencies -->

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

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>neo4j</artifactId>
<artifactId>testcontainers-neo4j</artifactId>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -127,7 +126,7 @@

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>selenium</artifactId>
<artifactId>testcontainers-selenium</artifactId>
<scope>test</scope>
</dependency>

Expand Down
10 changes: 8 additions & 2 deletions embedding-stores/langchain4j-community-sqlserver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,21 @@
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<artifactId>testcontainers-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mssqlserver</artifactId>
<artifactId>testcontainers-mssqlserver</artifactId>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
import java.util.*;
import java.util.Collection;
import java.util.Objects;
import java.util.function.BiFunction;
import java.util.stream.Collectors;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import static dev.langchain4j.store.embedding.TestUtils.awaitUntilAsserted;
import static dev.langchain4j.store.embedding.sqlserver.util.SQLServerTestsUtil.DEFAULT_CONTAINER;
import static dev.langchain4j.store.embedding.sqlserver.util.SQLServerTestsUtil.getSqlServerDataSource;
import static org.apache.commons.lang3.RandomUtils.nextInt;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.data.Percentage.withPercentage;
import static org.testcontainers.shaded.org.apache.commons.lang3.RandomUtils.nextInt;

import dev.langchain4j.data.embedding.Embedding;
import dev.langchain4j.data.segment.TextSegment;
Expand All @@ -21,14 +21,14 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.testcontainers.junit.jupiter.Testcontainers;

@Testcontainers
public class SQLServerCatalogSchemaEmbeddingStoreIT extends EmbeddingStoreWithFilteringIT {
class SQLServerCatalogSchemaEmbeddingStoreIT extends EmbeddingStoreWithFilteringIT {

static String tableName = "test_" + nextInt(1000, 2000);
static EmbeddingModel embeddingModel = new AllMiniLmL6V2QuantizedEmbeddingModel();
Expand All @@ -44,7 +44,7 @@ public class SQLServerCatalogSchemaEmbeddingStoreIT extends EmbeddingStoreWithFi
.build();

@Test
public void test_unicode_embeddings() {
void unicode_embeddings() {

TextSegment[] segments = SQLServerTestsUtil.japaneseSampling();
List<Embedding> embeddings = new ArrayList<>(segments.length);
Expand All @@ -54,7 +54,7 @@ public void test_unicode_embeddings() {
}

List<String> ids = embeddingStore().addAll(embeddings, Arrays.asList(segments));
awaitUntilAsserted(() -> assertThat(getAllEmbeddings()).hasSize(segments.length));
awaitUntilAsserted(() -> assertThat(getAllEmbeddings()).hasSameSizeAs(segments));

EmbeddingSearchRequest searchRequest = EmbeddingSearchRequest.builder()
.queryEmbedding(embeddings.get(0))
Expand All @@ -77,7 +77,7 @@ public void test_unicode_embeddings() {
}

@Test
public void test_unicode_metadata() {
void unicode_metadata() {
TextSegment[] segments = SQLServerTestsUtil.japaneseSampling();
List<Embedding> embeddings = new ArrayList<>(segments.length);
for (TextSegment segment : segments) {
Expand All @@ -88,7 +88,7 @@ public void test_unicode_metadata() {
Embedding emb = embeddingModel().embed("Test embedding").content();

embeddingStore().addAll(embeddings, Arrays.asList(segments));
awaitUntilAsserted(() -> assertThat(getAllEmbeddings()).hasSize(segments.length));
awaitUntilAsserted(() -> assertThat(getAllEmbeddings()).hasSameSizeAs(segments));

EmbeddingSearchRequest searchRequest = EmbeddingSearchRequest.builder()
.queryEmbedding(emb)
Expand Down Expand Up @@ -125,18 +125,18 @@ protected void clearStore() {
}
}

@Before
public void before() {
@BeforeEach
void before() {
clearStore();
}

@After
public void after() {
@AfterEach
void after() {
clearStore();
}

@AfterAll
public static void afterClass() {
static void afterClass() {
DEFAULT_CONTAINER.stop();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package dev.langchain4j.store.embedding.sqlserver;

import static dev.langchain4j.store.embedding.sqlserver.util.SQLServerTestsUtil.getSqlServerDataSource;
import static org.junit.jupiter.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;

import com.microsoft.sqlserver.jdbc.SQLServerDataSource;
import dev.langchain4j.data.embedding.Embedding;
Expand All @@ -26,7 +27,7 @@ void basic_config_test() {
.dimension(4)
.build())
.build();
assertNotNull(embeddingStore);
assertThat(embeddingStore).isNotNull();
}

@Test
Expand All @@ -52,7 +53,7 @@ void should_create_table_with_json_indexes() {
.build();

// Test that store was created successfully
assertNotNull(embeddingStore);
assertThat(embeddingStore).isNotNull();
}

@Test
Expand All @@ -76,14 +77,14 @@ void should_create_table_with_ordered_json_index() {
.build();

// Test that store was created successfully
assertNotNull(embeddingStore);
assertThat(embeddingStore).isNotNull();

// Test basic functionality
Embedding embedding = new Embedding(new float[] {0.1f, 0.2f, 0.3f, 0.4f});
TextSegment textSegment = TextSegment.from("test text");

String id = embeddingStore.add(embedding, textSegment);
assertNotNull(id);
assertThat(id).isNotNull();
}

@Test
Expand All @@ -93,6 +94,6 @@ void should_detect_sql_injection() {
.dimension(4);

// Test that store was created successfully
assertThrows(IllegalArgumentException.class, embeddingTable::build);
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(embeddingTable::build);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import static dev.langchain4j.store.embedding.TestUtils.awaitUntilAsserted;
import static dev.langchain4j.store.embedding.sqlserver.util.SQLServerTestsUtil.DEFAULT_CONTAINER;
import static dev.langchain4j.store.embedding.sqlserver.util.SQLServerTestsUtil.getSqlServerDataSource;
import static org.apache.commons.lang3.RandomUtils.nextInt;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.data.Percentage.withPercentage;
import static org.testcontainers.shaded.org.apache.commons.lang3.RandomUtils.nextInt;

import dev.langchain4j.data.embedding.Embedding;
import dev.langchain4j.data.segment.TextSegment;
Expand All @@ -21,14 +21,14 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.testcontainers.junit.jupiter.Testcontainers;

@Testcontainers
public class SQLServerEmbeddingStoreIT extends EmbeddingStoreWithFilteringIT {
class SQLServerEmbeddingStoreIT extends EmbeddingStoreWithFilteringIT {

static String tableName = "test_" + nextInt(1000, 2000);
static EmbeddingModel embeddingModel = new AllMiniLmL6V2QuantizedEmbeddingModel();
Expand All @@ -42,7 +42,7 @@ public class SQLServerEmbeddingStoreIT extends EmbeddingStoreWithFilteringIT {
.build();

@Test
public void test_unicode_embeddings() {
void unicode_embeddings() {

TextSegment[] segments = SQLServerTestsUtil.japaneseSampling();
List<Embedding> embeddings = new ArrayList<>(segments.length);
Expand All @@ -52,7 +52,7 @@ public void test_unicode_embeddings() {
}

List<String> ids = embeddingStore().addAll(embeddings, Arrays.asList(segments));
awaitUntilAsserted(() -> assertThat(getAllEmbeddings()).hasSize(segments.length));
awaitUntilAsserted(() -> assertThat(getAllEmbeddings()).hasSameSizeAs(segments));

EmbeddingSearchRequest searchRequest = EmbeddingSearchRequest.builder()
.queryEmbedding(embeddings.get(0))
Expand All @@ -75,7 +75,7 @@ public void test_unicode_embeddings() {
}

@Test
public void test_unicode_metadata() {
void unicode_metadata() {
TextSegment[] segments = SQLServerTestsUtil.japaneseSampling();
List<Embedding> embeddings = new ArrayList<>(segments.length);
for (TextSegment segment : segments) {
Expand All @@ -86,7 +86,7 @@ public void test_unicode_metadata() {
Embedding emb = embeddingModel().embed("Test embedding").content();

embeddingStore().addAll(embeddings, Arrays.asList(segments));
awaitUntilAsserted(() -> assertThat(getAllEmbeddings()).hasSize(segments.length));
awaitUntilAsserted(() -> assertThat(getAllEmbeddings()).hasSameSizeAs(segments));

EmbeddingSearchRequest searchRequest = EmbeddingSearchRequest.builder()
.queryEmbedding(emb)
Expand Down Expand Up @@ -123,18 +123,18 @@ protected void clearStore() {
}
}

@Before
public void before() {
@BeforeEach
void before() {
clearStore();
}

@After
public void after() {
@AfterEach
void after() {
clearStore();
}

@AfterAll
public static void afterClass() {
static void afterClass() {
DEFAULT_CONTAINER.stop();
}
}
Loading
Loading