aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/StudyDesignFormatSuite.scala
blob: 9cf9b5f12bd10918d14d193502b67234d730a487 (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
package xyz.driver.pdsuidomain.formats.json.sprayformats

import spray.json._
import org.scalatest.{FlatSpec, Matchers}
import xyz.driver.pdsuicommon.domain.LongId
import xyz.driver.pdsuidomain.entities.StudyDesign

class StudyDesignFormatSuite extends FlatSpec with Matchers {
  import studydesign._

  "Json format for StudyDesign" should "read and write correct JSON" in {
    val studyDesign = StudyDesign(
      id = LongId(10),
      name = "study design name"
    )
    val writtenJson = studyDesignFormat.write(studyDesign)

    writtenJson should be("""{"id":10,"name":"study design name"}""".parseJson)

    val parsedStudyDesign = studyDesignFormat.read(writtenJson)
    parsedStudyDesign should be(studyDesign)
  }

}