Search in sources :

Example 1 with Financial

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();
    }
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) Financial(com.github.robozonky.api.notifications.Financial)

Example 2 with Financial

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;
}
Also used : UnifiedMap(org.eclipse.collections.impl.map.mutable.UnifiedMap) Financial(com.github.robozonky.api.notifications.Financial) PortfolioOverview(com.github.robozonky.api.strategies.PortfolioOverview)

Aggregations

Financial (com.github.robozonky.api.notifications.Financial)2 PortfolioOverview (com.github.robozonky.api.strategies.PortfolioOverview)1 MimeMessage (javax.mail.internet.MimeMessage)1 UnifiedMap (org.eclipse.collections.impl.map.mutable.UnifiedMap)1