Package org.zanata.webtrans.shared.auth

Examples of org.zanata.webtrans.shared.auth.EditorClientId


    }

    @Test
    public void testUpdateEditorTranslatorsWithoutConcurrentEdit() {
        // Given: user in session map has selected different trans unit
        EditorClientId editorClientId = new EditorClientId("sessionId", 1);
        Map<EditorClientId, UserPanelSessionItem> sessionMap =
                ImmutableMap.<EditorClientId, UserPanelSessionItem> builder()
                        .put(editorClientId, panelSessionItem).build();
        when(sessionService.getUserSessionMap()).thenReturn(sessionMap);
        when(sessionService.getColor(editorClientId)).thenReturn("red");
        when(panelSessionItem.getSelectedId()).thenReturn(
                TestFixture.makeTransUnit(1).getId());
        Person person = TestFixture.person();
        when(panelSessionItem.getPerson()).thenReturn(person);
        EditorClientId ourClientId = new EditorClientId("another client id", 2);
        when(identity.getEditorClientId()).thenReturn(ourClientId);

        // When:
        editorTranslators.updateTranslator(display, new TransUnitId(2)); // different
                                                                         // id
View Full Code Here


    }

    @Test
    public void sessionMapClientHasNoSelectedTransUnitYet() {
        // Given: user in session map don't have selected trans unit
        EditorClientId editorClientId = new EditorClientId("sessionId", 1);
        Map<EditorClientId, UserPanelSessionItem> sessionMap =
                ImmutableMap.<EditorClientId, UserPanelSessionItem> builder()
                        .put(editorClientId, panelSessionItem).build();
        when(sessionService.getUserSessionMap()).thenReturn(sessionMap);
        when(panelSessionItem.getSelectedId()).thenReturn(null);
View Full Code Here

    @Test
    public void canRefreshRowIfNotOnCurrentSelection() {
        // 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),
                TransUnitUpdated.UpdateType.WebEditorSave);

        // Then:
        verify(targetContentsPresenter).updateRow(updatedTransUnit);
        verifyZeroInteractions(eventBus);
View Full Code Here

    }

    @Test
    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());
View Full Code Here

    }

    @Test
    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());
View Full Code Here

    @Test
    public
            void
            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);

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

        // Then:
        ArgumentCaptor<NotificationEvent> eventCaptor =
                ArgumentCaptor.forClass(NotificationEvent.class);
View Full Code Here

    }

    @Test
    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);
View Full Code Here

                .thenReturn(hLocale);
        TranslationWorkspaceManagerImpl spy = spy(manager);
        doReturn(mockWorkspace).when(spy).createWorkspace(workspaceId);
        doReturn("sessionId").when(spy).getSessionId();
        ArrayList<EditorClientId> editorClientIds =
                Lists.newArrayList(new EditorClientId("sessionId", 1L),
                        new EditorClientId("sessionId", 2L));
        when(mockWorkspace.removeEditorClients("sessionId")).thenReturn(
                editorClientIds);
        spy.getOrRegisterWorkspace(workspaceId);

        HAccount hAccount = new HAccount();
View Full Code Here

                .thenReturn(hLocale);
        TranslationWorkspaceManagerImpl spy = spy(manager);
        doReturn(mockWorkspace).when(spy).createWorkspace(workspaceId);
        doReturn("sessionId").when(spy).getSessionId();
        ArrayList<EditorClientId> editorClientIds =
                Lists.newArrayList(new EditorClientId("sessionId", 1L),
                        new EditorClientId("sessionId", 2L));
        when(mockWorkspace.removeEditorClients("sessionId")).thenReturn(
                editorClientIds);
        spy.getOrRegisterWorkspace(workspaceId);

        spy.exitWorkspace("admin");
View Full Code Here

                Matchers.equalTo(workspaceId));
    }

    @Test
    public void canGetUsers() {
        EditorClientId editorClientId = new EditorClientId("sessionId", 1);
        PersonId personId = new PersonId("personId");
        translationWorkspace.addEditorClient("sessionId", editorClientId,
                personId);

        Map<EditorClientId, PersonSessionDetails> users =
View Full Code Here

TOP

Related Classes of org.zanata.webtrans.shared.auth.EditorClientId

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.