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 07c5c90acb4059835102a01cb7c026d321a661bb
Author: Rodric Rabbah <rod...@gmail.com>
AuthorDate: Fri Jun 8 16:31:48 2018 -0400

    Move a trait and singleton around.
---
 tests/src/test/scala/common/BaseWsk.scala        | 92 +++++++++++++++---------
 tests/src/test/scala/common/Wsk.scala            | 58 ---------------
 tests/src/test/scala/common/WskTestHelpers.scala | 33 +++++++++
 3 files changed, 91 insertions(+), 92 deletions(-)

diff --git a/tests/src/test/scala/common/BaseWsk.scala 
b/tests/src/test/scala/common/BaseWsk.scala
index 53325e5..90e9ffa 100644
--- a/tests/src/test/scala/common/BaseWsk.scala
+++ b/tests/src/test/scala/common/BaseWsk.scala
@@ -25,11 +25,12 @@ import java.time.Instant
 import scala.concurrent.duration.DurationInt
 import scala.concurrent.duration.Duration
 import scala.language.postfixOps
-
 import TestUtils._
 import spray.json._
 import whisk.core.entity.ByteSize
 
+import scala.util.Try
+
 case class WskProps(
   authKey: String = 
WhiskProperties.readAuthKey(WhiskProperties.getAuthFileForTesting),
   cert: String =
@@ -86,6 +87,62 @@ trait WaitFor {
   }
 }
 
+trait HasActivation {
+
+  /**
+   * Extracts activation id from invoke (action or trigger) or activation get
+   */
+  def extractActivationId(result: RunResult): Option[String] = {
+    Try {
+      // try to interpret the run result as the result of an invoke
+      extractActivationIdFromInvoke(result) getOrElse 
extractActivationIdFromActivation(result).get
+    } toOption
+  }
+
+  /**
+   * Extracts activation id from 'wsk activation get' run result
+   */
+  private def extractActivationIdFromActivation(result: RunResult): 
Option[String] = {
+    Try {
+      // a characteristic string that comes right before the activationId
+      val idPrefix = "ok: got activation "
+      val output = if (result.exitCode != SUCCESS_EXIT) result.stderr else 
result.stdout
+      assert(output.contains(idPrefix), output)
+      extractActivationId(idPrefix, output).get
+    } toOption
+  }
+
+  /**
+   * Extracts activation id from 'wsk action invoke' or 'wsk trigger invoke'
+   */
+  private def extractActivationIdFromInvoke(result: RunResult): Option[String] 
= {
+    Try {
+      val output = if (result.exitCode != SUCCESS_EXIT) result.stderr else 
result.stdout
+      assert(output.contains("ok: invoked") || output.contains("ok: 
triggered"), output)
+      // a characteristic string that comes right before the activationId
+      val idPrefix = "with id "
+      extractActivationId(idPrefix, output).get
+    } toOption
+  }
+
+  /**
+   * Extracts activation id preceded by a prefix (idPrefix) from a string 
(output)
+   *
+   * @param idPrefix the prefix of the activation id
+   * @param output the string to be used in the extraction
+   * @return an option containing the id as a string or None if the extraction 
failed for any reason
+   */
+  private def extractActivationId(idPrefix: String, output: String): 
Option[String] = {
+    Try {
+      val start = output.indexOf(idPrefix) + idPrefix.length
+      var end = start
+      assert(start > 0)
+      while (end < output.length && output.charAt(end) != '\n') end = end + 1
+      output.substring(start, end) // a uuid
+    } toOption
+  }
+}
+
 trait BaseWsk {
   val action: BaseAction
   val trigger: BaseTrigger
@@ -104,39 +161,6 @@ trait BaseWsk {
   }
 }
 
-object FullyQualifiedNames {
-
-  /**
-   * Fully qualifies the name of an entity with its namespace.
-   * If the name already starts with the PATHSEP character, then
-   * it already is fully qualified. Otherwise (package name or
-   * basic entity name) it is prefixed with the namespace. The
-   * namespace is derived from the implicit whisk properties.
-   *
-   * @param name to fully qualify iff it is not already fully qualified
-   * @param wp whisk properties
-   * @return name if it is fully qualified else a name fully qualified for a 
namespace
-   */
-  def fqn(name: String)(implicit wp: WskProps) = {
-    val sep = "/" // Namespace.PATHSEP
-    if (name.startsWith(sep) || name.count(_ == sep(0)) == 2) name
-    else s"$sep${wp.namespace}$sep$name"
-  }
-
-  /**
-   * Resolves a namespace. If argument is defined, it takes precedence.
-   * else resolve to namespace in implicit WskProps.
-   *
-   * @param namespace an optional namespace
-   * @param wp whisk properties
-   * @return resolved namespace
-   */
-  def resolve(namespace: Option[String])(implicit wp: WskProps) = {
-    val sep = "/" // Namespace.PATHSEP
-    namespace getOrElse s"$sep${wp.namespace}"
-  }
-}
-
 trait BaseListOrGetFromCollection {
 
   protected val noun: String
diff --git a/tests/src/test/scala/common/Wsk.scala 
b/tests/src/test/scala/common/Wsk.scala
index 1d40ba3..473e175 100644
--- a/tests/src/test/scala/common/Wsk.scala
+++ b/tests/src/test/scala/common/Wsk.scala
@@ -21,69 +21,11 @@ import java.io.File
 
 import scala.collection.JavaConversions.mapAsJavaMap
 import scala.collection.mutable.Buffer
-import scala.language.postfixOps
-import scala.util.Try
 import org.scalatest.Matchers
 import TestUtils._
 
 import scala.collection.mutable
 
-trait HasActivation {
-
-  /**
-   * Extracts activation id from invoke (action or trigger) or activation get
-   */
-  def extractActivationId(result: RunResult): Option[String] = {
-    Try {
-      // try to interpret the run result as the result of an invoke
-      extractActivationIdFromInvoke(result) getOrElse 
extractActivationIdFromActivation(result).get
-    } toOption
-  }
-
-  /**
-   * Extracts activation id from 'wsk activation get' run result
-   */
-  private def extractActivationIdFromActivation(result: RunResult): 
Option[String] = {
-    Try {
-      // a characteristic string that comes right before the activationId
-      val idPrefix = "ok: got activation "
-      val output = if (result.exitCode != SUCCESS_EXIT) result.stderr else 
result.stdout
-      assert(output.contains(idPrefix), output)
-      extractActivationId(idPrefix, output).get
-    } toOption
-  }
-
-  /**
-   * Extracts activation id from 'wsk action invoke' or 'wsk trigger invoke'
-   */
-  private def extractActivationIdFromInvoke(result: RunResult): Option[String] 
= {
-    Try {
-      val output = if (result.exitCode != SUCCESS_EXIT) result.stderr else 
result.stdout
-      assert(output.contains("ok: invoked") || output.contains("ok: 
triggered"), output)
-      // a characteristic string that comes right before the activationId
-      val idPrefix = "with id "
-      extractActivationId(idPrefix, output).get
-    } toOption
-  }
-
-  /**
-   * Extracts activation id preceded by a prefix (idPrefix) from a string 
(output)
-   *
-   * @param idPrefix the prefix of the activation id
-   * @param output the string to be used in the extraction
-   * @return an option containing the id as a string or None if the extraction 
failed for any reason
-   */
-  private def extractActivationId(idPrefix: String, output: String): 
Option[String] = {
-    Try {
-      val start = output.indexOf(idPrefix) + idPrefix.length
-      var end = start
-      assert(start > 0)
-      while (end < output.length && output.charAt(end) != '\n') end = end + 1
-      output.substring(start, end) // a uuid
-    } toOption
-  }
-}
-
 trait RunWskCmd extends Matchers {
 
   /**
diff --git a/tests/src/test/scala/common/WskTestHelpers.scala 
b/tests/src/test/scala/common/WskTestHelpers.scala
index e889a22..0008784 100644
--- a/tests/src/test/scala/common/WskTestHelpers.scala
+++ b/tests/src/test/scala/common/WskTestHelpers.scala
@@ -35,6 +35,39 @@ import TestUtils.SUCCESS_EXIT
 import TestUtils.CONFLICT
 import akka.http.scaladsl.model.StatusCodes
 
+object FullyQualifiedNames {
+
+  /**
+   * Fully qualifies the name of an entity with its namespace.
+   * If the name already starts with the PATHSEP character, then
+   * it already is fully qualified. Otherwise (package name or
+   * basic entity name) it is prefixed with the namespace. The
+   * namespace is derived from the implicit whisk properties.
+   *
+   * @param name to fully qualify iff it is not already fully qualified
+   * @param wp whisk properties
+   * @return name if it is fully qualified else a name fully qualified for a 
namespace
+   */
+  def fqn(name: String)(implicit wp: WskProps) = {
+    val sep = "/" // Namespace.PATHSEP
+    if (name.startsWith(sep) || name.count(_ == sep(0)) == 2) name
+    else s"$sep${wp.namespace}$sep$name"
+  }
+
+  /**
+   * Resolves a namespace. If argument is defined, it takes precedence.
+   * else resolve to namespace in implicit WskProps.
+   *
+   * @param namespace an optional namespace
+   * @param wp whisk properties
+   * @return resolved namespace
+   */
+  def resolve(namespace: Option[String])(implicit wp: WskProps) = {
+    val sep = "/" // Namespace.PATHSEP
+    namespace getOrElse s"$sep${wp.namespace}"
+  }
+}
+
 /**
  * An arbitrary response of a whisk action. Includes the result as a JsObject 
as the
  * structure of "result" is not defined.

Reply via email to