From 54b15dae509212f6661dc1f1bc4ca248cb487443 Mon Sep 17 00:00:00 2001 From: Kseniya Tomskikh Date: Fri, 20 Oct 2017 16:25:04 +0700 Subject: PDSUI-2336 Deleted api classes of play format, userhistory and message services --- .../formats/json/TrialFormatSuite.scala | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialFormatSuite.scala (limited to 'src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialFormatSuite.scala') diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialFormatSuite.scala new file mode 100644 index 0000000..b832733 --- /dev/null +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialFormatSuite.scala @@ -0,0 +1,49 @@ +package xyz.driver.pdsuidomain.formats.json + +import java.time.LocalDateTime + +import org.scalatest.{FlatSpec, Matchers} +import spray.json._ +import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId} +import xyz.driver.pdsuidomain.entities.Trial + +class TrialFormatSuite extends FlatSpec with Matchers { + import xyz.driver.pdsuidomain.formats.json.trial._ + + "Json format for Trial" should "read and write correct JSON" in { + val orig = Trial( + id = StringId("NCT000001"), + externalId = UuidId("40892a07-c638-49d2-9795-1edfefbbcc7c"), + status = Trial.Status.New, + assignee = None, + previousStatus = None, + previousAssignee = None, + lastActiveUserId = None, + lastUpdate = LocalDateTime.parse("2017-08-10T18:16:19"), + phase = "", + hypothesisId = Some(UuidId("3b80b2e2-5372-4cf5-a342-6e4ebe10fafd")), + studyDesignId = Some(LongId(321)), + originalStudyDesign = None, + isPartner = false, + overview = None, + overviewTemplate = "", + isUpdated = false, + title = "trial title", + originalTitle = "orig trial title" + ) + val writtenJson = trialFormat.write(orig) + + writtenJson should be( + """{"isPartner":false,"assignee":null,"lastUpdate":"2017-08-10T18:16:19Z","previousStatus":null, + "isUpdated":false,"overviewTemplate":"","phase":"","originalStudyDesignId":null, + "hypothesisId":"3b80b2e2-5372-4cf5-a342-6e4ebe10fafd","originalTitle":"orig trial title", + "studyDesignId":321,"lastActiveUser":null,"externalid":"40892a07-c638-49d2-9795-1edfefbbcc7c", + "id":"NCT000001","status":"New","overview":null,"previousAssignee":null,"title":"trial title"}""".parseJson) + + val updateTrialJson = """{"hypothesisId":null,"overview":"new overview"}""".parseJson + val expectedUpdatedTrial = orig.copy(hypothesisId = None, overview = Some("new overview")) + val parsedUpdateTrial = applyUpdateToTrial(updateTrialJson, orig) + parsedUpdateTrial should be(expectedUpdatedTrial) + } + +} -- cgit v1.2.3