aboutsummaryrefslogtreecommitdiffstats
path: root/scalding/src/test/scala/sandcrawler/HBaseBuilderTest.scala
diff options
context:
space:
mode:
authorbnewbold <bnewbold@archive.org>2018-06-04 22:05:54 +0000
committerbnewbold <bnewbold@archive.org>2018-06-04 22:05:54 +0000
commitb21cc924224202aba412370acafaaa4846bb4a8d (patch)
tree3d0fcc2f2bee55eb038686c566bdab1763e65c74 /scalding/src/test/scala/sandcrawler/HBaseBuilderTest.scala
parent70069a78c8798352b5bef815a3fd4aa9e9b52394 (diff)
parent9a18da82738c16d3066e02e886ee84e04156889f (diff)
downloadsandcrawler-b21cc924224202aba412370acafaaa4846bb4a8d.tar.gz
sandcrawler-b21cc924224202aba412370acafaaa4846bb4a8d.zip
Merge branch 'refactoring' into 'master'
Refactoring to add, use, and test class HBaseBuilder to eliminate duplicated code and facilitate HBaseSource creation See merge request webgroup/sandcrawler!1
Diffstat (limited to 'scalding/src/test/scala/sandcrawler/HBaseBuilderTest.scala')
-rw-r--r--scalding/src/test/scala/sandcrawler/HBaseBuilderTest.scala43
1 files changed, 43 insertions, 0 deletions
diff --git a/scalding/src/test/scala/sandcrawler/HBaseBuilderTest.scala b/scalding/src/test/scala/sandcrawler/HBaseBuilderTest.scala
new file mode 100644
index 0000000..b45751d
--- /dev/null
+++ b/scalding/src/test/scala/sandcrawler/HBaseBuilderTest.scala
@@ -0,0 +1,43 @@
+package example
+
+import cascading.tuple.Fields
+import org.scalatest._
+import sandcrawler.HBaseBuilder
+
+class HBaseBuilderTest extends FlatSpec with Matchers {
+ "parseColSpec()" should "work on legal nontrivial input" in {
+ val (fams, fields) = HBaseBuilder.parseColSpec(List("file:size", "file:cdx", "match0:status"))
+ fams should have length 2
+ fields should have length 2
+ val fileIndex = fams.indexOf("file")
+ fileIndex should not be -1
+ fields(fileIndex) should be (new Fields("size", "cdx"))
+ val match0Index = fams.indexOf("match0")
+ match0Index should not be -1
+ fields(match0Index) should be (new Fields("status"))
+ }
+
+ it should "work on empty input" in {
+ val (fams, fields) = HBaseBuilder.parseColSpec(List())
+ fams should have length 0
+ fields should have length 0
+ }
+
+ it should "throw IllegalArgumentException on malformed input" in {
+ a [IllegalArgumentException] should be thrownBy {
+ HBaseBuilder.parseColSpec(List("file_size"))
+ }
+ }
+
+ it should "throw IllegalArgumentException on nonexistent family" in {
+ a [IllegalArgumentException] should be thrownBy {
+ HBaseBuilder.parseColSpec(List("foo:bar"))
+ }
+ }
+
+ it should "throw IllegalArgumentException on nonexistent column" in {
+ a [IllegalArgumentException] should be thrownBy {
+ HBaseBuilder.parseColSpec(List("file:bar"))
+ }
+ }
+}