openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdeu...@apache.org
Subject [incubator-openwhisk] 08/19: Remove unnecessary dependency injection and flatten type hiearchy some more.
Date Tue, 03 Jul 2018 20:20:54 GMT
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 583862d4d8c1705eea1a6bc1749ee24703660651
Author: Rodric Rabbah <rodric@gmail.com>
AuthorDate: Fri Jun 8 16:18:51 2018 -0400

    Remove unnecessary dependency injection and flatten type hiearchy some more.
---
 tests/src/test/scala/common/BaseWsk.scala      | 26 ++++++++++++--------------
 tests/src/test/scala/common/rest/WskRest.scala | 19 +++++++++----------
 2 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/tests/src/test/scala/common/BaseWsk.scala b/tests/src/test/scala/common/BaseWsk.scala
index d91c578..53325e5 100644
--- a/tests/src/test/scala/common/BaseWsk.scala
+++ b/tests/src/test/scala/common/BaseWsk.scala
@@ -86,17 +86,7 @@ trait WaitFor {
   }
 }
 
-trait BaseRunWsk {
-  /*
-   * Utility function to return a JSON object from the CLI output that returns
-   * an optional a status line following by the JSON data
-   */
-  def parseJsonString(jsonStr: String): JsObject = {
-    jsonStr.substring(jsonStr.indexOf("\n") + 1).parseJson.asJsObject // Skip optional status
line before parsing
-  }
-}
-
-trait BaseWsk extends BaseRunWsk {
+trait BaseWsk {
   val action: BaseAction
   val trigger: BaseTrigger
   val rule: BaseRule
@@ -104,9 +94,17 @@ trait BaseWsk extends BaseRunWsk {
   val pkg: BasePackage
   val namespace: BaseNamespace
   val api: BaseApi
+
+  /*
+   * Utility function to return a JSON object from the CLI output that returns
+   * an optional a status line following by the JSON data
+   */
+  def parseJsonString(jsonStr: String): JsObject = {
+    jsonStr.substring(jsonStr.indexOf("\n") + 1).parseJson.asJsObject // Skip optional status
line before parsing
+  }
 }
 
-trait FullyQualifiedNames {
+object FullyQualifiedNames {
 
   /**
    * Fully qualifies the name of an entity with its namespace.
@@ -139,7 +137,7 @@ trait FullyQualifiedNames {
   }
 }
 
-trait BaseListOrGetFromCollection extends FullyQualifiedNames {
+trait BaseListOrGetFromCollection {
 
   protected val noun: String
 
@@ -171,7 +169,7 @@ trait BaseListOrGetFromCollection extends FullyQualifiedNames {
           saveAs: Option[String] = None)(implicit wp: WskProps): RunResult
 }
 
-trait BaseDeleteFromCollection extends FullyQualifiedNames {
+trait BaseDeleteFromCollection {
 
   protected val noun: String
 
diff --git a/tests/src/test/scala/common/rest/WskRest.scala b/tests/src/test/scala/common/rest/WskRest.scala
index a4d7ac6..a209735 100644
--- a/tests/src/test/scala/common/rest/WskRest.scala
+++ b/tests/src/test/scala/common/rest/WskRest.scala
@@ -155,8 +155,8 @@ class WskRest() extends RunWskRestCmd with BaseWsk {
   override implicit val api = new WskRestApi
 }
 
-trait ListOrGetFromCollectionRest extends BaseListOrGetFromCollection {
-  self: RunWskRestCmd =>
+trait ListOrGetFromCollectionRest extends RunWskRestCmd with BaseListOrGetFromCollection
{
+  import FullyQualifiedNames.resolve
 
   /**
    * List entities in collection.
@@ -202,14 +202,13 @@ trait ListOrGetFromCollectionRest extends BaseListOrGetFromCollection
{
     val (ns, entity) = getNamespaceEntityName(name)
     val entPath = Path(s"$basePath/namespaces/$ns/$noun/$entity")
     val resp = requestEntity(GET, entPath)(wp)
-    val r = new RestResult(resp.status, getRespData(resp))
-    validateStatusCode(expectedExitCode, r.statusCode.intValue)
-    r
+    val rr = new RestResult(resp.status, getRespData(resp))
+    validateStatusCode(expectedExitCode, rr.statusCode.intValue)
+    rr
   }
 }
 
-trait DeleteFromCollectionRest extends BaseDeleteFromCollection {
-  self: RunWskRestCmd =>
+trait DeleteFromCollectionRest extends RunWskRestCmd with BaseDeleteFromCollection {
 
   /**
    * Deletes entity from collection.
@@ -222,9 +221,9 @@ trait DeleteFromCollectionRest extends BaseDeleteFromCollection {
     val (ns, entityName) = getNamespaceEntityName(name)
     val path = Path(s"$basePath/namespaces/$ns/$noun/$entityName")
     val resp = requestEntity(DELETE, path)(wp)
-    val r = new RestResult(resp.status, getRespData(resp))
-    validateStatusCode(expectedExitCode, r.statusCode.intValue)
-    r
+    val rr = new RestResult(resp.status, getRespData(resp))
+    validateStatusCode(expectedExitCode, rr.statusCode.intValue)
+    rr
   }
 
   /**


Mime
View raw message