mengw15 opened a new issue, #7876: URL: https://github.com/apache/texera/issues/7876
### Task Summary `DatasetResource` sits at **62.06 % with 86 uncovered lines** — the single largest coverage gap left in the repository. A cluster of its endpoints is never called at all, and this issue covers the half that needs **no external service**: the publicity/downloadable toggles, the description update, the public version list, and the owner/version listing helpers behind them. `DatasetResourceSpec` already provides the whole harness — it extends `MockTexeraDB` (embedded Postgres, `initializeDBAndReplaceDSLContext()`), seeds users and datasets through the generated DAOs, and instantiates `new DatasetResource()` directly — so this is a pure EXTEND, no new infrastructure. ### Behavior to add **`DatasetResource`** (`file-service/src/main/scala/org/apache/texera/service/resource/DatasetResource.scala`, codecov 62.06 % — EXTEND `DatasetResourceSpec`) Each endpoint below opens `withTransaction(context)`, performs an authorization check that throws `ForbiddenException`, then reads or writes through jOOQ. Cover **both** the authorized path and the rejection, since the guard is where the uncovered branch usually is. - `toggleDatasetPublicity` (line 1083) — checks `userHasWriteAccess(ctx, did, uid)` and otherwise throws `ForbiddenException(ERR_USER_HAS_NO_ACCESS_TO_DATASET_MESSAGE)`; on success it flips `isPublic` on the existing dataset and calls `datasetDao.update`. Assert the persisted flag flips on the second call as well (it is a toggle, not a setter), and that a user without write access is rejected. - `toggleDatasetDownloadable` (line 1107) — same shape against the downloadable flag. - `updateDatasetDescription` (line 566) — assert the new description is persisted and that a caller without write access is refused. - `getPublicDatasetVersionList` (line 1317) — guarded by `isDatasetPublic(ctx, did)` rather than by user access; assert it returns the versions for a public dataset and throws `ForbiddenException` for a private one. - `retrieveOwners` (lines 1513–1521) and `fetchDatasetVersions` (lines 1533–1537) — the helpers the endpoints above delegate to. Seed two datasets with different owners and several versions so the mapping and ordering are exercised rather than a single-row happy path. Determinism notes: - Seed every row the assertion depends on inside the test; do not rely on data another test left behind, and reset mutated fixtures between tests. - Assert on the persisted value re-read through the DAO, not on the object you passed in. - Do not assert on generated timestamps — insert them explicitly if a test needs to order by time. Out of scope for this issue: everything that reaches LakeFS or S3 (the presigned-download endpoints, the version file-node reads, the zip export). Those are covered separately. Verify locally before opening the PR: `sbt FileService/testOnly *DatasetResourceSpec`, plus `scalafmtCheck` and `scalafix --check`. ### Task Type - [ ] Refactor / Cleanup - [ ] DevOps / Deployment / CI - [x] Testing / QA - [ ] Documentation - [ ] Performance - [ ] Other -- 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]
