Package org.zanata.webtrans.client.history

Examples of org.zanata.webtrans.client.history.HistoryToken


    public void onRequestSelectTableRowSamePage() {
        TransUnitId selectingId = new TransUnitId(1);

        DocumentInfo docInfo = TestFixture.documentInfo();

        HistoryToken mockHistoryToken = mock(HistoryToken.class);
        when(history.getHistoryToken()).thenReturn(mockHistoryToken);

        // When:
        service.onRequestSelectTableRow(new RequestSelectTableRowEvent(docInfo,
                selectingId));
View Full Code Here


        KeyShortcut editorKey = shortcuts.get(1);
        KeyShortcut searchKey = shortcuts.get(2);

        // testing handlers
        // doc key handler
        HistoryToken docToken = new HistoryToken();
        when(history.getHistoryToken()).thenReturn(docToken);
        docListKey.getHandler().onKeyShortcut(null);
        assertThat(docToken.getView(), Matchers.is(MainView.Documents));
        verify(history).newItem(docToken.toTokenString());

        // editor key handler on selected doc is null
        when(messages.noDocumentSelected()).thenReturn("no doc selected");
        editorKey.getHandler().onKeyShortcut(null);
        verify(eventBus).fireEvent(isA(NotificationEvent.class));

        // editor key handler on selected doc is NOT null
        HistoryToken editorToken = new HistoryToken();
        when(history.getHistoryToken()).thenReturn(editorToken);
        DocumentInfo selectedDocument = mock(DocumentInfo.class);
        presenter.setStatesForTest(null, null, MainView.Documents,
                selectedDocument);
        editorKey.getHandler().onKeyShortcut(null);
        assertThat(editorToken.getView(), Matchers.is(MainView.Editor));
        verify(history).newItem(editorToken.toTokenString());

        // search key handler
        HistoryToken searchToken = new HistoryToken();
        when(history.getHistoryToken()).thenReturn(searchToken);
        searchKey.getHandler().onKeyShortcut(null);
        assertThat(searchToken.getView(), Matchers.is(MainView.Search));
        verify(history).newItem(searchToken.toTokenString());
    }
View Full Code Here

        documentListPresenter.fireFilterToken(filterText);
        documentListPresenter.fireExactSearchToken(false);

        verify(mockHistory).newItem(capturedHistoryTokenString.capture());

        HistoryToken capturedHistoryToken =
                HistoryToken.fromTokenString(capturedHistoryTokenString
                        .getValue());
        assertThat(
                "generated history token filter text should match the filter textbox",
                capturedHistoryToken.getDocFilterText(), is(filterText));
        assertThat(
                "generated history token filter exact flag should match the exact match checkbox",
                capturedHistoryToken.getDocFilterExact(), is(false));
    }
View Full Code Here

        // simulate checking 'exact search' checkbox
        documentListPresenter.fireExactSearchToken(true);

        verify(mockHistory).newItem(capturedHistoryTokenString.capture());

        HistoryToken exactSearchToken = new HistoryToken();
        exactSearchToken.setDocFilterExact(true);
        assertThat(
                "checking the 'exact search' checkbox should be reflected in a new history token",
                capturedHistoryTokenString.getValue(),
                is(exactSearchToken.toTokenString()));
    }
View Full Code Here

    }

    @Test
    public void uncheckExactSearchCheckboxGeneratesHistoryToken() {
        // history reflects checkbox already checked
        HistoryToken exactSearchToken = new HistoryToken();
        exactSearchToken.setDocFilterExact(true);

        when(mockHistory.getToken()).thenReturn(
                exactSearchToken.toTokenString());

        documentListPresenter.bind();
        documentListPresenter.fireExactSearchToken(false);

        verify(mockHistory).newItem(capturedHistoryTokenString.capture());

        HistoryToken inexactSearchToken = new HistoryToken();
        inexactSearchToken.setDocFilterExact(false);
        assertThat(
                "unchecking the 'exact search' checkbox should be reflected in a new history token",
                capturedHistoryTokenString.getValue(),
                is(inexactSearchToken.toTokenString()));
    }
View Full Code Here

    // TODO tests for check and uncheck case sensitive check

    @Test
    public void documentSelectUpdatesHistoryToken() {
        HistoryToken documentPathToken = new HistoryToken();
        documentPathToken.setDocumentPath(null);
        when(mockHistory.getHistoryToken()).thenReturn(documentPathToken);

        documentListPresenter.bind();

        // simulate document click on second document
        DocumentInfo docInfo =
                new DocumentInfo(new DocumentId(2222L, ""), "doc122",
                        "second/path/", LocaleId.EN_US,
                        new ContainerTranslationStatistics(), new AuditInfo(
                                new Date(), "Translator"),
                        new HashMap<String, String>(), new AuditInfo(
                                new Date(), "last translator"));
        documentListPresenter.fireDocumentSelection(docInfo);

        verify(mockHistory).newItem(capturedHistoryToken.capture());
        verify(mockUserWorkspaceContext).setSelectedDoc(docInfo);

        HistoryToken newToken = capturedHistoryToken.getValue();
        assertThat("path of selected document should be set in history token",
                newToken.getDocumentPath(), is("second/path/doc122"));
        assertThat(
                "view in history token should change to individual document view when a new document is selected",
                newToken.getView(), is(MainView.Editor));
    }
View Full Code Here

        documentListPresenter.updateFilterAndRun(filterText, true, false);

        verify(mockDisplay).updateFilter(false, true, filterText);

        // simulate firing history change event
        HistoryToken historyTokenWithExactFilter = new HistoryToken();
        historyTokenWithExactFilter.setDocFilterText(filterText);
        historyTokenWithExactFilter.setDocFilterExact(true);

        ArrayList<DocumentInfo> expectedDocs = buildSampleDocumentArray();
        expectedDocs.remove(2); // third doc does not match the filter
        expectedDocs.remove(0); // first doc does not match the filter
        ArrayList<DocumentInfo> actualDocInfos = new ArrayList<DocumentInfo>();
View Full Code Here

        documentListPresenter.bind();
        documentListPresenter.updateFilterAndRun(filterText, false, false);
        documentListPresenter.setDocuments(buildSampleDocumentArray());

        // simulate firing history change event
        HistoryToken historyTokenWithFilter = new HistoryToken();
        historyTokenWithFilter.setDocFilterText(filterText);

        verify(mockDisplay).updateFilter(false, false, filterText);

        ArrayList<DocumentInfo> expectedDocs = buildSampleDocumentArray();
        expectedDocs.remove(1); // second doc does not match any of the filter
View Full Code Here

        verify(display).isFocused();
    }

    @Test
    public void testSearchTerm() throws Exception {
        HistoryToken historyToken = new HistoryToken();
        when(history.getHistoryToken()).thenReturn(historyToken);

        presenter.searchTerm("blah");

        assertThat(historyToken.getEditorTextSearch(), Matchers.equalTo("blah"));
        verify(history).newItem(historyToken);
    }
View Full Code Here

    @Test
    public void willSetOptionsBackOnFilterViewCancelEvent() {
        FilterViewEvent event =
                new FilterViewEvent(true, true, true, true, true, false,
                        EditorFilter.ALL, true);
        HistoryToken historyToken = new HistoryToken();
        when(history.getHistoryToken()).thenReturn(historyToken);

        presenter.onFilterView(event);

        verify(display).setTranslatedFilter(event.isFilterUntranslated());
        verify(display).setNeedReviewFilter(event.isFilterTranslated());
        verify(display).setUntranslatedFilter(event.isFilterFuzzy());
        verify(display).setApprovedFilter(event.isFilterApproved());
        verify(display).setRejectedFilter(event.isFilterRejected());

        assertThat(historyToken.isFilterUntranslated(),
                Matchers.equalTo(event.isFilterUntranslated()));
        assertThat(historyToken.isFilterTranslated(),
                Matchers.equalTo(event.isFilterTranslated()));
        assertThat(historyToken.isFilterFuzzy(),
                Matchers.equalTo(event.isFilterFuzzy()));
        assertThat(historyToken.isFilterApproved(),
                Matchers.equalTo(event.isFilterApproved()));
        assertThat(historyToken.isFilterRejected(),
                Matchers.equalTo(event.isFilterRejected()));
        assertThat(historyToken.isFilterHasError(),
                Matchers.equalTo(event.isFilterHasError()));
    }
View Full Code Here

TOP

Related Classes of org.zanata.webtrans.client.history.HistoryToken

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.