aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksandr <ognelisar@gmail.com>2017-11-15 14:49:50 +0700
committerAleksandr <ognelisar@gmail.com>2017-11-15 14:49:50 +0700
commit977e5e1a17a385fdc215251924da0a64228413b5 (patch)
treef8b67cc8876c86d7c6fd915aa7b4a6a021b1a7d3
parent10e9512ff196d33ef6475e89fa89e937af6aea8b (diff)
downloadrest-query-977e5e1a17a385fdc215251924da0a64228413b5.tar.gz
rest-query-977e5e1a17a385fdc215251924da0a64228413b5.tar.bz2
rest-query-977e5e1a17a385fdc215251924da0a64228413b5.zip
Fixed json formats for DocumentHistory and MedicalRecordHistory; Added tests for them
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/entities/DocumentHistory.scala2
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/documenthistory.scala20
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/recordhistory.scala27
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentHistoryFormatSuite.scala24
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordHistoryFormatSuite.scala26
5 files changed, 78 insertions, 21 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/DocumentHistory.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/DocumentHistory.scala
index 43a1832..f076074 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/entities/DocumentHistory.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/entities/DocumentHistory.scala
@@ -61,7 +61,7 @@ object DocumentHistory {
case object Resolve extends Action
case object Flag extends Action
case object Archive extends Action
- case object PostEvidence extends Action
+ case object PostEvidence extends Action
case object CreateDocument extends Action
case object ReadDocument extends Action
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/documenthistory.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/documenthistory.scala
index ea79b92..1652f7b 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/documenthistory.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/documenthistory.scala
@@ -10,18 +10,24 @@ object documenthistory {
import common._
implicit val documentStateFormat = new EnumJsonFormat[State](
+ "New" -> State.New,
"Extract" -> State.Extract,
+ "Done" -> State.Done,
"Review" -> State.Review,
- "Flag" -> State.Flag
+ "Flag" -> State.Flag,
+ "Archive" -> State.Archive
)
implicit val documentActionFormat = new EnumJsonFormat[Action](
- "Start" -> Action.Start,
- "Submit" -> Action.Submit,
- "Unassign" -> Action.Unassign,
- "Resolve" -> Action.Resolve,
- "Flag" -> Action.Flag,
- "Archive" -> Action.Archive
+ "Start" -> Action.Start,
+ "Submit" -> Action.Submit,
+ "Unassign" -> Action.Unassign,
+ "Resolve" -> Action.Resolve,
+ "Flag" -> Action.Flag,
+ "Archive" -> Action.Archive,
+ "PostEvidence" -> Action.PostEvidence,
+ "CreateDocument" -> Action.CreateDocument,
+ "ReadDocument" -> Action.ReadDocument
)
implicit val documentHistoryFormat: RootJsonFormat[DocumentHistory] = jsonFormat6(DocumentHistory.apply)
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/recordhistory.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/recordhistory.scala
index 8341f97..be9dae9 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/recordhistory.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/recordhistory.scala
@@ -10,19 +10,32 @@ object recordhistory {
import common._
implicit val recordStateFormat = new EnumJsonFormat[State](
+ "New" -> State.New,
"Clean" -> State.Clean,
"Organize" -> State.Organize,
"Review" -> State.Review,
- "Flag" -> State.Flag
+ "Done" -> State.Done,
+ "Flag" -> State.Flag,
+ "Archive" -> State.Archive
)
implicit val recordActionFormat = new EnumJsonFormat[Action](
- "Start" -> Action.Start,
- "Submit" -> Action.Submit,
- "Unassign" -> Action.Unassign,
- "Resolve" -> Action.Resolve,
- "Flag" -> Action.Flag,
- "Archive" -> Action.Archive
+ "Start" -> Action.Start,
+ "Submit" -> Action.Submit,
+ "Unassign" -> Action.Unassign,
+ "Resolve" -> Action.Resolve,
+ "Flag" -> Action.Flag,
+ "Archive" -> Action.Archive,
+ "SaveDuplicate" -> Action.SaveDuplicate,
+ "SaveReorder" -> Action.SaveReorder,
+ "SaveRotation" -> Action.SaveRotation,
+ "DeleteDuplicate" -> Action.DeleteDuplicate,
+ "DeleteReorder" -> Action.DeleteReorder,
+ "DeleteRotation" -> Action.DeleteRotation,
+ "CreateDocument" -> Action.CreateDocument,
+ "DeleteDocument" -> Action.DeleteDocument,
+ "CreateRecord" -> Action.CreateRecord,
+ "ReadRecord" -> Action.ReadRecord
)
implicit val recordHistoryFormat: RootJsonFormat[MedicalRecordHistory] = jsonFormat6(MedicalRecordHistory.apply)
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentHistoryFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentHistoryFormatSuite.scala
index 4dc4d00..d85a53b 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentHistoryFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentHistoryFormatSuite.scala
@@ -2,15 +2,33 @@ package xyz.driver.pdsuidomain.formats.json
import java.time.LocalDateTime
-import org.scalatest.{FlatSpec, Matchers}
+import org.scalatest.{FreeSpecLike, Matchers}
import spray.json._
import xyz.driver.pdsuicommon.domain.LongId
import xyz.driver.pdsuidomain.entities.DocumentHistory
-class DocumentHistoryFormatSuite extends FlatSpec with Matchers {
+class DocumentHistoryFormatSuite extends FreeSpecLike with Matchers {
import xyz.driver.pdsuidomain.formats.json.documenthistory._
- "Json format for DocumentHistory" should "read and write correct JSON" in {
+ "Can read and write DocumentHistory states" - {
+ val states = DocumentHistory.State.All
+ states.foreach { state =>s"$state" in test(state)}
+ }
+
+ "Can read and write DocumentHistory actions" - {
+ val actions = DocumentHistory.Action.All
+ actions.foreach { action =>s"$action" in test(action)}
+ }
+
+ private def test(state: DocumentHistory.State) = {
+ documentStateFormat.read(documentStateFormat.write(state)) shouldBe state
+ }
+
+ private def test(action: DocumentHistory.Action) = {
+ documentActionFormat.read(documentActionFormat.write(action)) shouldBe action
+ }
+
+ "Json format for DocumentHistory should read and write correct JSON" - {
val documentHistory = DocumentHistory(
id = LongId(10),
documentId = LongId(1),
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordHistoryFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordHistoryFormatSuite.scala
index 88240cd..c34f8c0 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordHistoryFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordHistoryFormatSuite.scala
@@ -2,15 +2,35 @@ package xyz.driver.pdsuidomain.formats.json
import java.time.LocalDateTime
-import org.scalatest.{FlatSpec, Matchers}
+import org.scalatest.{FreeSpecLike, Matchers}
import spray.json._
import xyz.driver.pdsuicommon.domain.LongId
import xyz.driver.pdsuidomain.entities.MedicalRecordHistory
-class MedicalRecordHistoryFormatSuite extends FlatSpec with Matchers {
+class MedicalRecordHistoryFormatSuite extends FreeSpecLike with Matchers {
import xyz.driver.pdsuidomain.formats.json.recordhistory._
- "Json format for MedicalRecordHistory" should "read and write correct JSON" in {
+
+ "Can read and write MedicalRecordHistory states" - {
+ val states = MedicalRecordHistory.State.All
+ states.foreach { state =>s"$state" in test(state)}
+ }
+
+ "Can read and write MedicalRecordHistory actions" - {
+ val actions = MedicalRecordHistory.Action.All
+ actions.foreach { action =>s"$action" in test(action)}
+ }
+
+ private def test(state: MedicalRecordHistory.State) = {
+ recordStateFormat.read(recordStateFormat.write(state)) shouldBe state
+ }
+
+ private def test(action: MedicalRecordHistory.Action) = {
+ recordActionFormat.read(recordActionFormat.write(action)) shouldBe action
+ }
+
+
+ "Json format for MedicalRecordHistory should read and write correct JSON" - {
val recordHistory = MedicalRecordHistory(
id = LongId(10),
recordId = LongId(1),