1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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))
}
}
|