aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/BridgeUploadQueueFormat.scala
diff options
context:
space:
mode:
authorJakob Odersky <jakob@odersky.com>2017-08-14 22:29:45 -0700
committerGitHub <noreply@github.com>2017-08-14 22:29:45 -0700
commit322ea28ecf5ad5f65d3376f3e97e004d229d4736 (patch)
treec405d10d70f4ec1f18ffa81bc01cd8da64bddcba /src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/BridgeUploadQueueFormat.scala
parentbe74ae7c5531af998d38b9de8052791f17b25341 (diff)
parent442579b27ccbac82cb001a5b02402a593d005977 (diff)
downloadrest-query-322ea28ecf5ad5f65d3376f3e97e004d229d4736.tar.gz
rest-query-322ea28ecf5ad5f65d3376f3e97e004d229d4736.tar.bz2
rest-query-322ea28ecf5ad5f65d3376f3e97e004d229d4736.zip
Merge pull request #18 from drivergroup/PDSUI-2188
PDSUI-2188 Create spray json formats for domain entities
Diffstat (limited to 'src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/BridgeUploadQueueFormat.scala')
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/BridgeUploadQueueFormat.scala32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/BridgeUploadQueueFormat.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/BridgeUploadQueueFormat.scala
new file mode 100644
index 0000000..854f51f
--- /dev/null
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/BridgeUploadQueueFormat.scala
@@ -0,0 +1,32 @@
+package xyz.driver.pdsuidomain.formats.json.sprayformats
+
+import java.time.LocalDateTime
+
+import spray.json._
+import org.scalatest.{FlatSpec, Matchers}
+import xyz.driver.pdsuicommon.concurrent.BridgeUploadQueue
+
+class BridgeUploadQueueFormat extends FlatSpec with Matchers {
+ import bridgeuploadqueue._
+
+ "Json format for BridgeUploadQueue.Item" should "read and write correct JSON" in {
+ val item = BridgeUploadQueue.Item(
+ kind = "kind",
+ tag = "tag",
+ created = LocalDateTime.parse("2017-08-10T18:00:00"),
+ attempts = 0,
+ nextAttempt = LocalDateTime.parse("2017-08-10T18:10:00"),
+ completed = false,
+ dependencyKind = Some("dependency king"),
+ dependencyTag = None
+ )
+ val writtenJson = queueUploadItemFormat.write(item)
+
+ writtenJson should be(
+ """{"kind":"kind","tag":"tag","created":"2017-08-10T18:00Z","attempts":0,"nextAttempt":"2017-08-10T18:10Z","completed":false}""".parseJson)
+
+ val parsedItem = queueUploadItemFormat.read(writtenJson)
+ parsedItem should be(item.copy(dependencyKind = None, completed = true))
+ }
+
+}