rabbah closed pull request #3850: Replace occurrences of JsObject() with
JsObject.empty
URL: https://github.com/apache/incubator-openwhisk/pull/3850
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/common/scala/src/main/scala/whisk/core/connector/Message.scala
b/common/scala/src/main/scala/whisk/core/connector/Message.scala
index d540a54abd..55e5a64e62 100644
--- a/common/scala/src/main/scala/whisk/core/connector/Message.scala
+++ b/common/scala/src/main/scala/whisk/core/connector/Message.scala
@@ -56,7 +56,7 @@ case class ActivationMessage(override val transid:
TransactionId,
override def serialize = ActivationMessage.serdes.write(this).compactPrint
override def toString = {
- val value = (content getOrElse JsObject()).compactPrint
+ val value = (content getOrElse JsObject.empty).compactPrint
s"$action?message=$value"
}
diff --git
a/common/scala/src/main/scala/whisk/core/containerpool/logging/ElasticSearchRestClient.scala
b/common/scala/src/main/scala/whisk/core/containerpool/logging/ElasticSearchRestClient.scala
index 750728ea35..0290e96f1f 100644
---
a/common/scala/src/main/scala/whisk/core/containerpool/logging/ElasticSearchRestClient.scala
+++
b/common/scala/src/main/scala/whisk/core/containerpool/logging/ElasticSearchRestClient.scala
@@ -134,7 +134,7 @@ object ElasticSearchJsonProtocol extends
DefaultJsonProtocol {
implicit object EsQueryAllJsonFormat extends RootJsonFormat[EsQueryAll] {
def read(query: JsValue) = ???
- def write(query: EsQueryAll) = JsObject("match_all" -> JsObject())
+ def write(query: EsQueryAll) = JsObject("match_all" -> JsObject.empty)
}
implicit object EsQueryMethod extends RootJsonFormat[EsQueryMethod] {
diff --git
a/common/scala/src/main/scala/whisk/core/database/CouchDbRestStore.scala
b/common/scala/src/main/scala/whisk/core/database/CouchDbRestStore.scala
index fba0def425..1e43eb7ad2 100644
--- a/common/scala/src/main/scala/whisk/core/database/CouchDbRestStore.scala
+++ b/common/scala/src/main/scala/whisk/core/database/CouchDbRestStore.scala
@@ -299,7 +299,7 @@ class CouchDbRestStore[DocumentAbstraction <:
DocumentSerializer](dbProtocol: St
assert(rows.length == 1, s"result of reduced view contains more
than one value: '$rows'")
rows.head.fields("value").convertTo[List[JsObject]]
} else if (reduce) {
- List(JsObject())
+ List(JsObject.empty)
} else {
rows
}
diff --git a/common/scala/src/main/scala/whisk/core/entity/Exec.scala
b/common/scala/src/main/scala/whisk/core/entity/Exec.scala
index a281144a62..ca77a9d1e9 100644
--- a/common/scala/src/main/scala/whisk/core/entity/Exec.scala
+++ b/common/scala/src/main/scala/whisk/core/entity/Exec.scala
@@ -247,7 +247,7 @@ protected[core] object Exec extends ArgNormalizer[Exec]
with DefaultJsonProtocol
val code = b.code.filter(_.trim.nonEmpty).map("code" -> JsString(_))
val main = b.entryPoint.map("main" -> JsString(_))
JsObject(base ++ code ++ main)
- case _ => JsObject()
+ case _ => JsObject.empty
}
override def read(v: JsValue) = {
diff --git a/common/scala/src/main/scala/whisk/core/entity/Parameter.scala
b/common/scala/src/main/scala/whisk/core/entity/Parameter.scala
index c27744e3dd..14ebf5161d 100644
--- a/common/scala/src/main/scala/whisk/core/entity/Parameter.scala
+++ b/common/scala/src/main/scala/whisk/core/entity/Parameter.scala
@@ -89,7 +89,7 @@ protected[core] class Parameters protected[entity] (private
val params: Map[Para
* In case of overlap, the keys in the payload supersede.
*/
protected[core] def merge(payload: Option[JsObject]): Some[JsObject] = {
- val args = payload getOrElse JsObject()
+ val args = payload getOrElse JsObject.empty
Some { (toJsObject.fields ++ args.fields).toJson.asJsObject }
}
diff --git a/common/scala/src/main/scala/whisk/core/entity/WhiskPackage.scala
b/common/scala/src/main/scala/whisk/core/entity/WhiskPackage.scala
index 7c9373766b..0eb6d41285 100644
--- a/common/scala/src/main/scala/whisk/core/entity/WhiskPackage.scala
+++ b/common/scala/src/main/scala/whisk/core/entity/WhiskPackage.scala
@@ -232,14 +232,14 @@ object Binding extends ArgNormalizer[Binding] with
DefaultJsonProtocol {
protected[entity] val optionalBindingDeserializer = new
JsonReader[Option[Binding]] {
override def read(js: JsValue) = {
- if (js == JsObject()) None else Some(serdes.read(js))
+ if (js == JsObject.empty) None else Some(serdes.read(js))
}
}
protected[entity] val optionalBindingSerializer = new
JsonWriter[Option[Binding]] {
override def write(b: Option[Binding]) = b match {
- case None => JsObject()
+ case None => JsObject.empty
case Some(n) => Binding.serdes.write(n)
}
}
diff --git
a/core/controller/src/main/scala/whisk/core/controller/RestAPIs.scala
b/core/controller/src/main/scala/whisk/core/controller/RestAPIs.scala
index a76e64a333..5ed6d80a53 100644
--- a/core/controller/src/main/scala/whisk/core/controller/RestAPIs.scala
+++ b/core/controller/src/main/scala/whisk/core/controller/RestAPIs.scala
@@ -93,7 +93,7 @@ protected[controller] object RestApiCommons {
implicit val emptyEntityToJsObject: FromEntityUnmarshaller[JsObject] = {
Unmarshaller.byteStringUnmarshaller.forContentTypes(`application/json`).mapWithCharset
{ (data, charset) =>
if (data.size == 0) {
- JsObject()
+ JsObject.empty
} else {
val input = {
if (charset == HttpCharsets.`UTF-8`) ParserInput(data.toArray)
diff --git
a/core/controller/src/main/scala/whisk/core/controller/Triggers.scala
b/core/controller/src/main/scala/whisk/core/controller/Triggers.scala
index a295b9f3f6..ddf3f9836e 100644
--- a/core/controller/src/main/scala/whisk/core/controller/Triggers.scala
+++ b/core/controller/src/main/scala/whisk/core/controller/Triggers.scala
@@ -144,7 +144,7 @@ trait WhiskTriggersApi extends WhiskCollectionAPI {
triggerActivationId,
Instant.now(Clock.systemUTC()),
Instant.EPOCH,
- response = ActivationResponse.success(payload orElse
Some(JsObject())),
+ response = ActivationResponse.success(payload orElse
Some(JsObject.empty)),
version = trigger.version,
duration = None)
@@ -153,7 +153,7 @@ trait WhiskTriggersApi extends WhiskCollectionAPI {
trigger.rules.map(_.filter(_._2.status ==
Status.ACTIVE)).getOrElse(Map.empty)
if (activeRules.nonEmpty) {
- val args: JsObject =
trigger.parameters.merge(payload).getOrElse(JsObject())
+ val args: JsObject =
trigger.parameters.merge(payload).getOrElse(JsObject.empty)
activateRules(user, args, trigger.rules.getOrElse(Map.empty))
.map(results =>
triggerActivation.withLogs(ActivationLogs(results.map(_.toJson.compactPrint).toVector)))
diff --git
a/core/controller/src/main/scala/whisk/core/controller/actions/PrimitiveActions.scala
b/core/controller/src/main/scala/whisk/core/controller/actions/PrimitiveActions.scala
index 49d84c2782..7ab80eb19e 100644
---
a/core/controller/src/main/scala/whisk/core/controller/actions/PrimitiveActions.scala
+++
b/core/controller/src/main/scala/whisk/core/controller/actions/PrimitiveActions.scala
@@ -312,7 +312,7 @@ protected[actions] trait PrimitiveActions {
} else {
// inject state into payload if any
val params = session.state
- .map(state => Some(JsObject(payload.getOrElse(JsObject()).fields ++
state.fields)))
+ .map(state => Some(JsObject(payload.getOrElse(JsObject.empty).fields
++ state.fields)))
.getOrElse(payload)
// invoke conductor action
diff --git
a/core/invoker/src/main/scala/whisk/core/containerpool/ContainerProxy.scala
b/core/invoker/src/main/scala/whisk/core/containerpool/ContainerProxy.scala
index 566d80047d..d04dfb3547 100644
--- a/core/invoker/src/main/scala/whisk/core/containerpool/ContainerProxy.scala
+++ b/core/invoker/src/main/scala/whisk/core/containerpool/ContainerProxy.scala
@@ -352,7 +352,7 @@ class ContainerProxy(
val activation: Future[WhiskActivation] = initialize
.flatMap { initInterval =>
- val parameters = job.msg.content getOrElse JsObject()
+ val parameters = job.msg.content getOrElse JsObject.empty
val authEnvironment = job.msg.user.authkey.toEnvironment
diff --git a/tests/src/test/scala/actionContainers/BasicActionRunnerTests.scala
b/tests/src/test/scala/actionContainers/BasicActionRunnerTests.scala
index cb36472468..3bae049e14 100644
--- a/tests/src/test/scala/actionContainers/BasicActionRunnerTests.scala
+++ b/tests/src/test/scala/actionContainers/BasicActionRunnerTests.scala
@@ -49,7 +49,7 @@ trait BasicActionRunnerTests extends
ActionProxyContainerTestUtils {
val (out, err) = withActionContainer() { c =>
val (initCode, _) = c.init(initPayload(codeNotReturningJson))
initCode should be(200)
- val (runCode, out) = c.run(JsObject())
+ val (runCode, out) = c.run(JsObject.empty)
runCode should be(502)
out should be(Some(JsObject("error" -> JsString("The action did not
return a dictionary."))))
}
@@ -161,7 +161,7 @@ trait BasicActionRunnerTests extends
ActionProxyContainerTestUtils {
val (initCode, _) = c.init(initPayload(s._2))
initCode should be(200)
- val (runCode, out) = c.run(runPayload(JsObject(),
Some(props.toMap.toJson.asJsObject)))
+ val (runCode, out) = c.run(runPayload(JsObject.empty,
Some(props.toMap.toJson.asJsObject)))
runCode should be(200)
out shouldBe defined
props.map {
diff --git a/tests/src/test/scala/common/rest/WskRestOperations.scala
b/tests/src/test/scala/common/rest/WskRestOperations.scala
index f12d4775b1..ccea88bfed 100644
--- a/tests/src/test/scala/common/rest/WskRestOperations.scala
+++ b/tests/src/test/scala/common/rest/WskRestOperations.scala
@@ -1425,15 +1425,15 @@ object RestResult {
}
def getFieldJsObject(obj: JsObject, key: String): JsObject = {
- obj.fields.get(key).map(_.asJsObject).getOrElse(JsObject())
+ obj.fields.get(key).map(_.asJsObject).getOrElse(JsObject.empty)
}
def getFieldJsValue(obj: JsObject, key: String): JsValue = {
- obj.fields.get(key).getOrElse(JsObject())
+ obj.fields.get(key).getOrElse(JsObject.empty)
}
def getFieldListJsObject(obj: JsObject, key: String): Vector[JsObject] = {
-
obj.fields.get(key).map(_.convertTo[Vector[JsObject]]).getOrElse(Vector(JsObject()))
+
obj.fields.get(key).map(_.convertTo[Vector[JsObject]]).getOrElse(Vector(JsObject.empty))
}
def convertStausCodeToExitCode(statusCode: StatusCode, blocking: Boolean =
false): Int = {
diff --git a/tests/src/test/scala/system/basic/WskRestBasicTests.scala
b/tests/src/test/scala/system/basic/WskRestBasicTests.scala
index d8a54d3ca9..6932ee6468 100644
--- a/tests/src/test/scala/system/basic/WskRestBasicTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestBasicTests.scala
@@ -177,7 +177,7 @@ class WskRestBasicTests extends TestHelpers with
WskTestHelpers with WskActorSys
result.getField("name") shouldBe name
result.getField("version") shouldBe "0.0.1"
result.getFieldJsValue("publish") shouldBe JsBoolean(false)
- result.getFieldJsValue("binding") shouldBe JsObject()
+ result.getFieldJsValue("binding") shouldBe JsObject.empty
result.getField("invalid") shouldBe ""
}
@@ -473,7 +473,7 @@ class WskRestBasicTests extends TestHelpers with
WskTestHelpers with WskActorSys
}
val result = wsk.action.invoke(name, blocking = true, result = true)
- result.stdout.parseJson.asJsObject shouldBe JsObject()
+ result.stdout.parseJson.asJsObject shouldBe JsObject.empty
}
it should "create, and invoke an action that times out to ensure the proper
response is received" in withAssetCleaner(
@@ -563,7 +563,7 @@ class WskRestBasicTests extends TestHelpers with
WskTestHelpers with WskActorSys
val runWithNoParams = wsk.trigger.fire(triggerName, Map())
withActivation(wsk.activation, runWithNoParams) { activation =>
- activation.response.result shouldBe Some(JsObject())
+ activation.response.result shouldBe Some(JsObject.empty)
activation.duration shouldBe 0L // shouldn't exist but CLI generates it
activation.end shouldBe Instant.EPOCH // shouldn't exist but CLI
generates it
}
@@ -658,7 +658,7 @@ class WskRestBasicTests extends TestHelpers with
WskTestHelpers with WskActorSys
result.getFieldJsValue("annotations").toString shouldBe "[]"
result.getFieldJsValue("parameters") shouldBe JsArray(
JsObject("key" -> JsString("payload"), "value" -> JsString("test")))
- result.getFieldJsValue("limits") shouldBe JsObject()
+ result.getFieldJsValue("limits") shouldBe JsObject.empty
result.getField("invalid") shouldBe ""
}
@@ -681,7 +681,7 @@ class WskRestBasicTests extends TestHelpers with
WskTestHelpers with WskActorSys
val run = wsk.trigger.fire(triggerName)
withActivation(wsk.activation, run) { activation =>
- activation.response.result shouldBe Some(JsObject())
+ activation.response.result shouldBe Some(JsObject.empty)
}
}
@@ -1036,9 +1036,9 @@ class WskRestBasicTests extends TestHelpers with
WskTestHelpers with WskActorSys
result.getFieldJsValue("publish") shouldBe JsBoolean(false)
result.getField("subject") shouldBe ns
result.getField("activationId") shouldBe activation.activationId
- result.getFieldJsValue("start").toString should not be
JsObject().toString
- result.getFieldJsValue("end").toString shouldBe JsObject().toString
- result.getFieldJsValue("duration").toString shouldBe JsObject().toString
+ result.getFieldJsValue("start").toString should not be
JsObject.empty.toString
+ result.getFieldJsValue("end").toString shouldBe JsObject.empty.toString
+ result.getFieldJsValue("duration").toString shouldBe
JsObject.empty.toString
result.getFieldListJsObject("annotations").length shouldBe 0
}
}
diff --git a/tests/src/test/scala/system/rest/RestUtil.scala
b/tests/src/test/scala/system/rest/RestUtil.scala
index fe2a564288..212238f037 100644
--- a/tests/src/test/scala/system/rest/RestUtil.scala
+++ b/tests/src/test/scala/system/rest/RestUtil.scala
@@ -75,8 +75,8 @@ trait RestUtil {
val body = Try { response.body().asString().parseJson.asJsObject }
val schema = body map { _.fields("definitions").asJsObject }
- val t = schema map { _.fields(model).asJsObject } getOrElse JsObject()
- val d = JsObject("definitions" -> (schema getOrElse JsObject()))
+ val t = schema map { _.fields(model).asJsObject } getOrElse JsObject.empty
+ val d = JsObject("definitions" -> (schema getOrElse JsObject.empty))
JsObject(t.fields ++ d.fields)
}
}
diff --git
a/tests/src/test/scala/whisk/core/cli/test/WskRestBasicUsageTests.scala
b/tests/src/test/scala/whisk/core/cli/test/WskRestBasicUsageTests.scala
index 03d20355db..27364f7428 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskRestBasicUsageTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskRestBasicUsageTests.scala
@@ -242,7 +242,7 @@ class WskRestBasicUsageTests extends TestHelpers with
WskTestHelpers with WskAct
activation.end should be > Instant.EPOCH
activation.response.status shouldBe
ActivationResponse.messageForCode(ActivationResponse.Success)
activation.response.success shouldBe true
- activation.response.result shouldBe Some(JsObject())
+ activation.response.result shouldBe Some(JsObject.empty)
activation.logs shouldBe Some(List())
activation.annotations shouldBe defined
}
diff --git
a/tests/src/test/scala/whisk/core/containerpool/docker/test/ContainerConnectionTests.scala
b/tests/src/test/scala/whisk/core/containerpool/docker/test/ContainerConnectionTests.scala
index 95754220b2..3816cfc298 100644
---
a/tests/src/test/scala/whisk/core/containerpool/docker/test/ContainerConnectionTests.scala
+++
b/tests/src/test/scala/whisk/core/containerpool/docker/test/ContainerConnectionTests.scala
@@ -96,7 +96,7 @@ class ContainerConnectionTests
val connection = new HttpUtils(hostWithPort, timeout, 1.B)
testHang = timeout * 2
val start = Instant.now()
- val result = connection.post("/init", JsObject(), retry = true)
+ val result = connection.post("/init", JsObject.empty, retry = true)
val end = Instant.now()
val waited = end.toEpochMilli - start.toEpochMilli
result shouldBe 'left
@@ -108,7 +108,7 @@ class ContainerConnectionTests
val timeout = 5.seconds
val connection = new HttpUtils(hostWithPort, timeout, 1.B)
testStatusCode = 204
- val result = connection.post("/init", JsObject(), retry = true)
+ val result = connection.post("/init", JsObject.empty, retry = true)
result shouldBe Left(NoResponseReceived())
}
@@ -119,7 +119,7 @@ class ContainerConnectionTests
Seq(null, "", "abc", """{"a":"B"}""", """["a", "b"]""").foreach { r =>
testStatusCode = if (code) 200 else 500
testResponse = r
- val result = connection.post("/init", JsObject(), retry = true)
+ val result = connection.post("/init", JsObject.empty, retry = true)
result shouldBe Right {
ContainerResponse(okStatus = code, if (r != null) r else "", None)
}
@@ -136,7 +136,7 @@ class ContainerConnectionTests
Seq("abc", """{"a":"B"}""", """["a", "b"]""").foreach { r =>
testStatusCode = if (code) 200 else 500
testResponse = r
- val result = connection.post("/init", JsObject(), retry = true)
+ val result = connection.post("/init", JsObject.empty, retry = true)
result shouldBe Right {
ContainerResponse(okStatus = code, r.take(limit.toBytes.toInt),
Some((r.length.B, limit)))
}
diff --git
a/tests/src/test/scala/whisk/core/containerpool/docker/test/DockerClientWithFileAccessTests.scala
b/tests/src/test/scala/whisk/core/containerpool/docker/test/DockerClientWithFileAccessTests.scala
index 2918c8e5e7..d960c86b92 100644
---
a/tests/src/test/scala/whisk/core/containerpool/docker/test/DockerClientWithFileAccessTests.scala
+++
b/tests/src/test/scala/whisk/core/containerpool/docker/test/DockerClientWithFileAccessTests.scala
@@ -145,7 +145,7 @@ class DockerClientWithFileAccessTestsOom
}
it should "default to 'false' if the json structure is unparseable" in {
- val dc = dockerClient(Future.successful(JsObject()))
+ val dc = dockerClient(Future.successful(JsObject.empty))
await(dc.isOomKilled(id)) shouldBe false
}
}
diff --git
a/tests/src/test/scala/whisk/core/containerpool/docker/test/DockerContainerTests.scala
b/tests/src/test/scala/whisk/core/containerpool/docker/test/DockerContainerTests.scala
index b3aa2b0227..490bf1236f 100644
---
a/tests/src/test/scala/whisk/core/containerpool/docker/test/DockerContainerTests.scala
+++
b/tests/src/test/scala/whisk/core/containerpool/docker/test/DockerContainerTests.scala
@@ -362,7 +362,7 @@ class DockerContainerTests
Future.successful(RunResult(interval, Right(ContainerResponse(true, "",
None))))
}
- val initInterval = container.initialize(JsObject(), initTimeout)
+ val initInterval = container.initialize(JsObject.empty, initTimeout)
await(initInterval, initTimeout) shouldBe interval
// assert the starting log is there
@@ -386,7 +386,7 @@ class DockerContainerTests
Future.successful(RunResult(interval, Left(Timeout(new Throwable()))))
}
- val init = container.initialize(JsObject(), initTimeout)
+ val init = container.initialize(JsObject.empty, initTimeout)
val error = the[InitializationError] thrownBy await(init, initTimeout)
error.interval shouldBe interval
@@ -408,12 +408,12 @@ class DockerContainerTests
implicit val runc = stub[RuncApi]
val interval = intervalOf(1.millisecond)
- val result = JsObject()
+ val result = JsObject.empty
val container = dockerContainer() {
Future.successful(RunResult(interval, Right(ContainerResponse(true,
result.compactPrint, None))))
}
- val runResult = container.run(JsObject(), JsObject(), 1.second)
+ val runResult = container.run(JsObject.empty, JsObject.empty, 1.second)
await(runResult) shouldBe (interval,
ActivationResponse.success(Some(result)))
// assert the starting log is there
@@ -437,7 +437,7 @@ class DockerContainerTests
Future.successful(RunResult(interval, Left(Timeout(new Throwable()))))
}
- val runResult = container.run(JsObject(), JsObject(), runTimeout)
+ val runResult = container.run(JsObject.empty, JsObject.empty, runTimeout)
await(runResult) shouldBe (interval, ActivationResponse.applicationError(
Messages.timedoutActivation(runTimeout, false)))
diff --git
a/tests/src/test/scala/whisk/core/containerpool/kubernetes/test/KubernetesContainerTests.scala
b/tests/src/test/scala/whisk/core/containerpool/kubernetes/test/KubernetesContainerTests.scala
index a6e5d20f57..bd3c948410 100644
---
a/tests/src/test/scala/whisk/core/containerpool/kubernetes/test/KubernetesContainerTests.scala
+++
b/tests/src/test/scala/whisk/core/containerpool/kubernetes/test/KubernetesContainerTests.scala
@@ -215,7 +215,7 @@ class KubernetesContainerTests
Future.successful(RunResult(interval, Right(ContainerResponse(true, "",
None))))
}
- val initInterval = container.initialize(JsObject(), initTimeout)
+ val initInterval = container.initialize(JsObject.empty, initTimeout)
await(initInterval, initTimeout) shouldBe interval
// assert the starting log is there
@@ -238,7 +238,7 @@ class KubernetesContainerTests
Future.successful(RunResult(interval, Left(Timeout(new Throwable()))))
}
- val init = container.initialize(JsObject(), initTimeout)
+ val init = container.initialize(JsObject.empty, initTimeout)
val error = the[InitializationError] thrownBy await(init, initTimeout)
error.interval shouldBe interval
@@ -259,12 +259,12 @@ class KubernetesContainerTests
implicit val kubernetes = stub[KubernetesApi]
val interval = intervalOf(1.millisecond)
- val result = JsObject()
+ val result = JsObject.empty
val container = kubernetesContainer() {
Future.successful(RunResult(interval, Right(ContainerResponse(true,
result.compactPrint, None))))
}
- val runResult = container.run(JsObject(), JsObject(), 1.second)
+ val runResult = container.run(JsObject.empty, JsObject.empty, 1.second)
await(runResult) shouldBe (interval,
ActivationResponse.success(Some(result)))
// assert the starting log is there
@@ -287,7 +287,7 @@ class KubernetesContainerTests
Future.successful(RunResult(interval, Left(Timeout(new Throwable()))))
}
- val runResult = container.run(JsObject(), JsObject(), runTimeout)
+ val runResult = container.run(JsObject.empty, JsObject.empty, runTimeout)
await(runResult) shouldBe (interval, ActivationResponse.applicationError(
Messages.timedoutActivation(runTimeout, false)))
@@ -305,10 +305,10 @@ class KubernetesContainerTests
val container = new KubernetesContainer(id, ContainerAddress("ip"),
"127.0.0.1", "docker://foo")
val logChunk = 10.kilobytes
- await(container.forwardLogs(logChunk, false, Map.empty, JsObject()))
- await(container.forwardLogs(42.bytes, false, Map.empty, JsObject()))
- await(container.forwardLogs(logChunk, false, Map.empty, JsObject()))
- await(container.forwardLogs(42.bytes, false, Map.empty, JsObject()))
+ await(container.forwardLogs(logChunk, false, Map.empty, JsObject.empty))
+ await(container.forwardLogs(42.bytes, false, Map.empty, JsObject.empty))
+ await(container.forwardLogs(logChunk, false, Map.empty, JsObject.empty))
+ await(container.forwardLogs(42.bytes, false, Map.empty, JsObject.empty))
kubernetes.forwardLogs(0) shouldBe (id, 0)
kubernetes.forwardLogs(1) shouldBe (id, logChunk.toBytes)
diff --git
a/tests/src/test/scala/whisk/core/containerpool/logging/ElasticSearchRestClientTests.scala
b/tests/src/test/scala/whisk/core/containerpool/logging/ElasticSearchRestClientTests.scala
index a6dd318e14..040b0fcbf0 100644
---
a/tests/src/test/scala/whisk/core/containerpool/logging/ElasticSearchRestClientTests.scala
+++
b/tests/src/test/scala/whisk/core/containerpool/logging/ElasticSearchRestClientTests.scala
@@ -119,7 +119,7 @@ class ElasticSearchRestClientTests
val queryAgg = EsQueryAggs("someAgg", aggArg, "someField")
EsQuery(EsQueryAll(), aggs = Some(queryAgg)).toJson shouldBe JsObject(
- "query" -> JsObject("match_all" -> JsObject()),
+ "query" -> JsObject("match_all" -> JsObject.empty),
"aggs" -> JsObject("someAgg" -> JsObject(aggValue ->
JsObject("field" -> "someField".toJson))))
}
}
@@ -160,7 +160,7 @@ class ElasticSearchRestClientTests
val queryOrder = EsQueryOrder("someField", orderArg)
EsQuery(EsQueryAll(), Some(queryOrder)).toJson shouldBe JsObject(
- "query" -> JsObject("match_all" -> JsObject()),
+ "query" -> JsObject("match_all" -> JsObject.empty),
"sort" -> JsArray(JsObject("someField" -> JsObject("order" ->
orderValue.toJson))))
}
}
@@ -169,7 +169,7 @@ class ElasticSearchRestClientTests
val querySize = EsQuerySize(1)
EsQuery(EsQueryAll(), size = Some(querySize)).toJson shouldBe JsObject(
- "query" -> JsObject("match_all" -> JsObject()),
+ "query" -> JsObject("match_all" -> JsObject.empty),
"size" -> JsNumber(1))
}
diff --git
a/tests/src/test/scala/whisk/core/containerpool/logging/SplunkLogStoreTests.scala
b/tests/src/test/scala/whisk/core/containerpool/logging/SplunkLogStoreTests.scala
index 526b17c4a1..b149417563 100644
---
a/tests/src/test/scala/whisk/core/containerpool/logging/SplunkLogStoreTests.scala
+++
b/tests/src/test/scala/whisk/core/containerpool/logging/SplunkLogStoreTests.scala
@@ -75,7 +75,7 @@ class SplunkLogStoreTests
method = POST,
uri = "https://some.url",
headers = List(RawHeader("key", "value")),
- entity = HttpEntity(MediaTypes.`application/json`,
JsObject().compactPrint))
+ entity = HttpEntity(MediaTypes.`application/json`,
JsObject.empty.compactPrint))
val activation = WhiskActivation(
namespace = EntityPath("ns"),
diff --git
a/tests/src/test/scala/whisk/core/controller/test/ActionsApiTests.scala
b/tests/src/test/scala/whisk/core/controller/test/ActionsApiTests.scala
index ce6529e197..7ed95ca46b 100644
--- a/tests/src/test/scala/whisk/core/controller/test/ActionsApiTests.scala
+++ b/tests/src/test/scala/whisk/core/controller/test/ActionsApiTests.scala
@@ -1384,7 +1384,7 @@ class ActionsApiTests extends ControllerTestCommon with
WhiskActionsApi {
put(entityStore, action)
- Put(s"$collectionPath/${action.name}?overwrite=true", JsObject()) ~>
Route.seal(routes(creds)) ~> check {
+ Put(s"$collectionPath/${action.name}?overwrite=true", JsObject.empty) ~>
Route.seal(routes(creds)) ~> check {
status shouldBe BadRequest
responseAs[ErrorResponse].error shouldBe
Messages.runtimeDeprecated(action.exec)
}
diff --git
a/tests/src/test/scala/whisk/core/controller/test/ConductorsApiTests.scala
b/tests/src/test/scala/whisk/core/controller/test/ConductorsApiTests.scala
index bacd9124e4..a95c560eb3 100644
--- a/tests/src/test/scala/whisk/core/controller/test/ConductorsApiTests.scala
+++ b/tests/src/test/scala/whisk/core/controller/test/ConductorsApiTests.scala
@@ -352,7 +352,7 @@ class ConductorsApiTests extends ControllerTestCommon with
WhiskActionsApi {
val state = args.fields.get("state") map { state =>
Map("state" -> state)
} getOrElse Map()
- val wrappedParams = args.fields.getOrElse("params",
JsObject()).asJsObject.fields
+ val wrappedParams = args.fields.getOrElse("params",
JsObject.empty).asJsObject.fields
val escapedParams = args.fields - "action" - "state" -
"params"
val params = Map("params" -> JsObject(wrappedParams ++
escapedParams))
JsObject(params ++ action ++ state)
diff --git
a/tests/src/test/scala/whisk/core/controller/test/WebActionsApiTests.scala
b/tests/src/test/scala/whisk/core/controller/test/WebActionsApiTests.scala
index 1fd2ab6d50..301cdf74b3 100644
--- a/tests/src/test/scala/whisk/core/controller/test/WebActionsApiTests.scala
+++ b/tests/src/test/scala/whisk/core/controller/test/WebActionsApiTests.scala
@@ -405,7 +405,7 @@ trait WebActionsApiBaseTests extends ControllerTestCommon
with BeforeAndAfterEac
response shouldBe JsObject(
"pkg" -> s"$systemId/proxy".toJson,
"action" -> "export_auth".toJson,
- "content" -> metaPayload(m.method.name.toLowerCase,
JsObject(), creds, pkgName = "proxy"))
+ "content" -> metaPayload(m.method.name.toLowerCase,
JsObject.empty, creds, pkgName = "proxy"))
response
.fields("content")
.asJsObject
@@ -430,7 +430,7 @@ trait WebActionsApiBaseTests extends ControllerTestCommon
with BeforeAndAfterEac
"action" -> "export_auth".toJson,
"content" -> metaPayload(
m.method.name.toLowerCase,
- JsObject(),
+ JsObject.empty,
creds,
pkgName = "proxy",
headers = List(RawHeader("X-Require-Whisk-Auth",
requireAuthenticationKey))))
@@ -525,7 +525,7 @@ trait WebActionsApiBaseTests extends ControllerTestCommon
with BeforeAndAfterEac
"action" -> "export_c".toJson,
"content" -> metaPayload(
m.method.name.toLowerCase,
- JsObject(),
+ JsObject.empty,
creds,
body = Some(content),
path = p,
@@ -539,7 +539,7 @@ trait WebActionsApiBaseTests extends ControllerTestCommon
with BeforeAndAfterEac
it should s"invoke action which receives an empty entity (auth?
${creds.isDefined})" in {
implicit val tid = transid()
- Seq("", JsArray().compactPrint, JsObject().compactPrint,
JsNull.compactPrint).foreach { arg =>
+ Seq("", JsArray().compactPrint, JsObject.empty.compactPrint,
JsNull.compactPrint).foreach { arg =>
Seq(s"$systemId/proxy/export_c.json").foreach { path =>
allowedMethodsWithEntity.foreach { m =>
invocationsAllowed += 1
@@ -551,7 +551,7 @@ trait WebActionsApiBaseTests extends ControllerTestCommon
with BeforeAndAfterEac
"action" -> "export_c".toJson,
"content" -> metaPayload(
m.method.name.toLowerCase,
- if (arg.nonEmpty && arg != "{}")
JsObject(webApiDirectives.body -> arg.parseJson) else JsObject(),
+ if (arg.nonEmpty && arg != "{}")
JsObject(webApiDirectives.body -> arg.parseJson) else JsObject.empty,
creds,
pkgName = "proxy",
headers =
List(`Content-Type`(ContentTypes.`application/json`))))
@@ -600,7 +600,7 @@ trait WebActionsApiBaseTests extends ControllerTestCommon
with BeforeAndAfterEac
response shouldBe JsObject(
"pkg" -> s"$systemId".toJson,
"action" -> "export_c".toJson,
- "content" -> metaPayload(m.method.name.toLowerCase, JsObject(),
creds))
+ "content" -> metaPayload(m.method.name.toLowerCase,
JsObject.empty, creds))
}
}
}
@@ -618,7 +618,7 @@ trait WebActionsApiBaseTests extends ControllerTestCommon
with BeforeAndAfterEac
val response = responseAs[JsObject]
response shouldBe metaPayload(
m.method.name.toLowerCase,
- JsObject(),
+ JsObject.empty,
creds,
path = "/content",
pkgName = "proxy")
@@ -792,7 +792,7 @@ trait WebActionsApiBaseTests extends ControllerTestCommon
with BeforeAndAfterEac
}
Seq(s"$systemId/proxy/export_c.http").foreach { path =>
- Set(JsObject(), JsObject("body" -> "".toJson), JsObject("body" ->
JsNull)).foreach { bodyResult =>
+ Set(JsObject.empty, JsObject("body" -> "".toJson), JsObject("body" ->
JsNull)).foreach { bodyResult =>
allowedMethods.foreach { m =>
invocationsAllowed += 2
actionResult = Some(bodyResult)
@@ -1036,7 +1036,7 @@ trait WebActionsApiBaseTests extends ControllerTestCommon
with BeforeAndAfterEac
Seq(
(JsObject("content-type" -> "application/json".toJson), OK),
- (JsObject(), OK),
+ (JsObject.empty, OK),
(JsObject("content-type" -> "text/html".toJson), BadRequest)).foreach {
case (headers, expectedCode) =>
Seq(s"$systemId/proxy/export_c.http").foreach { path =>
@@ -1455,7 +1455,7 @@ trait WebActionsApiBaseTests extends ControllerTestCommon
with BeforeAndAfterEac
pkgName = "proxy"))
}
- Post(s"$testRoutePath/$systemId/proxy/export_c.json?a=b&c=d",
JsObject()) ~> Route.seal(routes(creds)) ~> check {
+ Post(s"$testRoutePath/$systemId/proxy/export_c.json?a=b&c=d",
JsObject.empty) ~> Route.seal(routes(creds)) ~> check {
status should be(OK)
val response = responseAs[JsObject]
response shouldBe JsObject(
diff --git
a/tests/src/test/scala/whisk/core/database/test/DocumentHandlerTests.scala
b/tests/src/test/scala/whisk/core/database/test/DocumentHandlerTests.scala
index 20dc280c7b..f4f7e273fa 100644
--- a/tests/src/test/scala/whisk/core/database/test/DocumentHandlerTests.scala
+++ b/tests/src/test/scala/whisk/core/database/test/DocumentHandlerTests.scala
@@ -43,7 +43,7 @@ class DocumentHandlerTests extends FlatSpec with Matchers
with ScalaFutures with
behavior of "WhisksHandler computeFields"
it should "return empty object when namespace does not exist" in {
- WhisksHandler.computedFields(JsObject()) shouldBe JsObject.empty
+ WhisksHandler.computedFields(JsObject.empty) shouldBe JsObject.empty
}
it should "return JsObject when namespace is simple name" in {
diff --git
a/tests/src/test/scala/whisk/core/entity/test/ExecManifestTests.scala
b/tests/src/test/scala/whisk/core/entity/test/ExecManifestTests.scala
index e14c7c46e3..53e3cd1409 100644
--- a/tests/src/test/scala/whisk/core/entity/test/ExecManifestTests.scala
+++ b/tests/src/test/scala/whisk/core/entity/test/ExecManifestTests.scala
@@ -118,7 +118,7 @@ class ExecManifestTests extends FlatSpec with
WskActorSystem with StreamLogging
ImageName("???", Some("ppp"), Some("ttt")),
ImageName("???", None, Some("ttt")))
- val mf = JsObject("runtimes" -> JsObject(), "blackboxes" -> imgs.toJson)
+ val mf = JsObject("runtimes" -> JsObject.empty, "blackboxes" ->
imgs.toJson)
val runtimes = ExecManifest.runtimes(mf, RuntimeManifestConfig()).get
runtimes.blackboxImages shouldBe imgs
@@ -133,7 +133,7 @@ class ExecManifestTests extends FlatSpec with
WskActorSystem with StreamLogging
ImageName("???", Some("ppp"), Some("ttt")),
ImageName("???", None, Some("ttt")))
- val mf = JsObject("runtimes" -> JsObject(), "blackboxes" -> imgs.toJson)
+ val mf = JsObject("runtimes" -> JsObject.empty, "blackboxes" ->
imgs.toJson)
val rmc = RuntimeManifestConfig()
val runtimes = ExecManifest.runtimes(mf, rmc).get
@@ -182,7 +182,7 @@ class ExecManifestTests extends FlatSpec with
WskActorSystem with StreamLogging
}
it should "indicate image is local if it matches deployment docker prefix"
in {
- val mf = JsObject()
+ val mf = JsObject.empty
val rmc = RuntimeManifestConfig(bypassPullForLocalImages = Some(true),
localImagePrefix = Some("localpre"))
val manifest = ExecManifest.runtimes(mf, rmc)
diff --git a/tests/src/test/scala/whisk/core/entity/test/SchemaTests.scala
b/tests/src/test/scala/whisk/core/entity/test/SchemaTests.scala
index 717eeba211..7569ffc4e0 100644
--- a/tests/src/test/scala/whisk/core/entity/test/SchemaTests.scala
+++ b/tests/src/test/scala/whisk/core/entity/test/SchemaTests.scala
@@ -99,7 +99,7 @@ class SchemaTests extends FlatSpec with BeforeAndAfter with
ExecHelpers with Mat
"namespace" -> i.namespace.toJson,
"authkey" -> i.authkey.toEnvironment,
"rights" -> Array("READ", "PUT", "DELETE", "ACTIVATE").toJson,
- "limits" -> JsObject())
+ "limits" -> JsObject.empty)
Identity.serdes.write(i) shouldBe expected
}
@@ -115,7 +115,7 @@ class SchemaTests extends FlatSpec with BeforeAndAfter with
ExecHelpers with Mat
"namespace" -> Namespace(entity, uuid).toJson,
"authkey" -> JsObject("test_key" -> "test_value".toJson),
"rights" -> Array("READ", "PUT", "DELETE", "ACTIVATE").toJson,
- "limits" -> JsObject())
+ "limits" -> JsObject.empty)
Identity.serdes.read(json) shouldBe i
}
@@ -371,7 +371,11 @@ class SchemaTests extends FlatSpec with BeforeAndAfter
with ExecHelpers with Mat
it should "desiarilize legacy format" in {
val names =
- Seq(JsObject("namespace" -> "a".toJson, "name" -> "b".toJson),
JsObject(), JsObject("name" -> "b".toJson), JsNull)
+ Seq(
+ JsObject("namespace" -> "a".toJson, "name" -> "b".toJson),
+ JsObject.empty,
+ JsObject("name" -> "b".toJson),
+ JsNull)
Binding.optionalBindingDeserializer.read(names(0)) shouldBe
Some(Binding(EntityName("a"), EntityName("b")))
Binding.optionalBindingDeserializer.read(names(1)) shouldBe None
@@ -380,15 +384,15 @@ class SchemaTests extends FlatSpec with BeforeAndAfter
with ExecHelpers with Mat
}
it should "serialize optional binding to empty object" in {
- Binding.optionalBindingSerializer.write(None) shouldBe JsObject()
+ Binding.optionalBindingSerializer.write(None) shouldBe JsObject.empty
}
behavior of "WhiskPackagePut"
it should "deserialize empty request" in {
- WhiskPackagePut.serdes.read(JsObject()) shouldBe WhiskPackagePut()
+ WhiskPackagePut.serdes.read(JsObject.empty) shouldBe WhiskPackagePut()
//WhiskPackagePut.serdes.read(JsObject("binding" -> JsNull)) shouldBe
WhiskPackagePut()
- WhiskPackagePut.serdes.read(JsObject("binding" -> JsObject())) shouldBe
WhiskPackagePut()
+ WhiskPackagePut.serdes.read(JsObject("binding" -> JsObject.empty))
shouldBe WhiskPackagePut()
//WhiskPackagePut.serdes.read(JsObject("binding" -> "a/b".toJson))
shouldBe WhiskPackagePut(binding = Some(Binding(EntityPath("a"),
EntityName("b"))))
a[DeserializationException] should be thrownBy
WhiskPackagePut.serdes.read(JsObject("binding" -> JsNull))
}
@@ -397,7 +401,7 @@ class SchemaTests extends FlatSpec with BeforeAndAfter with
ExecHelpers with Mat
it should "not deserialize package without binding property" in {
val pkg = WhiskPackage(EntityPath("a"), EntityName("b"))
- WhiskPackage.serdes.read(JsObject(pkg.toJson.fields + ("binding" ->
JsObject()))) shouldBe pkg
+ WhiskPackage.serdes.read(JsObject(pkg.toJson.fields + ("binding" ->
JsObject.empty))) shouldBe pkg
a[DeserializationException] should be thrownBy
WhiskPackage.serdes.read(JsObject(pkg.toJson.fields - "binding"))
}
@@ -406,7 +410,7 @@ class SchemaTests extends FlatSpec with BeforeAndAfter with
ExecHelpers with Mat
WhiskPackage.serdes.write(pkg) shouldBe JsObject(
"namespace" -> "a".toJson,
"name" -> "b".toJson,
- "binding" -> JsObject(),
+ "binding" -> JsObject.empty,
"parameters" -> Parameters().toJson,
"version" -> SemVer().toJson,
"publish" -> JsBoolean(false),
@@ -575,7 +579,7 @@ class SchemaTests extends FlatSpec with BeforeAndAfter with
ExecHelpers with Mat
val execs = Seq[JsValue](
null,
- JsObject(),
+ JsObject.empty,
JsNull,
JsObject("init" -> "zipfile".toJson),
JsObject("kind" -> "nodejs:6".toJson, "code" -> JsNumber(42)),
@@ -643,7 +647,7 @@ class SchemaTests extends FlatSpec with BeforeAndAfter with
ExecHelpers with Mat
it should "reject malformed JSON" in {
val params = Seq[JsValue](
null,
- JsObject(),
+ JsObject.empty,
JsObject("key" -> "k".toJson),
JsObject("value" -> "v".toJson),
JsObject("key" -> JsNull, "value" -> "v".toJson),
@@ -704,7 +708,7 @@ class SchemaTests extends FlatSpec with BeforeAndAfter with
ExecHelpers with Mat
it should "reject malformed JSON" in {
val limits = Seq[JsValue](
null,
- JsObject(),
+ JsObject.empty,
JsNull,
JsObject("timeout" -> TimeLimit.STD_DURATION.toMillis.toInt.toJson),
JsObject("memory" -> MemoryLimit.stdMemory.toMB.toInt.toJson),
@@ -847,6 +851,6 @@ class SchemaTests extends FlatSpec with BeforeAndAfter with
ExecHelpers with Mat
JsHelpers.getFieldPath(js, "a", "b") shouldBe Some(JsObject("c" ->
JsString("v")))
JsHelpers.getFieldPath(js, "a", "b", "c") shouldBe Some(JsString("v"))
JsHelpers.getFieldPath(js, "a", "b", "c", "d") shouldBe None
- JsHelpers.getFieldPath(JsObject()) shouldBe Some(JsObject())
+ JsHelpers.getFieldPath(JsObject.empty) shouldBe Some(JsObject.empty)
}
}
diff --git a/tests/src/test/scala/whisk/http/PoolingRestClientTests.scala
b/tests/src/test/scala/whisk/http/PoolingRestClientTests.scala
index 7213e4ae4b..d8be97ae39 100644
--- a/tests/src/test/scala/whisk/http/PoolingRestClientTests.scala
+++ b/tests/src/test/scala/whisk/http/PoolingRestClientTests.scala
@@ -88,7 +88,7 @@ class PoolingRestClientTests
}
it should "return payload from a request" in {
- val httpResponse = HttpResponse(entity =
HttpEntity(ContentTypes.`application/json`, JsObject().compactPrint))
+ val httpResponse = HttpResponse(entity =
HttpEntity(ContentTypes.`application/json`, JsObject.empty.compactPrint))
val httpRequest = HttpRequest()
val poolingRestClient = new PoolingRestClient("https", "host", 443, 1,
Some(testFlow(httpResponse)))
@@ -96,7 +96,7 @@ class PoolingRestClientTests
}
it should "send headers when making a request" in {
- val httpResponse = HttpResponse(entity =
HttpEntity(ContentTypes.`application/json`, JsObject().compactPrint))
+ val httpResponse = HttpResponse(entity =
HttpEntity(ContentTypes.`application/json`, JsObject.empty.compactPrint))
val httpRequest = HttpRequest(headers = List(RawHeader("key", "value")))
val poolingRestClient = new PoolingRestClient("https", "host", 443, 1,
Some(testFlow(httpResponse, httpRequest)))
@@ -104,7 +104,7 @@ class PoolingRestClientTests
}
it should "send uri when making a request" in {
- val httpResponse = HttpResponse(entity =
HttpEntity(ContentTypes.`application/json`, JsObject().compactPrint))
+ val httpResponse = HttpResponse(entity =
HttpEntity(ContentTypes.`application/json`, JsObject.empty.compactPrint))
val httpRequest = HttpRequest(uri = Uri("/some/where"))
val poolingRestClient = new PoolingRestClient("https", "host", 443, 1,
Some(testFlow(httpResponse, httpRequest)))
@@ -112,7 +112,7 @@ class PoolingRestClientTests
}
it should "send a payload when making a request" in {
- val httpResponse = HttpResponse(entity =
HttpEntity(ContentTypes.`application/json`, JsObject().compactPrint))
+ val httpResponse = HttpResponse(entity =
HttpEntity(ContentTypes.`application/json`, JsObject.empty.compactPrint))
val httpRequest = HttpRequest(POST, entity =
HttpEntity(ContentTypes.`text/plain(UTF-8)`, "payload"))
val poolingRestClient = new PoolingRestClient("https", "host", 443, 1,
Some(testFlow(httpResponse, httpRequest)))
@@ -120,37 +120,37 @@ class PoolingRestClientTests
}
it should "return JSON when making a request" in {
- val httpResponse = HttpResponse(entity =
HttpEntity(ContentTypes.`application/json`, JsObject().compactPrint))
- val httpRequest = HttpRequest(entity =
HttpEntity(ContentTypes.`application/json`, JsObject().compactPrint))
+ val httpResponse = HttpResponse(entity =
HttpEntity(ContentTypes.`application/json`, JsObject.empty.compactPrint))
+ val httpRequest = HttpRequest(entity =
HttpEntity(ContentTypes.`application/json`, JsObject.empty.compactPrint))
val poolingRestClient = new PoolingRestClient("https", "host", 443, 1,
Some(testFlow(httpResponse, httpRequest)))
- val request = mkJsonRequest(GET, Uri./, JsObject(), List.empty)
+ val request = mkJsonRequest(GET, Uri./, JsObject.empty, List.empty)
- await(poolingRestClient.requestJson[JsObject](request)) shouldBe
Right(JsObject())
+ await(poolingRestClient.requestJson[JsObject](request)) shouldBe
Right(JsObject.empty)
}
it should "throw timeout exception when Future fails in httpFlow" in {
- val httpResponse = HttpResponse(entity =
HttpEntity(ContentTypes.`application/json`, JsObject().compactPrint))
- val httpRequest = HttpRequest(entity =
HttpEntity(ContentTypes.`application/json`, JsObject().compactPrint))
+ val httpResponse = HttpResponse(entity =
HttpEntity(ContentTypes.`application/json`, JsObject.empty.compactPrint))
+ val httpRequest = HttpRequest(entity =
HttpEntity(ContentTypes.`application/json`, JsObject.empty.compactPrint))
val poolingRestClient = new PoolingRestClient("https", "host", 443, 1,
Some(failFlow(httpResponse, httpRequest)))
- val request = mkJsonRequest(GET, Uri./, JsObject(), List.empty)
+ val request = mkJsonRequest(GET, Uri./, JsObject.empty, List.empty)
a[TimeoutException] should be thrownBy
await(poolingRestClient.requestJson[JsObject](request))
}
it should "return a status code on request failure" in {
val httpResponse = HttpResponse(NotFound)
- val httpRequest = HttpRequest(entity =
HttpEntity(ContentTypes.`application/json`, JsObject().compactPrint))
+ val httpRequest = HttpRequest(entity =
HttpEntity(ContentTypes.`application/json`, JsObject.empty.compactPrint))
val poolingRestClient = new PoolingRestClient("https", "host", 443, 1,
Some(testFlow(httpResponse, httpRequest)))
- val request = mkJsonRequest(GET, Uri./, JsObject(), List.empty)
+ val request = mkJsonRequest(GET, Uri./, JsObject.empty, List.empty)
await(poolingRestClient.requestJson[JsObject](request)) shouldBe
Left(NotFound)
}
it should "throw an unsupported content-type exception when unexpected
content-type is returned" in {
val httpResponse = HttpResponse(entity =
HttpEntity(ContentTypes.`text/plain(UTF-8)`, "plain text"))
- val httpRequest = HttpRequest(entity =
HttpEntity(ContentTypes.`application/json`, JsObject().compactPrint))
+ val httpRequest = HttpRequest(entity =
HttpEntity(ContentTypes.`application/json`, JsObject.empty.compactPrint))
val poolingRestClient = new PoolingRestClient("https", "host", 443, 1,
Some(testFlow(httpResponse, httpRequest)))
- val request = mkJsonRequest(GET, Uri./, JsObject(), List.empty)
+ val request = mkJsonRequest(GET, Uri./, JsObject.empty, List.empty)
a[UnsupportedContentTypeException] should be thrownBy
await(poolingRestClient.requestJson[JsObject](request))
}
@@ -162,17 +162,17 @@ class PoolingRestClientTests
}
it should "create an HttpRequest with a JSON payload" in {
- val httpRequest = HttpRequest(entity =
HttpEntity(ContentTypes.`application/json`, JsObject().compactPrint))
+ val httpRequest = HttpRequest(entity =
HttpEntity(ContentTypes.`application/json`, JsObject.empty.compactPrint))
- await(mkJsonRequest(GET, Uri./, JsObject(), List.empty)) shouldBe
httpRequest
+ await(mkJsonRequest(GET, Uri./, JsObject.empty, List.empty)) shouldBe
httpRequest
}
it should "create an HttpRequest with a payload" in {
- val httpRequest = HttpRequest(entity =
HttpEntity(ContentTypes.`application/json`, JsObject().compactPrint))
+ val httpRequest = HttpRequest(entity =
HttpEntity(ContentTypes.`application/json`, JsObject.empty.compactPrint))
val request = mkRequest(
GET,
Uri./,
- Future.successful(HttpEntity(ContentTypes.`application/json`,
JsObject().compactPrint)),
+ Future.successful(HttpEntity(ContentTypes.`application/json`,
JsObject.empty.compactPrint)),
List.empty)
await(request) shouldBe httpRequest
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services