Package org.zanata.webtrans.shared.model

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


    @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);
        TransUnit selectedTransUnit = TestFixture.makeTransUnit(1);
        sessionItem.setSelectedId(selectedTransUnit.getId());
        service.getUserSessionMap().put(editorClientId, sessionItem);

        service.onExitWorkspace(event);

        verify(workspaceUsersPresenter).removeUser(panel,
                person.getId().toString());
        verify(translatorInteractionService).personExit(person,
                selectedTransUnit.getId());
        assertThat(service.getUserSessionMap().size(), Matchers.is(0));
    }
View Full Code Here

                HasWorkspaceChatData.MESSAGE_TYPE.SYSTEM_WARNING);
    }

    @Test
    public void testKeyShortcut() {
        Person person = TestFixture.person();
        WorkspaceUsersPresenter spyPresenter = Mockito.spy(presenter);
        doNothing().when(spyPresenter).dispatchChatAction(
                person.getId().toString(), "hello",
                HasWorkspaceChatData.MESSAGE_TYPE.USER_MSG);
        when(messages.publishChatContent()).thenReturn("publish chat");
        spyPresenter.onBind();
        verify(keyShortcutPresenter).register(keyShortcutCaptor.capture());

        // key is 'enter', context is Chat, description is publish chat
        KeyShortcut keyShortcut = keyShortcutCaptor.getValue();
        assertThat(keyShortcut.getAllKeys(), Matchers.hasSize(1));
        Keys keys = keyShortcut.getAllKeys().iterator().next();
        assertThat(keys.getModifiers(), Matchers.equalTo(Keys.NO_MODIFIER));
        assertThat(keys.getKeyCode(), Matchers.equalTo(KeyCodes.KEY_ENTER));
        assertThat(keyShortcut.getDescription(),
                Matchers.equalTo("publish chat"));
        assertThat(keyShortcut.getContext(),
                Matchers.equalTo(ShortcutContext.Chat));

        // key handler
        when(identity.getPerson()).thenReturn(person);
        when(display.getChatInputText()).thenReturn("hello");
        keyShortcut.getHandler().onKeyShortcut(new KeyShortcutEvent(keys));
        verify(spyPresenter).dispatchChatAction(person.getId().toString(),
                "hello", HasWorkspaceChatData.MESSAGE_TYPE.USER_MSG);
    }
View Full Code Here

    @Test
    public void onSendButtonClicked() {
        // Given:
        when(display.getChatInputText()).thenReturn("hello");
        Person person = TestFixture.person();
        when(identity.getPerson()).thenReturn(person);

        // When:
        presenter.onSendButtonClicked();

        // Then:
        ArgumentCaptor<PublishWorkspaceChatAction> actionCaptor =
                ArgumentCaptor.forClass(PublishWorkspaceChatAction.class);
        verify(dispatcher).execute(actionCaptor.capture(),
                isA(NoOpAsyncCallback.class));
        PublishWorkspaceChatAction chatAction = actionCaptor.getValue();
        assertThat(chatAction.getPerson(),
                Matchers.equalTo(person.getId().toString()));
        assertThat(chatAction.getMsg(), Matchers.equalTo("hello"));
        assertThat(chatAction.getMessageType(),
                Matchers.equalTo(HasWorkspaceChatData.MESSAGE_TYPE.USER_MSG));
        verify(display).setChatInputText("");
    }
View Full Code Here

                event.getMsg(), event.getMessageType());
    }

    @Test
    public void onAddNewUser() {
        Person person = TestFixture.person();
        when(messages.hasJoinedWorkspace(person.getId().toString()))
                .thenReturn("someone entered");
        WorkspaceUsersPresenter spyPresenter = spy(presenter);
        doNothing().when(spyPresenter)
                .dispatchChatAction(null, "someone entered",
                        HasWorkspaceChatData.MESSAGE_TYPE.SYSTEM_MSG);
View Full Code Here

        verify(display).addUser(person);
    }

    @Test
    public void onRemoveUser() {
        Person person = TestFixture.person();
        when(messages.hasQuitWorkspace(person.getId().toString())).thenReturn(
                "someone quit");
        WorkspaceUsersPresenter spyPresenter = spy(presenter);
        doNothing().when(spyPresenter).dispatchChatAction(null, "someone quit",
                HasWorkspaceChatData.MESSAGE_TYPE.SYSTEM_MSG);

        spyPresenter.removeUser(userSessionPanel, person.getId().toString());

        verify(spyPresenter).dispatchChatAction(null, "someone quit",
                HasWorkspaceChatData.MESSAGE_TYPE.SYSTEM_MSG);
        verify(display).removeUser(userSessionPanel);
    }
View Full Code Here

        return new WorkspaceId(new ProjectIterationId(projectSlug,
                iterationSlug, projectType), localeId);
    }

    public static Person person() {
        return new Person(new PersonId("pid"), "admin", null);
    }
View Full Code Here

                        .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:
View Full Code Here

                        .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:
View Full Code Here

      // @formatter:on
    }

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

TOP

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

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.