blob: 3ce05492f9129bd7c1868a5f3130cb0002db9388 [file] [log] [blame]
/*
* Copyright 2015-2016 IBM Corporation
*
* Licensed 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 packages
import common.{TestHelpers, Wsk, WskProps, WskTestHelpers, _}
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import spray.json.DefaultJsonProtocol.StringJsonFormat
import spray.json.pimpAny
@RunWith(classOf[JUnitRunner])
class PushNotificationsTests
extends TestHelpers
with WskTestHelpers{
implicit val wskprops = WskProps()
val wsk = new Wsk()
val credentials = TestUtils.getVCAPcredentials("imfpush")
val appSecret = credentials.get("appSecret").toJson;
val credentialsUrl = credentials.get("url");
val appGuid = credentialsUrl.split("/").last.toJson;
val url = "www.google.com".toJson;
val messageText = "This is pushnotifications Testing".toJson;
val unicodeMessage = "\ue04a".toJson;
val accentMessage = "Máxima de 33 C and Mínima de 26 C".toJson;
behavior of "Push Package"
it should "Send Notification action" in {
val name = "/whisk.system/pushnotifications/sendMessage"
withActivation(wsk.activation,wsk.action.invoke(name, Map("appSecret" -> appSecret, "appGuid" -> appGuid, "text" -> messageText))){
_.response.result.get.toString should include ("message")
}
}
it should "Send Notification action with unicode message" in {
val name = "/whisk.system/pushnotifications/sendMessage"
withActivation(wsk.activation,wsk.action.invoke(name, Map("appSecret" -> appSecret, "appGuid" -> appGuid, "text" -> unicodeMessage))){
_.response.result.get.toString should include ("message")
}
}
it should "Send Notification action with accent message" in {
val name = "/whisk.system/pushnotifications/sendMessage"
withActivation(wsk.activation,wsk.action.invoke(name, Map("appSecret" -> appSecret, "appGuid" -> appGuid, "text" -> accentMessage))){
_.response.result.get.toString should include ("message")
}
}
it should "Send Notification action with url" in {
val name = "/whisk.system/pushnotifications/sendMessage"
withActivation(wsk.activation,wsk.action.invoke(name, Map("appSecret" -> appSecret, "appGuid" -> appGuid, "text" -> messageText, "url"-> url))){
_.response.result.get.toString should include ("message")
}
}
}