@Test
  public void testCustomScriptConfigurationByScriptFilename() throws Exception {
    final String filename = "foo.py";
    final String scriptDirectory = "/var/lib/ambari-server/resources/scripts/foo";
    m_configuration.setProperty(DISPATCH_PROPERTY_SCRIPT_DIRECTORY_KEY,scriptDirectory);

    DispatchCallback callback = EasyMock.createNiceMock(DispatchCallback.class);
    AlertNotification notification = new AlertNotification();
    notification.Callback = callback;
    notification.CallbackIds = Collections.singletonList(UUID.randomUUID().toString());

    notification.DispatchProperties = new HashMap();
    notification.DispatchProperties.put(AlertScriptDispatcher.DISPATCH_PROPERTY_SCRIPT_FILENAME_KEY,filename);

    callback.onSuccess(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(dispatcher.getScriptLocation(notification), notification)).andReturn(
            powerMockProcessBuilder).once();

    EasyMock.replay(callback, dispatcher);

    dispatcher.dispatch(notification);

    EasyMock.verify(callback, dispatcher);
    PowerMock.verifyAll();
  }
Tests that we will pickup the correct script when script filename is specified on the notification
ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/AlertScriptDispatcherTest.java