From 5da6d85175992fae019e1d4d1ebeb4accfec1820 Mon Sep 17 00:00:00 2001 From: Ellen Spertus Date: Sun, 3 Jun 2018 16:31:59 -0700 Subject: Added HBaseBuilder.parseColSpecs and tests, which pass. --- .../test/scala/sandcrawler/HBaseBuilderTest.scala | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 scalding/src/test/scala/sandcrawler/HBaseBuilderTest.scala (limited to 'scalding/src/test') 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")) + } + } +} -- cgit v1.2.3