diff options
author | Aleksandr <ognelisar@gmail.com> | 2017-10-26 18:30:27 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-26 18:30:27 +0700 |
commit | fde83eb31ef4f2c2334b41d3a727239c034bfd63 (patch) | |
tree | 6406d9b37f8b4ad8d93741c9cd57dc262620a0d4 /src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats | |
parent | a453d027f4a7a9a4f14ef272724c24fd19eb82a2 (diff) | |
parent | b6943690e5e572f6edc9fe985d33a6349a4a6812 (diff) | |
download | rest-query-fde83eb31ef4f2c2334b41d3a727239c034bfd63.tar.gz rest-query-fde83eb31ef4f2c2334b41d3a727239c034bfd63.tar.bz2 rest-query-fde83eb31ef4f2c2334b41d3a727239c034bfd63.zip |
Merge pull request #57 from drivergroup/PDSUI-2350v0.10.13
PDSUI-2350 Extracted data meta fields "evidence" and "keyword" should be optional for action-based saving
Diffstat (limited to 'src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats')
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala index 1feca6a..d87b6c7 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala @@ -9,6 +9,7 @@ import xyz.driver.pdsuidomain.entities.{ExtractedData, ExtractedDataLabel} import xyz.driver.pdsuidomain.services.ExtractedDataService.RichExtractedData class ExtractedDataFormatSuite extends FlatSpec with Matchers { + import extracteddata._ "Json format for ExtractedData" should "read and write correct JSON" in { @@ -17,8 +18,18 @@ class ExtractedDataFormatSuite extends FlatSpec with Matchers { documentId = LongId(101), keywordId = Some(LongId(201)), evidenceText = Some("evidence text"), - meta = None - ) + meta = Option(TextJson(Meta( + evidence = None, + keyword = + Some(Meta.Keyword( + page = 1, + pageRatio = Some(1.6161616161616161d), + index = 0, + sortIndex = "1080000" + )) + ) + ))) + val extractedDataLabels = List( ExtractedDataLabel( id = LongId(1), @@ -43,11 +54,13 @@ class ExtractedDataFormatSuite extends FlatSpec with Matchers { writtenJson should be( """{"id":1,"documentId":101,"keywordId":201,"evidence":"evidence text","meta":null, - "labels":[{"id":null,"categoryId":null,"value":"Yes"},{"id":12,"categoryId":1,"value":"No"}]}""".parseJson) + "labels":[{"id":null,"categoryId":null,"value":"Yes"},{"id":12,"categoryId":1,"value":"No"}], + "meta":{"keyword":{"index":0,"page":1,"pageRatio":1.6161616161616161,"sortIndex":"1080000"}}}""".parseJson) val createExtractedDataJson = """{"documentId":101,"keywordId":201,"evidence":"evidence text", - "labels":[{"value":"Yes"},{"id":12,"categoryId":1,"value":"No"}]}""".parseJson + "labels":[{"value":"Yes"},{"id":12,"categoryId":1,"value":"No"}], + "meta":{"keyword":{"index":0,"page":1,"pageRatio":1.6161616161616161,"sortIndex":"1080000"}}}""".parseJson val expectedCreatedExtractedData = origRichExtractedData.copy( extractedData = extractedData.copy(id = LongId(0)), labels = extractedDataLabels.map(_.copy(id = LongId(0), dataId = LongId(0))) @@ -80,12 +93,12 @@ class ExtractedDataFormatSuite extends FlatSpec with Matchers { evidenceText = Some("new evidence text"), meta = Some( TextJson(Meta( - keyword = Meta.Keyword(page = 1, pageRatio = None, index = 2, sortIndex = "ASC"), - evidence = Meta.Evidence( + keyword = Some(Meta.Keyword(page = 1, pageRatio = None, index = 2, sortIndex = "ASC")), + evidence = Some(Meta.Evidence( pageRatio = 1.0, start = Meta.TextLayerPosition(page = 1, index = 3, offset = 2), end = Meta.TextLayerPosition(page = 2, index = 3, offset = 10) - ) + )) ))) ), labels = updatedExtractedDataLabels |