diff options
author | bnewbold <bnewbold@archive.org> | 2018-09-05 00:29:32 +0000 |
---|---|---|
committer | bnewbold <bnewbold@archive.org> | 2018-09-05 00:29:32 +0000 |
commit | cb8a3684867adceb9ac363799ef10be0ebca7850 (patch) | |
tree | 2b6920951ab3d14948deb59ffbc6d9516fd7c417 /scalding/src/test/scala/sandcrawler/GrobidScorableTest.scala | |
parent | 7df420014512d6e34ca5ed7db9b7690fbdf5e44b (diff) | |
parent | 0fbe7827f65dc34af4f27e6bee7adf3aaf2622b6 (diff) | |
download | sandcrawler-cb8a3684867adceb9ac363799ef10be0ebca7850.tar.gz sandcrawler-cb8a3684867adceb9ac363799ef10be0ebca7850.zip |
Merge branch 'ellen-none-refactor' into 'master'
Ellen none refactor
See merge request webgroup/sandcrawler!23
Diffstat (limited to 'scalding/src/test/scala/sandcrawler/GrobidScorableTest.scala')
-rw-r--r-- | scalding/src/test/scala/sandcrawler/GrobidScorableTest.scala | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/scalding/src/test/scala/sandcrawler/GrobidScorableTest.scala b/scalding/src/test/scala/sandcrawler/GrobidScorableTest.scala index 119cf90..b395a64 100644 --- a/scalding/src/test/scala/sandcrawler/GrobidScorableTest.scala +++ b/scalding/src/test/scala/sandcrawler/GrobidScorableTest.scala @@ -68,29 +68,30 @@ class GrobidScorableTest extends FlatSpec with Matchers { // Unit tests "GrobidScorable.jsonToMapFeatures()" should "handle invalid JSON" in { - val result = GrobidScorable.jsonToMapFeatures(Key, MalformedGrobidString) - result.slug shouldBe Scorable.NoSlug + GrobidScorable.jsonToMapFeatures(Key, MalformedGrobidString) should be (None) } it should "handle null title" in { - val result = GrobidScorable.jsonToMapFeatures(Key, GrobidStringWithNullTitle) - result.slug shouldBe Scorable.NoSlug + GrobidScorable.jsonToMapFeatures(Key, GrobidStringWithNullTitle) should be (None) } it should "handle missing title" in { - val result = GrobidScorable.jsonToMapFeatures(Key, GrobidStringWithoutTitle) - result.slug shouldBe Scorable.NoSlug + GrobidScorable.jsonToMapFeatures(Key, GrobidStringWithoutTitle) should be (None) } it should "handle valid input" in { - val result = GrobidScorable.jsonToMapFeatures(Key, GrobidStringWithGoodTitle) - result.slug shouldBe "dummyexamplefile" - Scorable.jsonToMap(result.json) match { + GrobidScorable.jsonToMapFeatures(Key, GrobidStringWithGoodTitle) match { case None => fail() - case Some(map) => { - map should contain key "title" - map("title").asInstanceOf[String] shouldBe "Dummy Example File" - map("authors").asInstanceOf[List[String]] shouldBe List("Brewster Kahle", "J Doe") + case Some(result) => { + result.slug shouldBe "dummyexamplefile" + Scorable.jsonToMap(result.json) match { + case None => fail() + case Some(map) => { + map should contain key "title" + map("title").asInstanceOf[String] shouldBe "Dummy Example File" + map("authors").asInstanceOf[List[String]] shouldBe List("Brewster Kahle", "J Doe") + } + } } } } |