@Test
  public void testFailedProcess() throws Exception {
    DispatchCallback callback = EasyMock.createNiceMock(DispatchCallback.class);
    AlertNotification notification = new AlertNotification();
    notification.Callback = callback;
    notification.CallbackIds = Collections.singletonList(UUID.randomUUID().toString());

    callback.onFailure(notification.CallbackIds);
    EasyMock.expectLastCall().once();

    AlertScriptDispatcher dispatcher = (AlertScriptDispatcher) m_dispatchFactory.getDispatcher(TargetType.ALERT_SCRIPT.name());
    m_injector.injectMembers(dispatcher);

    ProcessBuilder powerMockProcessBuilder = m_injector.getInstance(ProcessBuilder.class);
    EasyMock.expect(dispatcher.getProcessBuilder(SCRIPT_CONFIG_VALUE, notification)).andReturn(
        powerMockProcessBuilder).once();

    Process mockProcess = powerMockProcessBuilder.start();
    EasyMock.expect(mockProcess.exitValue()).andReturn(255).anyTimes();

    EasyMock.replay(callback, dispatcher, mockProcess);

    dispatcher.dispatch(notification);

    EasyMock.verify(callback, dispatcher);
    PowerMock.verifyAll();
  }
Tests that a process with an error code of 255 causes the failure callback
to be invoked.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/AlertScriptDispatcherTest.java