use of org.kie.workbench.common.widgets.client.discussion.DiscussionWidgetPresenter in project kie-wb-common by kiegroup.
the class DiscussionWidgetPresenterTest method testInit.
@Test
public void testInit() throws Exception {
Metadata metadata = new Metadata();
metadata.getDiscussion().add(new DiscussionRecord(1234, "Toni", "Knock Knock"));
metadata.getDiscussion().add(new DiscussionRecord(1235, "Michael", "Who is there?"));
metadata.getDiscussion().add(new DiscussionRecord(1236, "Toni", "Can't think of anything funny :("));
DiscussionWidgetPresenter presenter = new DiscussionWidgetPresenter(view, identity, appConfigService);
presenter.setContent(metadata);
ArgumentCaptor<DiscussionRecord> discussionRecordArgumentCaptor = ArgumentCaptor.forClass(DiscussionRecord.class);
verify(view, times(3)).addRow(discussionRecordArgumentCaptor.capture());
assertComment(discussionRecordArgumentCaptor.getAllValues().get(0), 1234, "Toni", "Knock Knock");
assertComment(discussionRecordArgumentCaptor.getAllValues().get(1), 1235, "Michael", "Who is there?");
assertComment(discussionRecordArgumentCaptor.getAllValues().get(2), 1236, "Toni", "Can't think of anything funny :(");
}
use of org.kie.workbench.common.widgets.client.discussion.DiscussionWidgetPresenter in project kie-wb-common by kiegroup.
the class DiscussionWidgetPresenterTest method testPresenterSet.
@Test
public void testPresenterSet() throws Exception {
DiscussionWidgetPresenter presenter = new DiscussionWidgetPresenter(view, identity, appConfigService);
verify(view).setPresenter(presenter);
}
use of org.kie.workbench.common.widgets.client.discussion.DiscussionWidgetPresenter in project kie-wb-common by kiegroup.
the class DiscussionWidgetPresenterTest method testAddComment.
@Test
public void testAddComment() throws Exception {
ArgumentCaptor<DiscussionRecord> discussionRecordArgumentCaptor = ArgumentCaptor.forClass(DiscussionRecord.class);
when(identity.getIdentifier()).thenReturn("Toni");
DiscussionWidgetPresenter presenterImpl = new DiscussionWidgetPresenter(view, identity, appConfigService);
DiscussionWidgetView.Presenter presenter = presenterImpl;
Metadata metadata = spy(new Metadata());
Path path = mock(Path.class);
when(metadata.getPath()).thenReturn(path);
presenterImpl.setContent(metadata);
presenter.onAddComment("Hello World!");
verify(view).addRow(discussionRecordArgumentCaptor.capture());
DiscussionRecord line = discussionRecordArgumentCaptor.getValue();
assertNotNull(line);
assertEquals(line.getTimestamp(), new Long(1234));
assertEquals(line.getAuthor(), "Toni");
assertEquals(line.getNote(), "Hello World!");
}
Aggregations