mengw15 opened a new issue, #7559:
URL: https://github.com/apache/texera/issues/7559

   ### Task Summary
   
   `FileService.scala` 
(`file-service/src/main/scala/org/apache/texera/service/FileService.scala`) is 
at **25% coverage** with 39 uncovered lines. `FileServiceRunSpec` exists but 
only asserts role-annotation coverage on the resource classes; it never calls 
`run()`. (The separate `FileServiceSpec` covers the `awaitDependency` retry 
helper, not the bootstrap.)
   
   Covering `run()` moves the **file-service flag from 69.1% to roughly 77%**.
   
   **Goal: exercise `run()` against a mocked Dropwizard `Environment` and 
assert the wiring it installs**, then check the coverage report for anything 
left.
   
   ### Pattern to follow
   
   `AccessControlServiceRunSpec` already does exactly this and is the template 
(74 lines; mockito is already on the test classpath):
   
   ```scala
   val jersey   = mock(classOf[JerseyEnvironment])
   val servlets = mock(classOf[ServletEnvironment])
   val context  = mock(classOf[MutableServletContextHandler])
   val env      = mock(classOf[Environment])
   when(env.jersey).thenReturn(jersey)
   when(env.servlets).thenReturn(servlets)
   when(env.getApplicationContext).thenReturn(context)
   
when(jersey.getResourceConfig).thenReturn(DropwizardResourceConfig.forTesting())
   
   service.run(mock(classOf[XxxConfiguration]), env)
   
   verify(jersey).register(classOf[SomeResource])
   ```
   
   Keep the existing role-annotation assertions in the spec.
   
   ### Behavior to add
   
   Extend `FileServiceRunSpec` to call `run(config, env)` and verify:
   
   - `jersey.setUrlPattern("/api/*")`
   - `servlets.setSessionHandler(...)`
   - `jersey.register(classOf[HealthCheckResource])`
   - the file-service resource registrations (dataset / dataset-access 
endpoints)
   - the auth stack installed via `AuthFeatures.register(environment)`
   - `RequestLoggingFilter.register(environment.getApplicationContext)`
   
   Keep the existing `awaitDependency` tests in `FileServiceSpec` as they are.
   
   ### Scope note
   
   Cover **`run()` only**. Do **not** add tests for `initialize()`, `main()`, 
or the per-service `configFilePath` / `initConnection` helpers — #5983 
(`refactor(service): unify Dropwizard service bootstrap into common/auth`) 
moves exactly that boilerplate into a shared `ServiceBootstrap`, so tests 
written against it would be discarded. `run()` and its resource registrations 
stay put under that refactor (that PR's own description confirms the existing 
service specs still pass).
   
   ### 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]

Reply via email to