Package org.zanata.webtrans.shared.model

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


            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

    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

    }

    @Test
    public void testExecute() throws Exception {
        Person person = TestFixture.person();
        TransUnit selectedTransUnit = TestFixture.makeTransUnit(1);
        WorkspaceId workspaceId = TestFixture.workspaceId();
        EditorClientId editorClientId = new EditorClientId("sessionId", 1);
        TransUnitEditAction action =
                new TransUnitEditAction(person, selectedTransUnit.getId());
        action.setWorkspaceId(workspaceId);
        action.setEditorClientId(editorClientId);
        when(translationWorkspaceManager.getOrRegisterWorkspace(workspaceId))
                .thenReturn(translationWorkspace);

        handler.execute(action, null);

        verify(identity).checkLoggedIn();
        verify(translationWorkspace).updateUserSelection(editorClientId,
                selectedTransUnit.getId());
        verify(translationWorkspace).publish(eventCaptor.capture());
        TransUnitEdit transUnitEdit = eventCaptor.getValue();
        assertThat(transUnitEdit.getEditorClientId(),
                Matchers.sameInstance(editorClientId));
        assertThat(transUnitEdit.getPerson(), Matchers.sameInstance(person));
        assertThat(transUnitEdit.getSelectedTransUnitId(),
                Matchers.sameInstance(selectedTransUnit.getId()));
    }
View Full Code Here

    @Test
    public void canUpdateUserSelection() {
        EditorClientId editorClientId = new EditorClientId("sessionId", 1);
        translationWorkspace.addEditorClient("sessionId", editorClientId,
                new PersonId("personId"));
        TransUnit selectedTransUnit = TestFixture.makeTransUnit(1);

        translationWorkspace.updateUserSelection(editorClientId,
                selectedTransUnit.getId());

        PersonSessionDetails personSessionDetails =
                translationWorkspace.getUsers().get(editorClientId);
        assertThat(personSessionDetails.getSelectedTransUnitId(),
                Matchers.equalTo(selectedTransUnit.getId()));
        assertThat(translationWorkspace.getUserSelection(editorClientId),
                Matchers.equalTo(selectedTransUnit.getId()));
    }
View Full Code Here

                        .setVerNum(0).setRowIndex(0);
    }

    @Test
    public void canReplaceTextCaseInsensitively() throws ActionException {
        TransUnit transUnit =
                transUnitBuilder.addTargets("abc", "AbC", "ABC").build();
        ReplaceText action =
                new ReplaceText(transUnit, "abc", "123", CASE_INSENSITIVE);

        handler.execute(action, context);
View Full Code Here

                .getNewContents(), Matchers.equalTo(expectedList));
    }

    @Test
    public void canReplaceTextCaseSensitively() throws ActionException {
        TransUnit transUnit =
                transUnitBuilder.addTargets("abc", "AbC", "ABC").build();
        ReplaceText action =
                new ReplaceText(transUnit, "abc", "123", CASE_SENSITIVE);

        handler.execute(action, context);
View Full Code Here

                .getNewContents(), Matchers.equalTo(expectedList));
    }

    @Test(expectedExceptions = { ActionException.class })
    public void willThrowExceptionIfSearchTextIsEmpty() throws ActionException {
        TransUnit transUnit = transUnitBuilder.build();
        ReplaceText action =
                new ReplaceText(transUnit, "", "123", CASE_SENSITIVE);
        handler.execute(action, context);
    }
View Full Code Here

        handler.execute(action, context);
    }

    @Test(expectedExceptions = { ActionException.class })
    public void willThrowExceptionIfReplaceTextIsEmpty() throws ActionException {
        TransUnit transUnit = transUnitBuilder.build();
        ReplaceText action =
                new ReplaceText(transUnit, "abc", null, CASE_SENSITIVE);
        handler.execute(action, context);
    }
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.