@Test
public void
fireSearchEventInSequentialWillBlockSecondRequestUntilFirstReturn() {
// Given:
DocumentInfo docInfo =
new DocumentInfo(new DocumentId(new Long(1), ""), "test",
"test/path", LocaleId.EN_US,
new ContainerTranslationStatistics(), new AuditInfo(
new Date(), "Translator"),
new HashMap<String, String>(), new AuditInfo(
new Date(), "last translator"));
userWorkspaceContext.setSelectedDoc(docInfo);
when(messages.searchGlossary()).thenReturn("Search glossary");
when(display.getGlossaryTextBox()).thenReturn(mockGlossaryTextBox);
when(mockGlossaryTextBox.getText()).thenReturn("query1", "query2");
when(display.getSearchType()).thenReturn(mockSearchType);
when(mockSearchType.getValue()).thenReturn(SearchType.FUZZY,
SearchType.FUZZY_PLURAL);
// When: calling search glossary twice while the first one hasn't return
// any result
presenter.fireSearchEvent();
presenter.fireSearchEvent();
// Then: there is only one RPC call to the server and the second request
// get ignored
verify(display).startProcessing();
verify(dispatcher).execute(getGlossaryCaptor.capture(),
callbackCaptor.capture());
GetGlossary action = getGlossaryCaptor.getValue();
assertThat(action.getQuery(), Matchers.equalTo("query1"));
assertThat(action.getSearchType(), Matchers.equalTo(SearchType.FUZZY));
assertThat(action.getSrcLocaleId(),
Matchers.equalTo(docInfo.getSourceLocale()));
}