eugenegujing opened a new pull request, #6473:
URL: https://github.com/apache/texera/pull/6473

   ### What changes were proposed in this PR?
   
   This PR adds unit test coverage for the URI parsing in `DatasetFileDocument` 
(`common/workflow-core`). Every dataset file read in the engine goes through 
this parsing — the constructor splits a 
`dataset:///{repositoryName}/{versionHash}/{fileRelativePath}` URI into its 
three components — yet the class previously had zero references in the test 
tree.
   
   The new `DatasetFileDocumentSpec` (10 tests, constructor + getters only, no 
I/O) covers:
   
   - Parsing a valid 3-segment dataset URI into repository name, version hash, 
and relative file path, plus joining of multi-segment relative paths (expected 
paths built with `Paths.get` so assertions are platform-separator independent).
   - URL decoding that mirrors how `FileResolver` builds these URIs in 
production (URLEncoder-encoded segments assembled with the multi-argument `URI` 
constructor): percent-escapes and bare `+` in the version hash and in each 
relative-path segment decode exactly once, including a non-ASCII UTF-8 
file-name round trip.
   - The four getters (`getRepositoryName`, `getVersionHash`, 
`getFileRelativePath`, `getURI`), asserting `getURI` returns the original URI 
unchanged.
   - Current edge-case behavior, pinned deliberately: the repository name is 
not URL-decoded (matching `FileResolver`, which encodes only the relative-path 
segments), redundant and trailing slashes are collapsed by `Paths.get` before 
segment counting, and dot segments (`.` / `..`) are preserved without 
normalization — marked "(current behavior)" in the test rather than endorsed.
   - The error path: URIs with fewer than three path segments (0, 1, 2, and a 
trailing-slash form that looks like 3 but yields 2) throw 
`IllegalArgumentException` with the message "URI format is incorrect".
   
   The spec lives in the `org.apache.texera.amber.core.storage.model` package 
so it can construct the `private[storage]` class directly. No test touches 
`asInputStream`, `asFile`, or `clear`, so the suite runs without network, 
LakeFS, or environment-variable dependencies. Test-only change — no production 
code modified, no UI change.
   
   ### Any related issues, documentation, discussions?
   
   Closes #6441
   
   ### How was this PR tested?
   
   - `sbt "WorkflowCore/testOnly 
org.apache.texera.amber.core.storage.model.DatasetFileDocumentSpec"` — 10/10 
pass (suite runs in ~170 ms).
   - Mutation-checked during development: deliberately breaking individual 
assertions made exactly the corresponding tests fail, then restored to green, 
confirming each assertion constrains the implementation.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   Co-authored using Claude Code(Fable 5)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to