Examples of TransUnit


Examples of org.zanata.webtrans.shared.model.TransUnit

    }

    @Test
    public void testSetterAndGetter() {
        MockitoAnnotations.initMocks(this);
        TransUnit transUnit = TestFixture.makeTransUnit(1);
        TransUnitReplaceInfo info =
                new TransUnitReplaceInfo(CONTAINING_DOC_ID, transUnit);

        // init state
        assertThat(info.getDocId(), Matchers.equalTo(CONTAINING_DOC_ID));
        assertThat(info.getPreview(), Matchers.nullValue());
        assertThat(info.getPreviewState(),
                Matchers.equalTo(PreviewState.NotFetched));
        assertThat(info.getReplaceInfo(), Matchers.nullValue());
        assertThat(info.getReplaceState(),
                Matchers.equalTo(ReplacementState.NotReplaced));
        assertThat(info.getTransUnit(), Matchers.sameInstance(transUnit));

        // update state
        info.setPreview(updatePreview);
        info.setPreviewState(PreviewState.Show);
        info.setReplaceInfo(updateInfo);
        info.setReplaceState(ReplacementState.Replaced);
        TransUnit newTU = TestFixture.makeTransUnit(2);
        info.setTransUnit(newTU);

        assertThat(info.getPreview(), Matchers.sameInstance(updatePreview));
        assertThat(info.getPreviewState(), Matchers.equalTo(PreviewState.Show));
        assertThat(info.getReplaceInfo(), Matchers.sameInstance(updateInfo));
View Full Code Here

Examples of org.zanata.webtrans.shared.model.TransUnit

        when(messages.searchGlossary()).thenReturn("Search glossary");
        when(display.getGlossaryTextBox()).thenReturn(mockGlossaryTextBox);
        when(mockGlossaryTextBox.getText()).thenReturn("query");
        when(display.getSearchType()).thenReturn(mockSearchType);
        when(mockSearchType.getValue()).thenReturn(SearchType.FUZZY);
        TransUnit transUnit =
                TransUnit.Builder.newTransUnitBuilder().setId(1)
                        .setResId("resId").setVerNum(0).setLocaleId("en")
                        .addSource("source1", "source2").setRowIndex(1).build();

        presenter.onTransUnitSelected(new TransUnitSelectionEvent(transUnit));
View Full Code Here

Examples of org.zanata.webtrans.shared.model.TransUnit

        presenter.showData(transUnits);

        // When:
        TransUnitUpdatedEvent event =
                mock(TransUnitUpdatedEvent.class, Mockito.RETURNS_DEEP_STUBS);
        TransUnit updated = TestFixture.makeTransUnit(1);
        when(event.getUpdateInfo().getTransUnit()).thenReturn(updated);

        presenter.onTransUnitUpdated(event);

        verify(display1).updateTransUnitDetails(updated);
View Full Code Here

Examples of org.zanata.webtrans.shared.model.TransUnit

        inOrder.verify(display).stopProcessing(false);
    }

    @Test
    public void testOnTransUnitSelected() {
        TransUnit selection = TestFixture.makeTransUnit(1);
        TransMemoryPresenter spyPresenter = spy(presenter);
        doNothing().when(spyPresenter).createTMRequestForTransUnit(selection);

        spyPresenter
                .onTransUnitSelected(new TransUnitSelectionEvent(selection));
View Full Code Here

Examples of org.zanata.webtrans.shared.model.TransUnit

    }

    @Test
    public void onTransUnitSelected() {
        // Given:
        TransUnit selection = TestFixture.makeTransUnit(1);
        TransUnitSelectionEvent transUnitSelectionEvent =
                new TransUnitSelectionEvent(selection);

        // When:
        presenter.onTransUnitSelected(transUnitSelectionEvent);

        // Then:
        verify(sourceContentsPresenter).setSelectedSource(selection.getId());
        verify(targetContentsPresenter).setSelected(selection.getId());
        verify(translatorService).transUnitSelected(selection);
        verify(display).ensureVisible(
                targetContentsPresenter.getCurrentDisplay());
    }
View Full Code Here

Examples of org.zanata.webtrans.shared.model.TransUnit

        // Given: coming updated ID is NOT equal to current selected id and is
        // from another user
        EditorClientId editorClientId = new EditorClientId("session", 1);
        when(translatorService.getCurrentEditorClientId()).thenReturn(
                editorClientId);
        TransUnit updatedTransUnit = TestFixture.makeTransUnit(1);
        presenter.setStateForTesting(new TransUnitId(99));

        // When: update type is save and done by different user
        presenter.refreshRow(updatedTransUnit,
                new EditorClientId("session", 2),
View Full Code Here

Examples of org.zanata.webtrans.shared.model.TransUnit

    public void refreshRowFromCurrentUserWillGetIgnored() {
        // Given: coming client id is the same as current user
        EditorClientId editorClientId = new EditorClientId("session", 1);
        when(translatorService.getCurrentEditorClientId()).thenReturn(
                editorClientId);
        TransUnit updatedTransUnit = TestFixture.makeTransUnit(1);
        presenter.setStateForTesting(updatedTransUnit.getId());

        // When: refreshRow from same user
        presenter.refreshRow(updatedTransUnit, editorClientId,
                TransUnitUpdated.UpdateType.WebEditorSave);
View Full Code Here

Examples of org.zanata.webtrans.shared.model.TransUnit

    public void willRefreshRowFromCurrentUserNotAsEditorSave() {
        // Given: coming client id is the same as current user
        EditorClientId editorClientId = new EditorClientId("session", 1);
        when(translatorService.getCurrentEditorClientId()).thenReturn(
                editorClientId);
        TransUnit updatedTransUnit = TestFixture.makeTransUnit(1);
        presenter.setStateForTesting(updatedTransUnit.getId());

        // When: refreshRow from same user but update type is replace
        presenter.refreshRow(updatedTransUnit, editorClientId,
                TransUnitUpdated.UpdateType.NonEditorSave);
View Full Code Here

Examples of org.zanata.webtrans.shared.model.TransUnit

            willDetectSaveDoneByAnotherUserAndCurrentUserDoNotHaveUnsavedChange() {
        // Given: coming client id is NOT current user
        EditorClientId currentUser = new EditorClientId("session1", 1);
        when(translatorService.getCurrentEditorClientId()).thenReturn(
                currentUser);
        TransUnit updatedTransUnit = TestFixture.makeTransUnit(1);
        presenter.setStateForTesting(updatedTransUnit.getId());
        when(messages.concurrentEdit()).thenReturn("concurrent edit detected");
        // current user does not have unsaved change
        when(targetContentsPresenter.currentEditorContentHasChanged())
                .thenReturn(false);
View Full Code Here

Examples of org.zanata.webtrans.shared.model.TransUnit

    public void willDetectSaveDoneByAnotherUserAndCurrentUserHasUnsavedChange() {
        // Given: coming client id is NOT current user
        EditorClientId currentUser = new EditorClientId("session1", 1);
        when(translatorService.getCurrentEditorClientId()).thenReturn(
                currentUser);
        TransUnit updatedTransUnit = TestFixture.makeTransUnit(1);
        presenter.setStateForTesting(updatedTransUnit.getId());
        when(messages.concurrentEdit()).thenReturn("concurrent edit detected");
        when(messages.concurrentEditTitle()).thenReturn(
                "please resolve conflict");
        // current user does not have unsaved change
        when(targetContentsPresenter.currentEditorContentHasChanged())
                .thenReturn(true);

        // When: update type is save
        presenter.refreshRow(updatedTransUnit,
                new EditorClientId("session2", 2),
                TransUnitUpdated.UpdateType.WebEditorSave);

        // Then:
        ArgumentCaptor<NotificationEvent> eventCaptor =
                ArgumentCaptor.forClass(NotificationEvent.class);
        verify(eventBus).fireEvent(eventCaptor.capture());
        assertThat(eventCaptor.getValue().getMessage(),
                Matchers.equalTo("concurrent edit detected"));

        ArgumentCaptor<TransHistoryItem> transHistoryCaptor =
                ArgumentCaptor.forClass(TransHistoryItem.class);
        InOrder inOrder =
                Mockito.inOrder(targetContentsPresenter,
                        translationHistoryPresenter);
        inOrder.verify(translationHistoryPresenter).popupAndShowLoading(
                "please resolve conflict");
        inOrder.verify(translationHistoryPresenter).displayEntries(
                transHistoryCaptor.capture(),
                eq(Collections.<TransHistoryItem> emptyList()),
                eq(Collections.<ReviewComment> emptyList()));
        assertThat(transHistoryCaptor.getValue().getVersionNum(),
                Matchers.equalTo(updatedTransUnit.getVerNum().toString()));
        assertThat(transHistoryCaptor.getValue().getContents(),
                Matchers.equalTo(updatedTransUnit.getTargets()));
        inOrder.verify(targetContentsPresenter).updateRow(updatedTransUnit);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.