Search in sources :

Example 1 with NotificationContext

use of org.kie.workbench.common.stunner.client.widgets.notification.NotificationContext in project kie-wb-common by kiegroup.

the class ProjectMessagesListenerTest method testFireNotificationInfo.

@Test
public void testFireNotificationInfo() {
    NotificationContext context = new NotificationContext.Builder().build("test", "test", "test");
    Command<?, CanvasViolation> source = mock(Command.class);
    CommandNotification commandNotification = CommandNotification.Builder.build(context, source, Notification.Type.INFO, "message");
    projectMessagesListener.fireNotification(commandNotification);
    ArgumentCaptor<PublishMessagesEvent> eventCaptor = ArgumentCaptor.forClass(PublishMessagesEvent.class);
    verify(publishMessagesEvent, times(1)).fire(eventCaptor.capture());
    final List<SystemMessage> messagesToPublish = eventCaptor.getValue().getMessagesToPublish();
    assertEquals(messagesToPublish.size(), 1);
    SystemMessage message = messagesToPublish.get(0);
    assertEquals(message.getText(), "message");
    assertEquals(message.getLevel(), Level.INFO);
}
Also used : NotificationContext(org.kie.workbench.common.stunner.client.widgets.notification.NotificationContext) SystemMessage(org.guvnor.messageconsole.events.SystemMessage) CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) PublishMessagesEvent(org.guvnor.messageconsole.events.PublishMessagesEvent) CommandNotification(org.kie.workbench.common.stunner.client.widgets.notification.CommandNotification) Test(org.junit.Test)

Example 2 with NotificationContext

use of org.kie.workbench.common.stunner.client.widgets.notification.NotificationContext in project kie-wb-common by kiegroup.

the class ProjectMessagesListenerTest method testFireNotificationWarning.

@Test
public void testFireNotificationWarning() {
    NotificationContext context = new NotificationContext.Builder().build("test", "test", "test");
    Command<?, CanvasViolation> source = mock(Command.class);
    CommandNotification commandNotification = CommandNotification.Builder.build(context, source, Notification.Type.WARNING, "message");
    projectMessagesListener.fireNotification(commandNotification);
    ArgumentCaptor<PublishMessagesEvent> eventCaptor = ArgumentCaptor.forClass(PublishMessagesEvent.class);
    verify(publishMessagesEvent, times(1)).fire(eventCaptor.capture());
    final List<SystemMessage> messagesToPublish = eventCaptor.getValue().getMessagesToPublish();
    assertEquals(messagesToPublish.size(), 1);
    SystemMessage message = messagesToPublish.get(0);
    assertEquals(message.getText(), "message");
    assertEquals(message.getLevel(), Level.WARNING);
}
Also used : NotificationContext(org.kie.workbench.common.stunner.client.widgets.notification.NotificationContext) SystemMessage(org.guvnor.messageconsole.events.SystemMessage) CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) PublishMessagesEvent(org.guvnor.messageconsole.events.PublishMessagesEvent) CommandNotification(org.kie.workbench.common.stunner.client.widgets.notification.CommandNotification) Test(org.junit.Test)

Example 3 with NotificationContext

use of org.kie.workbench.common.stunner.client.widgets.notification.NotificationContext in project kie-wb-common by kiegroup.

the class ProjectMessagesListenerTest method testFireNotificationError.

@Test
public void testFireNotificationError() {
    NotificationContext context = new NotificationContext.Builder().build("test", "test", "test");
    Command<?, CanvasViolation> source = mock(Command.class);
    CommandNotification commandNotification = CommandNotification.Builder.build(context, source, Notification.Type.ERROR, "message");
    projectMessagesListener.fireNotification(commandNotification);
    ArgumentCaptor<PublishMessagesEvent> eventCaptor = ArgumentCaptor.forClass(PublishMessagesEvent.class);
    verify(publishMessagesEvent, times(1)).fire(eventCaptor.capture());
    final List<SystemMessage> messagesToPublish = eventCaptor.getValue().getMessagesToPublish();
    assertEquals(messagesToPublish.size(), 1);
    SystemMessage message = messagesToPublish.get(0);
    assertEquals(message.getText(), "message");
    assertEquals(message.getLevel(), Level.ERROR);
}
Also used : NotificationContext(org.kie.workbench.common.stunner.client.widgets.notification.NotificationContext) SystemMessage(org.guvnor.messageconsole.events.SystemMessage) CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) PublishMessagesEvent(org.guvnor.messageconsole.events.PublishMessagesEvent) CommandNotification(org.kie.workbench.common.stunner.client.widgets.notification.CommandNotification) Test(org.junit.Test)

Aggregations

PublishMessagesEvent (org.guvnor.messageconsole.events.PublishMessagesEvent)3 SystemMessage (org.guvnor.messageconsole.events.SystemMessage)3 Test (org.junit.Test)3 CommandNotification (org.kie.workbench.common.stunner.client.widgets.notification.CommandNotification)3 NotificationContext (org.kie.workbench.common.stunner.client.widgets.notification.NotificationContext)3 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)3