Created
August 29, 2012 14:26
-
-
Save manuelbernhardt/3513352 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[info] Compiling 1 Scala source to /Users/manu/workspace/saas/modules/simple-document-upload/target/scala-2.9.1/test-classes... | |
[error] /Users/manu/workspace/saas/modules/simple-document-upload/test/SimpleDocumentUploadSpec.scala:28: diverging implicit expansion for type play.api.libs.json.Writes[java.lang.String] | |
[error] starting with method GenericFormat in trait DefaultFormat | |
[error] "id" -> toJson("delving_uploadDocuments_503e203903643da47461306e"), | |
[error] ^ | |
[error] /Users/manu/workspace/saas/modules/simple-document-upload/test/SimpleDocumentUploadSpec.scala:31: diverging implicit expansion for type play.api.libs.json.Writes[java.lang.String] | |
[error] starting with method GenericFormat in trait DefaultFormat | |
[error] "key" -> toJson("dc:title"), | |
[error] ^ | |
[error] /Users/manu/workspace/saas/modules/simple-document-upload/test/SimpleDocumentUploadSpec.scala:32: diverging implicit expansion for type play.api.libs.json.Writes[java.lang.String] | |
[error] starting with method GenericFormat in trait DefaultFormat | |
[error] "label" -> toJson("Title"), | |
[error] ^ | |
[error] /Users/manu/workspace/saas/modules/simple-document-upload/test/SimpleDocumentUploadSpec.scala:33: diverging implicit expansion for type play.api.libs.json.Writes[java.lang.String] | |
[error] starting with method GenericFormat in trait DefaultFormat | |
[error] "value" -> toJson("Sample title") | |
[error] ^ | |
[error] /Users/manu/workspace/saas/modules/simple-document-upload/test/SimpleDocumentUploadSpec.scala:30: diverging implicit expansion for type play.api.libs.json.Writes[scala.collection.immutable.Map[java.lang.String,play.api.libs.json.JsValue]] | |
[error] starting with method GenericFormat in trait DefaultFormat | |
[error] toJson(Map( | |
[error] ^ | |
[error] 5 errors found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import core.SystemField | |
import models.MetadataCache | |
import play.api.libs.json.Json._ | |
import play.api.libs.json.Format._ | |
import play.api.libs.json._ | |
import play.api.mvc.AnyContentAsJson | |
import play.api.test.Helpers._ | |
import play.api.test.{FakeHeaders, FakeRequest} | |
/** | |
* | |
* @author Manuel Bernhardt <[email protected]> | |
*/ | |
class SimpleDocumentUploadSpec extends TestContext { | |
"The SimpleDocumentUpload controller" should { | |
"upload a document" in { | |
withTestConfig { | |
val fakeRequest = FakeRequest( | |
method = "POST", | |
uri = "", | |
headers = FakeHeaders(Map(CONTENT_TYPE -> Seq("application/json"))), | |
body = AnyContentAsJson( | |
toJson(Map( | |
"id" -> "delving_uploadDocuments_503e203903643da47461306e", | |
"fields" -> Seq( | |
Map( | |
"key" -> JsString("dc:title"), | |
"label" -> JsString("Title"), | |
"value" -> JsString("Sample title") | |
), | |
Map( | |
"key" -> JsString("dc:subject"), | |
"label" -> JsString("Subject"), | |
"value" -> JsString("Random subject") | |
) | |
), | |
"files" -> Seq() | |
)) | |
) | |
) | |
val result = asyncToResult(controllers.organizations.SimpleDocumentUpload.submit("delving")(fakeRequest)) | |
status(result) must equalTo(OK) | |
val maybeDoc = MetadataCache.get("delving", "uploadDocuments", "uploadDocument").findOne("delving_uploadDocuments_503e203903643da47461306e") | |
maybeDoc must not equalTo (None) | |
val doc = maybeDoc.get | |
doc.getSystemFieldValues(SystemField.TITLE).headOption must equalTo (Some("Sample title")) | |
doc.index must equalTo (0) | |
doc.schemaVersions.get("tib") must equalTo("1.0.0") | |
doc.xml.get("tib") must equalTo("<tib:record><dc:title>Sample title</dc:title><dc:subject>Random subject</dc:subject></tib:record>") | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment