@Test
public final void testQuery() {
INDEXFIELD testarr[] = INDEXFIELD.values();
for (INDEXFIELD fld : testarr) {
LocalDictionary dict = new LocalDictionary(idxProps, fld);
//pre-populate with known terms
String[] myterms = {"test","best","crest","zest","testy","tether","temper", "teat","tempest"};
for (String term : myterms) {
dict.lookup(term);
}
//exact match
assertArrayEquals(new Object[] {"test"}, getSortedArray(dict.query("test")));
//no match for a given exact match
assertNull(dict.query("doom"));
//wildcard at start
assertArrayEquals(new Object[] {"best","crest","tempest","test","zest"}, getSortedArray(dict.query("*est")));
//wildcard at end
assertArrayEquals(new Object[] {"teat","temper","tempest","test","testy","tether"}, getSortedArray(dict.query("te*")));
//wildcard in the middle
assertArrayEquals(new Object[] {"teat","tempest","test"}, getSortedArray(dict.query("te*t")));
dict = null;
}
}