@Test public void testEnable() { projectMessagesListener.enable(); final ArgumentCaptor<ParameterizedCommand> callbackCaptor = ArgumentCaptor.forClass(ParameterizedCommand.class); verify(notificationsObserver).onCommandExecutionFailed(callbackCaptor.capture()); callbackCaptor.getAllValues().get(0).execute(CommandNotification.Builder.build(buildNotificationContext(), mock(Command.class), Notification.Type.INFO, "message")); verify(projectMessagesListener, times(1)).fireNotification(any()); verify(notificationsObserver).onValidationFailed(callbackCaptor.capture()); final DiagramElementViolation diagramElementViolation = mock(DiagramElementViolation.class); final DomainViolation domainViolation = mock(DomainViolation.class); final ClientTranslationService translationService = mock(ClientTranslationService.class); when(diagramElementViolation.getViolationType()).thenReturn(Violation.Type.ERROR); when(diagramElementViolation.getDomainViolations()).thenReturn(Arrays.asList(domainViolation)); when(domainViolation.getViolationType()).thenReturn(Violation.Type.ERROR); when(translationService.getElementName(anyString())).thenReturn(Optional.of("name")); when(translationService.getValue(anyString(), anyString(), anyString())).thenReturn("message"); when(domainViolation.getMessage()).thenReturn("message"); callbackCaptor.getAllValues().get(1).execute(ValidationFailedNotification.Builder.build(translationService, buildNotificationContext(), Arrays.asList(diagramElementViolation)).get()); verify(projectMessagesListener, times(2)).fireNotification(any()); verify(notificationsObserver).onValidationExecuted(callbackCaptor.capture()); callbackCaptor.getAllValues().get(2).execute(null); verify(projectMessagesListener, times(1)).clearMessages(any()); }
public void enable() { notificationsObserver.onCommandExecutionFailed(parameter -> fireNotification(parameter)); notificationsObserver.onValidationFailed(parameter -> fireNotification(parameter)); notificationsObserver.onValidationExecuted(parameter -> clearMessages(parameter)); }
ProjectMessagesListener { public void enable() { notificationsObserver.onCommandExecutionFailed(parameter -> fireNotification(parameter)); notificationsObserver.onValidationFailed(parameter -> fireNotification(parameter)); notificationsObserver.onValidationExecuted(parameter -> clearMessages(parameter)); } }
ProjectMessagesListener { public void enable() { notificationsObserver.onCommandExecutionFailed(parameter -> fireNotification(parameter)); notificationsObserver.onValidationFailed(parameter -> fireNotification(parameter)); notificationsObserver.onValidationExecuted(parameter -> clearMessages(parameter)); } protected  ProjectMessagesListener(); @Inject  ProjectMessagesListener(final NotificationsObserver notificationsObserver,
                                   final Event<PublishMessagesEvent> publishMessagesEvent,
                                   final Event<UnpublishMessagesEvent> unpublishMessagesEvent,
                                   final SessionManager clientSessionManager); }
ProjectMessagesListener { public void enable() { notificationsObserver.onCommandExecutionFailed(parameter -> fireNotification(parameter)); notificationsObserver.onValidationFailed(parameter -> fireNotification(parameter)); notificationsObserver.onValidationExecuted(parameter -> clearMessages(parameter)); } protected  ProjectMessagesListener(); @Inject  ProjectMessagesListener(final NotificationsObserver notificationsObserver,
                                   final Event<PublishMessagesEvent> publishMessagesEvent,
                                   final Event<UnpublishMessagesEvent> unpublishMessagesEvent,
                                   final SessionManager clientSessionManager); void enable(); }
ProjectMessagesListener { public void enable() { notificationsObserver.onCommandExecutionFailed(parameter -> fireNotification(parameter)); notificationsObserver.onValidationFailed(parameter -> fireNotification(parameter)); notificationsObserver.onValidationExecuted(parameter -> clearMessages(parameter)); } protected  ProjectMessagesListener(); @Inject  ProjectMessagesListener(final NotificationsObserver notificationsObserver,
                                   final Event<PublishMessagesEvent> publishMessagesEvent,
                                   final Event<UnpublishMessagesEvent> unpublishMessagesEvent,
                                   final SessionManager clientSessionManager); void enable(); static final String MESSAGE_TYPE; }