diff options
author | Kseniya Tomskikh <ktomskih@datamonsters.co> | 2017-08-10 19:25:00 +0600 |
---|---|---|
committer | Kseniya Tomskikh <ktomskih@datamonsters.co> | 2017-08-11 14:41:30 +0600 |
commit | 9e60edb6216fce615b13f9bcc68d8f86258b85c3 (patch) | |
tree | 04ca0ec035cabd617bc215f470166d507cdc4f27 /src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ArmFormatTestSuite.scala | |
parent | ef9517e1b8f599fbdd15c474cf7dfea61e803c2f (diff) | |
download | rest-query-9e60edb6216fce615b13f9bcc68d8f86258b85c3.tar.gz rest-query-9e60edb6216fce615b13f9bcc68d8f86258b85c3.tar.bz2 rest-query-9e60edb6216fce615b13f9bcc68d8f86258b85c3.zip |
PDSUI-2188 Created and fixed test for json formats of TriC
Diffstat (limited to 'src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ArmFormatTestSuite.scala')
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ArmFormatTestSuite.scala | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ArmFormatTestSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ArmFormatTestSuite.scala new file mode 100644 index 0000000..4a4b3c4 --- /dev/null +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ArmFormatTestSuite.scala @@ -0,0 +1,36 @@ +package xyz.driver.pdsuidomain.formats.json.sprayformats + +import spray.json._ +import org.scalatest.{FlatSpec, Matchers} +import xyz.driver.pdsuicommon.domain.{LongId, StringId} +import xyz.driver.pdsuidomain.entities.Arm + +class ArmFormatTestSuite extends FlatSpec with Matchers { + import arm._ + + "Json format for Arm" should "read and write correct JSON" in { + val arm = Arm( + id = LongId(10), + trialId = StringId("NCT000001"), + name = "arm name", + originalName = "orig arm name" + ) + val writtenJson = armFormat.write(arm) + + writtenJson should be("""{"id":10,"trialId":"NCT000001","name":"arm name","originalName":"orig arm name"}""".parseJson) + + val createArmJson = """{"trialId":"NCT000001","name":"arm name"}""".parseJson + val parsedArm = armFormat.read(createArmJson) + val expectedCreatedArm = arm.copy( + id = LongId(0), + originalName = "arm name" + ) + parsedArm should be(expectedCreatedArm) + + val updateArmJson = """{"name":"new arm name"}""".parseJson + val expectedUpdatedArm = arm.copy(name = "new arm name") + val parsedUpdateArm = applyUpdateToArm(updateArmJson, arm) + parsedUpdateArm should be(expectedUpdatedArm) + } + +} |