fixes for not found scenarios

pull/4/head
Zlatin Balevsky 2018-07-21 09:15:32 +01:00
parent e395c37c31
commit 01617f876d
2 changed files with 19 additions and 2 deletions

View File

@ -22,7 +22,7 @@ class SearchIndex {
Set<String> rv = null;
terms.each {
Set<String> forWord = keywords.get it
Set<String> forWord = keywords.getOrDefault(it,[])
if (rv == null) {
rv = forWord
} else {
@ -31,6 +31,8 @@ class SearchIndex {
}
rv.asList()
if (rv != null)
return rv.asList()
[]
}
}

View File

@ -40,4 +40,19 @@ class SearchIndexTest {
assert found.size() == 1
assert found.contains("c d.e")
}
@Test
void testNotFound() {
initIndex(["a b.c"])
def found = index.search(["d"])
assert found.size() == 0
}
@Test
void testSomeNotFound() {
initIndex(["a b.c"])
def found = index.search(["a","d"])
assert found.size() == 0
}
}