### Question:
NotificationsObserver { @SuppressWarnings("unchecked") void onCanvasValidationFailEvent(final @Observes CanvasValidationFailEvent validationFailEvent) { final NotificationContext context = buildContext(validationFailEvent); handleValidationExecuted(context); handleValidationFailed(validationFailEvent, context); } @Inject  NotificationsObserver(final ClientTranslationService translationService); protected  NotificationsObserver(ClientTranslationService translationService, NotificationBuilder notificationBuilder); NotificationsObserver onNotification(final ParameterizedCommand<Notification> callback); NotificationsObserver onCommandExecutionSuccess(final ParameterizedCommand<CommandNotification> callback); NotificationsObserver onCommandExecutionFailed(final ParameterizedCommand<CommandNotification> callback); NotificationsObserver onValidationSuccess(final ParameterizedCommand<ValidationSuccessNotification> callback); NotificationsObserver onValidationFailed(final ParameterizedCommand<ValidationFailedNotification> callback); NotificationsObserver onValidationExecuted(final ParameterizedCommand<ValidationExecutedNotification> callback); @PreDestroy void destroy();  }### Answer:
@Test @SuppressWarnings("unchecked") public void testNotifyValidationFailed() { final DomainViolation domainV1 = mock(DomainViolation.class); when(domainV1.getMessage()).thenReturn("message"); when(translationService.getElementName(anyString())).thenReturn(Optional.of("name")); when(translationService.getValue(anyString(), anyString(), anyString())).thenReturn("message"); final DiagramElementViolation violation = mock(DiagramElementViolation.class); final DiagramElementViolation violation2 = mock(DiagramElementViolation.class); when(violation.getDomainViolations()).thenReturn(Arrays.asList(domainV1)); when(violation2.getDomainViolations()).thenReturn(Arrays.asList(domainV1)); final Collection<DiagramElementViolation<RuleViolation>> violations = Arrays.asList(violation, violation2); validationFailedNotification = new ValidationFailedNotification(violations, notificationContext, "message1", Notification.Type.ERROR); final CanvasValidationFailEvent validationFailEvent = new CanvasValidationFailEvent(UUID, NAME, TITLE, violations); tested.onCanvasValidationFailEvent(validationFailEvent); final InOrder inOrder = inOrder(validationExecuted, onNotification, validationFailed, commandFailed, validationSuccess, commandSuccess); inOrder.verify(validationExecuted).execute(any(ValidationExecutedNotification.class)); inOrder.verify(onNotification, times(1)).execute(any(Notification.class)); inOrder.verify(validationFailed, times(1)).execute(eq(validationFailedNotification)); inOrder.verify(onNotification, times(1)).execute(any(Notification.class)); inOrder.verify(validationFailed, times(1)).execute(eq(validationFailedNotification)); inOrder.verify(commandFailed, never()).execute(any(CommandNotification.class)); inOrder.verify(validationSuccess, never()).execute(any(ValidationSuccessNotification.class)); inOrder.verify(commandSuccess, never()).execute(any(CommandNotification.class)); verify(validationFailed, times(2)).execute(eq(validationFailedNotification)); verify(onNotification, times(2)).execute(any(Notification.class)); }