use of org.apache.geode.cache.lucene.internal.distributed.EntryScore in project geode by apache.
the class PageableLuceneQueryResultsImplJUnitTest method setUp.
@Before
public void setUp() {
hits = new ArrayList<EntryScore<String>>();
for (int i = 0; i < 23; i++) {
hits.add(new EntryScore("key_" + i, i));
expected.add(new LuceneResultStructImpl<String, String>("key_" + i, "value_" + i, i));
}
userRegion = mock(Region.class);
final ResultCollector collector = mock(ResultCollector.class);
execution = mock(Execution.class);
when(execution.withFilter(any())).thenReturn(execution);
when(execution.withCollector(any())).thenReturn(execution);
when(execution.execute(anyString())).thenReturn(collector);
when(collector.getResult()).then(new Answer() {
@Override
public Map answer(InvocationOnMock invocation) throws Throwable {
ArgumentCaptor<Set> captor = ArgumentCaptor.forClass(Set.class);
verify(execution, atLeast(1)).withFilter(captor.capture());
Collection<String> keys = captor.getValue();
Map<String, String> results = new HashMap<String, String>();
for (String key : keys) {
results.put(key, key.replace("key_", "value_"));
}
return results;
}
});
}
use of org.apache.geode.cache.lucene.internal.distributed.EntryScore in project geode by apache.
the class LuceneQueryImplJUnitTest method addValueToResults.
private void addValueToResults() {
TopEntries entries = new TopEntries();
entries.addHit(new EntryScore("hi", 5));
when(collector.getResult()).thenReturn(entries);
when(results.getMaxScore()).thenReturn(5f);
when(results.size()).thenReturn(1);
List<LuceneResultStruct<Object, Object>> page = Collections.singletonList(new LuceneResultStructImpl<>("hi", "value", 5f));
when(results.next()).thenReturn(page);
when(results.hasNext()).thenReturn(true);
}
use of org.apache.geode.cache.lucene.internal.distributed.EntryScore in project geode by apache.
the class LuceneTestUtilities method verifyResultOrder.
public static void verifyResultOrder(Collection<EntryScore<String>> list, EntryScore<String>... expectedEntries) {
Iterator<EntryScore<String>> iter = list.iterator();
for (EntryScore expectedEntry : expectedEntries) {
if (!iter.hasNext()) {
fail();
}
EntryScore toVerify = iter.next();
assertEquals(expectedEntry.getKey(), toVerify.getKey());
assertEquals(expectedEntry.getScore(), toVerify.getScore(), .0f);
}
}
Aggregations