You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by md...@apache.org on 2018/07/03 20:21:02 UTC

[incubator-openwhisk] 16/19: Add back utility method used downstream, with deprecation notice issued in logs.

This is an automated email from the ASF dual-hosted git repository.

mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git

commit 49e89cbaa12b9aee8a0cb1c18f21a112c42df24a
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Sat Jun 9 01:15:04 2018 -0400

    Add back utility method used downstream, with deprecation notice issued in logs.
---
 tests/src/test/scala/common/WskTestHelpers.scala | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/tests/src/test/scala/common/WskTestHelpers.scala b/tests/src/test/scala/common/WskTestHelpers.scala
index 65d2f16..31e3d7c 100644
--- a/tests/src/test/scala/common/WskTestHelpers.scala
+++ b/tests/src/test/scala/common/WskTestHelpers.scala
@@ -320,6 +320,19 @@ trait WskTestHelpers extends Matchers {
       wskadmin.cli(Seq("user", "delete", subject), expectedExitCode).stdout should include("Subject deleted")
     }
   }
-  //Append the current timestamp in ms
+
+  /** Appends the current timestamp in ms. */
   def withTimestamp(text: String) = s"${text}-${System.currentTimeMillis}"
+
+  /** Strips the first line if it ends in a new line as is common for CLI output. */
+  def removeCLIHeader(response: String): String = {
+    if (response.contains("\n")) response.substring(response.indexOf("\n")) else response
+  }
+
+  // using annotation will cause compile errors because we use -Xfatal-warnings
+  // @deprecated(message = "use wsk.parseJsonString instead", since = "pr #3741")
+  def getJSONFromResponse(response: String, isCli: Boolean = false): JsObject = {
+    println("!!! WARNING: method is deprecated; use wsk.parseJsonString instead")
+    if (isCli) removeCLIHeader(response).parseJson.asJsObject else response.parseJson.asJsObject
+  }
 }