You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2017/10/26 15:02:35 UTC

[GitHub] houshengbo commented on a change in pull request #2895: Update the test cases about rules with REST implementation

houshengbo commented on a change in pull request #2895: Update the test cases about rules with REST implementation
URL: https://github.com/apache/incubator-openwhisk/pull/2895#discussion_r147170786
 
 

 ##########
 File path: tests/src/test/scala/system/basic/WskRestRuleTests.scala
 ##########
 @@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package system.basic
+
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+import scala.util.control.Breaks._
+
+import common.TestUtils.RunResult
+import common.rest.WskRest
+import common.rest.RestResult
+
+import spray.json.JsObject
+
+@RunWith(classOf[JUnitRunner])
+class WskRestRuleTests extends WskRuleTests {
+  override val wsk: common.rest.WskRest = new WskRest
+
+  override def verifyRuleList(ruleListResult: RunResult,
+                              ruleNameEnable: String,
+                              ruleName: String): org.scalatest.Assertion = {
+    val ruleListResultRest = ruleListResult.asInstanceOf[RestResult]
+    val rules = ruleListResultRest.getBodyListJsObject()
+    val ruleEnable = wsk.rule.get(ruleNameEnable)
+    ruleEnable.getField("status") shouldBe "active"
+    val ruleDisable = wsk.rule.get(ruleName)
+    ruleDisable.getField("status") shouldBe "inactive"
+    verifyListIncludeRule(rules, ruleNameEnable)
+    verifyListIncludeRule(rules, ruleName)
+    ruleListResultRest.respData should not include ("Unknown")
+  }
+
+  private def verifyListIncludeRule(rules: Vector[JsObject], ruleName: String) = {
+    var found = false
+    for (rule <- rules) {
+      breakable {
+        if (RestResult.getField(rule, "name") == ruleName) {
+          found = true
+          break
+        }
+      }
+    }
+    found shouldBe true
+  }
 
 Review comment:
   Done.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services