test: add comprehensive RDF/RDFS mapping tests#413
Conversation
- Add 19 integration tests for InMemoryTripleStore RDF/RDFS mapping - Vocabulary triple generation and storage - Asset triple generation with RDF predicates - RDF/RDFS query patterns (rdf:type, rdfs:subClassOf, etc.) - Transitive closure and circular hierarchy handling - Backward compatibility (ExoRDF + RDF/RDFS) - Edge cases (empty vocabulary, large datasets, deduplication) - Add 12 performance tests for RDF mapping - Vocabulary generation: <1ms average - Triple store loading: <0.5ms per triple - Query performance: <10ms for type queries, <5ms for hierarchy - Mapped triple generation: <0.1ms per triple - Memory usage validation: <2.5x increase - Deduplication efficiency: <100ms for 1000 ops - Fix TypeScript errors in RDFVocabularyMapper.test.ts - Add IRI casting for union type properties - Fix hash-style URI matching (#Class not /Class) Total: 50 RDF mapping tests passing (19 + 12 + 19 fixed) Closes #368
44911a1 to
7ec6b45
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive test coverage for the RDF/RDFS mapping functionality, introducing 50 new tests across three test files to validate the ExoRDF to standard RDF/RDFS vocabulary mapping.
Key Changes:
- Comprehensive unit tests for
RDFVocabularyMapperwith 19 tests covering class/property hierarchy generation and triple mapping - Integration tests for
InMemoryTripleStoreRDF mapping with 19 tests validating storage, querying, and backward compatibility - Performance benchmark suite with 12 tests ensuring mapping overhead stays within acceptable limits (<1ms vocabulary generation, <10ms queries)
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
packages/core/tests/unit/infrastructure/rdf/RDFVocabularyMapper.test.ts |
New unit test file (261 lines) testing vocabulary mapper functionality including class/property hierarchies, mapped triple generation, and edge cases with proper IRI type casting |
packages/core/tests/unit/infrastructure/rdf/InMemoryTripleStore.rdf-mapping.test.ts |
New integration test file (437 lines) validating RDF/RDFS integration with triple store including vocabulary storage, query patterns, transitive closure, backward compatibility, and edge cases |
packages/core/tests/performance/RDFMappingPerformance.test.ts |
New performance test file (295 lines) benchmarking vocabulary generation, triple store loading, query performance, memory usage, and deduplication efficiency |
packages/core/src/infrastructure/rdf/RDFVocabularyMapper.ts |
New implementation class (157 lines) providing RDF/RDFS vocabulary mapping with property mappings and triple generation methods |
packages/core/src/index.ts |
Updated exports to include RDFVocabularyMapper for public API access |
Comments suppressed due to low confidence (1)
packages/core/tests/unit/infrastructure/rdf/RDFVocabularyMapper.test.ts:2
- Unused import Namespace.
import { Namespace } from "../../../../src/domain/models/rdf/Namespace";
| } | ||
|
|
||
| const endTime = performance.now(); | ||
| const avgDuration = (endTime - startTime) / iterations / 2; // 2 calls per iteration |
There was a problem hiding this comment.
[nitpick] The average duration calculation on line 221 divides by iterations / 2 because there are 2 calls per iteration, but this could be confusing. Consider clarifying this calculation or restructuring the test to make it more explicit:
const totalCalls = iterations * 2; // 2 calls per iteration
const avgDuration = (endTime - startTime) / totalCalls;This makes the intent clearer and aligns with the comment on line 221.
| const avgDuration = (endTime - startTime) / iterations / 2; // 2 calls per iteration | |
| const totalCalls = iterations * 2; // 2 calls per iteration | |
| const avgDuration = (endTime - startTime) / totalCalls; |
| const withMappingSize = (await store.match(undefined, undefined, undefined)) | ||
| .length; | ||
|
|
||
| // Memory increase should be exactly 100 triples (100% increase, but that's expected for dual representation) |
There was a problem hiding this comment.
[nitpick] The comment on line 260 states "Memory increase should be exactly 100 triples" but the assertion on line 262 allows for up to 2.5x increase. While this provides a safety margin for performance tests, the comment is misleading. Consider updating the comment to reflect the actual assertion:
// Memory increase should be exactly 100 triples (2x baseline),
// with 2.5x as upper bound to account for test environment variabilityThis clarifies that 2x is expected but 2.5x is allowed as a buffer.
| // Memory increase should be exactly 100 triples (100% increase, but that's expected for dual representation) | |
| // Memory increase should be exactly 100 triples (2x baseline), | |
| // with 2.5x as upper bound to account for test environment variability |
Summary
Adds comprehensive test coverage for ExoRDF to RDF/RDFS mapping functionality implemented in PR #406 (Task #367).
Changes
New Test Files
InMemoryTripleStore.rdf-mapping.test.ts (19 tests)
RDFMappingPerformance.test.ts (12 tests)
Bug Fixes
#Classnot/Class)Test Summary
Definition of Done
Future Work (Not in Scope)
Closes #368