Skip to content

Commit

Permalink
[ADAM-1380] Adds isEmpty method to RecordGroupDictionary.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnothaft committed Mar 3, 2017
1 parent eb4aa6c commit e39cfdc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Expand Up @@ -58,6 +58,13 @@ object RecordGroupDictionary {
*/
case class RecordGroupDictionary(recordGroups: Seq[RecordGroup]) {

/**
* @return Returns true if this dictionary contains no record groups.
*/
def isEmpty: Boolean = {
recordGroups.isEmpty
}

/**
* A representation of this record group dictionary that can be indexed into
* by record group name.
Expand Down
Expand Up @@ -69,11 +69,19 @@ class RecordGroupDictionarySuite extends FunSuite {
RecordGroup("sample2", "rgSample2"),
RecordGroup("sample3", "rg1Sample3"),
RecordGroup("sample3", "rg2Sample3")))
assert(!rgd.isEmpty)
val samples = rgd.toSamples

assert(samples.size === 3)
assert(samples.count(_.getSampleId == "sample1") === 1)
assert(samples.count(_.getSampleId == "sample2") === 1)
assert(samples.count(_.getSampleId == "sample3") === 1)
}

test("empty record group is empty") {
val emptyRgd = RecordGroupDictionary.empty

assert(emptyRgd.isEmpty)
assert(rgd.recordGroups.size === 0)
}
}

0 comments on commit e39cfdc

Please sign in to comment.