@Test
@SuppressWarnings("unchecked")
public void emailNotifyTest() {

	EventEmailNotifier<String> mailNotifier = new EventEmailNotifier<String>();
	try {
		mailNotifier.notifyByEmail(null);
		fail("Null payload should have resulted in an exception");
	} catch (Exception e) {
		// as expected
	}
	JavaMailSender mailSender = mock(JavaMailSender.class);
	Map<Event, EmailContentGenerator<String>> eventEmailContentGeneratorMap = Maps.newIdentityHashMap();
	Event event = mock(Event.class);
	EmailContentGenerator<String> contentGenerator = mock(EmailContentGenerator.class);
	eventEmailContentGeneratorMap.put(event, contentGenerator);
	TradingConfig tradingConfig = mock(TradingConfig.class);
	mailNotifier.eventEmailContentGeneratorMap = eventEmailContentGeneratorMap;
	mailNotifier.mailSender = mailSender;
	mailNotifier.tradingConfig = tradingConfig;
	EventPayLoad<String> eventPayLoad = new EventPayLoad<String>(mock(Event.class), "null");
	mailNotifier.notifyByEmail(eventPayLoad);
	verify(mailSender, times(0)).send(any(SimpleMailMessage.class));
	eventPayLoad = new EventPayLoad<String>(event, "hello world");
	EmailPayLoad emailPayLoad = new EmailPayLoad("hi", "test email");
	when(contentGenerator.generate(eventPayLoad)).thenReturn(emailPayLoad);
	when(tradingConfig.getMailTo()).thenReturn("info@foobar.com");
	mailNotifier.notifyByEmail(eventPayLoad);
	verify(mailSender, times(1)).send(any(SimpleMailMessage.class));
}