Skip to content

Commit

Permalink
chore(deps): Update syntax to be Scala 3 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
AshCorr committed Nov 8, 2023
1 parent d8e8256 commit 5297790
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/test/scala/mockws/AuthenticationTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ class AuthenticationTest extends AnyFunSuite with Matchers with ScalaCheckProper
}
}

val wsResponseOk = await(ws.url("/").withAuth("user", "s3cr3t", WSAuthScheme.BASIC).get)
val wsResponseOk = await(ws.url("/").withAuth("user", "s3cr3t", WSAuthScheme.BASIC).get())
wsResponseOk.status shouldEqual OK

val wsResponseUnauthorized = await(ws.url("/").withAuth("user", "secret", WSAuthScheme.BASIC).get)
val wsResponseUnauthorized = await(ws.url("/").withAuth("user", "secret", WSAuthScheme.BASIC).get())
wsResponseUnauthorized.status shouldEqual UNAUTHORIZED

ws.close()
Expand All @@ -45,16 +45,16 @@ class AuthenticationTest extends AnyFunSuite with Matchers with ScalaCheckProper
}

a[UnsupportedOperationException] shouldBe thrownBy(
await(ws.url("/").withAuth("user", "s3cr3t", WSAuthScheme.NTLM).get)
await(ws.url("/").withAuth("user", "s3cr3t", WSAuthScheme.NTLM).get())
)
a[UnsupportedOperationException] shouldBe thrownBy(
await(ws.url("/").withAuth("user", "s3cr3t", WSAuthScheme.DIGEST).get)
await(ws.url("/").withAuth("user", "s3cr3t", WSAuthScheme.DIGEST).get())
)
a[UnsupportedOperationException] shouldBe thrownBy(
await(ws.url("/").withAuth("user", "s3cr3t", WSAuthScheme.KERBEROS).get)
await(ws.url("/").withAuth("user", "s3cr3t", WSAuthScheme.KERBEROS).get())
)
a[UnsupportedOperationException] shouldBe thrownBy(
await(ws.url("/").withAuth("user", "s3cr3t", WSAuthScheme.SPNEGO).get)
await(ws.url("/").withAuth("user", "s3cr3t", WSAuthScheme.SPNEGO).get())
)

}
Expand Down
1 change: 1 addition & 0 deletions src/test/scala/mockws/Example.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import scala.concurrent.Future
import scala.util.Try
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.matchers.should.Matchers
import play.api.libs.ws.readableAsString

object ImplementationToTest {

Expand Down
11 changes: 7 additions & 4 deletions src/test/scala/mockws/MockWSTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import scala.concurrent.Future
import scala.concurrent.duration._
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import play.api.libs.ws.writeableOf_String
import play.api.libs.ws.readableAsString
import play.api.libs.ws.writeableOf_JsValue

/**
* Tests that [[MockWS]] simulates a WS client
Expand Down Expand Up @@ -180,7 +183,7 @@ class MockWSTest extends AnyFunSuite with Matchers with ScalaCheckPropertyChecks
}
}

val wsResponse = await(ws.url("/").addHttpHeaders(CONTENT_TYPE -> "hello/world").get)
val wsResponse = await(ws.url("/").addHttpHeaders(CONTENT_TYPE -> "hello/world").get())
wsResponse.status shouldEqual OK
wsResponse.body shouldEqual "hello/world"
ws.close()
Expand All @@ -198,7 +201,7 @@ class MockWSTest extends AnyFunSuite with Matchers with ScalaCheckPropertyChecks
}
}

val wsResponse = await(ws.url("/uri").addQueryStringParameters(q -> v).get)
val wsResponse = await(ws.url("/uri").addQueryStringParameters(q -> v).get())
wsResponse.status shouldEqual OK
wsResponse.body shouldEqual v
ws.close()
Expand All @@ -218,8 +221,8 @@ class MockWSTest extends AnyFunSuite with Matchers with ScalaCheckPropertyChecks
}
}

await(ws.url("/uri").addHttpHeaders(Seq(q -> v): _*).get)
await(ws.url("/uri").addQueryStringParameters(Seq(q -> v): _*).get)
await(ws.url("/uri").addHttpHeaders(Seq(q -> v): _*).get())
await(ws.url("/uri").addQueryStringParameters(Seq(q -> v): _*).get())
ws.close()
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/test/scala/mockws/StreamingTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ import play.api.mvc.MultipartFormData.DataPart
import play.api.mvc.MultipartFormData.FilePart
import play.api.mvc.MultipartFormData.Part
import play.api.mvc.Results._
import play.api.mvc.AnyContent
import play.api.mvc.Request
import play.api.mvc.ResponseHeader
import play.api.mvc.Result
import play.api.test.FakeRequest
import play.api.test.Helpers._
import play.api.libs.ws.readableAsString

import scala.collection.immutable.Seq
import scala.concurrent.ExecutionContext.Implicits._
Expand Down Expand Up @@ -122,7 +125,7 @@ class StreamingTest extends AnyFunSuite with Matchers with ScalaCheckPropertyChe
ws.close()
}

val streamBackAction = Action { req =>
val streamBackAction = Action { (req: Request[AnyContent]) =>
val inputWords: Seq[String] = Seq() ++ req.body.asMultipartFormData.toSeq.flatMap(_.dataParts("k1"))
val returnWords = Seq(req.method + ": ") ++ inputWords
val outputStream: Source[ByteString, _] = Source(returnWords.map(v => ByteString(v)))
Expand Down

0 comments on commit 5297790

Please sign in to comment.