aboutsummaryrefslogtreecommitdiffstats
path: root/scalding/src/test/scala/sandcrawler/GrobidScorableTest.scala
diff options
context:
space:
mode:
authorEllen Spertus <ellen.spertus@gmail.com>2018-08-12 18:08:51 -0700
committerEllen Spertus <ellen.spertus@gmail.com>2018-08-12 18:08:51 -0700
commit31354b1a6062c5c56a30610f68fa48c82a7e83f0 (patch)
treea730150c3f29ea76579ee6928a7c2db9e5b22eac /scalding/src/test/scala/sandcrawler/GrobidScorableTest.scala
parent728e50a33cec921c9a624439f2e1c8561a6e12ce (diff)
downloadsandcrawler-31354b1a6062c5c56a30610f68fa48c82a7e83f0.tar.gz
sandcrawler-31354b1a6062c5c56a30610f68fa48c82a7e83f0.zip
Tests pass.
Diffstat (limited to 'scalding/src/test/scala/sandcrawler/GrobidScorableTest.scala')
-rw-r--r--scalding/src/test/scala/sandcrawler/GrobidScorableTest.scala20
1 files changed, 15 insertions, 5 deletions
diff --git a/scalding/src/test/scala/sandcrawler/GrobidScorableTest.scala b/scalding/src/test/scala/sandcrawler/GrobidScorableTest.scala
index 5bb955a..3fcd856 100644
--- a/scalding/src/test/scala/sandcrawler/GrobidScorableTest.scala
+++ b/scalding/src/test/scala/sandcrawler/GrobidScorableTest.scala
@@ -57,18 +57,28 @@ class GrobidScorableTest extends FlatSpec with Matchers {
val GrobidStringWithTitle = GrobidString.replace("<<TITLE>>", "Dummy Example File")
val GrobidStringWithoutTitle = GrobidString.replace("title", "nottitle")
val MalformedGrobidString = GrobidString.replace("}", "")
+ val Key = "Dummy Key"
// Unit tests
"GrobidScorable.jsonToMapFeatures()" should "handle invalid JSON" in {
- val result = GrobidScorable.jsonToMapFeatures(MalformedGrobidString) shouldBe None
+ val result = GrobidScorable.jsonToMapFeatures(Key, MalformedGrobidString)
result.slug shouldBe Scorable.NoSlug
- result.json shouldBe MalformedGrobidString
}
- "GrobidScorable.jsonToMapFeatures()" should "handle missing title" in {
- val result = GrobidScorable.jsonToMapFeatures(GrobidStringWithoutTitle) shouldBe None
+ it should "handle missing title" in {
+ val result = GrobidScorable.jsonToMapFeatures(Key, GrobidStringWithoutTitle)
result.slug shouldBe Scorable.NoSlug
- result.json shouldBe GrobidStringWithoutTitle
+ }
+
+ it should "handle valid input" in {
+ val result = GrobidScorable.jsonToMapFeatures(Key, GrobidStringWithTitle)
+ result.slug shouldBe "dummyexamplefile"
+ Scorable.jsonToMap(result.json) match {
+ case None => fail()
+ case Some(map) => {
+ map("title").asInstanceOf[String] shouldBe "Dummy Example File"
+ }
+ }
}
}