You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by du...@apache.org on 2018/02/06 16:12:56 UTC

[incubator-openwhisk] branch master updated: Refactor List Limit Error Message (#3251)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new f22955f  Refactor List Limit Error Message (#3251)
f22955f is described below

commit f22955f170b1500db550ef12119f3ef766d443b7
Author: James Dubee <jw...@us.ibm.com>
AuthorDate: Tue Feb 6 11:12:53 2018 -0500

    Refactor List Limit Error Message (#3251)
---
 common/scala/src/main/scala/whisk/http/ErrorResponse.scala            | 4 ++--
 core/controller/src/main/scala/whisk/core/controller/RestAPIs.scala   | 2 +-
 tests/src/test/scala/whisk/core/controller/test/ActionsApiTests.scala | 2 +-
 .../test/scala/whisk/core/controller/test/ActivationsApiTests.scala   | 2 +-
 .../src/test/scala/whisk/core/controller/test/PackagesApiTests.scala  | 2 +-
 tests/src/test/scala/whisk/core/controller/test/RulesApiTests.scala   | 2 +-
 .../src/test/scala/whisk/core/controller/test/TriggersApiTests.scala  | 2 +-
 7 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/common/scala/src/main/scala/whisk/http/ErrorResponse.scala b/common/scala/src/main/scala/whisk/http/ErrorResponse.scala
index e89fad9..bd0bfb3 100644
--- a/common/scala/src/main/scala/whisk/http/ErrorResponse.scala
+++ b/common/scala/src/main/scala/whisk/http/ErrorResponse.scala
@@ -133,8 +133,8 @@ object Messages {
     s"${error.field} larger than allowed: ${error.is.toBytes} > ${error.allowed.toBytes} bytes."
   }
 
-  def maxListLimitExceeded(collection: String, value: Int, max: Int) = {
-    s"The value $value exceeds the allowed limit $max for $collection."
+  def listLimitOutOfRange(collection: String, value: Int, max: Int) = {
+    s"The value $value is not in the range of 0 to $max for $collection."
   }
   def listLimitIsNotAString = s"The API expects the 'limit' value to be an integer but the given value is not."
 
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 161ef4b..3c2ac46 100644
--- a/core/controller/src/main/scala/whisk/core/controller/RestAPIs.scala
+++ b/core/controller/src/main/scala/whisk/core/controller/RestAPIs.scala
@@ -130,7 +130,7 @@ protected[controller] object RestApiCommons {
         case Success(n) if (n > 0 && n <= Collection.MAX_LIST_LIMIT) => ListLimit(n)
         case Success(n) =>
           throw new IllegalArgumentException(
-            Messages.maxListLimitExceeded(collection.path, n, Collection.MAX_LIST_LIMIT))
+            Messages.listLimitOutOfRange(collection.path, n, Collection.MAX_LIST_LIMIT))
         case Failure(t) => throw new IllegalArgumentException(Messages.listLimitIsNotAString)
       }
     }
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 3566713..9018759 100644
--- a/tests/src/test/scala/whisk/core/controller/test/ActionsApiTests.scala
+++ b/tests/src/test/scala/whisk/core/controller/test/ActionsApiTests.scala
@@ -95,7 +95,7 @@ class ActionsApiTests extends ControllerTestCommon with WhiskActionsApi {
     val response = Get(s"$collectionPath?limit=$exceededMaxLimit") ~> Route.seal(routes(creds)) ~> check {
       status should be(BadRequest)
       responseAs[String] should include {
-        Messages.maxListLimitExceeded(Collection.ACTIONS, exceededMaxLimit, Collection.MAX_LIST_LIMIT)
+        Messages.listLimitOutOfRange(Collection.ACTIONS, exceededMaxLimit, Collection.MAX_LIST_LIMIT)
       }
     }
   }
diff --git a/tests/src/test/scala/whisk/core/controller/test/ActivationsApiTests.scala b/tests/src/test/scala/whisk/core/controller/test/ActivationsApiTests.scala
index cc16220..7d69ccf 100644
--- a/tests/src/test/scala/whisk/core/controller/test/ActivationsApiTests.scala
+++ b/tests/src/test/scala/whisk/core/controller/test/ActivationsApiTests.scala
@@ -388,7 +388,7 @@ class ActivationsApiTests extends ControllerTestCommon with WhiskActivationsApi
     val response = Get(s"$collectionPath?limit=$exceededMaxLimit") ~> Route.seal(routes(creds)) ~> check {
       status should be(BadRequest)
       responseAs[String] should include {
-        Messages.maxListLimitExceeded(Collection.ACTIVATIONS, exceededMaxLimit, Collection.MAX_LIST_LIMIT)
+        Messages.listLimitOutOfRange(Collection.ACTIVATIONS, exceededMaxLimit, Collection.MAX_LIST_LIMIT)
       }
     }
   }
diff --git a/tests/src/test/scala/whisk/core/controller/test/PackagesApiTests.scala b/tests/src/test/scala/whisk/core/controller/test/PackagesApiTests.scala
index 54e3823..9dbb8c2 100644
--- a/tests/src/test/scala/whisk/core/controller/test/PackagesApiTests.scala
+++ b/tests/src/test/scala/whisk/core/controller/test/PackagesApiTests.scala
@@ -157,7 +157,7 @@ class PackagesApiTests extends ControllerTestCommon with WhiskPackagesApi {
     val response = Get(s"$collectionPath?limit=$exceededMaxLimit") ~> Route.seal(routes(creds)) ~> check {
       status should be(BadRequest)
       responseAs[String] should include {
-        Messages.maxListLimitExceeded(Collection.PACKAGES, exceededMaxLimit, Collection.MAX_LIST_LIMIT)
+        Messages.listLimitOutOfRange(Collection.PACKAGES, exceededMaxLimit, Collection.MAX_LIST_LIMIT)
       }
     }
   }
diff --git a/tests/src/test/scala/whisk/core/controller/test/RulesApiTests.scala b/tests/src/test/scala/whisk/core/controller/test/RulesApiTests.scala
index 54fb047..6430a52 100644
--- a/tests/src/test/scala/whisk/core/controller/test/RulesApiTests.scala
+++ b/tests/src/test/scala/whisk/core/controller/test/RulesApiTests.scala
@@ -99,7 +99,7 @@ class RulesApiTests extends ControllerTestCommon with WhiskRulesApi {
     val response = Get(s"$collectionPath?limit=$exceededMaxLimit") ~> Route.seal(routes(creds)) ~> check {
       status should be(BadRequest)
       responseAs[String] should include {
-        Messages.maxListLimitExceeded(Collection.RULES, exceededMaxLimit, Collection.MAX_LIST_LIMIT)
+        Messages.listLimitOutOfRange(Collection.RULES, exceededMaxLimit, Collection.MAX_LIST_LIMIT)
       }
     }
   }
diff --git a/tests/src/test/scala/whisk/core/controller/test/TriggersApiTests.scala b/tests/src/test/scala/whisk/core/controller/test/TriggersApiTests.scala
index 3a8d3ce..1734a17 100644
--- a/tests/src/test/scala/whisk/core/controller/test/TriggersApiTests.scala
+++ b/tests/src/test/scala/whisk/core/controller/test/TriggersApiTests.scala
@@ -103,7 +103,7 @@ class TriggersApiTests extends ControllerTestCommon with WhiskTriggersApi {
     val response = Get(s"$collectionPath?limit=$exceededMaxLimit") ~> Route.seal(routes(creds)) ~> check {
       status should be(BadRequest)
       responseAs[String] should include {
-        Messages.maxListLimitExceeded(Collection.TRIGGERS, exceededMaxLimit, Collection.MAX_LIST_LIMIT)
+        Messages.listLimitOutOfRange(Collection.TRIGGERS, exceededMaxLimit, Collection.MAX_LIST_LIMIT)
       }
     }
   }

-- 
To stop receiving notification emails like this one, please contact
dubeejw@apache.org.