aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorAleksandr <ognelisar@gmail.com>2017-10-26 09:55:50 +0700
committerAleksandr <ognelisar@gmail.com>2017-10-26 09:55:50 +0700
commit91d58df031f5fdac59d70289bf9a7377a3529a9a (patch)
tree2f22fa741c8ec1f997e4ea09a928c1aa84b22829 /src/test
parent72e4fe43bb03d2922a46f54e5a2f51a13c6df63a (diff)
downloadrest-query-91d58df031f5fdac59d70289bf9a7377a3529a9a.tar.gz
rest-query-91d58df031f5fdac59d70289bf9a7377a3529a9a.tar.bz2
rest-query-91d58df031f5fdac59d70289bf9a7377a3529a9a.zip
Moved MedicalRecord.Meta tests to MedicalRecordFormatSuite
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordFormatSuite.scala74
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordMetaFormatSuite.scala85
2 files changed, 74 insertions, 85 deletions
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordFormatSuite.scala
index 9616e70..363e352 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordFormatSuite.scala
@@ -12,6 +12,80 @@ class MedicalRecordFormatSuite extends FlatSpec with Matchers {
import record._
import MedicalRecord._
+ "Json format for MedicalRecord.Meta" should "read and write correct JSON" in {
+ val duplicate1 = Meta.Duplicate(
+ startPage = 1.0d,
+ endPage = 2.0d,
+ startOriginalPage = 1.0d,
+ endOriginalPage = Some(2.0d)
+ )
+
+ val duplicate2 = Meta.Duplicate(
+ startPage = 1.0d,
+ endPage = 2.0d,
+ startOriginalPage = 1.0d,
+ endOriginalPage = None
+ )
+
+ val reorder = Meta.Reorder(
+ Seq(1, 2)
+ )
+
+ val rotation = Meta.Rotation(
+ Map("item1" -> 1, "item2" -> 2)
+ )
+
+ val writtenDuplicateJson1 =
+ duplicateMetaFormat.write(duplicate1)
+
+ val writtenDuplicateJson2 =
+ duplicateMetaFormat.write(duplicate2)
+
+ val writtenReorderJson =
+ reorderMetaFormat.write(reorder)
+
+ val writtenRotationJson =
+ rotateMetaFormat.write(rotation)
+
+ writtenDuplicateJson1 should be(
+ """{"startOriginalPage":1.0,"endPage":2.0,"startPage":1.0,"type":"duplicate","endOriginalPage":2.0}""".parseJson)
+
+ writtenDuplicateJson2 should be(
+ """{"startOriginalPage":1.0,"endPage":2.0,"startPage":1.0,"type":"duplicate","endOriginalPage":null}""".parseJson)
+
+ writtenReorderJson should be(
+ """{"type":"reorder","items":[1,2]}""".parseJson)
+
+ writtenRotationJson should be(
+ """{"type":"rotation","items":{"item1":1,"item2":2}}""".parseJson)
+
+ val parsedDuplicateJson1 =
+ duplicateMetaFormat.read(writtenDuplicateJson1)
+
+ val parsedDuplicateJson2 =
+ duplicateMetaFormat.read(writtenDuplicateJson2)
+
+ val parsedReorderJson =
+ reorderMetaFormat.read(writtenReorderJson)
+
+ val parsedRotationJson =
+ rotateMetaFormat.read(writtenRotationJson)
+
+ duplicate1 should be(parsedDuplicateJson1)
+
+ duplicate2 should be(parsedDuplicateJson2)
+
+ reorder should be(parsedReorderJson)
+
+ rotation should be(parsedRotationJson)
+
+ duplicate1 should be(recordMetaTypeFormat.read(recordMetaTypeFormat.write(duplicate1)))
+ duplicate2 should be(recordMetaTypeFormat.read(recordMetaTypeFormat.write(duplicate2)))
+ reorder should be(recordMetaTypeFormat.read(recordMetaTypeFormat.write(reorder)))
+ rotation should be(recordMetaTypeFormat.read(recordMetaTypeFormat.write(rotation)))
+ }
+
+
"Json format for MedicalRecord" should "read and write correct JSON" in {
val orig = MedicalRecord(
id = LongId(1),
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordMetaFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordMetaFormatSuite.scala
deleted file mode 100644
index 845bffc..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordMetaFormatSuite.scala
+++ /dev/null
@@ -1,85 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.sprayformats
-
-import org.scalatest.{FlatSpec, Matchers}
-import spray.json._
-import xyz.driver.pdsuidomain.entities.MedicalRecord.Meta
-import record._
-
-class MedicalRecordMetaFormatSuite
- extends FlatSpec
- with Matchers {
-
- "Json format for MedicalRecord.Meta" should "read and write correct JSON" in {
- val duplicate1 = Meta.Duplicate(
- startPage = 1.0d,
- endPage = 2.0d,
- startOriginalPage = 1.0d,
- endOriginalPage = Some(2.0d)
- )
-
- val duplicate2 = Meta.Duplicate(
- startPage = 1.0d,
- endPage = 2.0d,
- startOriginalPage = 1.0d,
- endOriginalPage = None
- )
-
- val reorder = Meta.Reorder(
- Seq(1, 2)
- )
-
- val rotation = Meta.Rotation(
- Map("item1" -> 1, "item2" -> 2)
- )
-
- val writtenDuplicateJson1 =
- duplicateMetaFormat.write(duplicate1)
-
- val writtenDuplicateJson2 =
- duplicateMetaFormat.write(duplicate2)
-
- val writtenReorderJson =
- reorderMetaFormat.write(reorder)
-
- val writtenRotationJson =
- rotateMetaFormat.write(rotation)
-
- writtenDuplicateJson1 should be(
- """{"startOriginalPage":1.0,"endPage":2.0,"startPage":1.0,"type":"duplicate","endOriginalPage":2.0}""".parseJson)
-
- writtenDuplicateJson2 should be(
- """{"startOriginalPage":1.0,"endPage":2.0,"startPage":1.0,"type":"duplicate","endOriginalPage":null}""".parseJson)
-
- writtenReorderJson should be(
- """{"type":"reorder","items":[1,2]}""".parseJson)
-
- writtenRotationJson should be(
- """{"type":"rotation","items":{"item1":1,"item2":2}}""".parseJson)
-
- val parsedDuplicateJson1 =
- duplicateMetaFormat.read(writtenDuplicateJson1)
-
- val parsedDuplicateJson2 =
- duplicateMetaFormat.read(writtenDuplicateJson2)
-
- val parsedReorderJson =
- reorderMetaFormat.read(writtenReorderJson)
-
- val parsedRotationJson =
- rotateMetaFormat.read(writtenRotationJson)
-
- duplicate1 should be(parsedDuplicateJson1)
-
- duplicate2 should be(parsedDuplicateJson2)
-
- reorder should be(parsedReorderJson)
-
- rotation should be(parsedRotationJson)
-
- duplicate1 should be(recordMetaTypeFormat.read(recordMetaTypeFormat.write(duplicate1)))
- duplicate2 should be(recordMetaTypeFormat.read(recordMetaTypeFormat.write(duplicate2)))
- reorder should be(recordMetaTypeFormat.read(recordMetaTypeFormat.write(reorder)))
- rotation should be(recordMetaTypeFormat.read(recordMetaTypeFormat.write(rotation)))
- }
-
-}