-
Notifications
You must be signed in to change notification settings - Fork 0
Phase 1: Setup Testcontainers Infrastructure for Vector Search Tests #528
Copy link
Copy link
Closed
Description
Overview
Create Testcontainers infrastructure to replace Mockito mocks with real production code for better test coverage and lower maintenance.
Priority: HIGH
Estimated Time: Week 1
Context
After analyzing both approaches (see PHASE1_COMPARISON.md), we chose Testcontainers + Real Production Code instead of in-memory stubs because:
- ✅ Lower implementation cost (5h vs 10h)
- ✅ Better bug detection (catches SQL errors, schema issues, vector index config)
- ✅ Less code to maintain (~50 lines vs ~200 lines)
- ✅ Reuses production code (
ContentPersistenceAdapter,ArcadeContentRepository)
Tasks
1.1 Create ArcadeDB Testcontainer
File: src/test/java/it/robfrank/linklift/testcontainers/ArcadeDbContainer.java
Create a reusable Testcontainer for ArcadeDB that handles:
- Database lifecycle management
- Schema initialization (Content vertex type, vector index)
- Wait strategy for container readiness
- Helper methods for database creation and cleanup
Key Features:
- Vector index:
LSM_TREE METRIC COSINE DIMENSIONS 384 - Exposes methods:
getHttpUrl(),getRootPassword(),createDatabase(),cleanDatabase()
1.2 Create Base Test Class
File: src/test/java/it/robfrank/linklift/testcontainers/ArcadeDbTestBase.java
Abstract base class that:
- Manages shared Testcontainer lifecycle (
@Containerstatic field) - Sets up real
ContentPersistenceAdapterandArcadeContentRepositoryin@BeforeEach - Cleans database between tests in
@AfterEach - Provides
repositoryfield for test classes
1.3 Create FakeEmbeddingGenerator
File: src/test/java/it/robfrank/linklift/adapter/out/ai/FakeEmbeddingGenerator.java
Deterministic fake implementation to replace mocked EmbeddingGenerator:
- Generates consistent 384-dimensional embeddings based on text hash
- Provides test helpers:
throwOnNextCall(),clearCache(),getCacheSize() - No randomness - same text always produces same embedding
1.4 Update Dependencies
File: pom.xml
Add dependencies:
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.19.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>1.19.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.2.0</version>
<scope>test</scope>
</dependency>1.5 Verify Infrastructure
- Container starts successfully
- Schema initializes correctly
- Vector index is created with correct configuration
- Database cleanup works between tests
- Create test resource directory for WireMock (future use)
Success Criteria
-
ArcadeDbContainerstarts and initializes schema -
ArcadeDbTestBaseprovides workingrepositoryfield -
FakeEmbeddingGeneratorproduces deterministic embeddings - All dependencies added to pom.xml
- Infrastructure verified with simple test
Related
- See
PHASE1_COMPARISON.mdfor detailed analysis - See
TEST_REFACTORING_PLAN.mdfor full plan - Blocks: Phase 2 (Refactor Service Tests)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels