}
@Test
public void processHistoryTokenWithInitializedContext() {
// Given: history token contains everything and editor context is loaded
HistoryToken token = new HistoryToken();
token.setDocFilterText("doc filter test");
token.setEditorTextSearch("search text");
token.setProjectSearchText("project search text");
token.setDocumentPath("doc/path");
token.setProjectSearchReplacement("replacement");
when(historyChangeEvent.getValue()).thenReturn(token.toTokenString());
DocumentInfo documentInfo = TestFixture.documentInfo(1, "doc/path");
DocumentId documentId = documentInfo.getId();
when(documentListPresenter.getDocumentId("doc/path")).thenReturn(
documentId);
when(documentListPresenter.getDocumentInfo(documentId)).thenReturn(
documentInfo);
when(appPresenter.getSelectedDocIdOrNull()).thenReturn(
new DocumentId(new Long(99), ""));
contextHolder.updateContext(new GetTransUnitActionContext(documentInfo(
99, "")));
// When:
service.onValueChange(historyChangeEvent);
// Then:
InOrder inOrder =
Mockito.inOrder(documentListPresenter, appPresenter, eventBus,
searchResultsPresenter);
inOrder.verify(documentListPresenter).updateFilterAndRun(
token.getDocFilterText(), token.getDocFilterExact(),
token.isDocFilterCaseSensitive());
inOrder.verify(searchResultsPresenter).updateViewAndRun(
token.getProjectSearchText(),
token.getProjectSearchCaseSensitive(),
token.isProjectSearchInSource(),
token.isProjectSearchInTarget());
inOrder.verify(searchResultsPresenter).updateReplacementText(
token.getProjectSearchReplacement());
inOrder.verify(documentListPresenter).getDocumentId(
token.getDocumentPath());
inOrder.verify(appPresenter).getSelectedDocIdOrNull();
inOrder.verify(appPresenter).selectDocument(documentId);
inOrder.verify(documentListPresenter).getDocumentInfo(documentId);
inOrder.verify(eventBus).fireEvent(
Mockito.isA(DocumentSelectionEvent.class));
inOrder.verify(eventBus).fireEvent(UserConfigChangeEvent.EDITOR_CONFIG_CHANGE_EVENT);
inOrder.verify(eventBus).fireEvent(Mockito.isA(FilterViewEvent.class));
inOrder.verify(appPresenter).showView(token.getView());
verifyNoMoreInteractions(documentListPresenter, appPresenter, eventBus,
searchResultsPresenter);
}