|
| 1 | +# Testing Guide |
| 2 | + |
| 3 | +## Run all tests |
| 4 | + |
| 5 | +```bash |
| 6 | +./mvnw test |
| 7 | +``` |
| 8 | + |
| 9 | +Runs all 97 tests (unit + integration). Integration tests use Testcontainers to spin up Neo4j automatically — no local Neo4j needed. |
| 10 | + |
| 11 | +## Run specific test classes |
| 12 | + |
| 13 | +```bash |
| 14 | +# Single class |
| 15 | +./mvnw test -Dtest=IngestionResultTest |
| 16 | + |
| 17 | +# Multiple classes |
| 18 | +./mvnw test -Dtest="IngestionResultTest,IngestionRunnerTest,DataManagerControllerTest" |
| 19 | + |
| 20 | +# Single method |
| 21 | +./mvnw test -Dtest="IngestionRunnerTest#summary banner contains URL results" |
| 22 | +``` |
| 23 | + |
| 24 | +## Test coverage by area |
| 25 | + |
| 26 | +### Ingestion pipeline (new) |
| 27 | + |
| 28 | +| Test class | Type | What it covers | |
| 29 | +|---|---|---| |
| 30 | +| `IngestionResultTest` | Unit | `IngestionResult` record: totals, `hasFailures()`, duration | |
| 31 | +| `IngestionRunnerTest` | Unit | `IngestionRunner`: calls `loadReferences`, prints banner with URLs/dirs/stats/port, `formatDuration` | |
| 32 | +| `DataManagerControllerTest` | Unit | REST endpoints: `GET /stats`, `POST /load-references` returns `IngestionResult` | |
| 33 | +| `DataManagerLoadReferencesIntegrationTest` | Integration | Full pipeline: DataManager → Neo4j. Ingests sample directory, verifies structured result + documents/chunks in store | |
| 34 | + |
| 35 | +Run just these: |
| 36 | + |
| 37 | +```bash |
| 38 | +./mvnw test -Dtest="IngestionResultTest,IngestionRunnerTest,DataManagerControllerTest,DataManagerLoadReferencesIntegrationTest" |
| 39 | +``` |
| 40 | + |
| 41 | +### Other test areas |
| 42 | + |
| 43 | +| Test class | Type | What it covers | |
| 44 | +|---|---|---| |
| 45 | +| `GuidePropertiesPathResolutionTest` | Unit | Path resolution (`~/`, absolute, relative) | |
| 46 | +| `HubApiControllerTest` | Integration | Hub REST API (register, login, sessions, JWT) | |
| 47 | +| `HubServiceTest` | Integration | User registration validation | |
| 48 | +| `DrivineGuideUserRepositoryTest` | Integration | Neo4j user repository (Drivine) | |
| 49 | +| `GuideUserRepositoryDefaultImplTest` | Integration | Neo4j user repository (GraphView) | |
| 50 | +| `GuideUserServiceTest` | Integration | Anonymous web user service | |
| 51 | +| `McpSecurityTest` | Integration | MCP endpoints are publicly accessible | |
| 52 | + |
| 53 | +## Using local Neo4j (faster iteration) |
| 54 | + |
| 55 | +By default, tests use Testcontainers (slower startup, fully isolated). For faster runs during development: |
| 56 | + |
| 57 | +1. Start Neo4j: |
| 58 | + |
| 59 | +```bash |
| 60 | +docker compose up neo4j -d |
| 61 | +``` |
| 62 | + |
| 63 | +2. Run tests with local Neo4j: |
| 64 | + |
| 65 | +```bash |
| 66 | +USE_LOCAL_NEO4J=true ./mvnw test |
| 67 | +``` |
| 68 | + |
| 69 | +## Manual testing of fresh-ingest.sh |
| 70 | + |
| 71 | +To test the full ingestion flow end-to-end: |
| 72 | + |
| 73 | +1. Set up your `.env` and personal profile (see `scripts/README.md`) |
| 74 | +2. Run: |
| 75 | + |
| 76 | +```bash |
| 77 | +./scripts/fresh-ingest.sh |
| 78 | +``` |
| 79 | + |
| 80 | +3. Watch for the **INGESTION COMPLETE** banner with: |
| 81 | + - Time elapsed |
| 82 | + - Loaded/failed URLs |
| 83 | + - Ingested/failed directories |
| 84 | + - RAG store stats (documents, chunks, elements) |
| 85 | + - Port and MCP endpoint |
| 86 | + |
| 87 | +4. Verify the REST API: |
| 88 | + |
| 89 | +```bash |
| 90 | +# Stats |
| 91 | +curl http://localhost:1337/api/v1/data/stats |
| 92 | + |
| 93 | +# Trigger ingestion manually (returns JSON IngestionResult) |
| 94 | +curl -X POST http://localhost:1337/api/v1/data/load-references |
| 95 | +``` |
| 96 | + |
| 97 | +5. Verify MCP: |
| 98 | + |
| 99 | +```bash |
| 100 | +curl -i --max-time 3 http://localhost:1337/sse |
| 101 | +``` |
| 102 | + |
| 103 | +Should return `Content-Type: text/event-stream`. |
0 commit comments