@Test
  public void testValidateTargetConfig_invalidOnMessagingException() throws Exception {

    Map<String, Object> properties = new HashMap<>();
    Transport mockedTransport = EasyMock.createNiceMock(Transport.class);
    EmailDispatcher dispatcher = EasyMock.createMockBuilder(EmailDispatcher.class).
        addMockedMethods("getMailTransport").createNiceMock();

    EasyMock.expect(dispatcher.getMailTransport(properties)).andReturn(mockedTransport);
    mockedTransport.connect();
    EasyMock.expectLastCall().andThrow(new MessagingException());

    EasyMock.replay(dispatcher, mockedTransport);

    TargetConfigurationResult configValidationResult = dispatcher.validateTargetConfig(properties);
    Assert.assertEquals(TargetConfigurationResult.Status.INVALID, configValidationResult.getStatus());
  }
Tests that an email without properties causes a callback error.
ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/EmailDispatcherTest.java