Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
update participant enter workspace test for compatability with Presen…
Browse files Browse the repository at this point in the history
…terTest
  • Loading branch information
davidmason committed Jul 16, 2012
1 parent 30e5531 commit 148c53f
Showing 1 changed file with 17 additions and 29 deletions.
Expand Up @@ -215,7 +215,6 @@ public void showsSouthPanel()
verifyAllMocks();
}

// TODO extract methods for common south panel show/hide test components

/**
* similar to showsSouthPanel() but with non-null selected TU
Expand All @@ -226,7 +225,6 @@ public void fireTMGlossarySearchOnShowSouthPanel()
expectHideSouthPanel();
TransUnit mockTU = createMock(TransUnit.class);
expectShowSouthPanel(mockTU);

// these called for non-null TU
mockTransMemoryPresenter.createTMRequestForTransUnit(mockTU);
mockGlossaryPresenter.createGlossaryRequestForTransUnit(mockTU);
Expand All @@ -240,39 +238,19 @@ public void fireTMGlossarySearchOnShowSouthPanel()
@Test
public void updateParticipantsOnEnterWorkspace()
{
replayAllMocks();
translationPresenter.bind();
reset(mockDispatcher, mockDisplay, mockMessages, mockWorkspaceUsersPresenter);

// expect lookup translator list
Map<EditorClientId, Person> participants = new HashMap<EditorClientId, Person>();
participants.put(new EditorClientId("sessionId1", 1), new Person(new PersonId("bob"), "Bob Smith", "http://www.gravatar.com/avatar/bob@zanata.org?d=mm&s=16"));
participants.put(new EditorClientId("sessionId2", 1), new Person(new PersonId("smith"), "Smith Bob", "http://www.gravatar.com/avatar/smith@zanata.org?d=mm&s=16"));

expect(mockMessages.nUsersOnline(participants.size())).andReturn(TEST_USERS_ONLINE_MESSAGE).anyTimes();
int numUsersOnline = 5;
expect(mockMessages.nUsersOnline(numUsersOnline)).andReturn(TEST_USERS_ONLINE_MESSAGE).anyTimes();
expect(mockMessages.hasJoinedWorkspace("bob")).andReturn(TEST_HAS_JONINED_WORKSPACE_MESSAGE).once();
mockDisplay.setParticipantsTitle(TEST_USERS_ONLINE_MESSAGE);
expectLastCall().once(); // once for now

expect(mockWorkspaceUsersPresenter.getTranslatorsSize()).andReturn(2);

expect(mockWorkspaceUsersPresenter.getTranslatorsSize()).andReturn(numUsersOnline);
mockWorkspaceUsersPresenter.dispatchChatAction(null, TEST_HAS_JONINED_WORKSPACE_MESSAGE, MESSAGE_TYPE.SYSTEM_MSG);
expectLastCall();

mockWorkspaceUsersPresenter.addTranslator(new EditorClientId("sessionId1", 1), new Person(new PersonId("bob"), "Bob Smith", "http://www.gravatar.com/avatar/bob@zanata.org?d=mm&s=16"), null);
expectLastCall();

// simulate enter workspace event
EnterWorkspaceEvent event = createMock(EnterWorkspaceEvent.class);

expect(event.getEditorClientId()).andReturn(new EditorClientId("sessionId1", 1));
expect(event.getPerson()).andReturn(new Person(new PersonId("bob"), "Bob Smith", "http://www.gravatar.com/avatar/bob@zanata.org?d=mm&s=16")).times(2);

replay(mockDispatcher, mockDisplay, mockMessages, mockWorkspaceUsersPresenter, event);

capturedEnterWorkspaceEventHandler.getValue().onEnterWorkspace(event);

verify(mockDispatcher, mockDisplay, mockMessages, mockWorkspaceUsersPresenter);
replayAllMocks();
translationPresenter.bind();
simulateEnterWorkspaceEvent();
verifyAllMocks();
}

@Test
Expand All @@ -282,6 +260,7 @@ public void updateParticipantsOnExitWorkspace()
translationPresenter.bind();
reset(mockDispatcher, mockDisplay, mockMessages, mockWorkspaceUsersPresenter);

// TODO this map is not used, check why before deleting
// expect lookup translator list
Map<EditorClientId, Person> participants = new HashMap<EditorClientId, Person>();
participants.put(new EditorClientId("sessionId1", 1), new Person(new PersonId("john"), "John Jones", "http://www.gravatar.com/avatar/john@zanata.org?d=mm&s=16"));
Expand Down Expand Up @@ -381,6 +360,15 @@ private void simulateShowSouthPanel(boolean show)
capturedSouthPanelToggleValueChangeHandler.getValue().onValueChange(southPanelToggleEvent);
}

private void simulateEnterWorkspaceEvent()
{
EnterWorkspaceEvent event = createMock(EnterWorkspaceEvent.class);
expect(event.getEditorClientId()).andReturn(new EditorClientId("sessionId1", 1));
expect(event.getPerson()).andReturn(new Person(new PersonId("bob"), "Bob Smith", "http://www.gravatar.com/avatar/bob@zanata.org?d=mm&s=16")).anyTimes();
replay(event);
capturedEnterWorkspaceEventHandler.getValue().onEnterWorkspace(event);
}

/**
* Fire a mock read-only event and check that south panel is hidden and
* presenters on south panel are unbound
Expand Down

0 comments on commit 148c53f

Please sign in to comment.