use of org.guvnor.messageconsole.events.PublishMessagesEvent in project kie-wb-common by kiegroup.
the class ProjectMessagesListener method fireNotification.
void fireNotification(final AbstractNotification notification) {
final ClientSession session = clientSessionManager.getCurrentSession();
final Path path = session.getCanvasHandler().getDiagram().getMetadata().getPath();
final SystemMessage systemMessage = new SystemMessage();
final ArrayList<SystemMessage> messagesList = new ArrayList<>();
switch(notification.getType()) {
case ERROR:
systemMessage.setLevel(Level.ERROR);
break;
case WARNING:
systemMessage.setLevel(Level.WARNING);
break;
case INFO:
systemMessage.setLevel(Level.INFO);
break;
}
systemMessage.setText(notification.getMessage());
systemMessage.setPath(path);
messagesList.add(systemMessage);
PublishMessagesEvent messages = new PublishMessagesEvent();
messages.setMessagesToPublish(messagesList);
publishMessagesEvent.fire(messages);
}
use of org.guvnor.messageconsole.events.PublishMessagesEvent 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);
}
use of org.guvnor.messageconsole.events.PublishMessagesEvent 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);
}
use of org.guvnor.messageconsole.events.PublishMessagesEvent 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);
}
Aggregations