Skip to content

test: add comprehensive RDF/RDFS mapping tests#413

Merged
kitelev merged 1 commit intomainfrom
feature/rdf-rdfs-mapping
Nov 12, 2025
Merged

test: add comprehensive RDF/RDFS mapping tests#413
kitelev merged 1 commit intomainfrom
feature/rdf-rdfs-mapping

Conversation

@kitelev
Copy link
Owner

@kitelev kitelev commented Nov 12, 2025

Summary

Adds comprehensive test coverage for ExoRDF to RDF/RDFS mapping functionality implemented in PR #406 (Task #367).

Changes

New Test Files

  1. InMemoryTripleStore.rdf-mapping.test.ts (19 tests)

    • Vocabulary triple generation and storage
    • Asset triple generation with RDF predicates
    • RDF/RDFS query patterns (rdf:type, rdfs:subClassOf, rdfs:subPropertyOf)
    • Transitive closure and circular hierarchy handling
    • Backward compatibility (ExoRDF + RDF/RDFS coexistence)
    • Edge cases (empty vocabulary, large datasets, deduplication)
  2. RDFMappingPerformance.test.ts (12 tests)

    • 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: <2.5x increase ✅
    • Deduplication efficiency ✅

Bug Fixes

  1. RDFVocabularyMapper.test.ts (from Task feat: Integrate ExoRDF to RDF/RDFS Mapping into SPARQL Triple Store #367)
    • Fixed TypeScript errors: Property 'value' does not exist on type 'Object'
    • Added IRI casting for union type properties
    • Fixed hash-style URI matching (#Class not /Class)

Test Summary

  • Total RDF Mapping Tests: 50 passing
    • RDFVocabularyMapper: 19 tests (fixed)
    • InMemoryTripleStore RDF Integration: 19 tests (new)
    • RDF Mapping Performance: 12 tests (new)

Definition of Done

  • Unit tests for InMemoryTripleStore RDF/RDFS integration (>80% coverage)
  • Performance tests for triple generation overhead
  • Edge case tests (circular hierarchies, large datasets, deduplication)
  • Backward compatibility tests (existing SPARQL queries still work)
  • All tests pass

Future Work (Not in Scope)

  • SPARQL query tests using RDF/RDFS predicates (will be in separate task)
  • E2E tests demonstrating semantic queries (will be in separate task)

Closes #368

Copilot AI review requested due to automatic review settings November 12, 2025 16:47
@kitelev kitelev enabled auto-merge (squash) November 12, 2025 16:47
- 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
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 RDFVocabularyMapper with 19 tests covering class/property hierarchy generation and triple mapping
  • Integration tests for InMemoryTripleStore RDF 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
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

[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.

Suggested change
const avgDuration = (endTime - startTime) / iterations / 2; // 2 calls per iteration
const totalCalls = iterations * 2; // 2 calls per iteration
const avgDuration = (endTime - startTime) / totalCalls;

Copilot uses AI. Check for mistakes.
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)
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

[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 variability

This clarifies that 2x is expected but 2.5x is allowed as a buffer.

Suggested change
// 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

Copilot uses AI. Check for mistakes.
@kitelev kitelev merged commit bbf5b61 into main Nov 12, 2025
8 checks passed
@kitelev kitelev deleted the feature/rdf-rdfs-mapping branch November 12, 2025 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: Add Tests for ExoRDF to RDF/RDFS Mapping

2 participants