### Question:
NotificationsObserver { @SuppressWarnings("unchecked") void onGraphCommandExecuted(final @Observes CanvasCommandExecutedEvent<? extends CanvasHandler> commandExecutedEvent) { final Notification notification = translateCommand(commandExecutedEvent); fireCommandNotification(notification); } @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 testNotifyCommandExecutionSuccess() { final Command command = mock(Command.class); final CommandResult<CanvasViolation> result = mock(CommandResult.class); final CanvasCommandExecutedEvent<? extends CanvasHandler> commandExecutedEvent = new CanvasCommandExecutedEvent<>(canvasHandler, command, result); commandNotification = new CommandNotification(Notification.Type.INFO, notificationContext, command, "message1"); tested.onGraphCommandExecuted(commandExecutedEvent); verify(onNotification, times(1)).execute(eq(commandNotification)); verify(commandSuccess, times(1)).execute(eq(commandNotification)); verify(commandFailed, never()).execute(any(CommandNotification.class)); verify(validationSuccess, never()).execute(any(ValidationSuccessNotification.class)); verify(validationFailed, never()).execute(any(ValidationFailedNotification.class)); }
@Test @SuppressWarnings("unchecked") public void testNotifyCommandExecutionFailed() { final Command command = mock(Command.class); final CommandResult<CanvasViolation> result = mock(CommandResult.class); final CanvasCommandExecutedEvent<? extends CanvasHandler> commandExecutedEvent = new CanvasCommandExecutedEvent<>(canvasHandler, command, result); commandNotification = new CommandNotification(Notification.Type.ERROR, notificationContext, command, "message1"); tested.onGraphCommandExecuted(commandExecutedEvent); verify(onNotification, times(1)).execute(eq(commandNotification)); verify(commandFailed, times(1)).execute(eq(commandNotification)); verify(commandSuccess, never()).execute(any(CommandNotification.class)); verify(validationSuccess, never()).execute(any(ValidationSuccessNotification.class)); verify(validationFailed, never()).execute(any(ValidationFailedNotification.class)); }