blob: 306fb17dfd983f50b5db0486d3df5ff5df1e4a87 (
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
|
package xyz.driver.pdsuidomain.formats.json.sprayformats
import spray.json._
import org.scalatest.{FlatSpec, Matchers}
import xyz.driver.pdsuicommon.domain.UuidId
import xyz.driver.pdsuidomain.entities.Hypothesis
class HypothesisFormatSuite extends FlatSpec with Matchers {
import hypothesis._
"Json format for Hypothesis" should "read and write correct JSON" in {
val hypothesis = Hypothesis(
id = UuidId("3b80b2e2-5372-4cf5-a342-6e4ebe10fafd"),
name = "hypothesis name",
treatmentType = "treatment type",
description = "descr"
)
val writtenJson = hypothesisFormat.write(hypothesis)
writtenJson should be(
"""{"id":"3b80b2e2-5372-4cf5-a342-6e4ebe10fafd","name":"hypothesis name",
"treatmentType":"treatment type","description":"descr"}""".parseJson)
val parsedHypothesis = hypothesisFormat.read(writtenJson)
parsedHypothesis should be(hypothesis)
}
}
|