Skip to content

Instantly share code, notes, and snippets.

@iainporter
Created July 18, 2020 10:17
Show Gist options
  • Save iainporter/84446dd70a80ae06f6ddbbb9456916f7 to your computer and use it in GitHub Desktop.
Save iainporter/84446dd70a80ae06f6ddbbb9456916f7 to your computer and use it in GitHub Desktop.
Component test to send a message
class SendMessageTest : TestEnvironment() {
@Test
fun `a valid request to send a SMS Message`() {
//send a message
val request = """{"text":"Foo Bar", "fromNumber":"+1234567890", "toNumber":"+1234567899"}"""
val response = RestFunctions.sendSmsMessage(request)
val location = response.header("Location")
//check the message can be retrieved
val messageResponse = RestFunctions.getMessage(location)
val json = messageResponse.body.jsonPath()
assertThat(json.get("id"), `is`(location.substring(location.lastIndexOf("/")+ 1)))
assertThat(json.get("status"), `is`("WAITING"))
assertThat(json.get("toNumber"), `is`("+1234567899"))
assertThat(json.get("fromNumber"), `is`("+1234567890"))
assertThat(json.get("text"), `is`("Foo Bar"))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment