Package org.zanata.webtrans.shared.model

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


    @Test
    public void onPRCFailure() {
        // Given:
        String errorMessage = "doh";
        TransUnit old =
                TestFixture.makeTransUnit(TRANS_UNIT_ID.getId(),
                        ContentState.NeedReview, "old content");
        when(navigationService.getByIdOrNull(TRANS_UNIT_ID)).thenReturn(old);

        // When: save as fuzzy
View Full Code Here


        boolean plural = false;

        ArrayList<String> targets = new ArrayList<String>();
        targets.add("this is the target");

        TransUnit newTransUnit =
                TransUnit.Builder.newTransUnitBuilder().setId(12345L)
                        .setResId("resId").setLocaleId("es").setPlural(plural)
                        .setSources(sources)
                        .setSourceComment("this is the source comment")
                        .setTargets(targets).setStatus(ContentState.Approved)
View Full Code Here

    }

    @Test
    public void onSouthPanelExpandedFromCollapsed() {
        // Given: current selected trans unit and is NOT expanded
        TransUnit selection = TestFixture.makeTransUnit(1);
        when(navigationService.getSelectedOrNull()).thenReturn(selection);
        presenter.setSouthPanelExpanded(false);

        // When:
        presenter.setSouthPanelExpanded(true);
View Full Code Here

    }

    @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

        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

        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

        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

    }

    @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

        // 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

    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

TOP

Related Classes of org.zanata.webtrans.shared.model.TransUnit

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.