@Test
public void generatePayLoad() {

	TradeEventHandler eventHandler = new TradeEventHandler(null, null, null);
	// its ok if the we pass null to the constructor here as its not used
	JSONObject jsonPayLoad = mock(JSONObject.class);
	EventPayLoad<JSONObject> payLoad = new TradeEventPayLoad(TradeEvents.TAKE_PROFIT_FILLED, jsonPayLoad);
	when(jsonPayLoad.get(OandaJsonKeys.instrument)).thenReturn("GBP_USD");
	when(jsonPayLoad.get(OandaJsonKeys.type)).thenReturn(TradeEvents.TAKE_PROFIT_FILLED.name());
	when(jsonPayLoad.get(OandaJsonKeys.accountId)).thenReturn(OandaTestConstants.accountId);
	when(jsonPayLoad.get(OandaJsonKeys.accountBalance)).thenReturn(100.00);
	when(jsonPayLoad.get(OandaJsonKeys.tradeId)).thenReturn(OandaTestConstants.tradeId);
	when(jsonPayLoad.get(OandaJsonKeys.pl)).thenReturn(22.45);
	when(jsonPayLoad.get(OandaJsonKeys.interest)).thenReturn(-1.45);
	when(jsonPayLoad.get(OandaJsonKeys.units)).thenReturn(10000L);
	EmailPayLoad emailPayLoad = eventHandler.generate(payLoad);
	assertEquals("Trade event TAKE_PROFIT_FILLED for GBP_USD", emailPayLoad.getSubject());
	assertEquals(
			"Trade event TAKE_PROFIT_FILLED received for account 123456. Trade id=1800805337. Pnl=22.450, Interest=-1.450, Trade Units=10000. Account balance after the event=100.00",
			emailPayLoad.getBody());
}