@Test
  public void testGetScriptLocation() throws Exception {
    AlertScriptDispatcher dispatcher = (AlertScriptDispatcher) m_dispatchFactory.getDispatcher(TargetType.ALERT_SCRIPT.name());
    m_injector.injectMembers(dispatcher);

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

    //1.ambari.dispatch-property.script.filename is not set in notification
    Assert.assertEquals(dispatcher.getScriptLocation(notification),null);

    //2.ambari.dispatch-property.script.filename is set in notification,but notification.dispatch.alert.script.directory not in ambari.properties
    final String filename = "foo.py";
    notification.DispatchProperties.put(AlertScriptDispatcher.DISPATCH_PROPERTY_SCRIPT_FILENAME_KEY,filename);
    Assert.assertEquals(dispatcher.getScriptLocation(notification),"/var/lib/ambari-server/resources/scripts/foo.py");

    //3.both properties are set
    final String scriptDirectory = "/var/lib/ambari-server/resources/scripts/foo";
    m_configuration.setProperty(DISPATCH_PROPERTY_SCRIPT_DIRECTORY_KEY,scriptDirectory);
    Assert.assertEquals(dispatcher.getScriptLocation(notification),"/var/lib/ambari-server/resources/scripts/foo/foo.py");
  }
Tests the invocation of method getScriptLocation().
ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/AlertScriptDispatcherTest.java