Skip to content

extend CollaborationResource unit test coverage (collaboration lock handling) #7228

Description

@mengw15

Task Summary

CollaborationResource (amber/src/main/scala/org/apache/texera/web/resource/CollaborationResource.scala, codecov ~62%) is a websocket collaboration endpoint. Bring it to full unit coverage. An earlier pass (#6900) covered the session lifecycle; the remaining uncovered lines are the collaboration lock-request handlingTryLockRequestcheckIsReadOnly → grant/reject via the in-memory session-holder maps (wIdLockHolderSessionIdMap, sessionIdWIdMap / sessionIdUIdMap). Test it the way the existing spec does — with a mocked javax.websocket.Session — and run the coverage report to cover the remaining red lines.

Behavior to add

Drive a TryLockRequest through myOnMsg with a mocked Session and seeded session maps, covering the lock branches:

  • DUMMY_WID session → immediately grants (WorkflowAccessEvent(readonly=false) + LockGrantedEvent).
  • read-only user (checkIsReadOnly true) → LockRejectedEvent + WorkflowAccessEvent(readonly=true).
  • writable user with no current holder (or the holder is the sender) → grantLock; writable user with a different holder → LockRejectedEvent.

checkIsReadOnly calls WorkflowAccessResource.hasWriteAccess (a DB lookup) — back it with a MockTexeraDB setup (seed a workflow_user_access row for the read/write cases) or stub that single access call. Explore the coverage output for any remaining unit-testable lines. No other infra.

Task Type

  • Refactor / Cleanup
  • DevOps / Deployment / CI
  • Testing / QA
  • Documentation
  • Performance
  • Other

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions