aboutsummaryrefslogtreecommitdiffstats
path: root/scalding/src/test
diff options
context:
space:
mode:
authorEllen Spertus <ellen.spertus@gmail.com>2018-08-11 21:03:53 -0700
committerEllen Spertus <ellen.spertus@gmail.com>2018-08-11 21:03:53 -0700
commit728e50a33cec921c9a624439f2e1c8561a6e12ce (patch)
tree671548fe0e4bd38badb76453c0a1a90dea5e0ce7 /scalding/src/test
parent768e7ef0d127cf55119543be6e656751704ca5b2 (diff)
downloadsandcrawler-728e50a33cec921c9a624439f2e1c8561a6e12ce.tar.gz
sandcrawler-728e50a33cec921c9a624439f2e1c8561a6e12ce.zip
It compiles.
Diffstat (limited to 'scalding/src/test')
-rw-r--r--scalding/src/test/scala/sandcrawler/CrossrefScorableTest.scala26
-rw-r--r--scalding/src/test/scala/sandcrawler/GrobidScorableTest.scala19
2 files changed, 23 insertions, 22 deletions
diff --git a/scalding/src/test/scala/sandcrawler/CrossrefScorableTest.scala b/scalding/src/test/scala/sandcrawler/CrossrefScorableTest.scala
index 67a8bfe..1c35d66 100644
--- a/scalding/src/test/scala/sandcrawler/CrossrefScorableTest.scala
+++ b/scalding/src/test/scala/sandcrawler/CrossrefScorableTest.scala
@@ -66,20 +66,24 @@ class CrossrefScorableTest extends FlatSpec with Matchers {
val MalformedCrossrefString = CrossrefString.replace("}", "")
// Unit tests
-/*
- "crossrefToSlug()" should "get the right slug for a crossref json string" in {
- val slug = CrossrefScorable.crossrefToSlug(CrossrefStringWithTitle)
- slug should contain ("sometitle")
+ "simplifyJson()" should "return None for bad JSON" in {
+ CrossrefScorable.simplifyJson("") shouldBe None
+ CrossrefScorable.simplifyJson(MalformedCrossrefString) shouldBe None
}
- it should "return None if given json string without title" in {
- val slug = CrossrefScorable.crossrefToSlug(CrossrefStringWithoutTitle)
- slug shouldBe None
+ it should "return None for JSON lacking title" in {
+ CrossrefScorable.simplifyJson(CrossrefStringWithoutTitle) shouldBe None
}
- it should "return None if given a malformed json string" in {
- val slug = CrossrefScorable.crossrefToSlug(MalformedCrossrefString)
- slug shouldBe None
+ it should "return appropriate result for valid JSON" in {
+ CrossrefScorable.simplifyJson(CrossrefStringWithTitle) match {
+ case None => fail("None unexpectedly returned by simplifyJson")
+ case Some(map) => {
+ Scorable.isScorableMap(map) shouldBe true
+ map.size shouldBe 1
+ map.keys should contain ("title")
+ map("title") shouldBe "SomeTitle"
+ }
+ }
}
- */
}
diff --git a/scalding/src/test/scala/sandcrawler/GrobidScorableTest.scala b/scalding/src/test/scala/sandcrawler/GrobidScorableTest.scala
index 7777610..5bb955a 100644
--- a/scalding/src/test/scala/sandcrawler/GrobidScorableTest.scala
+++ b/scalding/src/test/scala/sandcrawler/GrobidScorableTest.scala
@@ -60,18 +60,15 @@ class GrobidScorableTest extends FlatSpec with Matchers {
// Unit tests
- "grobidToSlug()" should "get the right slug for a grobid json string" in {
- val slug = GrobidScorable.grobidToSlug(GrobidStringWithTitle)
- slug should contain ("dummy example file")
+ "GrobidScorable.jsonToMapFeatures()" should "handle invalid JSON" in {
+ val result = GrobidScorable.jsonToMapFeatures(MalformedGrobidString) shouldBe None
+ result.slug shouldBe Scorable.NoSlug
+ result.json shouldBe MalformedGrobidString
}
- it should "return None if given json string without title" in {
- val slug = GrobidScorable.grobidToSlug(GrobidStringWithoutTitle)
- slug shouldBe None
- }
-
- it should "return None if given a malformed json string" in {
- val slug = GrobidScorable.grobidToSlug(MalformedGrobidString)
- slug shouldBe None
+ "GrobidScorable.jsonToMapFeatures()" should "handle missing title" in {
+ val result = GrobidScorable.jsonToMapFeatures(GrobidStringWithoutTitle) shouldBe None
+ result.slug shouldBe Scorable.NoSlug
+ result.json shouldBe GrobidStringWithoutTitle
}
}