package uk.ac.wellcome.platform.idminter.fixtures

import org.scalatest.Suite
import uk.ac.wellcome.monitoring.test.fixtures.CloudWatch
import uk.ac.wellcome.platform.idminter.{Server => AppServer}
import uk.ac.wellcome.test.fixtures.ServerFixtures

trait Server extends ServerFixtures with CloudWatch { this: Suite =>
  def newAppServer: () => AppServer = () => new AppServer()

  val defaultFlags: Map[String, String] = Map("aws.region" -> "localhost") ++ cloudWatchLocalFlags
}

package uk.ac.wellcome.platform.idminter.fixtures

import com.twitter.finatra.http.EmbeddedHttpServer
import org.scalatest.Suite
import uk.ac.wellcome.monitoring.test.fixtures.CloudWatch
import uk.ac.wellcome.platform.idminter.{Server => AppServer}
import uk.ac.wellcome.test.fixtures.TestWith

trait Server extends CloudWatch { this: Suite =>
  def withServer[R](
    flags: Map[String, String],
    modifyServer: (EmbeddedHttpServer) => EmbeddedHttpServer = identity
  )(testWith: TestWith[EmbeddedHttpServer, R]) = {

    val server: EmbeddedHttpServer = modifyServer(
      new EmbeddedHttpServer(
        new AppServer(),
        flags = Map(
          "aws.region" -> "localhost"
        ) ++ flags ++ cloudWatchLocalFlags
      )
    )

    server.start()

    try {
      testWith(server)
    } finally {
      server.close()
    }
  }
}

--- 
+++ 
@@ -1,32 +1,12 @@
 package uk.ac.wellcome.platform.idminter.fixtures
 
-import com.twitter.finatra.http.EmbeddedHttpServer
 import org.scalatest.Suite
 import uk.ac.wellcome.monitoring.test.fixtures.CloudWatch
 import uk.ac.wellcome.platform.idminter.{Server => AppServer}
-import uk.ac.wellcome.test.fixtures.TestWith
+import uk.ac.wellcome.test.fixtures.ServerFixtures
 
-trait Server extends CloudWatch { this: Suite =>
-  def withServer[R](
-    flags: Map[String, String],
-    modifyServer: (EmbeddedHttpServer) => EmbeddedHttpServer = identity
-  )(testWith: TestWith[EmbeddedHttpServer, R]) = {
+trait Server extends ServerFixtures with CloudWatch { this: Suite =>
+  def newAppServer: () => AppServer = () => new AppServer()
 
-    val server: EmbeddedHttpServer = modifyServer(
-      new EmbeddedHttpServer(
-        new AppServer(),
-        flags = Map(
-          "aws.region" -> "localhost"
-        ) ++ flags ++ cloudWatchLocalFlags
-      )
-    )
-
-    server.start()
-
-    try {
-      testWith(server)
-    } finally {
-      server.close()
-    }
-  }
+  val defaultFlags: Map[String, String] = Map("aws.region" -> "localhost") ++ cloudWatchLocalFlags
 }
Move the ID minter server fixture to use the base trait
