我有一个创建方法来创建实体槽POST
:
def create = Action(parse.json) { request =>
val address = Json.fromJson[Address](request.body)
Ok(address.toString())
}
我想像这样测试它:
"A POST request on addresses create method" should "return OK " in {
val node = Json.toJson(Address(None, "street 2", "33", "343333", "Arad", "Romania", None))(controllers.AddressBean.addressWrites);
val result = AddressBean.create(FakeRequest().withJsonBody(node, Helpers.POST))
status(result) should equal(OK)
contentType(result) should be(Some("application/json"))
}
但对我来说这个警告似乎很奇怪status(result)
:
类型不匹配; 找到:play.api.libs.iteratee.Iteratee[Array[Byte],play.api.mvc.Result] 需要:play.api.mvc.Result
有谁知道为什么会发生这种类型不匹配?