Feature/validate vehicle references - #948
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
There is at least one compile-blocking issue (unused import) and the current cache refresh wiring appears to call the vehicle registry even when the feature flag is disabled.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds an (intended) feature-flagged validation path for VehicleRef / VehicleTypeRef that checks references against a cached set fetched from the Vehicle Registry, plus operational plumbing to refresh that cache via scheduled jobs and an admin endpoint.
Changes:
- Introduces a vehicle-registry client + repository + Redis-backed cache and a leader-driven refresher job (
RefreshVehicleReferenceCache). - Wires the new
ReferenceToVehicleRegistryValidatorintoNetexReferenceValidatorbehindantu.netex.validation.vehicles.enabled. - Extends the cache-admin API and Helm configuration to support vehicle registry settings and refresh operations; adds tests around the new behavior.
File summaries
| File | Description |
|---|---|
| src/main/java/no/entur/antu/validation/validator/vehicletype/VehicleRefRepository.java | New repository interface for vehicle/vehicle-type reference lookups + cache refresh. |
| src/main/java/no/entur/antu/validation/validator/vehicletype/VehicleReferenceResource.java | WebClient-based fetch of allowed vehicle-related NeTEx IDs from Vehicle Registry. |
| src/main/java/no/entur/antu/validation/validator/vehicletype/DefaultVehicleRefRepository.java | Cache-backed implementation of VehicleRefRepository with refresh logic. |
| src/main/java/no/entur/antu/validation/validator/id/ReferenceToVehicleRegistryValidator.java | New external reference validator that accepts only known vehicle/vehicle-type refs. |
| src/main/java/no/entur/antu/pipeline/VehicleReferenceCacheRefresher.java | Leader-primed + scheduled refresh job enqueuer and executor for vehicle ref cache. |
| src/main/java/no/entur/antu/config/VehicleRegistryWebClientConfiguration.java | Adds an OAuth2-authorized WebClient for the vehicle registry. |
| src/main/java/no/entur/antu/config/VehicleConfig.java | Wires VehicleReferenceResource + VehicleRefRepository beans (non-test). |
| src/main/java/no/entur/antu/config/ValidatorConfig.java | Adds vehicle validator behind feature flag; otherwise keeps ignoring vehicle refs. |
| src/main/java/no/entur/antu/config/cache/CacheConfig.java | Adds Redis/Redisson-backed distributed set for vehicle references. |
| src/main/java/no/entur/antu/rest/CacheAdminController.java | Adds admin endpoint to enqueue vehicle cache refresh. |
| src/main/java/no/entur/antu/job/AntuJob.java | Adds RefreshVehicleReferenceCache job type. |
| src/main/java/no/entur/antu/job/JobType.java | Adds REFRESH_VEHICLE_REFERENCE_CACHE wire/job type. |
| src/main/java/no/entur/antu/job/JobDispatcher.java | Dispatches the new refresh job to VehicleReferenceCacheRefresher. |
| src/main/java/no/entur/antu/pubsub/JobMessageCodec.java | Encodes/decodes the new job type. |
| src/test/java/no/entur/antu/validation/validator/vehicletype/VehicleTypeRefCheckTest.java | Tests vehicle-type ref acceptance/rejection when vehicle validation is enabled. |
| src/test/java/no/entur/antu/validation/validator/vehicletype/VehicleTypeIgnorerTest.java | Updates test to reflect new validator wiring + feature flag off path. |
| src/test/java/no/entur/antu/validation/validator/vehicletype/VehicleReferenceResourceTest.java | Tests WebClient parsing + error behavior for vehicle registry fetch. |
| src/test/java/no/entur/antu/validation/validator/vehicletype/DefaultVehicleReferenceRepositoryTest.java | Tests cache semantics for the default repository implementation. |
| src/test/java/no/entur/antu/pipeline/VehicleReferenceCacheRefresherTest.java | Tests priming/leader scheduling/enqueue/containment behavior of refresher. |
| src/test/java/no/entur/antu/rest/CacheAdminControllerTest.java | Extends controller test coverage for the new refresh endpoint and auth. |
| src/test/java/no/entur/antu/job/JobDispatcherTest.java | Extends dispatcher tests to include the new refresh job. |
| src/test/java/no/entur/antu/config/TestConfig.java | Adds a test VehicleRefRepository bean override. |
| src/test/http/antu.pubsub.http | Adds example PubSub publish payload for datasets with vehicle references. |
| helm/antu/templates/configmap.yaml | Adds vehicle registry URL + feature flag property wiring. |
| helm/antu/templates/external-secrets-auth0.yaml | Adds secret mapping for sobek client credentials. |
| helm/antu/env/values-kub-ent-dev.yaml | Enables feature flag in dev + sets vehicle registry URL. |
| helm/antu/env/values-kub-ent-tst.yaml | Disables feature flag in tst + sets vehicle registry URL. |
| helm/antu/env/values-kub-ent-prd.yaml | Disables feature flag in prd + sets vehicle registry URL. |
Review details
- Files reviewed: 28/28 changed files
- Comments generated: 6
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…ystem, using DummyVehicleRefRepository when vehicle reference validation is disabled
|



Adds validation of vehicle and vehicle type references against a real registry.
This validation is opitional, guarded by a feature flag. It's enabled in dev and disabled in tst and prd