Skip to content

Commit

Permalink
add test for ApiHelpController
Browse files Browse the repository at this point in the history
  • Loading branch information
dwickern committed Nov 1, 2023
1 parent d316204 commit d70c8d2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ lazy val swagger = (projectMatrix in file("."))
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play" % "2.7.3",
"com.typesafe.play" %% "routes-compiler" % "2.7.3",
"com.typesafe.play" %% "play-test" % "2.7.3" % Test,
"com.typesafe.play" %% "play-specs2" % "2.7.3" % Test,
"io.swagger" % "swagger-core" % "1.5.24",
"io.swagger" %% "swagger-scala-module" % "1.0.6",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.9.10",
Expand All @@ -67,6 +69,8 @@ lazy val swagger = (projectMatrix in file("."))
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play" % "2.8.0",
"com.typesafe.play" %% "routes-compiler" % "2.8.0",
"com.typesafe.play" %% "play-test" % "2.8.0" % Test,
"com.typesafe.play" %% "play-specs2" % "2.8.0" % Test,
"io.swagger" % "swagger-core" % "1.6.1",
"io.swagger" %% "swagger-scala-module" % "1.0.6", // FIXME: no version supports jackson 2.10
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.10.5",
Expand All @@ -82,6 +86,8 @@ lazy val swagger = (projectMatrix in file("."))
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play" % "2.9.0",
"com.typesafe.play" %% "play-routes-compiler" % "2.9.0",
"com.typesafe.play" %% "play-test" % "2.9.0" % Test,
"com.typesafe.play" %% "play-specs2" % "2.9.0" % Test,
"io.swagger" % "swagger-core" % "1.6.11",
"io.swagger" %% "swagger-scala-module" % "1.0.6",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.14.2",
Expand Down
21 changes: 21 additions & 0 deletions src/test/scala/PlayApiHelpControllerSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import controllers.ApiHelpController
import org.specs2.concurrent.ExecutionEnv
import org.specs2.mutable._
import play.api.libs.json.JsString
import play.api.test.Helpers._
import play.api.test.{FakeRequest, Helpers, WithApplication}
import play.modules.swagger._

class PlayApiHelpControllerSpec(implicit ee: ExecutionEnv) extends Specification {

"ApiHelpController" should {
"return the swagger specification" in new WithApplication {
val swaggerPlugin = new SwaggerPluginImpl(app.environment, app.configuration)
val controller = new ApiHelpController(Helpers.stubControllerComponents(), swaggerPlugin)
val result = controller.getResources(FakeRequest("GET", "/swagger.json"))
result.map(_.header.status) must beEqualTo (200).await
val body = contentAsJson(result)
(body \ "swagger").get must beEqualTo (JsString("2.0"))
}
}
}

0 comments on commit d70c8d2

Please sign in to comment.