use of com.github.robozonky.api.notifications.Financial in project robozonky by RoboZonky.
the class EmailingListenerTest method testMailSent.
private static void testMailSent(final AbstractEmailingListener<Event> listener, final Event event) throws Exception {
// dynamic tests in JUnit don't call before/after methods !!!
BalanceTracker.INSTANCE.reset();
final int originalMessages = EMAIL.getReceivedMessages().length;
listener.handle(event, SESSION_INFO);
assertThat(EMAIL.getReceivedMessages()).hasSize(originalMessages + 1);
final MimeMessage m = EMAIL.getReceivedMessages()[originalMessages];
assertThat(m.getContentType()).contains(Defaults.CHARSET.displayName());
assertThat(m.getSubject()).isNotNull().isEqualTo(listener.getSubject(event));
assertThat(m.getFrom()[0].toString()).contains("user@seznam.cz");
if (event instanceof Financial) {
// this event must register the last known balance
assertThat(BalanceTracker.INSTANCE.getLastKnownBalance()).isPresent();
} else {
// and this event carries no such information
assertThat(BalanceTracker.INSTANCE.getLastKnownBalance()).isEmpty();
}
}
use of com.github.robozonky.api.notifications.Financial in project robozonky by RoboZonky.
the class AbstractEmailingListener method getData.
protected Map<String, Object> getData(final T event) {
final Map<String, Object> result = new UnifiedMap<>(getBaseData(event));
if (event instanceof Financial) {
final PortfolioOverview portfolioOverview = ((Financial) event).getPortfolioOverview();
result.put("portfolio", Util.summarizePortfolioStructure(portfolioOverview));
}
return result;
}
Aggregations