Package org.zanata.webtrans.shared.auth

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


        service = new TranslatorInteractionService(identity, dispatcher);
    }

    @Test
    public void canGetEditorClientId() {
        EditorClientId currentEditorClientId =
                service.getCurrentEditorClientId();

        assertThat(currentEditorClientId,
                Matchers.equalTo(identity.getEditorClientId()));
    }
View Full Code Here


                        .defaultAnswer(RETURNS_DEEP_STUBS));
        when(updatedData.getUpdateInfo().getDocumentId()).thenReturn(
                initContext.getDocument().getId());
        TransUnit updatedTU = data.get(0);
        when(updatedData.getUpdateInfo().getTransUnit()).thenReturn(updatedTU);
        EditorClientId editorClientId = new EditorClientId("sessionId", 1);
        when(updatedData.getEditorClientId()).thenReturn(editorClientId);
        when(updatedData.getUpdateType()).thenReturn(
                TransUnitUpdated.UpdateType.WebEditorSave);

        // When:
View Full Code Here

                        "green"));
    }

    private static EditorClientId newEditorClientId() {
        counter++;
        return new EditorClientId(String.valueOf(counter), counter);
    }
View Full Code Here

                Matchers.is("red"));
    }

    @Test
    public void willReuseColorForSameEditorClientId() {
        EditorClientId editorClientId = newEditorClientId();
        String color = distinctColor.getOrCreateColor(editorClientId);
        String sameColor = distinctColor.getOrCreateColor(editorClientId);

        assertThat(sameColor, Matchers.equalTo(color));
    }
View Full Code Here

        assertThat(sameColor, Matchers.equalTo(color));
    }

    @Test
    public void canReleaseColor() {
        EditorClientId editorClientId = newEditorClientId();
        String color = distinctColor.getOrCreateColor(editorClientId);
        distinctColor.releaseColor(editorClientId);
        String newColor = distinctColor.getOrCreateColor(editorClientId);

        assertThat(newColor, Matchers.not(Matchers.equalTo(color)));
View Full Code Here

        verify(eventBus).addHandler(TransUnitEditEvent.getType(), service);
    }

    private static EditorClientId editorClientId() {
        return new EditorClientId("session", 1);
    }
View Full Code Here

    }

    @Test
    public void onTransUnitEditEvent() {
        // Given:
        EditorClientId editorClientId = editorClientId();
        UserPanelSessionItem sessionItem =
                new UserPanelSessionItem(panel, TestFixture.person());
        TransUnit transUnit = TestFixture.makeTransUnit(2);
        service.getUserSessionMap().put(editorClientId, sessionItem);
        when(hasTransUnitData.getEditorClientId()).thenReturn(editorClientId);
View Full Code Here

    }

    @Test
    public void onEnterWorkspace() {
        EnterWorkspaceEvent event = mock(EnterWorkspaceEvent.class);
        EditorClientId editorClientId = editorClientId();
        Person person = TestFixture.person();
        when(event.getEditorClientId()).thenReturn(editorClientId);
        when(event.getPerson()).thenReturn(person);
        when(workspaceUsersPresenter.addNewUser(person)).thenReturn(panel);
        when(distinctColor.getOrCreateColor(editorClientId)).thenReturn("red");
View Full Code Here

    }

    @Test
    public void onExitWorkspace() {
        ExitWorkspaceEvent event = mock(ExitWorkspaceEvent.class);
        EditorClientId editorClientId = editorClientId();
        Person person = TestFixture.person();
        when(event.getEditorClientId()).thenReturn(editorClientId);
        when(event.getPerson()).thenReturn(person);
        UserPanelSessionItem sessionItem =
                new UserPanelSessionItem(panel, person);
View Full Code Here

    }

    @Test
    public void testUpdateEditorTranslatorsWithConcurrentEdit() {
        // Given: user in session map has selected same 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(1));
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.