Search in sources :

Example 1 with DiscussionWidgetPresenter

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 :(");
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) DiscussionRecord(org.guvnor.common.services.shared.metadata.model.DiscussionRecord) DiscussionWidgetPresenter(org.kie.workbench.common.widgets.client.discussion.DiscussionWidgetPresenter) Test(org.junit.Test)

Example 2 with DiscussionWidgetPresenter

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);
}
Also used : DiscussionWidgetPresenter(org.kie.workbench.common.widgets.client.discussion.DiscussionWidgetPresenter) Test(org.junit.Test)

Example 3 with DiscussionWidgetPresenter

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!");
}
Also used : DiscussionWidgetView(org.kie.workbench.common.widgets.client.discussion.DiscussionWidgetView) Path(org.uberfire.backend.vfs.Path) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) DiscussionRecord(org.guvnor.common.services.shared.metadata.model.DiscussionRecord) DiscussionWidgetPresenter(org.kie.workbench.common.widgets.client.discussion.DiscussionWidgetPresenter) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 DiscussionWidgetPresenter (org.kie.workbench.common.widgets.client.discussion.DiscussionWidgetPresenter)3 DiscussionRecord (org.guvnor.common.services.shared.metadata.model.DiscussionRecord)2 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)2 DiscussionWidgetView (org.kie.workbench.common.widgets.client.discussion.DiscussionWidgetView)1 Path (org.uberfire.backend.vfs.Path)1