blob: 5cd6c8d1ffc86b0a3881160ee566546567c4ffc8 (
plain) (
blame)
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.domain.{LongId, StringId}
import xyz.driver.pdsuidomain.entities.MedicalRecordHistory
class MedicalRecordHistoryFormatSuite extends FlatSpec with Matchers {
import recordhistory._
"Json format for MedicalRecordHistory" should "read and write correct JSON" in {
val recordHistory = MedicalRecordHistory(
id = LongId(10),
recordId = LongId(1),
executor = StringId("userId-001"),
state = MedicalRecordHistory.State.Clean,
action = MedicalRecordHistory.Action.Start,
created = LocalDateTime.parse("2017-08-10T18:00:00")
)
val writtenJson = recordHistoryFormat.write(recordHistory)
writtenJson should be(
"""{"id":10,"executor":"userId-001","recordId":1,"state":"Clean",
"action":"Start","created":"2017-08-10T18:00Z"}""".parseJson)
val parsedRecordHistory = recordHistoryFormat.read(writtenJson)
parsedRecordHistory should be(recordHistory)
}
}
|