# TASK 2.4: Add Unit Tests And Live E2E Validation For Extract Raw

## Summary

Add the required verification layer for the first real ETL boundary. This subtask closes `TASK 2` by proving both locally and against real integrations that `extract_raw` works for Brink orders.

The verification split must respect the architectural boundary:

- Brink integration tests validate the adapter against explicit test connection context
- Warehouse/ETL tests validate binding resolution, orchestration, S3 persistence, and stage semantics

## Dependencies

- [TASK 2.1](./TASK2.1.md) - child extract orchestration and business-date resolution
- [TASK 2.2](./TASK2.2.md) - Brink raw capture boundary
- [TASK 2.3](./TASK2.3.md) - S3 raw persistence and persisted-raw validation

## Files to Create

### 1. Extract-stage test coverage

Create or finalize the test suites needed for:

- unit coverage of orchestration and validation rules
- live E2E coverage of real Brink extraction and S3 persistence
- adapter tests that do not require operational DB coupling inside `Kds.Ai.Integrations.BrinkPos`

## Required Behavior

- unit tests must cover the final `extract_raw` flow assembled from `TASK 2.1`-`TASK 2.3`
- live E2E must verify the real integration path whenever Aspire-managed secrets are available
- the live test should prove that the real Brink call results in a persisted raw S3 object that passes validation
- integration adapter tests should run with explicit `BrinkConnectionDefinition` or equivalent bound-client setup rather than repository-backed tenant resolution inside the integration module

## Testing

### Unit tests

Ensure the final unit suite covers:

- Warehouse-side binding resolution handoff
- business-date routing
- raw-client routing
- persisted-raw validation semantics
- diagnostics recording

### Live E2E

Add a live E2E test that verifies at least:

- real Brink connection resolution
- `GetCurrentBusinessDate` when no explicit date is provided
- real `GetOrders` call
- persisted raw XML in S3 `raw/`
- successful read-back validation of the persisted object
- the tested ETL path uses Warehouse/app-layer binding resolution rather than DB-coupled resolution inside `Kds.Ai.Integrations.BrinkPos`

## Acceptance Criteria

- [ ] Unit-test coverage exists for the assembled `extract_raw` flow
- [ ] Live E2E exists for real Brink extraction and S3 raw persistence
- [ ] Live E2E verifies that the persisted object can be validated successfully
- [ ] Integration adapter tests no longer depend on Warehouse/Data-backed connection resolution inside `Kds.Ai.Integrations.BrinkPos`
- [ ] `TASK 2` is verifiable as a completed ETL stage

## Notes

- This subtask is mandatory because `extract_raw` is a finished ETL boundary.
- Keep integration-adapter verification separate from Warehouse orchestration verification.
- If live E2E cannot run in one environment, document the blocker explicitly instead of silently skipping it.
