mengw15 commented on code in PR #7561:
URL: https://github.com/apache/texera/pull/7561#discussion_r3760937590


##########
workflow-compiling-service/src/test/scala/org/apache/texera/service/WorkflowCompilingServiceRunSpec.scala:
##########
@@ -19,13 +19,63 @@
 
 package org.apache.texera.service
 
-import org.apache.texera.auth.RoleAnnotationEnforcer
+import io.dropwizard.core.setup.Environment
+import io.dropwizard.jersey.DropwizardResourceConfig
+import io.dropwizard.jersey.setup.JerseyEnvironment
+import io.dropwizard.jetty.MutableServletContextHandler
+import io.dropwizard.jetty.setup.ServletEnvironment
+import org.apache.texera.auth.{RoleAnnotationEnforcer, 
UnauthorizedExceptionMapper}
 import org.apache.texera.service.resource.{HealthCheckResource, 
WorkflowCompilationResource}
+import org.eclipse.jetty.servlet.FilterHolder
+import org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature
+import org.mockito.ArgumentMatchers.{any, eq => eqTo, isA}
+import org.mockito.Mockito.{mock, verify, when}
 import org.scalatest.flatspec.AnyFlatSpec
 import org.scalatest.matchers.should.Matchers
 
 class WorkflowCompilingServiceRunSpec extends AnyFlatSpec with Matchers {
 
+  // Mirrors AccessControlServiceRunSpec: run() is driven against a mocked 
Dropwizard
+  // environment so the wiring it installs can be asserted without starting a 
server.
+  private def runService(): (JerseyEnvironment, MutableServletContextHandler) 
= {
+    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())
+
+    val service = new WorkflowCompilingService
+    service.run(mock(classOf[WorkflowCompilingServiceConfiguration]), env)
+
+    (jersey, context)
+  }

Review Comment:
   Good point — `run()` starts an operator-metadata warmup thread and swaps the 
global `SqlServer`, so calling it per test meant four of each. It's now 
memoized in a `lazy val` and the service starts once for the suite; the 
assertions only read recorded interactions, so they're unaffected.



-- 
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